Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Yonggang Luo
relibc
Commits
55df1faf
Commit
55df1faf
authored
Oct 15, 2020
by
Yonggang Luo
Browse files
The gen procedure are lowring down
sync it
parent
b8b35bdd
Changes
4
Hide whitespace changes
Inline
Side-by-side
README.md
View file @
55df1faf
...
...
@@ -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
```
build.rs
View file @
55df1faf
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
()
.iter
()
.nth
(
2
)
.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
.strip_prefix
(
"src/header"
)
.ok
()
.and_then
(|
p
|
p
.parent
())
.and_then
(|
p
|
p
.to_str
())
.unwrap
()
.replace
(
"_"
,
"/"
);
let
header_path
=
Path
::
new
(
"target/include"
)
.join
(
&
relative_path
)
.with_extension
(
"h"
);
let
mod_path
=
cbindgen_config_path
.with_file_name
(
"mod.rs"
);
let
config
=
cbindgen
::
Config
::
from_file
(
cbindgen_config_path
)
.unwrap
();
cbindgen
::
Builder
::
new
()
.with_config
(
config
)
.with_src
(
mod_path
)
.generate
()
.expect
(
"Unable to generate bindings"
)
.write_to_file
(
header_path
);
}
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
fs
::
read_dir
(
&
Path
::
new
(
"src/header"
))
.unwrap
()
.into_iter
()
.filter_map
(
Result
::
ok
)
.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
(
"mod.rs"
));
generate_bindings
(
&
p
);
});
let
mut
build
=
cc
::
Build
::
new
();
let
compiler
=
build
.get_compiler
();
if
compiler
.is_like_msvc
()
{
...
...
checkout-modules.sh
0 → 100644
View file @
55df1faf
git submodule update
--init
cd
deps/rust
git submodule update
--progress
--init
--
"library/backtrace"
git submodule update
--progress
--init
--
"library/stdarch"
echo
done
restore-modules.sh
0 → 100644
View file @
55df1faf
#!/bin/sh
set
-e
git config
-f
.gitmodules
--get-regexp
'^submodule\..*\.path$'
|
while
read
path_key path
do
url_key
=
$(
echo
$path_key
|
sed
's/\.path/.url/'
)
url
=
$(
git config
-f
.gitmodules
--get
"
$url_key
"
)
git submodule add
$url
$path
||
true
done
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment