Skip to content

Commit edea250

Browse files
authored
Default interface methods (#93)
1 parent 622c663 commit edea250

File tree

27 files changed

+917
-144
lines changed

27 files changed

+917
-144
lines changed

.github/workflows/ci.yml

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -141,11 +141,8 @@ jobs:
141141
run: Copy-Item -Path .cargo/config-windows.toml -Destination .cargo/config.toml
142142
- name: Caching
143143
uses: Swatinem/rust-cache@v1
144-
- name: Build
145-
uses: actions-rs/cargo@v1
146-
with:
147-
command: build
148-
args: --release
144+
- name: Build FFI and JNI
145+
run: cargo build -p foo-ffi -p foo-ffi-java --release --target ${{ matrix.target }}
149146
- name: C bindings
150147
uses: actions-rs/cargo@v1
151148
with:
@@ -190,11 +187,8 @@ jobs:
190187
override: true
191188
- name: Caching
192189
uses: Swatinem/rust-cache@v1
193-
- name: Build
194-
uses: actions-rs/cargo@v1
195-
with:
196-
command: build
197-
args: --release
190+
- name: Build FFI and JNI
191+
run: cargo build -p foo-ffi -p foo-ffi-java --release
198192
- name: C bindings
199193
uses: actions-rs/cargo@v1
200194
with:
@@ -247,12 +241,10 @@ jobs:
247241
toolchain: stable
248242
target: ${{ matrix.target }}
249243
override: true
250-
- name: Build
251-
uses: actions-rs/cargo@v1
252-
with:
253-
use-cross: true
254-
command: build
255-
args: --release --target ${{ matrix.target }}
244+
- name: Install Rust Cross
245+
run: cargo install cross
246+
- name: Build FFI and JNI
247+
run: cross build -p foo-ffi -p foo-ffi-java --release --target ${{ matrix.target }}
256248
- name: C bindings
257249
uses: actions-rs/cargo@v1
258250
with:

Cargo.lock

Lines changed: 59 additions & 30 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ci-script/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@ oo-bindgen = { path = "../oo-bindgen" }
99
c-oo-bindgen = { path = "../generators/c-oo-bindgen" }
1010
dotnet-oo-bindgen = { path = "../generators/dotnet-oo-bindgen" }
1111
java-oo-bindgen = { path = "../generators/java-oo-bindgen" }
12-
clap = "3.2.17"
12+
clap = { version = "^4", features = ["derive"] }
1313
pathdiff = "0.2"
1414
tracing = "^0.1"

ci-script/src/builders/dotnet.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,26 @@
11
use crate::{BindingBuilder, BindingBuilderSettings};
2+
use dotnet_oo_bindgen::TargetFramework;
23
use oo_bindgen::backend::PlatformLocations;
34
use std::path::PathBuf;
45
use std::process::Command;
56

67
pub(crate) struct DotnetBindingBuilder {
78
settings: BindingBuilderSettings,
9+
target_framework: TargetFramework,
810
platforms: PlatformLocations,
911
extra_files: Vec<PathBuf>,
1012
}
1113

1214
impl DotnetBindingBuilder {
1315
pub(crate) fn new(
1416
settings: BindingBuilderSettings,
17+
target_framework: TargetFramework,
1518
platforms: PlatformLocations,
1619
extra_files: &[PathBuf],
1720
) -> Self {
1821
Self {
1922
settings,
23+
target_framework,
2024
platforms,
2125
extra_files: extra_files.to_vec(),
2226
}
@@ -52,6 +56,7 @@ impl BindingBuilder for DotnetBindingBuilder {
5256
extra_files: self.extra_files.clone(),
5357
platforms: self.platforms.clone(),
5458
generate_doxygen,
59+
target_framework: self.target_framework,
5560
};
5661

5762
dotnet_oo_bindgen::generate_dotnet_bindings(&self.settings.library, &config).unwrap();

ci-script/src/cli.rs

Lines changed: 30 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,32 @@
1-
use clap::{App, Arg, ArgMatches};
1+
use clap::Parser;
2+
use dotnet_oo_bindgen::TargetFramework;
3+
use std::path::PathBuf;
24

3-
pub(crate) fn build() -> ArgMatches {
4-
App::new("oo-bindgen")
5-
.arg(
6-
Arg::with_name("c")
7-
.long("c")
8-
.takes_value(false)
9-
.help("Build C bindings"),
10-
)
11-
.arg(
12-
Arg::with_name("dotnet")
13-
.long("dotnet")
14-
.takes_value(false)
15-
.help("Build .NET Core bindings"),
16-
)
17-
.arg(
18-
Arg::with_name("java")
19-
.long("java")
20-
.takes_value(false)
21-
.help("Build Java (JNI) bindings"),
22-
)
23-
.arg(
24-
Arg::with_name("doxygen")
25-
.long("doxygen")
26-
.takes_value(false)
27-
.help("Generate Doxygen documentation"),
28-
)
29-
.arg(
30-
Arg::with_name("no-tests")
31-
.long("no-tests")
32-
.takes_value(false)
33-
.help("Do not run the unit tests"),
34-
)
35-
.arg(
36-
Arg::with_name("package")
37-
.long("package")
38-
.takes_value(true)
39-
.help("Generate package with the provided modules"),
40-
)
41-
.arg(
42-
Arg::with_name("extra-files")
43-
.short('f')
44-
.long("extra-files")
45-
.takes_value(true)
46-
.help("Path to extra files to include in the generated bindings"),
47-
)
48-
.get_matches()
5+
#[derive(Parser)]
6+
#[command(author, version, about, long_about = None)]
7+
pub(crate) struct Args {
8+
/// build the C bindings
9+
#[arg(long = "c", default_value_t = false)]
10+
pub(crate) build_c: bool,
11+
/// build the .NET bindings
12+
#[arg(long = "dotnet", default_value_t = false)]
13+
pub(crate) build_dotnet: bool,
14+
/// build the Java bindings
15+
#[arg(long = "java", default_value_t = false)]
16+
pub(crate) build_java: bool,
17+
/// Target .NET framework, which indirectly determines the C# language version
18+
#[arg(value_enum, short = 't', long = "target-dotnet-framework", default_value_t = TargetFramework::NetStandard2_0)]
19+
pub(crate) target_framework: TargetFramework,
20+
/// generate doxygen documentation
21+
#[arg(long = "doxygen", default_value_t = false)]
22+
pub(crate) generate_doxygen: bool,
23+
/// do NOT run the unit tests
24+
#[arg(long = "no-tests", default_value_t = false)]
25+
pub(crate) no_tests: bool,
26+
/// Generate package from the provided directory
27+
#[arg(long = "package")]
28+
pub(crate) package: Option<PathBuf>,
29+
/// Path(s) to extra files to include in the generated bindings
30+
#[arg(short = 'f', long = "extra-files")]
31+
pub(crate) extra_files: Vec<PathBuf>,
4932
}

0 commit comments

Comments
 (0)