Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get dune build working on Windows #92

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
# PENDING

Build system:

- `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) (@jonahbeckford #92)
- Windows compiler flags and commands are detected and used in benchmarks
(@jonahbeckford #92)

# v3.6.0

- Update README to talk about stdint, not uint (reported by @liyishuai).
Expand Down
12 changes: 9 additions & 3 deletions README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -563,12 +563,18 @@ capnp-ocaml requires OCaml >= 4.02.
You should be able to install capnp-ocaml with
http://opam.ocaml.org[OPAM] using using `opam install capnp`.

If you prefer to compile manually, you will need jbuilder, Findlib, and OCaml
If you prefer to compile manually, you will need Dune, Findlib, and OCaml
packages `core_kernel`, `extunix`, `uint`, `ocplib-endian`, and `res`.
Run `jbuilder build` to build both the compiler and the runtime library,
and then use `jbuilder install` to copy them into appropriate places within your
Run `dune build` to build both the compiler and the runtime library,
and then use `opam install` or `dune install` to copy them into appropriate places within your
filesystem.

Compiling manually on Windows can be done if you create an opam 2.2 switch or DkML switch,
and download and extract the [Cap’n Proto Win32 zip](https://capnproto.org/install.html#installation-windows).
Use a PowerShell command like the following for development, replacing *YOU* with your username and
*1.0.2* with the capnp version you downloaded:
`opam exec -- env CAPNP_INCLUDE='C:\Users\YOU\Downloads\capnproto-c++-win32-1.0.2\capnproto-c++-1.0.2\src' sh -c "PATH=`"`$(cygpath 'C:\Users\YOU\Downloads\capnproto-c++-win32-1.0.2\capnproto-tools-win32-1.0.2'):`$PATH`" dune build"`

Contact
-------
pelzlpj at gmail dot com
42 changes: 31 additions & 11 deletions src/benchmark/dune
Original file line number Diff line number Diff line change
Expand Up @@ -2,44 +2,64 @@
(name main)
(enabled_if (= %{architecture} amd64))
(libraries capnp capnp_unix fast_rand base)
(ocamlopt_flags :standard -O3 -inline 2000))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could just get rid of this. It was for flambda, but it's probably out of date by now anyway.

(ocamlopt_flags :standard (:include fastRand/foreign_stubs_flags.sexp) -inline 2000))

(rule
(targets carsales)
(enabled_if (= %{os_type} "Unix"))
(target ln.lines)
(action (with-stdout-to %{target} (echo "ln"))))

(rule
(enabled_if (= %{os_type} "Win32"))
(target ln.lines)
(action (with-stdout-to %{target} (echo "cmd\n/c\ncopy"))))

Comment on lines +12 to +16
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be easier to have main.ml just take the benchmark name as the first argument instead of using the program name. I'm not sure why it's using hard-links at the moment.

(rule
(targets carsales%{ext_exe})
(enabled_if (= %{architecture} amd64))
(deps main.exe)
(action
(run ln main.exe %{targets})))
(run %{read-lines:ln.lines} main.exe %{targets})))

(rule
(targets catrank)
(targets catrank%{ext_exe})
(enabled_if (= %{architecture} amd64))
(deps main.exe)
(action
(run ln main.exe %{targets})))
(run %{read-lines:ln.lines} main.exe %{targets})))

(rule
(targets eval)
(targets eval%{ext_exe})
(enabled_if (= %{architecture} amd64))
(deps main.exe)
(action
(run ln main.exe %{targets})))
(run %{read-lines:ln.lines} main.exe %{targets})))

(rule
(enabled_if (<> %{env:CAPNP_INCLUDE=} ""))
(target capnp_compile_args.lines)
(action (with-stdout-to %{target} (echo "-I\n%{env:CAPNP_INCLUDE=}\n"))))

(rule
(enabled_if (= %{env:CAPNP_INCLUDE=} ""))
(target capnp_compile_args.lines)
(action (with-stdout-to %{target} (echo ""))))

(rule
(targets carsales.ml carsales.mli)
(action
(run capnp compile -o %{bin:capnpc-ocaml} %{dep:carsales.capnp})))
(run capnp compile -o %{bin:capnpc-ocaml} %{read-lines:capnp_compile_args.lines} %{dep:carsales.capnp})))

(rule
(targets catrank.ml catrank.mli)
(action
(run capnp compile -o %{bin:capnpc-ocaml} %{dep:catrank.capnp})))
(run capnp compile -o %{bin:capnpc-ocaml} %{read-lines:capnp_compile_args.lines} %{dep:catrank.capnp})))

(rule
(targets eval.ml eval.mli)
(action
(run capnp compile -o %{bin:capnpc-ocaml} %{dep:eval.capnp})))
(run capnp compile -o %{bin:capnpc-ocaml} %{read-lines:capnp_compile_args.lines} %{dep:eval.capnp})))

(alias
(name benchmarks)
(deps carsales catrank eval))
(deps carsales%{ext_exe} catrank%{ext_exe} eval%{ext_exe}))
12 changes: 11 additions & 1 deletion src/benchmark/fastRand/dune
Original file line number Diff line number Diff line change
@@ -1,9 +1,19 @@
(rule
(enabled_if (= %{os_type} "Unix"))
(target foreign_stubs_flags.sexp)
(action (with-stdout-to %{target} (echo "(-O3)"))))

(rule
(enabled_if (= %{os_type} "Win32"))
(target foreign_stubs_flags.sexp)
(action (with-stdout-to %{target} (echo "(-O2)"))))

(library
(enabled_if (= %{architecture} amd64))
(foreign_stubs
(language c)
(names fast_rand)
(flags :standard -O3))
(flags :standard (:include foreign_stubs_flags.sexp)))
(name fast_rand)
(wrapped false)
(flags :standard -w -3))