File tree Expand file tree Collapse file tree 12 files changed +97
-12
lines changed Expand file tree Collapse file tree 12 files changed +97
-12
lines changed Original file line number Diff line number Diff line change 36
36
- name : Test
37
37
env :
38
38
CARGO_TARGET_WASM32_WASI_RUNNER : wasmtime --dir=.
39
- run : cargo hack wasi test --workspace --exclude=javy-cli --each-feature -- --nocapture
39
+ run : cargo hack wasi test --workspace --exclude=javy-cli --exclude=javy-config --each-feature -- --nocapture
40
+
41
+ - name : Test Config
42
+ run : cargo test --package=javy-config
40
43
41
44
- name : Lint
42
45
run : cargo clippy --workspace --exclude=javy-cli --target=wasm32-wasi --all-targets -- -D warnings
Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ members = [
7
7
" crates/core" ,
8
8
" crates/cli" ,
9
9
" crates/javy-test-macros" ,
10
+ " crates/javy-config" ,
10
11
]
11
12
resolver = " 2"
12
13
@@ -23,7 +24,9 @@ wasmtime-wasi = "19"
23
24
wasi-common = " 19"
24
25
anyhow = " 1.0"
25
26
once_cell = " 1.19"
27
+ bitflags = " 2.5.0"
26
28
javy = { path = " crates/javy" , version = " 3.0.0-alpha.1" }
29
+ javy-config = { path = " crates/javy-config" }
27
30
28
31
[profile .release ]
29
32
lto = true
Original file line number Diff line number Diff line change @@ -41,7 +41,10 @@ test-wpt:
41
41
npm install --prefix wpt
42
42
npm test --prefix wpt
43
43
44
- tests : test-javy test-core test-cli test-wpt
44
+ test-config :
45
+ CARGO_PROFILE_RELEASE_LTO=off cargo test --package=javy-config -- --nocapture
46
+
47
+ tests : test-javy test-core test-cli test-wpt test-config
45
48
46
49
fmt : fmt-quickjs-wasm-sys fmt-quickjs-wasm-rs fmt-javy fmt-apis fmt-core fmt-cli
47
50
Original file line number Diff line number Diff line change @@ -17,6 +17,7 @@ crate-type = ["cdylib"]
17
17
anyhow = { workspace = true }
18
18
javy = { workspace = true , features = [" export_alloc_fns" , " json" ] }
19
19
once_cell = { workspace = true }
20
+ javy-config = { workspace = true }
20
21
21
22
[features ]
22
23
experimental_event_loop = []
Original file line number Diff line number Diff line change 1
1
use anyhow:: anyhow;
2
2
use javy:: Runtime ;
3
+ use javy_config:: Config ;
3
4
use once_cell:: sync:: OnceCell ;
4
5
use std:: slice;
5
6
use std:: str;
@@ -16,7 +17,7 @@ static mut RUNTIME: OnceCell<Runtime> = OnceCell::new();
16
17
/// Used by Wizer to preinitialize the module.
17
18
#[ export_name = "wizer.initialize" ]
18
19
pub extern "C" fn init ( ) {
19
- let runtime = runtime:: new_runtime ( ) . unwrap ( ) ;
20
+ let runtime = runtime:: new ( Config :: all ( ) ) . unwrap ( ) ;
20
21
unsafe {
21
22
RUNTIME
22
23
. set ( runtime)
@@ -43,7 +44,7 @@ pub extern "C" fn init() {
43
44
#[ export_name = "compile_src" ]
44
45
pub unsafe extern "C" fn compile_src ( js_src_ptr : * const u8 , js_src_len : usize ) -> * const u32 {
45
46
// Use fresh runtime to avoid depending on Wizened runtime
46
- let runtime = runtime:: new_runtime ( ) . unwrap ( ) ;
47
+ let runtime = runtime:: new ( Config :: all ( ) ) . unwrap ( ) ;
47
48
let js_src = str:: from_utf8 ( slice:: from_raw_parts ( js_src_ptr, js_src_len) ) . unwrap ( ) ;
48
49
49
50
let bytecode = runtime
Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ use std::slice;
6
6
use std:: str;
7
7
use std:: string:: String ;
8
8
9
+ use javy_config:: Config ;
9
10
mod execution;
10
11
mod runtime;
11
12
@@ -18,7 +19,7 @@ static mut BYTECODE: OnceCell<Vec<u8>> = OnceCell::new();
18
19
pub extern "C" fn init ( ) {
19
20
let _wasm_ctx = WasmCtx :: new ( ) ;
20
21
21
- let runtime = runtime:: new_runtime ( ) . unwrap ( ) ;
22
+ let runtime = runtime:: new ( Config :: all ( ) ) . unwrap ( ) ;
22
23
23
24
let mut contents = String :: new ( ) ;
24
25
io:: stdin ( ) . read_to_string ( & mut contents) . unwrap ( ) ;
Original file line number Diff line number Diff line change 1
1
use anyhow:: Result ;
2
2
use javy:: { Config , Runtime } ;
3
+ use javy_config:: Config as SharedConfig ;
3
4
4
- pub ( crate ) fn new_runtime ( ) -> Result < Runtime > {
5
+ pub ( crate ) fn new ( shared_config : SharedConfig ) -> Result < Runtime > {
5
6
let mut config = Config :: default ( ) ;
6
7
let config = config
7
- . text_encoding ( true )
8
- . redirect_stdout_to_stderr ( true )
9
- . javy_stream_io ( true )
10
- . override_json_parse_and_stringify ( true )
11
- . javy_json ( true ) ;
8
+ . text_encoding ( shared_config. contains ( SharedConfig :: TEXT_ENCODING ) )
9
+ . redirect_stdout_to_stderr ( shared_config. contains ( SharedConfig :: REDIRECT_STDOUT_TO_STDERR ) )
10
+ . javy_stream_io ( shared_config. contains ( SharedConfig :: JAVY_STREAM_IO ) )
11
+ . override_json_parse_and_stringify (
12
+ shared_config. contains ( SharedConfig :: OVERRIDE_JSON_PARSE_AND_STRINGIFY ) ,
13
+ )
14
+ . javy_json ( shared_config. contains ( SharedConfig :: JAVY_JSON ) ) ;
12
15
13
16
Runtime :: new ( std:: mem:: take ( config) )
14
17
}
Original file line number Diff line number Diff line change
1
+ [package ]
2
+ name = " javy-config"
3
+ version.workspace = true
4
+ authors.workspace = true
5
+ edition.workspace = true
6
+ license.workspace = true
7
+
8
+ # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
9
+
10
+ [dependencies ]
11
+ bitflags = { workspace = true }
Original file line number Diff line number Diff line change
1
+ # Shared Configuration for Javy
2
+
3
+ See ` src/lib.rs ` for more details.
You can’t perform that action at this time.
0 commit comments