capnp-ocaml icon indicating copy to clipboard operation
capnp-ocaml copied to clipboard

Get dune build working on Windows

Open jonahbeckford opened this issue 1 year ago • 3 comments

During capnp-ocaml development I want dune build to work. That compiles the whole project, including the benchmark code. dune build makes it easy to see if I'm breaking other code, even if I can't run the benchmarks (yet) on Windows.

Two changes:

  • CAPNP_INCLUDE environment variable can be set if the build machine does not have a standard location to store capnp/*.capnp schema file (ex. /usr/include on Unix)
  • Windows compiler flags and commands are detected and used in benchmarks

I also added in manual compile instructions for Windows.

The python benchmark tool was not modified. Running the benchmark on Unix is fine for now.

jonahbeckford avatar Nov 15 '24 17:11 jonahbeckford

I'm a bit confused about why CAPNP_INCLUDE is needed. If we can find the capnp binary OK on Windows, can't that can find the includes relative to itself?

capnp is a binary not under our control. Are you asking for changes to the upstream capnp binary? Because that mechanism does not exist today as far as I can tell: https://capnproto.org/language.html#imports has the rules for the search path.

EDIT: Here is the capnp search path logic: https://github.com/capnproto/capnproto/blob/6e071e34d88a8fc489638535899cd9d02e55bf76/c%2B%2B/src/capnp/compiler/capnp.c%2B%2B#L350-L367.

jonahbeckford avatar Nov 19 '24 16:11 jonahbeckford

Yes, it seems reasonable to get this in the upstream binary. Otherwise, we'll have to do this dune stuff in every project that uses capnp.

talex5 avatar Nov 19 '24 16:11 talex5

Yes, it seems reasonable to get this in the upstream binary. Otherwise, we'll have to do this dune stuff in every project that uses capnp.

If I were the maintainer of capnp I would say no to that request. I would question why the requester's build system and/or the package system does not support functions, aliases, macros ... anything so that this logic could be centralized and not repeated. I would also question why the requester wasn't using the build system (CMake) that capnp uses, which supports all of that. I would also do a quick google search and see that there is already a proposal in Dune to make it much more friendly to the CMake and has a specific example for capnp: https://github.com/ocaml/dune/discussions/8707#capnp-code-generation.

I'll let you ask for the upstream issue. In the meantime, we can keep this issue open. I'll update the other two minor and uncontroversial things you mentioned (-O3 and arg passing) when I get some free time.

jonahbeckford avatar Nov 19 '24 17:11 jonahbeckford