Skip to content

Commit f79d1d1

Browse files
authored
Packaging configuration (#97)
* first stab at packaging configuration * Only limit the packaged Java targets via the configuration. Add a package.json * improve configuration logging. Modify CI
1 parent 80c160f commit f79d1d1

File tree

9 files changed

+270
-129
lines changed

9 files changed

+270
-129
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ jobs:
229229
name: ffi-modules
230230
path: ffi-modules
231231
- name: Package all bindings
232-
run: cargo run --bin foo-bindings -- --package ./ffi-modules
232+
run: cargo run --bin foo-bindings -- --package ./ffi-modules --options ./packaging.json
233233
- name: Upload C/C++ bindings
234234
uses: actions/upload-artifact@v2
235235
with:

Cargo.lock

Lines changed: 16 additions & 0 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: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,6 @@ dotnet-oo-bindgen = { path = "../generators/dotnet-oo-bindgen" }
1111
java-oo-bindgen = { path = "../generators/java-oo-bindgen" }
1212
clap = { version = "^4", features = ["derive"] }
1313
pathdiff = "0.2"
14+
serde = { version = "1.0", features = ["derive"] }
15+
serde_json = "1.0"
1416
tracing = "^0.1"

ci-script/src/builders/dotnet.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ impl BindingBuilder for DotnetBindingBuilder {
4646
// Clear/create generated files
4747
let build_dir = self.build_dir();
4848
if build_dir.exists() {
49-
std::fs::remove_dir_all(&build_dir).unwrap();
49+
logged::remove_dir_all(&build_dir).unwrap();
5050
}
5151
logged::create_dir_all(&build_dir).unwrap();
5252

ci-script/src/cli.rs

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use clap::Parser;
22
use dotnet_oo_bindgen::TargetFramework;
3+
use std::collections::HashMap;
34
use std::path::PathBuf;
45

56
impl Args {
@@ -14,6 +15,45 @@ impl Args {
1415
}
1516
}
1617

18+
use crate::Platform;
19+
use serde::Deserialize;
20+
21+
#[derive(Deserialize)]
22+
pub(crate) struct EnabledLanguages {
23+
pub(crate) cpp: bool,
24+
pub(crate) dotnet: bool,
25+
pub(crate) java: bool,
26+
}
27+
28+
#[derive(Deserialize)]
29+
pub(crate) struct PackageOptions {
30+
/// This limits which available target platforms are packaged for each language
31+
targets: HashMap<String, EnabledLanguages>,
32+
}
33+
34+
impl PackageOptions {
35+
pub(crate) fn package_dotnet(&self, platform: &Platform) -> bool {
36+
self.targets
37+
.get(platform.target_triple)
38+
.map(|x| x.dotnet)
39+
.unwrap_or(false)
40+
}
41+
42+
pub(crate) fn package_cpp(&self, platform: &Platform) -> bool {
43+
self.targets
44+
.get(platform.target_triple)
45+
.map(|x| x.cpp)
46+
.unwrap_or(false)
47+
}
48+
49+
pub(crate) fn package_java(&self, platform: &Platform) -> bool {
50+
self.targets
51+
.get(platform.target_triple)
52+
.map(|x| x.java)
53+
.unwrap_or(false)
54+
}
55+
}
56+
1757
#[derive(Parser)]
1858
#[command(author, version, about, long_about = None)]
1959
pub(crate) struct Args {
@@ -45,6 +85,9 @@ pub(crate) struct Args {
4585
/// Generate package from the provided directory
4686
#[arg(long = "package", short = 'k')]
4787
pub(crate) package_dir: Option<PathBuf>,
88+
/// Generate package(s) with the following options file
89+
#[arg(long = "options", short = 'o')]
90+
pub(crate) package_options: Option<PathBuf>,
4891
/// Path(s) to extra files to include in the generated bindings
4992
#[arg(short = 'f', long = "extra-files")]
5093
pub(crate) extra_files: Vec<PathBuf>,

0 commit comments

Comments
 (0)