Skip to content

Commit 059fe7d

Browse files
vouillonhhugo
authored andcommitted
Set preprocess variables when preprocessing external runtime files as well
1 parent 0060b0a commit 059fe7d

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

compiler/bin-wasm_of_ocaml/compile.ml

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -76,25 +76,26 @@ let opt_with action x f =
7676
| None -> f None
7777
| Some x -> action x (fun y -> f (Some y))
7878

79+
let preprocessor_variables () =
80+
(* Keep this variables in sync with gen/gen.ml *)
81+
[ ( "effects"
82+
, Wat_preprocess.String
83+
(match Config.effects () with
84+
| `Disabled | `Jspi -> "jspi"
85+
| `Cps -> "cps"
86+
| `Double_translation -> assert false) )
87+
]
88+
7989
let with_runtime_files ~runtime_wasm_files f =
8090
let inputs =
8191
List.map
8292
~f:(fun file -> { Wat_preprocess.module_name = "env"; file; source = File })
8393
runtime_wasm_files
8494
in
85-
Wat_preprocess.with_preprocessed_files ~variables:[] ~inputs f
95+
Wat_preprocess.with_preprocessed_files ~variables:(preprocessor_variables ()) ~inputs f
8696

8797
let build_runtime ~runtime_file =
88-
(* Keep this variables in sync with gen/gen.ml *)
89-
let variables =
90-
[ ( "effects"
91-
, Wat_preprocess.String
92-
(match Config.effects () with
93-
| `Disabled | `Jspi -> "jspi"
94-
| `Cps -> "cps"
95-
| `Double_translation -> assert false) )
96-
]
97-
in
98+
let variables = preprocessor_variables () in
9899
match
99100
List.find_opt Runtime_files.precompiled_runtimes ~f:(fun (flags, _) ->
100101
assert (List.length flags = List.length variables);

0 commit comments

Comments
 (0)