From 8a77c730915eabf2d57d7442666c0f6709f3a46f Mon Sep 17 00:00:00 2001 From: jadamcrain Date: Mon, 13 May 2024 16:51:23 -0700 Subject: [PATCH 01/10] modernize --- oo-bindgen/src/backend/common/platforms.rs | 9 ----- oo-bindgen/src/backend/common/util.rs | 42 ---------------------- oo-bindgen/src/cli/args.rs | 2 +- oo-bindgen/src/lib.rs | 2 +- oo-bindgen/src/model/builder/library.rs | 4 +-- oo-bindgen/src/model/interface.rs | 2 +- oo-bindgen/src/model/types.rs | 7 ---- tests/foo-ffi/src/lifetime.rs | 5 +-- tests/foo-ffi/src/strings.rs | 2 +- 9 files changed, 7 insertions(+), 68 deletions(-) diff --git a/oo-bindgen/src/backend/common/platforms.rs b/oo-bindgen/src/backend/common/platforms.rs index d9f285b5..b567d263 100644 --- a/oo-bindgen/src/backend/common/platforms.rs +++ b/oo-bindgen/src/backend/common/platforms.rs @@ -3,7 +3,6 @@ use platforms::Platform; use std::path::PathBuf; pub(crate) trait PlatformExt { - fn static_lib_filename>(&self, libname: T) -> String; fn dyn_lib_filename>(&self, libname: T) -> String; fn bin_filename>(&self, libname: T) -> String; } @@ -14,14 +13,6 @@ pub(crate) trait PlatformExt { // - https://github.com/rust-lang/rust/blob/1.58.1/library/std/src/sys/windows/env.rs // - https://github.com/rust-lang/rust/blob/1.58.1/src/tools/compiletest/src/runtest.rs impl PlatformExt for Platform { - fn static_lib_filename>(&self, libname: T) -> String { - if self.target_os == OS::Windows { - format!("{}.lib", libname.as_ref()) - } else { - format!("lib{}.a", libname.as_ref()) - } - } - fn dyn_lib_filename>(&self, libname: T) -> String { if self.target_os == OS::Windows { format!("{}.dll.lib", libname.as_ref()) diff --git a/oo-bindgen/src/backend/common/util.rs b/oo-bindgen/src/backend/common/util.rs index 83723354..932fa74c 100644 --- a/oo-bindgen/src/backend/common/util.rs +++ b/oo-bindgen/src/backend/common/util.rs @@ -6,46 +6,8 @@ where next: Option, } -impl WithLast -where - I: Iterator, -{ - fn drop_last(self) -> DropLast { - DropLast { inner: self } - } -} - -pub(crate) struct DropLast -where - I: Iterator, -{ - inner: WithLast, -} - -impl Iterator for DropLast -where - I: Iterator, -{ - type Item = I::Item; - - fn next(&mut self) -> Option { - match self.inner.next() { - None => None, - Some((item, last)) => { - if last { - None - } else { - Some(item) - } - } - } - } -} - pub(crate) trait WithLastIndication: Iterator + Sized { fn with_last(self) -> WithLast; - - fn drop_last(self) -> DropLast; } impl WithLastIndication for I @@ -59,10 +21,6 @@ where next: first, } } - - fn drop_last(self) -> DropLast { - self.with_last().drop_last() - } } impl Iterator for WithLast diff --git a/oo-bindgen/src/cli/args.rs b/oo-bindgen/src/cli/args.rs index 6129b91f..0cd672da 100644 --- a/oo-bindgen/src/cli/args.rs +++ b/oo-bindgen/src/cli/args.rs @@ -5,7 +5,7 @@ use std::path::PathBuf; impl Args { pub(crate) fn get() -> Self { - let mut args = crate::cli::Args::parse(); + let mut args = Args::parse(); if !(args.build_c || args.build_dotnet || args.build_java) { args.build_c = true; args.build_dotnet = true; diff --git a/oo-bindgen/src/lib.rs b/oo-bindgen/src/lib.rs index ba439000..87e92d5d 100644 --- a/oo-bindgen/src/lib.rs +++ b/oo-bindgen/src/lib.rs @@ -10,7 +10,7 @@ patterns_in_fns_without_body, pub_use_of_private_extern_crate, unknown_crate_types, order_dependent_trait_objects, -illegal_floating_point_literal_pattern, + improper_ctypes, late_bound_lifetime_arguments, non_camel_case_types, diff --git a/oo-bindgen/src/model/builder/library.rs b/oo-bindgen/src/model/builder/library.rs index 2db58ad5..c9f1eb9c 100644 --- a/oo-bindgen/src/model/builder/library.rs +++ b/oo-bindgen/src/model/builder/library.rs @@ -582,7 +582,7 @@ impl LibraryBuilder { .returns(item_type.get_function_return_value(), "next value or NULL")? .build()?; - let iter = AbstractIteratorHandle::new(crate::model::iterator::AbstractIterator::new( + let iter = AbstractIteratorHandle::new(AbstractIterator::new( has_lifetime, class.inner, next_function, @@ -648,7 +648,7 @@ impl LibraryBuilder { .param("value", value_type.clone(), "value to add to the instance")? .build()?; - let collection = Handle::new(crate::model::collection::Collection::new( + let collection = Handle::new(Collection::new( class_decl.inner, value_type, create_func, diff --git a/oo-bindgen/src/model/interface.rs b/oo-bindgen/src/model/interface.rs index e505c495..1e743bec 100644 --- a/oo-bindgen/src/model/interface.rs +++ b/oo-bindgen/src/model/interface.rs @@ -403,7 +403,7 @@ where /// This type of interface can be converted to a Functor-type in many backend languages pub(crate) fn get_functional_callback(&self) -> Option<&CallbackFunction> { match self.callbacks.len() { - 1 => self.callbacks.get(0), + 1 => self.callbacks.first(), _ => None, } } diff --git a/oo-bindgen/src/model/types.rs b/oo-bindgen/src/model/types.rs index 2f349dd6..ec906428 100644 --- a/oo-bindgen/src/model/types.rs +++ b/oo-bindgen/src/model/types.rs @@ -341,13 +341,6 @@ pub(crate) trait TypeExtractor { _ => None, } } - - fn get_enum_type(&self) -> Option>> { - match self.get_basic_type() { - Some(BasicType::Enum(x)) => Some(x.clone()), - _ => None, - } - } } impl TypeExtractor for FunctionArgStructField { diff --git a/tests/foo-ffi/src/lifetime.rs b/tests/foo-ffi/src/lifetime.rs index fb6da729..8d35bbfe 100644 --- a/tests/foo-ffi/src/lifetime.rs +++ b/tests/foo-ffi/src/lifetime.rs @@ -39,10 +39,7 @@ pub unsafe fn chunk_iterator_next(it: *mut crate::ChunkIterator) -> Option<&crat None => None, Some(chunk) => { (*it.item.iter).values = chunk; - it.bytes = match it.bytes.get(it.chunk_size..) { - Some(x) => x, - None => &[], - }; + it.bytes = it.bytes.get(it.chunk_size..).unwrap_or_default(); Some(&it.item) } } diff --git a/tests/foo-ffi/src/strings.rs b/tests/foo-ffi/src/strings.rs index bbd9f3a5..b2e69228 100644 --- a/tests/foo-ffi/src/strings.rs +++ b/tests/foo-ffi/src/strings.rs @@ -25,7 +25,7 @@ pub unsafe fn string_class_destroy(string_class: *mut StringClass) { pub unsafe fn string_class_echo(string_class: *mut StringClass, value: &CStr) -> &CStr { let string_class = string_class.as_mut().unwrap(); - string_class.value = value.to_owned(); + value.clone_into(&mut string_class.value); &string_class.value } From 9fc476164b0727d712713a7b070c018d475b61f8 Mon Sep 17 00:00:00 2001 From: jadamcrain Date: Mon, 13 May 2024 17:13:27 -0700 Subject: [PATCH 02/10] tests target .NET 8 --- tests/bindings/dotnet/foo.Tests/foo.Tests.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/bindings/dotnet/foo.Tests/foo.Tests.csproj b/tests/bindings/dotnet/foo.Tests/foo.Tests.csproj index 665b8f4e..0ead17a4 100644 --- a/tests/bindings/dotnet/foo.Tests/foo.Tests.csproj +++ b/tests/bindings/dotnet/foo.Tests/foo.Tests.csproj @@ -1,7 +1,7 @@ - net6.0 + net8.0 false From f1eaa4bcf84993037b2938e19f90c19c2095d86c Mon Sep 17 00:00:00 2001 From: jadamcrain Date: Mon, 13 May 2024 17:40:51 -0700 Subject: [PATCH 03/10] build ARM8 and x64 macos bindings --- .github/workflows/ci.yml | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6d839f85..7841953a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -119,14 +119,17 @@ jobs: - name: Java Bindings Tests if: ${{ matrix.test }} run: cargo run --bin foo-bindings -- --java -r ${{ matrix.target }} -a ./target/${{ matrix.target }}/release - # Build bindings on MacOS [64-bit macOS (10.7+, Lion+) (x86_64-apple-darwin)] + # Build bindings on MacOS bindings-macos: - runs-on: macos-latest + runs-on: ${{ matrix.os }} strategy: fail-fast: false matrix: - target: - - x86_64-apple-darwin # 64-bit macOS (10.7+, Lion+) + include: + - target: aarch64_64-apple-darwin + runner: macos-14-arm + - target: x86_64-apple-darwin + runner: macos-13 steps: - name: Checkout uses: actions/checkout@v3 From 111a44e43799c6b714434438db163a6cb1e318ff Mon Sep 17 00:00:00 2001 From: jadamcrain Date: Mon, 13 May 2024 17:42:52 -0700 Subject: [PATCH 04/10] fix runner --- .github/workflows/ci.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7841953a..1b851ef4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -121,15 +121,15 @@ jobs: run: cargo run --bin foo-bindings -- --java -r ${{ matrix.target }} -a ./target/${{ matrix.target }}/release # Build bindings on MacOS bindings-macos: - runs-on: ${{ matrix.os }} + runs-on: ${{ matrix.runner }} strategy: fail-fast: false matrix: include: - - target: aarch64_64-apple-darwin - runner: macos-14-arm - - target: x86_64-apple-darwin - runner: macos-13 + - runner: macos-14-arm + target: aarch64_64-apple-darwin + - runner: macos-13 + target: x86_64-apple-darwin steps: - name: Checkout uses: actions/checkout@v3 From 2c6fdbd7efafc5b56e9dac3c5af7e358fe29eb9a Mon Sep 17 00:00:00 2001 From: jadamcrain Date: Mon, 13 May 2024 18:02:18 -0700 Subject: [PATCH 05/10] tweak --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1b851ef4..423d324e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -126,7 +126,7 @@ jobs: fail-fast: false matrix: include: - - runner: macos-14-arm + - runner: macos-14-arm64 target: aarch64_64-apple-darwin - runner: macos-13 target: x86_64-apple-darwin From 444c2a12b83318db2936ef5cf3aef22222f5c8ac Mon Sep 17 00:00:00 2001 From: jadamcrain Date: Mon, 13 May 2024 18:03:20 -0700 Subject: [PATCH 06/10] tweak --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 423d324e..ca6e515c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -126,7 +126,7 @@ jobs: fail-fast: false matrix: include: - - runner: macos-14-arm64 + - runner: macos-14 target: aarch64_64-apple-darwin - runner: macos-13 target: x86_64-apple-darwin From ffcd78cd74398e08d527fdc58e94a734560969fe Mon Sep 17 00:00:00 2001 From: jadamcrain Date: Mon, 13 May 2024 18:04:00 -0700 Subject: [PATCH 07/10] tweak --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ca6e515c..95430a98 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -127,7 +127,7 @@ jobs: matrix: include: - runner: macos-14 - target: aarch64_64-apple-darwin + target: aarch64-apple-darwin - runner: macos-13 target: x86_64-apple-darwin steps: From 65a423b2baa29088fb9b1fcf91d0efb16802dbd3 Mon Sep 17 00:00:00 2001 From: jadamcrain Date: Mon, 13 May 2024 19:14:18 -0700 Subject: [PATCH 08/10] add arm64 MacOS to packaging --- packaging.json | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/packaging.json b/packaging.json index f72dfb65..016ae68b 100644 --- a/packaging.json +++ b/packaging.json @@ -15,6 +15,11 @@ "dotnet": true, "java": true }, + "aarch64-apple-darwin": { + "cpp": false, + "dotnet": true, + "java": true + }, "x86_64-unknown-linux-gnu": { "cpp": true, "dotnet": true, From b17d722e864940585d1ffea0cfb759e0430c2be7 Mon Sep 17 00:00:00 2001 From: jadamcrain Date: Mon, 20 May 2024 11:16:12 -0700 Subject: [PATCH 09/10] add additional version information to C# project file --- oo-bindgen/src/backend/dotnet/mod.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/oo-bindgen/src/backend/dotnet/mod.rs b/oo-bindgen/src/backend/dotnet/mod.rs index 2b8bf45d..aa1d6374 100644 --- a/oo-bindgen/src/backend/dotnet/mod.rs +++ b/oo-bindgen/src/backend/dotnet/mod.rs @@ -146,6 +146,7 @@ fn generate_csproj(lib: &Library, config: &DotnetBindgenConfig) -> FormattingRes " {}", config.target_framework.get_target_framework_str() ))?; + f.writeln(" true")?; f.writeln(" true")?; // Include symbols f.writeln(" snupkg")?; // Use new file format @@ -154,6 +155,18 @@ fn generate_csproj(lib: &Library, config: &DotnetBindgenConfig) -> FormattingRes " {}", lib.version ))?; + f.writeln(&format!( + "{}.{}.{}", + lib.version.major, lib.version.minor, lib.version.patch + ))?; + + if !lib.version.pre.is_empty() { + f.writeln(&format!( + "{}", + lib.version.pre + ))?; + } + f.writeln(&format!( " {}", lib.info.description From 005eafeaa40fb0ba83d27f88e6cbce7da30e28e0 Mon Sep 17 00:00:00 2001 From: jadamcrain Date: Mon, 20 May 2024 11:42:24 -0700 Subject: [PATCH 10/10] bump version and changelog --- CHANGELOG.md | 3 +++ oo-bindgen/Cargo.toml | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7cab263d..9735e3b0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +### 0.8.7 ### +* :star: Sets assembly version information to match the schema in C# backend + ### 0.8.6 ### * :star: Improve Java native library loading. See [#124](https://github.com/stepfunc/oo_bindgen/pull/124). diff --git a/oo-bindgen/Cargo.toml b/oo-bindgen/Cargo.toml index 14a1f90a..0cf98afb 100644 --- a/oo-bindgen/Cargo.toml +++ b/oo-bindgen/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "oo-bindgen" -version = "0.8.6" +version = "0.8.7" authors = ["Step Function I/O LLC "] edition = "2021" license = "MIT OR Apache-2.0"