Skip to content

Commit d87ce22

Browse files
authored
CI: Generate dependencies information. (#57)
* Generate dependencies information. * NuGet new symbol format generation * Prepare for Java Maven central releases. * Remove temporary NuGet hack.
1 parent e59e034 commit d87ce22

File tree

15 files changed

+359
-75
lines changed

15 files changed

+359
-75
lines changed

.github/workflows/ci.yml

Lines changed: 66 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,52 @@ on:
55
- master
66
pull_request:
77
jobs:
8+
# Lock the dependencies
9+
lock:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Checkout
13+
uses: actions/checkout@v2
14+
with:
15+
path: oo-bindgen
16+
- name: Checkout complicense
17+
uses: actions/checkout@v2
18+
with:
19+
repository: stepfunc/complicense
20+
path: complicense
21+
- name: Install Rust
22+
uses: actions-rs/toolchain@v1
23+
with:
24+
profile: minimal
25+
toolchain: stable
26+
override: true
27+
- name: Caching
28+
uses: Swatinem/rust-cache@v1
29+
- name: Install cargo-license
30+
uses: actions-rs/cargo@v1
31+
with:
32+
command: install
33+
args: cargo-license
34+
- name: Update dependencies
35+
working-directory: oo-bindgen
36+
run: cargo update
37+
- name: Generate dependencies.json
38+
working-directory: oo-bindgen/oo-bindgen
39+
run: cargo-license --avoid-dev-deps --avoid-build-deps -j > ../dependencies.json
40+
- name: Generate dependencies.txt
41+
working-directory: complicense
42+
run: cargo run -- --import ../oo-bindgen/dependencies.json --config ../oo-bindgen/deps-config.json --token ${{ github.token }} > ../oo-bindgen/dependencies.txt
43+
- name: Upload dependencies info
44+
uses: actions/upload-artifact@v2
45+
with:
46+
name: dependencies
47+
path: |
48+
oo-bindgen/Cargo.lock
49+
oo-bindgen/dependencies.json
50+
oo-bindgen/dependencies.txt
851
# Run the unit tests on Windows and Linux
952
test:
53+
needs: lock
1054
strategy:
1155
fail-fast: false
1256
matrix:
@@ -19,7 +63,7 @@ jobs:
1963
runs-on: ${{ matrix.os }}
2064
steps:
2165
- name: Checkout
22-
uses: actions/checkout@v1
66+
uses: actions/checkout@v2
2367
- name: Install Rust ${{ matrix.rust }}
2468
uses: actions-rs/toolchain@v1
2569
with:
@@ -36,10 +80,10 @@ jobs:
3680
run: Copy-Item -Path .cargo/config-linux.toml -Destination .cargo/config.toml
3781
- name: Caching
3882
uses: Swatinem/rust-cache@v1
39-
- name: Update dependencies
40-
uses: actions-rs/cargo@v1
83+
- name: Download Cargo.lock
84+
uses: actions/download-artifact@v2
4185
with:
42-
command: update
86+
name: dependencies
4387
- name: Run Rust unit tests
4488
uses: actions-rs/cargo@v1
4589
with:
@@ -55,7 +99,7 @@ jobs:
5599
runs-on: ubuntu-latest
56100
steps:
57101
- name: Checkout
58-
uses: actions/checkout@v1
102+
uses: actions/checkout@v2
59103
- name: Install Rust ${{ matrix.rust }}
60104
uses: actions-rs/toolchain@v1
61105
with:
@@ -75,6 +119,7 @@ jobs:
75119
args: -- -D warnings
76120
# Build bindings on Windows x64 and Linux x64
77121
bindings:
122+
needs: lock
78123
strategy:
79124
fail-fast: false
80125
matrix:
@@ -84,7 +129,7 @@ jobs:
84129
runs-on: ${{ matrix.os }}
85130
steps:
86131
- name: Checkout
87-
uses: actions/checkout@v1
132+
uses: actions/checkout@v2
88133
- name: Install Rust
89134
uses: actions-rs/toolchain@v1
90135
with:
@@ -101,10 +146,10 @@ jobs:
101146
run: Copy-Item -Path .cargo/config-linux.toml -Destination .cargo/config.toml
102147
- name: Caching
103148
uses: Swatinem/rust-cache@v1
104-
- name: Update dependencies
105-
uses: actions-rs/cargo@v1
149+
- name: Download Cargo.lock
150+
uses: actions/download-artifact@v2
106151
with:
107-
command: update
152+
name: dependencies
108153
- name: Build
109154
uses: actions-rs/cargo@v1
110155
with:
@@ -144,6 +189,7 @@ jobs:
144189
path: tests/bindings/java/foo/src/main/resources
145190
# Cross-compilation for ARM devices and produce C bindings
146191
cross:
192+
needs: lock
147193
strategy:
148194
fail-fast: false
149195
matrix:
@@ -155,19 +201,18 @@ jobs:
155201
runs-on: ubuntu-latest
156202
steps:
157203
- name: Checkout
158-
uses: actions/checkout@v1
204+
uses: actions/checkout@v2
159205
- name: Install Rust
160206
uses: actions-rs/toolchain@v1
161207
with:
162208
profile: minimal
163209
toolchain: stable
164210
target: ${{ matrix.target }}
165211
override: true
166-
- name: Update dependencies
167-
uses: actions-rs/cargo@v1
212+
- name: Download Cargo.lock
213+
uses: actions/download-artifact@v2
168214
with:
169-
use-cross: true
170-
command: update
215+
name: dependencies
171216
- name: Build
172217
uses: actions-rs/cargo@v1
173218
with:
@@ -187,11 +232,11 @@ jobs:
187232
path: tests/bindings/c/generated/${{ matrix.target }}/lib
188233
# Package all the generated bindings
189234
packaging:
190-
needs: [bindings, cross]
235+
needs: [lock, bindings, cross]
191236
runs-on: ubuntu-latest
192237
steps:
193238
- name: Checkout
194-
uses: actions/checkout@v1
239+
uses: actions/checkout@v2
195240
- name: Install Rust
196241
uses: actions-rs/toolchain@v1
197242
with:
@@ -200,10 +245,10 @@ jobs:
200245
override: true
201246
- name: Caching
202247
uses: Swatinem/rust-cache@v1
203-
- name: Update dependencies
204-
uses: actions-rs/cargo@v1
248+
- name: Download Cargo.lock
249+
uses: actions/download-artifact@v2
205250
with:
206-
command: update
251+
name: dependencies
207252
- name: Download compiled FFI
208253
uses: actions/download-artifact@v2
209254
with:
@@ -213,7 +258,7 @@ jobs:
213258
uses: actions-rs/cargo@v1
214259
with:
215260
command: run
216-
args: --bin foo-bindings -- --package ./ffi-modules
261+
args: --bin foo-bindings -- --package ./ffi-modules -f dependencies.txt
217262
- name: Upload C bindings
218263
uses: actions/upload-artifact@v2
219264
with:
@@ -223,7 +268,7 @@ jobs:
223268
uses: actions/upload-artifact@v2
224269
with:
225270
name: dotnet-bindings
226-
path: tests/bindings/dotnet/nupkg/*.nupkg
271+
path: tests/bindings/dotnet/nupkg/*
227272
- name: Upload Java bindings
228273
uses: actions/upload-artifact@v2
229274
with:

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# Build files
22
/target
33
Cargo.lock
4+
dependencies.json
5+
dependencies.txt
46

57
# IDEs
68
/.vscode

ci-script/src/lib.rs

Lines changed: 58 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,13 @@ pub fn run(settings: BindingBuilderSettings) {
4343
.takes_value(true)
4444
.help("Generate package with the provided modules"),
4545
)
46+
.arg(
47+
Arg::with_name("extra-files")
48+
.short("f")
49+
.long("extra-files")
50+
.takes_value(true)
51+
.help("Path to extra files to include in the generated bindings"),
52+
)
4653
.get_matches();
4754

4855
let run_tests = !matches.is_present("no-tests");
@@ -55,18 +62,34 @@ pub fn run(settings: BindingBuilderSettings) {
5562
let package = matches.is_present("package");
5663
let package_src = matches.value_of("package");
5764

65+
let extra_files = matches
66+
.values_of("extra-files")
67+
.map_or(Vec::new(), |v| v.map(PathBuf::from).collect());
68+
5869
if run_c || run_all {
59-
let builder = run_builder::<CBindingBuilder>(&settings, run_tests, package, package_src);
70+
let builder = run_builder::<CBindingBuilder>(
71+
&settings,
72+
run_tests,
73+
package,
74+
package_src,
75+
&extra_files,
76+
);
6077

6178
if matches.is_present("doxygen") {
6279
builder.build_doxygen();
6380
}
6481
}
6582
if run_dotnet || run_all {
66-
run_builder::<DotnetBindingBuilder>(&settings, run_tests, package, package_src);
83+
run_builder::<DotnetBindingBuilder>(
84+
&settings,
85+
run_tests,
86+
package,
87+
package_src,
88+
&extra_files,
89+
);
6790
}
6891
if run_java || run_all {
69-
run_builder::<JavaBindingBuilder>(&settings, run_tests, package, package_src);
92+
run_builder::<JavaBindingBuilder>(&settings, run_tests, package, package_src, &extra_files);
7093
}
7194
}
7295

@@ -79,6 +102,7 @@ fn run_builder<'a, B: BindingBuilder<'a>>(
79102
run_tests: bool,
80103
package: bool,
81104
package_src: Option<&str>,
105+
extra_files: &[PathBuf],
82106
) -> B {
83107
let mut platforms = PlatformLocations::new();
84108
if let Some(package_src) = package_src {
@@ -111,7 +135,7 @@ fn run_builder<'a, B: BindingBuilder<'a>>(
111135

112136
let has_dynamic_libs = platforms.has_dynamic_lib();
113137

114-
let mut builder = B::new(settings, platforms);
138+
let mut builder = B::new(settings, platforms, extra_files);
115139

116140
if B::requires_dynamic_lib() && !has_dynamic_libs {
117141
println!(
@@ -144,7 +168,11 @@ pub struct BindingBuilderSettings<'a> {
144168
trait BindingBuilder<'a> {
145169
fn name() -> &'static str;
146170
fn requires_dynamic_lib() -> bool;
147-
fn new(settings: &'a BindingBuilderSettings<'a>, platforms: PlatformLocations) -> Self;
171+
fn new(
172+
settings: &'a BindingBuilderSettings<'a>,
173+
platforms: PlatformLocations,
174+
extra_files: &[PathBuf],
175+
) -> Self;
148176
fn generate(&mut self, is_packaging: bool);
149177
fn build(&mut self);
150178
fn test(&mut self);
@@ -154,13 +182,15 @@ trait BindingBuilder<'a> {
154182
struct CBindingBuilder<'a> {
155183
settings: &'a BindingBuilderSettings<'a>,
156184
platforms: PlatformLocations,
185+
extra_files: Vec<PathBuf>,
157186
}
158187

159188
impl<'a> CBindingBuilder<'a> {
160189
fn build_doxygen(&self) {
161190
let config = c_oo_bindgen::CBindgenConfig {
162191
output_dir: self.output_dir(),
163192
ffi_name: self.settings.ffi_name.to_owned(),
193+
extra_files: Vec::new(),
164194
platforms: self.platforms.clone(),
165195
};
166196

@@ -192,17 +222,23 @@ impl<'a> BindingBuilder<'a> for CBindingBuilder<'a> {
192222
false
193223
}
194224

195-
fn new(settings: &'a BindingBuilderSettings<'a>, platforms: PlatformLocations) -> Self {
225+
fn new(
226+
settings: &'a BindingBuilderSettings<'a>,
227+
platforms: PlatformLocations,
228+
extra_files: &[PathBuf],
229+
) -> Self {
196230
Self {
197231
settings,
198232
platforms,
233+
extra_files: extra_files.to_vec(),
199234
}
200235
}
201236

202237
fn generate(&mut self, _is_packaging: bool) {
203238
let config = c_oo_bindgen::CBindgenConfig {
204239
output_dir: self.output_dir(),
205240
ffi_name: self.settings.ffi_name.to_owned(),
241+
extra_files: self.extra_files.clone(),
206242
platforms: self.platforms.clone(),
207243
};
208244

@@ -253,6 +289,7 @@ impl<'a> BindingBuilder<'a> for CBindingBuilder<'a> {
253289
struct DotnetBindingBuilder<'a> {
254290
settings: &'a BindingBuilderSettings<'a>,
255291
platforms: PlatformLocations,
292+
extra_files: Vec<PathBuf>,
256293
}
257294

258295
impl<'a> DotnetBindingBuilder<'a> {
@@ -278,10 +315,15 @@ impl<'a> BindingBuilder<'a> for DotnetBindingBuilder<'a> {
278315
true
279316
}
280317

281-
fn new(settings: &'a BindingBuilderSettings<'a>, platforms: PlatformLocations) -> Self {
318+
fn new(
319+
settings: &'a BindingBuilderSettings<'a>,
320+
platforms: PlatformLocations,
321+
extra_files: &[PathBuf],
322+
) -> Self {
282323
Self {
283324
settings,
284325
platforms,
326+
extra_files: extra_files.to_vec(),
285327
}
286328
}
287329

@@ -296,6 +338,7 @@ impl<'a> BindingBuilder<'a> for DotnetBindingBuilder<'a> {
296338
let config = dotnet_oo_bindgen::DotnetBindgenConfig {
297339
output_dir: build_dir,
298340
ffi_name: self.settings.ffi_name.to_owned(),
341+
extra_files: self.extra_files.clone(),
299342
platforms: self.platforms.clone(),
300343
};
301344

@@ -344,6 +387,7 @@ impl<'a> BindingBuilder<'a> for DotnetBindingBuilder<'a> {
344387
struct JavaBindingBuilder<'a> {
345388
settings: &'a BindingBuilderSettings<'a>,
346389
platforms: PlatformLocations,
390+
extra_files: Vec<PathBuf>,
347391
}
348392

349393
impl<'a> JavaBindingBuilder<'a> {
@@ -390,10 +434,15 @@ impl<'a> BindingBuilder<'a> for JavaBindingBuilder<'a> {
390434
true
391435
}
392436

393-
fn new(settings: &'a BindingBuilderSettings<'a>, platforms: PlatformLocations) -> Self {
437+
fn new(
438+
settings: &'a BindingBuilderSettings<'a>,
439+
platforms: PlatformLocations,
440+
extra_files: &[PathBuf],
441+
) -> Self {
394442
Self {
395443
settings,
396444
platforms,
445+
extra_files: extra_files.to_vec(),
397446
}
398447
}
399448

@@ -404,6 +453,7 @@ impl<'a> BindingBuilder<'a> for JavaBindingBuilder<'a> {
404453
ffi_name: self.settings.ffi_name.to_owned(),
405454
ffi_path: self.settings.ffi_path.to_owned(),
406455
group_id: self.settings.java_group_id.to_owned(),
456+
extra_files: self.extra_files.clone(),
407457
platforms: self.platforms.clone(),
408458
};
409459

deps-config.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"ignore": ["oo-bindgen"],
3+
"allowed_licenses": ["Apache-2.0 OR MIT", "MIT OR Unlicense"],
4+
"crates": {}
5+
}

0 commit comments

Comments
 (0)