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

melange: define MELANGE conditional compilation variable #472

Merged
merged 3 commits into from
Jan 16, 2023
Merged
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
2 changes: 2 additions & 0 deletions Changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ Unreleased
[`NonEscapeCharacter`](https://tc39.es/ecma262/#prod-NonEscapeCharacter)
correctly in JS strings (those written using `{js|string here|js}`)
([#469](https://github.com/melange-re/melange/pull/469))
- [melange]: define `MELANGE` conditional compilation variable
([#472](https://github.com/melange-re/melange/pull/472))

0.3.2 2022-11-19
---------------
Expand Down
6 changes: 3 additions & 3 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions jscomp/core/bs_conditional_initial.ml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ let setup_env () =
Printexc.record_backtrace true;
#endif

Rescript_cpp.replace_directive_bool "MELANGE" true;
Rescript_cpp.replace_directive_bool "BS" true;
Rescript_cpp.replace_directive_bool "JS" true;
Rescript_cpp.replace_directive_string "BS_VERSION" Melange_version.version
Expand Down
21 changes: 21 additions & 0 deletions test/melange-conditional.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
Demonstrate the `#if MELANGE` conditional variable

$ export MELANGELIB="$INSIDE_DUNE/lib/melange"
$ cat > x.ml <<EOF
> let () =
> #if MELANGE then
> Js.log("It's Melange");
> #else
> Js.log2("Not Melange, type error, not 2 arguments");
> #end
> EOF

$ melc x.ml
// Generated by Melange
'use strict';


console.log("It's Melange");

/* Not a pure module */