Skip to content

Commit 9e97080

Browse files
author
Michael Bryan
authored
Merge pull request #34 from hotg-ai/hotfix/remove-cdylib-crate-type
Remove the "cdylib" crate-type from all proc-blocks
2 parents 08c82fc + f26a528 commit 9e97080

File tree

19 files changed

+62
-93
lines changed

19 files changed

+62
-93
lines changed

.github/workflows/main.yml

+30-3
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,13 @@ jobs:
2727
~/.cargo
2828
target/
2929
Cargo.lock
30-
key: ${{ runner.os }}-cargo-${{ matrix.rust }}
30+
key: ${{ runner.os }}-${{ github.job }}-${{ matrix.rust }}
3131
- name: Setup Rust Toolchain
3232
uses: actions-rs/toolchain@v1
3333
with:
3434
profile: minimal
3535
toolchain: ${{ matrix.rust }}
3636
override: true
37-
target: wasm32-unknown-unknown
3837
- run: ls -la */*
3938
- name: Type Checking
4039
uses: actions-rs/cargo@v1
@@ -51,11 +50,39 @@ jobs:
5150
with:
5251
command: test
5352
args: --all --verbose
53+
54+
compile-to-wasm:
55+
name: Compile to WebAssembly
56+
runs-on: ubuntu-latest
57+
strategy:
58+
matrix:
59+
rust:
60+
- nightly
61+
steps:
62+
- uses: actions/checkout@v2
63+
with:
64+
submodules: true
65+
- uses: actions/cache@v1
66+
with:
67+
path: |
68+
~/.cargo
69+
target/
70+
Cargo.lock
71+
key: ${{ runner.os }}-${{ github.job }}-${{ matrix.rust }}
72+
- name: Setup Rust Toolchain
73+
uses: actions-rs/toolchain@v1
74+
with:
75+
profile: minimal
76+
toolchain: ${{ matrix.rust }}
77+
override: true
78+
target: wasm32-unknown-unknown
5479
- name: Compile to WebAssembly
5580
uses: actions-rs/cargo@v1
5681
with:
5782
command: xtask
5883
args: dist --out-dir target/proc-blocks
84+
env:
85+
RUST_LOG: xtask=debug
5986
- name: Save Compiled proc-blocks
6087
uses: actions/upload-artifact@v2
6188
with:
@@ -74,7 +101,7 @@ jobs:
74101
if: github.ref == 'refs/heads/master'
75102
- name: Invalidate Cloudfront
76103
run: aws cloudfront create-invalidation --distribution-id=${{ secrets.AWS_DISTRIBUTION_ID }} --paths="/proc-blocks/*"
77-
if: github.ref == 'refs/heads/master' && matrix.rust == 'stable'
104+
if: github.ref == 'refs/heads/master'
78105

79106
api-docs:
80107
name: Publish API Docs to GitHub Pages

argmax/Cargo.toml

-3
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,6 @@ repository = "https://github.com/hotg-ai/proc-blocks"
1111
hotg-rune-proc-blocks = "^0.11.0"
1212
wit-bindgen-rust = { git = "https://github.com/bytecodealliance/wit-bindgen", optional = true }
1313

14-
[lib]
15-
crate-type = ["rlib", "cdylib"]
16-
1714
[features]
1815
default = []
1916
metadata = ["wit-bindgen-rust"]

audio_float_conversion/Cargo.toml

-3
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,6 @@ wit-bindgen-rust = { git = "https://github.com/bytecodealliance/wit-bindgen", op
1414
[dev-dependencies]
1515
pretty_assertions = "0.7.2"
1616

17-
[lib]
18-
crate-type = ["rlib", "cdylib"]
19-
2017
[features]
2118
default = []
2219
metadata = ["wit-bindgen-rust"]

binary_classification/Cargo.toml

-3
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,6 @@ repository = "https://github.com/hotg-ai/proc-blocks"
1111
hotg-rune-proc-blocks = "^0.11.0"
1212
wit-bindgen-rust = { git = "https://github.com/bytecodealliance/wit-bindgen", optional = true }
1313

14-
[lib]
15-
crate-type = ["rlib", "cdylib"]
16-
1714
[features]
1815
default = []
1916
metadata = ["wit-bindgen-rust"]

fft/Cargo.toml

-3
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,6 @@ wit-bindgen-rust = { git = "https://github.com/bytecodealliance/wit-bindgen", op
2222
[dev-dependencies]
2323
pretty_assertions = "0.7.2"
2424

25-
[lib]
26-
crate-type = ["rlib", "cdylib"]
27-
2825
[features]
2926
default = []
3027
metadata = ["wit-bindgen-rust"]

image-normalization/Cargo.toml

-3
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,6 @@ num-traits = { version = "0.2.14", default-features = false }
1212
hotg-rune-proc-blocks = "^0.11.0"
1313
wit-bindgen-rust = { git = "https://github.com/bytecodealliance/wit-bindgen", optional = true }
1414

15-
[lib]
16-
crate-type = ["rlib", "cdylib"]
17-
1815
[features]
1916
default = []
2017
metadata = ["wit-bindgen-rust"]

label/Cargo.toml

-3
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,6 @@ hotg-rune-proc-blocks = "^0.11.0"
1313
line-span = "0.1.3"
1414
wit-bindgen-rust = { git = "https://github.com/bytecodealliance/wit-bindgen", optional = true }
1515

16-
[lib]
17-
crate-type = ["rlib", "cdylib"]
18-
1916
[features]
2017
default = []
2118
metadata = ["wit-bindgen-rust"]

modulo/Cargo.toml

-3
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,6 @@ num-traits = { version = "0.2.14", default-features = false }
1313
hotg-rune-proc-blocks = "^0.11.0"
1414
wit-bindgen-rust = { git = "https://github.com/bytecodealliance/wit-bindgen", optional = true }
1515

16-
[lib]
17-
crate-type = ["rlib", "cdylib"]
18-
1916
[features]
2017
default = []
2118
metadata = ["wit-bindgen-rust"]

most_confident_indices/Cargo.toml

-3
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,6 @@ repository = "https://github.com/hotg-ai/proc-blocks"
1111
hotg-rune-proc-blocks = "^0.11.0"
1212
wit-bindgen-rust = { git = "https://github.com/bytecodealliance/wit-bindgen", optional = true }
1313

14-
[lib]
15-
crate-type = ["rlib", "cdylib"]
16-
1714
[features]
1815
default = []
1916
metadata = ["wit-bindgen-rust"]

noise-filtering/Cargo.toml

-3
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,6 @@ libm = "0.2.1"
1313
paste = "1.0.5"
1414
wit-bindgen-rust = { git = "https://github.com/bytecodealliance/wit-bindgen", optional = true }
1515

16-
[lib]
17-
crate-type = ["rlib", "cdylib"]
18-
1916
[features]
2017
default = []
2118
metadata = ["wit-bindgen-rust"]

normalize/Cargo.toml

-3
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,6 @@ repository = "https://github.com/hotg-ai/proc-blocks"
1212
hotg-rune-proc-blocks = "^0.11.0"
1313
wit-bindgen-rust = { git = "https://github.com/bytecodealliance/wit-bindgen", optional = true }
1414

15-
[lib]
16-
crate-type = ["rlib", "cdylib"]
17-
1815
[features]
1916
default = []
2017
metadata = ["wit-bindgen-rust"]

object_filter/Cargo.toml

-3
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,6 @@ hotg-rune-proc-blocks = "^0.11.0"
1212
libm = {version = "0.2.1", default-features = false}
1313
wit-bindgen-rust = { git = "https://github.com/bytecodealliance/wit-bindgen", optional = true }
1414

15-
[lib]
16-
crate-type = ["rlib", "cdylib"]
17-
1815
[features]
1916
default = []
2017
metadata = ["wit-bindgen-rust"]

parse/Cargo.toml

-3
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,6 @@ repository = "https://github.com/hotg-ai/proc-blocks"
1111
hotg-rune-proc-blocks = "^0.11.0"
1212
wit-bindgen-rust = { git = "https://github.com/bytecodealliance/wit-bindgen", optional = true }
1313

14-
[lib]
15-
crate-type = ["rlib", "cdylib"]
16-
1714
[features]
1815
default = []
1916
metadata = ["wit-bindgen-rust"]

segment_output/Cargo.toml

-3
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,6 @@ repository = "https://github.com/hotg-ai/proc-blocks"
1111
hotg-rune-proc-blocks = "^0.11.0"
1212
wit-bindgen-rust = { git = "https://github.com/bytecodealliance/wit-bindgen", optional = true }
1313

14-
[lib]
15-
crate-type = ["rlib", "cdylib"]
16-
1714
[features]
1815
default = []
1916
metadata = ["wit-bindgen-rust"]

softmax/Cargo.toml

-3
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,6 @@ hotg-rune-proc-blocks = "^0.11.0"
1212
libm = {version = "0.2.1", default-features = false}
1313
wit-bindgen-rust = { git = "https://github.com/bytecodealliance/wit-bindgen", optional = true }
1414

15-
[lib]
16-
crate-type = ["rlib", "cdylib"]
17-
1815
[features]
1916
default = []
2017
metadata = ["wit-bindgen-rust"]

text_extractor/Cargo.toml

-3
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,6 @@ repository = "https://github.com/hotg-ai/proc-blocks"
1111
hotg-rune-proc-blocks = "^0.11.0"
1212
wit-bindgen-rust = { git = "https://github.com/bytecodealliance/wit-bindgen", optional = true }
1313

14-
[lib]
15-
crate-type = ["rlib", "cdylib"]
16-
1714
[features]
1815
default = []
1916
metadata = ["wit-bindgen-rust"]

tokenizers/Cargo.toml

-3
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,6 @@ anyhow = { version = "1.0", default-features = false }
1414
unicode-normalization = {version = "0.1.19", default-features =false}
1515
wit-bindgen-rust = { git = "https://github.com/bytecodealliance/wit-bindgen", optional = true }
1616

17-
[lib]
18-
crate-type = ["rlib", "cdylib"]
19-
2017
[features]
2118
default = []
2219
metadata = ["wit-bindgen-rust"]

utf8_decode/Cargo.toml

-3
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,6 @@ repository = "https://github.com/hotg-ai/proc-blocks"
1111
hotg-rune-proc-blocks = "^0.11.0"
1212
wit-bindgen-rust = { git = "https://github.com/bytecodealliance/wit-bindgen", optional = true }
1313

14-
[lib]
15-
crate-type = ["rlib", "cdylib"]
16-
1714
[features]
1815
default = []
1916
metadata = ["wit-bindgen-rust"]

xtask/src/build.rs

+32-39
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,11 @@ pub fn discover_proc_block_manifests(
4646
Ok(ProcBlocks {
4747
packages,
4848
target_dir: metadata.target_directory.into_std_path_buf(),
49-
workspace_root: workspace_root.to_path_buf(),
5049
})
5150
}
5251

5352
#[derive(Debug)]
5453
pub struct ProcBlocks {
55-
workspace_root: PathBuf,
5654
packages: Vec<Package>,
5755
target_dir: PathBuf,
5856
}
@@ -70,48 +68,43 @@ impl ProcBlocks {
7068
let cargo =
7169
std::env::var("CARGO").unwrap_or_else(|_| "cargo".to_string());
7270

73-
let mut cmd = Command::new(cargo);
74-
cmd.arg("build")
75-
.arg("--manifest-path")
76-
.arg(&self.workspace_root)
77-
.arg("--workspace")
78-
.arg("--target=wasm32-unknown-unknown")
79-
.arg("--exclude=xtask")
80-
.arg("--features=metadata");
81-
82-
match mode {
83-
CompilationMode::Release => {
84-
cmd.arg("--release");
85-
},
86-
CompilationMode::Debug => {},
87-
}
71+
let mut libs = Vec::new();
72+
73+
for package in &self.packages {
74+
let mut cmd = Command::new(&cargo);
75+
cmd.arg("rustc")
76+
.arg("--manifest-path")
77+
.arg(&package.manifest_path)
78+
.arg("--lib")
79+
.arg("--target=wasm32-unknown-unknown")
80+
.arg("--features=metadata")
81+
.arg("-Zunstable-options")
82+
.arg("--crate-type=cdylib");
83+
84+
match mode {
85+
CompilationMode::Release => {
86+
cmd.arg("--release");
87+
},
88+
CompilationMode::Debug => {},
89+
}
8890

89-
tracing::debug!(command = ?cmd, "Running cargo build");
91+
tracing::debug!(command = ?cmd, "Running cargo build");
9092

91-
let status = cmd.status().with_context(|| {
92-
format!(
93-
"Unable to start \"{}\"",
94-
cmd.get_program().to_string_lossy()
95-
)
96-
})?;
93+
let status = cmd.status().with_context(|| {
94+
format!(
95+
"Unable to start \"{}\"",
96+
cmd.get_program().to_string_lossy()
97+
)
98+
})?;
9799

98-
tracing::debug!(exit_code = ?status.code(), "Cargo build completed");
100+
tracing::debug!(exit_code = ?status.code(), "Cargo build completed");
99101

100-
if !status.success() {
101-
anyhow::bail!("Compilation failed");
102-
}
102+
if !status.success() {
103+
anyhow::bail!("Compilation failed");
104+
}
103105

104-
let libs: Vec<_> = self
105-
.packages
106-
.iter()
107-
.filter(|pkg| pkg.features.contains_key("metadata"))
108-
.filter_map(|pkg| {
109-
pkg.targets
110-
.iter()
111-
.find(|t| t.kind.iter().any(|k| k == "cdylib"))
112-
.map(|t| &t.name)
113-
})
114-
.collect();
106+
libs.push(&package.name);
107+
}
115108

116109
tracing::debug!(?libs);
117110

0 commit comments

Comments
 (0)