Skip to content

Commit d76bbd6

Browse files
authored
CI: Adapts to all targets. (#75)
1 parent dccdd78 commit d76bbd6

2 files changed

Lines changed: 18 additions & 31 deletions

File tree

.github/workflows/main.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,8 @@ jobs:
7474
steps:
7575
- uses: actions/checkout@v3
7676
- run: |
77+
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -
78+
sudo add-apt-repository -y 'deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy main'
7779
sudo apt install libclang-dev
7880
cd gen && cargo run --release
7981
git diff --exit-code

gen/src/main.rs

Lines changed: 16 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,7 @@ fn main() {
3636
let entry = entry.unwrap();
3737
assert!(!entry.path().to_str().unwrap().ends_with("."));
3838
if entry.file_type().unwrap().is_dir() {
39-
let path = entry.path();
40-
if !rust_arch_is_pre_gen(path.file_name().unwrap().to_str().unwrap()) {
41-
fs::remove_dir_all(path).ok();
42-
}
39+
fs::remove_dir_all(entry.path()).ok();
4340
}
4441
}
4542

@@ -110,23 +107,20 @@ fn main() {
110107

111108
let mut headers_made = false;
112109
for rust_arch in rust_arches {
113-
let pre_gen = rust_arch_is_pre_gen(rust_arch);
114-
let src_arch = format!("../src/{}", rust_arch);
115-
116-
if !pre_gen {
117-
if !headers_made {
118-
make_headers_install(&linux_arch, &linux_headers);
119-
headers_made = true;
120-
}
121-
122-
fs::create_dir_all(&src_arch).unwrap();
110+
if !headers_made {
111+
make_headers_install(&linux_arch, &linux_headers);
112+
headers_made = true;
123113
}
124114

125115
eprintln!(
126116
"Generating all bindings for Linux {} architecture {}",
127117
linux_version, rust_arch
128118
);
129119

120+
let src_arch = format!("../src/{}", rust_arch);
121+
122+
fs::create_dir_all(&src_arch).unwrap();
123+
130124
let mut modules = fs::read_dir("modules")
131125
.unwrap()
132126
.map(|entry| entry.unwrap())
@@ -157,16 +151,14 @@ fn main() {
157151
writeln!(src_lib_rs, "#[path = \"{}/{}.rs\"]", rust_arch, mod_name).unwrap();
158152
writeln!(src_lib_rs, "pub mod {};", mod_name).unwrap();
159153

160-
if !pre_gen {
161-
run_bindgen(
162-
linux_include.to_str().unwrap(),
163-
header_name.to_str().unwrap(),
164-
&mod_rs,
165-
mod_name,
166-
rust_arch,
167-
linux_version,
168-
);
169-
}
154+
run_bindgen(
155+
linux_include.to_str().unwrap(),
156+
header_name.to_str().unwrap(),
157+
&mod_rs,
158+
mod_name,
159+
rust_arch,
160+
linux_version,
161+
);
170162

171163
// Collect all unique feature names across all architectures.
172164
if features.insert(mod_name.to_owned()) {
@@ -303,13 +295,6 @@ fn rust_arches(linux_arch: &str) -> &[&str] {
303295
}
304296
}
305297

306-
fn rust_arch_is_pre_gen(rust_arch: &str) -> bool {
307-
match rust_arch {
308-
"loongarch64" => true,
309-
_ => false,
310-
}
311-
}
312-
313298
fn run_bindgen(
314299
linux_include: &str,
315300
header_name: &str,

0 commit comments

Comments
 (0)