Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove the "cdylib" crate-type from all proc-blocks #34

Merged
merged 3 commits into from
Mar 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 30 additions & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,13 @@ jobs:
~/.cargo
target/
Cargo.lock
key: ${{ runner.os }}-cargo-${{ matrix.rust }}
key: ${{ runner.os }}-${{ github.job }}-${{ matrix.rust }}
- name: Setup Rust Toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: ${{ matrix.rust }}
override: true
target: wasm32-unknown-unknown
- run: ls -la */*
- name: Type Checking
uses: actions-rs/cargo@v1
Expand All @@ -51,11 +50,39 @@ jobs:
with:
command: test
args: --all --verbose

compile-to-wasm:
name: Compile to WebAssembly
runs-on: ubuntu-latest
strategy:
matrix:
rust:
- nightly
steps:
- uses: actions/checkout@v2
with:
submodules: true
- uses: actions/cache@v1
with:
path: |
~/.cargo
target/
Cargo.lock
key: ${{ runner.os }}-${{ github.job }}-${{ matrix.rust }}
- name: Setup Rust Toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: ${{ matrix.rust }}
override: true
target: wasm32-unknown-unknown
- name: Compile to WebAssembly
uses: actions-rs/cargo@v1
with:
command: xtask
args: dist --out-dir target/proc-blocks
env:
RUST_LOG: xtask=debug
- name: Save Compiled proc-blocks
uses: actions/upload-artifact@v2
with:
Expand All @@ -74,7 +101,7 @@ jobs:
if: github.ref == 'refs/heads/master'
- name: Invalidate Cloudfront
run: aws cloudfront create-invalidation --distribution-id=${{ secrets.AWS_DISTRIBUTION_ID }} --paths="/proc-blocks/*"
if: github.ref == 'refs/heads/master' && matrix.rust == 'stable'
if: github.ref == 'refs/heads/master'

api-docs:
name: Publish API Docs to GitHub Pages
Expand Down
3 changes: 0 additions & 3 deletions argmax/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@ repository = "/~https://github.com/hotg-ai/proc-blocks"
hotg-rune-proc-blocks = "^0.11.0"
wit-bindgen-rust = { git = "/~https://github.com/bytecodealliance/wit-bindgen", optional = true }

[lib]
crate-type = ["rlib", "cdylib"]

[features]
default = []
metadata = ["wit-bindgen-rust"]
3 changes: 0 additions & 3 deletions audio_float_conversion/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@ wit-bindgen-rust = { git = "/~https://github.com/bytecodealliance/wit-bindgen", op
[dev-dependencies]
pretty_assertions = "0.7.2"

[lib]
crate-type = ["rlib", "cdylib"]

[features]
default = []
metadata = ["wit-bindgen-rust"]
3 changes: 0 additions & 3 deletions binary_classification/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@ repository = "/~https://github.com/hotg-ai/proc-blocks"
hotg-rune-proc-blocks = "^0.11.0"
wit-bindgen-rust = { git = "/~https://github.com/bytecodealliance/wit-bindgen", optional = true }

[lib]
crate-type = ["rlib", "cdylib"]

[features]
default = []
metadata = ["wit-bindgen-rust"]
3 changes: 0 additions & 3 deletions fft/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,6 @@ wit-bindgen-rust = { git = "/~https://github.com/bytecodealliance/wit-bindgen", op
[dev-dependencies]
pretty_assertions = "0.7.2"

[lib]
crate-type = ["rlib", "cdylib"]

[features]
default = []
metadata = ["wit-bindgen-rust"]
Expand Down
3 changes: 0 additions & 3 deletions image-normalization/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@ num-traits = { version = "0.2.14", default-features = false }
hotg-rune-proc-blocks = "^0.11.0"
wit-bindgen-rust = { git = "/~https://github.com/bytecodealliance/wit-bindgen", optional = true }

[lib]
crate-type = ["rlib", "cdylib"]

[features]
default = []
metadata = ["wit-bindgen-rust"]
3 changes: 0 additions & 3 deletions label/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@ hotg-rune-proc-blocks = "^0.11.0"
line-span = "0.1.3"
wit-bindgen-rust = { git = "/~https://github.com/bytecodealliance/wit-bindgen", optional = true }

[lib]
crate-type = ["rlib", "cdylib"]

[features]
default = []
metadata = ["wit-bindgen-rust"]
3 changes: 0 additions & 3 deletions modulo/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@ num-traits = { version = "0.2.14", default-features = false }
hotg-rune-proc-blocks = "^0.11.0"
wit-bindgen-rust = { git = "/~https://github.com/bytecodealliance/wit-bindgen", optional = true }

[lib]
crate-type = ["rlib", "cdylib"]

[features]
default = []
metadata = ["wit-bindgen-rust"]
Expand Down
3 changes: 0 additions & 3 deletions most_confident_indices/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@ repository = "/~https://github.com/hotg-ai/proc-blocks"
hotg-rune-proc-blocks = "^0.11.0"
wit-bindgen-rust = { git = "/~https://github.com/bytecodealliance/wit-bindgen", optional = true }

[lib]
crate-type = ["rlib", "cdylib"]

[features]
default = []
metadata = ["wit-bindgen-rust"]
3 changes: 0 additions & 3 deletions noise-filtering/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@ libm = "0.2.1"
paste = "1.0.5"
wit-bindgen-rust = { git = "/~https://github.com/bytecodealliance/wit-bindgen", optional = true }

[lib]
crate-type = ["rlib", "cdylib"]

[features]
default = []
metadata = ["wit-bindgen-rust"]
3 changes: 0 additions & 3 deletions normalize/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@ repository = "/~https://github.com/hotg-ai/proc-blocks"
hotg-rune-proc-blocks = "^0.11.0"
wit-bindgen-rust = { git = "/~https://github.com/bytecodealliance/wit-bindgen", optional = true }

[lib]
crate-type = ["rlib", "cdylib"]

[features]
default = []
metadata = ["wit-bindgen-rust"]
3 changes: 0 additions & 3 deletions object_filter/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@ hotg-rune-proc-blocks = "^0.11.0"
libm = {version = "0.2.1", default-features = false}
wit-bindgen-rust = { git = "/~https://github.com/bytecodealliance/wit-bindgen", optional = true }

[lib]
crate-type = ["rlib", "cdylib"]

[features]
default = []
metadata = ["wit-bindgen-rust"]
3 changes: 0 additions & 3 deletions parse/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@ repository = "/~https://github.com/hotg-ai/proc-blocks"
hotg-rune-proc-blocks = "^0.11.0"
wit-bindgen-rust = { git = "/~https://github.com/bytecodealliance/wit-bindgen", optional = true }

[lib]
crate-type = ["rlib", "cdylib"]

[features]
default = []
metadata = ["wit-bindgen-rust"]
3 changes: 0 additions & 3 deletions segment_output/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@ repository = "/~https://github.com/hotg-ai/proc-blocks"
hotg-rune-proc-blocks = "^0.11.0"
wit-bindgen-rust = { git = "/~https://github.com/bytecodealliance/wit-bindgen", optional = true }

[lib]
crate-type = ["rlib", "cdylib"]

[features]
default = []
metadata = ["wit-bindgen-rust"]
3 changes: 0 additions & 3 deletions softmax/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@ hotg-rune-proc-blocks = "^0.11.0"
libm = {version = "0.2.1", default-features = false}
wit-bindgen-rust = { git = "/~https://github.com/bytecodealliance/wit-bindgen", optional = true }

[lib]
crate-type = ["rlib", "cdylib"]

[features]
default = []
metadata = ["wit-bindgen-rust"]
Expand Down
3 changes: 0 additions & 3 deletions text_extractor/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@ repository = "/~https://github.com/hotg-ai/proc-blocks"
hotg-rune-proc-blocks = "^0.11.0"
wit-bindgen-rust = { git = "/~https://github.com/bytecodealliance/wit-bindgen", optional = true }

[lib]
crate-type = ["rlib", "cdylib"]

[features]
default = []
metadata = ["wit-bindgen-rust"]
Expand Down
3 changes: 0 additions & 3 deletions tokenizers/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@ anyhow = { version = "1.0", default-features = false }
unicode-normalization = {version = "0.1.19", default-features =false}
wit-bindgen-rust = { git = "/~https://github.com/bytecodealliance/wit-bindgen", optional = true }

[lib]
crate-type = ["rlib", "cdylib"]

[features]
default = []
metadata = ["wit-bindgen-rust"]
3 changes: 0 additions & 3 deletions utf8_decode/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@ repository = "/~https://github.com/hotg-ai/proc-blocks"
hotg-rune-proc-blocks = "^0.11.0"
wit-bindgen-rust = { git = "/~https://github.com/bytecodealliance/wit-bindgen", optional = true }

[lib]
crate-type = ["rlib", "cdylib"]

[features]
default = []
metadata = ["wit-bindgen-rust"]
71 changes: 32 additions & 39 deletions xtask/src/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,11 @@ pub fn discover_proc_block_manifests(
Ok(ProcBlocks {
packages,
target_dir: metadata.target_directory.into_std_path_buf(),
workspace_root: workspace_root.to_path_buf(),
})
}

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

let mut cmd = Command::new(cargo);
cmd.arg("build")
.arg("--manifest-path")
.arg(&self.workspace_root)
.arg("--workspace")
.arg("--target=wasm32-unknown-unknown")
.arg("--exclude=xtask")
.arg("--features=metadata");

match mode {
CompilationMode::Release => {
cmd.arg("--release");
},
CompilationMode::Debug => {},
}
let mut libs = Vec::new();

for package in &self.packages {
let mut cmd = Command::new(&cargo);
cmd.arg("rustc")
.arg("--manifest-path")
.arg(&package.manifest_path)
.arg("--lib")
.arg("--target=wasm32-unknown-unknown")
.arg("--features=metadata")
.arg("-Zunstable-options")
.arg("--crate-type=cdylib");

match mode {
CompilationMode::Release => {
cmd.arg("--release");
},
CompilationMode::Debug => {},
}

tracing::debug!(command = ?cmd, "Running cargo build");
tracing::debug!(command = ?cmd, "Running cargo build");

let status = cmd.status().with_context(|| {
format!(
"Unable to start \"{}\"",
cmd.get_program().to_string_lossy()
)
})?;
let status = cmd.status().with_context(|| {
format!(
"Unable to start \"{}\"",
cmd.get_program().to_string_lossy()
)
})?;

tracing::debug!(exit_code = ?status.code(), "Cargo build completed");
tracing::debug!(exit_code = ?status.code(), "Cargo build completed");

if !status.success() {
anyhow::bail!("Compilation failed");
}
if !status.success() {
anyhow::bail!("Compilation failed");
}

let libs: Vec<_> = self
.packages
.iter()
.filter(|pkg| pkg.features.contains_key("metadata"))
.filter_map(|pkg| {
pkg.targets
.iter()
.find(|t| t.kind.iter().any(|k| k == "cdylib"))
.map(|t| &t.name)
})
.collect();
libs.push(&package.name);
}

tracing::debug!(?libs);

Expand Down