janestreet / ppx_optcomp

Optional compilation for OCaml
MIT License
65 stars 18 forks source link

A way to define variables on command line #5

Open zoggy opened 7 years ago

zoggy commented 7 years ago

Hello,

It would be nice that ppx-optcomp accept some -D var option to define a variable on command line, allowing, for example, to use such a flag to compile in {test|debug|...} mode or not. This would allow to use

#ifdef testmode
 ...
#endif

without having to #define testmode or not in each file.

ghost commented 7 years ago

Indeed, would you consider submitting a PR?

zoggy commented 7 years ago

Sure. By the way, I cant use ppx-optcomp with the provided example:

#if ocaml_version < (4, 02, 0)
let x = 1
#else
let y = 2
#endif
$ ppx-optcomp t.ml 
File "t.ml", line 3, characters 1-5:
Error: Syntax error

Any idea what's wrong ? (ocaml 4.03.0, ppx_optcomp 113.33.00+4.03)

zoggy commented 7 years ago

And when I try to compile ppx_optcomp, I get the following error:

File "myocamlbuild.ml", line 4, characters 12-42:
Error: Unbound module Jane_street_ocamlbuild_goodies

I have no idea what package is missing...

ghost commented 7 years ago

The syntax error looks like a bug in ppx_optcomp, some debugging is needed. For the second error, you need to install js-build-tools.

zoggy commented 7 years ago
$ opam install js-build-tools
[NOTE] Package js-build-tools is already installed (current version is
       113.33.04).
ghost commented 7 years ago

Ah, I think it's a bug with oasis 0.4.7, try downgrading oasis, or upgrading to 0.4.8 that was released recently

zoggy commented 7 years ago

Ok thanks. I also had to remove setup.exe manually because make distclean did not. Now it compiles :)