File tree Expand file tree Collapse file tree 6 files changed +54
-4
lines changed Expand file tree Collapse file tree 6 files changed +54
-4
lines changed Original file line number Diff line number Diff line change 1717* Compiler: introduce a Targetint module
1818 that follows the semantic of the backend (js or wasm)
1919* Compiler: warn on joo_global_object
20+ * Compiler: revisit static env handling (#1708 )
2021* Runtime: change Sys.os_type on windows (Cygwin -> Win32)
2122* Runtime: backtraces are really expensive, they need to be be explicitly
2223 requested at compile time (--enable with-js-error) or at startup (OCAMLRUNPARAM=b=1)
Original file line number Diff line number Diff line change 1+ (executable
2+ (modes js)
3+ (js_of_ocaml
4+ (flags :standard --setenv JSOO_C=from-jsoo-args))
5+ (name test))
6+
7+ (rule
8+ (target test.js)
9+ (action
10+ (with-outputs-to
11+ %{target}
12+ (cat %{dep:setup.js} %{dep:./test.bc.js}))))
13+
14+ (rule
15+ (target test.output)
16+ (action
17+ (with-outputs-to
18+ %{target}
19+ (setenv
20+ JSOO_B
21+ from-env
22+ (run node %{dep:./test.js})))))
23+
24+ (rule
25+ (alias runtest)
26+ (action
27+ (diff test.reference test.output)))
Original file line number Diff line number Diff line change 1+ globalThis . jsoo_env = { } ;
2+ globalThis . jsoo_env [ "JSOO_A" ] = "from-global-this" ;
Original file line number Diff line number Diff line change 1+ let test x =
2+ match Sys. getenv x with
3+ | exception Not_found -> print_endline (x ^ " not found" )
4+ | v -> print_endline (x ^ " = " ^ v)
5+
6+ let () =
7+ test " JSOO_A" ;
8+ test " JSOO_B" ;
9+ test " JSOO_C" ;
10+ test " JSOO_D"
Original file line number Diff line number Diff line change 1+ JSOO_A = from-global-this
2+ JSOO_B = from-env
3+ JSOO_C = from-jsoo-args
4+ JSOO_D not found
Original file line number Diff line number Diff line change @@ -98,21 +98,27 @@ function caml_fatal_uncaught_exception(err) {
9898 }
9999}
100100
101+ //Provides: jsoo_static_env
102+ var jsoo_static_env = { } ;
103+
101104//Provides: caml_set_static_env
105+ //Requires: jsoo_static_env
102106function caml_set_static_env ( k , v ) {
103- if ( ! globalThis . jsoo_static_env ) globalThis . jsoo_static_env = { } ;
104- globalThis . jsoo_static_env [ k ] = v ;
107+ jsoo_static_env [ k ] = v ;
105108 return 0 ;
106109}
107110
108111//Provides: jsoo_sys_getenv (const)
112+ //Requires: jsoo_static_env
109113function jsoo_sys_getenv ( n ) {
114+ if ( jsoo_static_env [ n ] ) return jsoo_static_env [ n ] ;
110115 var process = globalThis . process ;
111116 //nodejs env
112117 if ( process && process . env && process . env [ n ] !== undefined )
113118 return process . env [ n ] ;
114- if ( globalThis . jsoo_static_env && globalThis . jsoo_static_env [ n ] )
115- return globalThis . jsoo_static_env [ n ] ;
119+ if ( globalThis . jsoo_env && typeof globalThis . jsoo_env [ n ] === "string" ) {
120+ return globalThis . jsoo_env [ n ] ;
121+ }
116122}
117123
118124//Provides: caml_sys_getenv (const)
You can’t perform that action at this time.
0 commit comments