Skip to content

Commit e0e93f9

Browse files
committed
Generate and test debugmozjs artifacts
Signed-off-by: sagudev <[email protected]>
1 parent 29d28f6 commit e0e93f9

File tree

4 files changed

+43
-36
lines changed

4 files changed

+43
-36
lines changed

.github/workflows/build.yml

Lines changed: 22 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
strategy:
2020
fail-fast: false
2121
matrix:
22-
features: ["debugmozjs", '""']
22+
features: ["debugmozjs", ""]
2323
platform:
2424
- { target: aarch64-apple-darwin, os: macos-14 }
2525
- { target: x86_64-apple-darwin, os: macos-13 }
@@ -40,21 +40,20 @@ jobs:
4040
uses: mozilla-actions/[email protected]
4141
- name: Build
4242
run: |
43-
cargo build --verbose --features ${{ matrix.features }}
44-
cargo test --tests --examples --verbose --features ${{ matrix.features }}
43+
cargo build --verbose --features "${{ matrix.features }}"
44+
cargo test --tests --examples --verbose --features "${{ matrix.features }}"
4545
4646
- name: Generate artifact attestation
4747
uses: actions/attest-build-provenance@v1
48-
if: ${{ inputs.release && matrix.features != 'debugmozjs' }}
48+
if: ${{ inputs.release }}
4949
with:
50-
subject-path: ./target/libmozjs-${{ matrix.platform.target }}.tar.gz
50+
subject-path: ./target/libmozjs-${{ matrix.platform.target }}${{ matrix.features && '-debugmozjs' || '' }}.tar.gz
5151

5252
- name: Upload artifact
53-
if: ${{ matrix.features != 'debugmozjs' }}
5453
uses: actions/upload-artifact@v4
5554
with:
56-
path: ./target/libmozjs-${{ matrix.platform.target }}.tar.gz
57-
name: libmozjs-${{ matrix.platform.target }}.tar.gz
55+
path: ./target/libmozjs-${{ matrix.platform.target }}${{ matrix.features && '-debugmozjs' || '' }}.tar.gz
56+
name: libmozjs-${{ matrix.platform.target }}${{ matrix.features && '-debugmozjs' || '' }}.tar.gz
5857

5958
linux:
6059
env:
@@ -65,7 +64,7 @@ jobs:
6564
strategy:
6665
fail-fast: false
6766
matrix:
68-
features: ["debugmozjs", '""']
67+
features: ["debugmozjs", ""]
6968
steps:
7069
- uses: actions/checkout@v4
7170
- uses: dtolnay/rust-toolchain@stable
@@ -76,8 +75,8 @@ jobs:
7675
uses: mozilla-actions/[email protected]
7776
- name: Build
7877
run: |
79-
cargo build --verbose --features ${{ matrix.features }}
80-
cargo test --tests --examples --verbose --features ${{ matrix.features }}
78+
cargo build --verbose --features "${{ matrix.features }}"
79+
cargo test --tests --examples --verbose --features "${{ matrix.features }}"
8180
- name: Check wrappers integrity
8281
# we generate wrappers only without debugmozjs
8382
if: ${{ matrix.features != 'debugmozjs' }}
@@ -87,23 +86,22 @@ jobs:
8786
8887
- name: Generate artifact attestation
8988
uses: actions/attest-build-provenance@v1
90-
if: ${{ inputs.release && matrix.features != 'debugmozjs' }}
89+
if: ${{ inputs.release }}
9190
with:
92-
subject-path: ./target/libmozjs-x86_64-unknown-linux-gnu.tar.gz
91+
subject-path: ./target/libmozjs-x86_64-unknown-linux-gnu${{ matrix.features && '-debugmozjs' || '' }}.tar.gz
9392

9493
- name: Upload artifact
95-
if: ${{ matrix.features != 'debugmozjs' }}
9694
uses: actions/upload-artifact@v4
9795
with:
98-
path: ./target/libmozjs-x86_64-unknown-linux-gnu.tar.gz
99-
name: libmozjs-x86_64-unknown-linux-gnu.tar.gz
96+
path: ./target/libmozjs-x86_64-unknown-linux-gnu${{ matrix.features && '-debugmozjs' || '' }}.tar.gz
97+
name: libmozjs-x86_64-unknown-linux-gnu${{ matrix.features && '-debugmozjs' || '' }}.tar.gz
10098

10199
windows:
102100
runs-on: windows-latest
103101
strategy:
104102
fail-fast: false
105103
matrix:
106-
features: ["debugmozjs", '""']
104+
features: ["debugmozjs", ""]
107105
target: ["x86_64-pc-windows-msvc", "aarch64-pc-windows-msvc"]
108106
env:
109107
LINKER: "lld-link.exe"
@@ -126,25 +124,25 @@ jobs:
126124
- name: Build Windows
127125
shell: cmd
128126
run: |
129-
cargo build --verbose --target ${{ matrix.target }} --features ${{ matrix.features }}
127+
cargo build --verbose --target ${{ matrix.target }} --features "${{ matrix.features }}"
130128
- name: Test Windows
131129
if: ${{ !contains(matrix.target, 'aarch64') }}
132130
shell: cmd
133131
run: |
134-
cargo test --tests --examples --verbose --target ${{ matrix.target }} --features ${{ matrix.features }}
132+
cargo test --tests --examples --verbose --target ${{ matrix.target }} --features "${{ matrix.features }}"
135133
136134
- name: Generate artifact attestation
137135
uses: actions/attest-build-provenance@v1
138-
if: ${{ inputs.release && !contains(matrix.target, 'aarch64') && matrix.features != 'debugmozjs' }}
136+
if: ${{ inputs.release && !contains(matrix.target, 'aarch64') }}
139137
with:
140-
subject-path: ./target/${{ matrix.target }}/libmozjs-x86_64-pc-windows-msvc.tar.gz
138+
subject-path: ./target/${{ matrix.target }}/libmozjs-${{ matrix.target }}${{ matrix.features && '-debugmozjs' || '' }}.tar.gz
141139

142140
- name: Upload artifact
143-
if: ${{ !contains(matrix.target, 'aarch64') && matrix.features != 'debugmozjs' }}
141+
if: ${{ !contains(matrix.target, 'aarch64') }}
144142
uses: actions/upload-artifact@v4
145143
with:
146-
path: ./target/${{ matrix.target }}/libmozjs-x86_64-pc-windows-msvc.tar.gz
147-
name: libmozjs-x86_64-pc-windows-msvc.tar.gz
144+
path: ./target/${{ matrix.target }}/libmozjs-${{ matrix.target }}${{ matrix.features && '-debugmozjs' || '' }}.tar.gz
145+
name: libmozjs-${{ matrix.target }}${{ matrix.features && '-debugmozjs' || '' }}.tar.gz
148146

149147
android:
150148
runs-on: ubuntu-latest

.github/workflows/release-check.yml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ jobs:
1919
strategy:
2020
fail-fast: false
2121
matrix:
22+
features: ["debugmozjs", ""]
2223
platform:
2324
- { target: aarch64-apple-darwin, os: macos-14 }
2425
- { target: x86_64-apple-darwin, os: macos-13 }
@@ -39,15 +40,15 @@ jobs:
3940
env:
4041
MOZJS_ARCHIVE: libmozjs-${{ matrix.platform.target }}.tar.gz
4142
run: |
42-
cargo build --verbose
43-
cargo test --tests --examples --verbose
43+
cargo build --verbose --features "${{ matrix.features }}"
44+
cargo test --tests --examples --verbose --features "${{ matrix.features }}"
4445
- name: Build from auto-download
4546
if: ${{ env.RELEASE_TAG != '' }}
4647
env:
4748
MOZJS_ATTESTATION: strict
4849
run: |
49-
cargo build --verbose
50-
cargo test --tests --examples --verbose
50+
cargo build --verbose --features "${{ matrix.features }}"
51+
cargo test --tests --examples --verbose --features "${{ matrix.features }}"
5152
5253
verify-archive-ohos:
5354
name: "Verify archive OpenHarmony"

mozjs-sys/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
name = "mozjs_sys"
33
description = "System crate for the Mozilla SpiderMonkey JavaScript engine."
44
repository.workspace = true
5-
version = "0.128.3-9"
5+
version = "0.128.3-10"
66
authors = ["Mozilla"]
77
links = "mozjs"
88
build = "build.rs"

mozjs-sys/build.rs

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -131,9 +131,6 @@ fn should_build_from_source() -> bool {
131131
true
132132
} else if env::var_os("MOZJS_ARCHIVE").is_some() {
133133
false
134-
} else if env::var_os("CARGO_FEATURE_DEBUGMOZJS").is_some() {
135-
println!("debug-mozjs feature is enabled. Building from source directly.");
136-
true
137134
} else {
138135
false
139136
}
@@ -863,7 +860,7 @@ fn get_cargo_target_dir(build_dir: &Path) -> Option<&Path> {
863860
fn compress_static_lib(build_dir: &Path) -> Result<(), std::io::Error> {
864861
let target = env::var("TARGET").unwrap();
865862
let target_dir = get_cargo_target_dir(build_dir).unwrap().display();
866-
let tar_gz = File::create(format!("{}/libmozjs-{}.tar.gz", target_dir, target))?;
863+
let tar_gz = File::create(format!("{}/{}", target_dir, archive()))?;
867864
let enc = GzEncoder::new(tar_gz, Compression::default());
868865
let mut tar = tar::Builder::new(enc);
869866

@@ -1046,13 +1043,23 @@ fn attest_artifact(kind: AttestationType, archive_path: &Path) -> Result<(), std
10461043
Ok(())
10471044
}
10481045

1046+
/// Returns name of libmozjs archive
1047+
fn archive() -> String {
1048+
let target = env::var("TARGET").unwrap();
1049+
let features = if env::var_os("CARGO_FEATURE_DEBUGMOZJS").is_some() {
1050+
"-debugmozjs"
1051+
} else {
1052+
""
1053+
};
1054+
format!("libmozjs-{target}{features}.tar.gz")
1055+
}
1056+
10491057
/// Download the SpiderMonkey archive with cURL using the provided base URL. If it's None,
10501058
/// it will use `servo/mozjs`'s release page as the base URL.
10511059
fn download_archive(base: Option<&str>) -> Result<PathBuf, std::io::Error> {
10521060
let base = base.unwrap_or("https://github.com/servo/mozjs/releases");
10531061
let version = env::var("CARGO_PKG_VERSION").unwrap();
1054-
let target = env::var("TARGET").unwrap();
1055-
let archive_path = PathBuf::from(env::var_os("OUT_DIR").unwrap()).join("libmozjs.tar.gz");
1062+
let archive_path = PathBuf::from(env::var_os("OUT_DIR").unwrap()).join(&archive());
10561063
if !archive_path.exists() {
10571064
eprintln!("Trying to download prebuilt mozjs static library from Github Releases");
10581065
let curl_start = Instant::now();
@@ -1063,7 +1070,8 @@ fn download_archive(base: Option<&str>) -> Result<PathBuf, std::io::Error> {
10631070
.arg("-o")
10641071
.arg(&archive_path)
10651072
.arg(format!(
1066-
"{base}/download/mozjs-sys-v{version}/libmozjs-{target}.tar.gz"
1073+
"{base}/download/mozjs-sys-v{version}/{}",
1074+
archive()
10671075
))
10681076
.status()?
10691077
.success()

0 commit comments

Comments
 (0)