Skip to content

Commit

Permalink
chore: remove sys/build.rs
Browse files Browse the repository at this point in the history
Signed-off-by: Roman Volosatovs <[email protected]>
  • Loading branch information
rvolosatovs committed Sep 20, 2024
1 parent e420cdd commit adc2ba2
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 15 deletions.
9 changes: 8 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions crates/generate-header/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[package]
name = "generate-header"
version = "0.1.0"
publish = false

authors.workspace = true
categories.workspace = true
edition.workspace = true
homepage.workspace = true
license.workspace = true
repository.workspace = true

[dependencies]
anyhow = { workspace = true, features = ["std"] }
cbindgen = { workspace = true }
19 changes: 10 additions & 9 deletions crates/sys/build.rs → crates/generate-header/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,25 +1,26 @@
use std::env;
use std::path::Path;
use std::path::PathBuf;

use anyhow::Context as _;

fn main() -> anyhow::Result<()> {
let crate_dir =
env::var("CARGO_MANIFEST_DIR").context("failed to lookup `CARGO_MANIFEST_DIR`")?;
let crate_dir = PathBuf::from(crate_dir);
let crates = crate_dir
.parent()
.context("failed to lookup crate parent directory")?;
let root = crates
.parent()
.context("failed to lookup workspace root directory")?;
let bindings = cbindgen::generate_with_config(
&crate_dir,
crates.join("sys"),
cbindgen::Config {
language: cbindgen::Language::C,
..Default::default()
},
)
.context("failed to generate bindings")?;
bindings.write_to_file(
Path::new(&crate_dir)
.join("..")
.join("..")
.join("include")
.join("west.h"),
);
bindings.write_to_file(root.join("include").join("west.h"));
Ok(())
}
6 changes: 1 addition & 5 deletions crates/sys/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "west-sys"
version = "0.1.0"
version = "0.1.1"
description = "WebAssembly component test runtime C bindings"

authors.workspace = true
Expand All @@ -20,7 +20,3 @@ wasmtime = { workspace = true }
wasmtime-cabish = { workspace = true }
wasmtime-wasi = { workspace = true }
west = { workspace = true }

[build-dependencies]
anyhow = { workspace = true }
cbindgen = { workspace = true }
2 changes: 2 additions & 0 deletions west.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:generate cargo run -p generate-header

package west

// #cgo LDFLAGS: -lwest
Expand Down

0 comments on commit adc2ba2

Please sign in to comment.