janestreet / ppx_optcomp

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

Add demo for defining variables via cookie (Fix issue #5) #16

Open Kakadu opened 2 years ago

Kakadu commented 2 years ago

It looks we are able to define variables from command line, so issue #5 is kind of closed. In this PR I added demo to make it more obvious.

edwintorok commented 1 year ago

Thanks, this is very useful! Here is how you can use it from 'dune', in this case to define a directive based on the version of a package:

==> dune <==
(executable
  (name vtest)
  (libraries tsdl)
  (preprocess (pps ppx_optcomp -- -cookie "ppx_optcomp.env=env ~tsdl_version:(Defined \"%{version:tsdl}\")"))
)

==> dune-project <==
(lang dune 2.9)