File tree 6 files changed +54
-4
lines changed 6 files changed +54
-4
lines changed Original file line number Diff line number Diff line change 17
17
* Compiler: introduce a Targetint module
18
18
that follows the semantic of the backend (js or wasm)
19
19
* Compiler: warn on joo_global_object
20
+ * Compiler: revisit static env handling (#1708 )
20
21
* Runtime: change Sys.os_type on windows (Cygwin -> Win32)
21
22
* Runtime: backtraces are really expensive, they need to be be explicitly
22
23
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) {
98
98
}
99
99
}
100
100
101
+ //Provides: jsoo_static_env
102
+ var jsoo_static_env = { } ;
103
+
101
104
//Provides: caml_set_static_env
105
+ //Requires: jsoo_static_env
102
106
function 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 ;
105
108
return 0 ;
106
109
}
107
110
108
111
//Provides: jsoo_sys_getenv (const)
112
+ //Requires: jsoo_static_env
109
113
function jsoo_sys_getenv ( n ) {
114
+ if ( jsoo_static_env [ n ] ) return jsoo_static_env [ n ] ;
110
115
var process = globalThis . process ;
111
116
//nodejs env
112
117
if ( process && process . env && process . env [ n ] !== undefined )
113
118
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
+ }
116
122
}
117
123
118
124
//Provides: caml_sys_getenv (const)
You can’t perform that action at this time.
0 commit comments