-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Roman Volosatovs <[email protected]>
- Loading branch information
1 parent
e420cdd
commit adc2ba2
Showing
5 changed files
with
36 additions
and
15 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|