Skip to content

Commit

Permalink
melange: define MELANGE conditional compilation variable (#472)
Browse files Browse the repository at this point in the history
* melange: define `MELANGE` conditional compilation variable

* add changelog entry
  • Loading branch information
anmonteiro authored Jan 16, 2023
1 parent 781978a commit 0be7b28
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 3 deletions.
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 */

0 comments on commit 0be7b28

Please sign in to comment.