Skip to content

Commit

Permalink
Fix js-confdefs.h includes (#521)
Browse files Browse the repository at this point in the history
* Add streams available test

Signed-off-by: sagudev <[email protected]>

* try

Signed-off-by: sagudev <[email protected]>

* Fix usages of FI

Signed-off-by: sagudev <[email protected]>

* try

Signed-off-by: sagudev <[email protected]>

* fmt

Signed-off-by: sagudev <[email protected]>

---------

Signed-off-by: sagudev <[email protected]>
  • Loading branch information
sagudev authored Nov 4, 2024
1 parent 3a0a5f0 commit 8526195
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 12 deletions.
2 changes: 1 addition & 1 deletion mozjs-sys/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "mozjs_sys"
description = "System crate for the Mozilla SpiderMonkey JavaScript engine."
repository.workspace = true
version = "0.128.3-3"
version = "0.128.3-4"
authors = ["Mozilla"]
links = "mozjs"
build = "build.rs"
Expand Down
17 changes: 6 additions & 11 deletions mozjs-sys/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -704,7 +704,8 @@ mod jsglue {

let confdefs_path: PathBuf = outdir.join("js/src/js-confdefs.h");
let msvc = if build.get_compiler().is_like_msvc() {
build.flag(&format!("-FI{}", confdefs_path.to_string_lossy()));
build.flag("-FI");
build.flag(&confdefs_path);
build.define("WIN32", "");
build.flag("-Zi");
build.flag("-GR-");
Expand Down Expand Up @@ -733,19 +734,13 @@ mod jsglue {
.clang_args(["-I", &include_path.to_string_lossy()])
.enable_cxx_namespaces()
.allowlist_file("./src/jsglue.cpp")
.allowlist_recursively(false);
.allowlist_recursively(false)
.clang_args(["-include", &confdefs_path.to_str().expect("UTF-8")]);

if msvc {
builder = builder.clang_args([
"-fms-compatibility",
&format!("-FI{}", confdefs_path.to_string_lossy()),
"-DWIN32",
"-std=c++17",
])
builder = builder.clang_args(["-fms-compatibility", "-DWIN32", "-std=c++17"])
} else {
builder = builder
.clang_args(["-fPIC", "-fno-rtti", "-std=c++17"])
.clang_args(["-include", &confdefs_path.to_str().expect("UTF-8")])
builder = builder.clang_args(["-fPIC", "-fno-rtti", "-std=c++17"])
}

for ty in BLACKLIST_TYPES {
Expand Down
22 changes: 22 additions & 0 deletions mozjs-sys/tests/streams_available.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

#![cfg(feature = "streams")]

use mozjs_sys::glue::ReadableStreamUnderlyingSourceTraps;

static UNDERLYING_SOURCE_TRAPS: ReadableStreamUnderlyingSourceTraps =
ReadableStreamUnderlyingSourceTraps {
requestData: None,
writeIntoReadRequestBuffer: None,
cancel: None,
onClosed: None,
onErrored: None,
finalize: None,
};

#[test]
fn test_ok() {
assert!(UNDERLYING_SOURCE_TRAPS.requestData.is_none());
}

0 comments on commit 8526195

Please sign in to comment.