Commit 55df1faf authored by Yonggang Luo's avatar Yonggang Luo
Browse files

The gen procedure are lowring down

sync it
parent b8b35bdd
......@@ -35,5 +35,12 @@ The motivation for this project is:
## Developing
cargo install --force cargo-make
cargo make
\ No newline at end of file
Build debug version
cargo make build
Build release version
cargo make build --profile production
extern crate cbindgen;
extern crate cc;
use cc;
use std::{env, fs, fs::DirEntry, path::Path};
// include src/header directories that don't start with '_'
fn include_dir(d: &DirEntry) -> bool {
d.metadata().map(|m| m.is_dir()).unwrap_or(false)
&& d.path()
.map_or(false, |c| c.to_str().map_or(false, |x| !x.starts_with("_")))
fn generate_bindings(cbindgen_config_path: &Path) {
let relative_path = cbindgen_config_path
.and_then(|p| p.parent())
.and_then(|p| p.to_str())
.replace("_", "/");
let header_path = Path::new("target/include")
let mod_path = cbindgen_config_path.with_file_name("");
let config = cbindgen::Config::from_file(cbindgen_config_path).unwrap();
.expect("Unable to generate bindings")
use std::{env, fs};
fn main() {
let crate_dir = env::var("CARGO_MANIFEST_DIR").expect("CARGO_MANIFEST_DIR not set");
// Generate C includes
// - based on contents of src/header/**
// - headers written to target/include
.filter(|d| include_dir(d))
.map(|d| d.path().as_path().join("cbindgen.toml"))
.filter(|p| p.exists())
.for_each(|p| {
println!("cargo:rerun-if-changed={:?}", p.parent().unwrap());
println!("cargo:rerun-if-changed={:?}", p);
println!("cargo:rerun-if-changed={:?}", p.with_file_name(""));
let mut build = cc::Build::new();
let compiler = build.get_compiler();
if compiler.is_like_msvc() {
git submodule update --init
cd deps/rust
git submodule update --progress --init -- "library/backtrace"
git submodule update --progress --init -- "library/stdarch"
echo done
set -e
git config -f .gitmodules --get-regexp '^submodule\..*\.path$' |
while read path_key path
url_key=$(echo $path_key | sed 's/\.path/.url/')
url=$(git config -f .gitmodules --get "$url_key")
git submodule add $url $path || true
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment