Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prepare 0.8.7 #126

Merged
merged 10 commits into from
May 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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.runner }}
strategy:
fail-fast: false
matrix:
target:
- x86_64-apple-darwin # 64-bit macOS (10.7+, Lion+)
include:
- runner: macos-14
target: aarch64-apple-darwin
- runner: macos-13
target: x86_64-apple-darwin
steps:
- name: Checkout
uses: actions/checkout@v3
Expand Down
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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).

Expand Down
2 changes: 1 addition & 1 deletion oo-bindgen/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "oo-bindgen"
version = "0.8.6"
version = "0.8.7"
authors = ["Step Function I/O LLC <[email protected]>"]
edition = "2021"
license = "MIT OR Apache-2.0"
Expand Down
9 changes: 0 additions & 9 deletions oo-bindgen/src/backend/common/platforms.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ use platforms::Platform;
use std::path::PathBuf;

pub(crate) trait PlatformExt {
fn static_lib_filename<T: AsRef<str>>(&self, libname: T) -> String;
fn dyn_lib_filename<T: AsRef<str>>(&self, libname: T) -> String;
fn bin_filename<T: AsRef<str>>(&self, libname: T) -> String;
}
Expand All @@ -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<T: AsRef<str>>(&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<T: AsRef<str>>(&self, libname: T) -> String {
if self.target_os == OS::Windows {
format!("{}.dll.lib", libname.as_ref())
Expand Down
42 changes: 0 additions & 42 deletions oo-bindgen/src/backend/common/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,46 +6,8 @@ where
next: Option<I::Item>,
}

impl<I> WithLast<I>
where
I: Iterator,
{
fn drop_last(self) -> DropLast<I> {
DropLast { inner: self }
}
}

pub(crate) struct DropLast<I>
where
I: Iterator,
{
inner: WithLast<I>,
}

impl<I> Iterator for DropLast<I>
where
I: Iterator,
{
type Item = I::Item;

fn next(&mut self) -> Option<Self::Item> {
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<Self>;

fn drop_last(self) -> DropLast<Self>;
}

impl<I> WithLastIndication for I
Expand All @@ -59,10 +21,6 @@ where
next: first,
}
}

fn drop_last(self) -> DropLast<I> {
self.with_last().drop_last()
}
}

impl<I> Iterator for WithLast<I>
Expand Down
13 changes: 13 additions & 0 deletions oo-bindgen/src/backend/dotnet/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ fn generate_csproj(lib: &Library, config: &DotnetBindgenConfig) -> FormattingRes
" <TargetFramework>{}</TargetFramework>",
config.target_framework.get_target_framework_str()
))?;

f.writeln(" <GenerateDocumentationFile>true</GenerateDocumentationFile>")?;
f.writeln(" <IncludeSymbols>true</IncludeSymbols>")?; // Include symbols
f.writeln(" <SymbolPackageFormat>snupkg</SymbolPackageFormat>")?; // Use new file format
Expand All @@ -154,6 +155,18 @@ fn generate_csproj(lib: &Library, config: &DotnetBindgenConfig) -> FormattingRes
" <PackageVersion>{}</PackageVersion>",
lib.version
))?;
f.writeln(&format!(
"<VersionPrefix>{}.{}.{}</VersionPrefix>",
lib.version.major, lib.version.minor, lib.version.patch
))?;

if !lib.version.pre.is_empty() {
f.writeln(&format!(
"<VersionSuffix>{}</VersionSuffix>",
lib.version.pre
))?;
}

f.writeln(&format!(
" <Description>{}</Description>",
lib.info.description
Expand Down
2 changes: 1 addition & 1 deletion oo-bindgen/src/cli/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion oo-bindgen/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions oo-bindgen/src/model/builder/library.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion oo-bindgen/src/model/interface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<D>> {
match self.callbacks.len() {
1 => self.callbacks.get(0),
1 => self.callbacks.first(),
_ => None,
}
}
Expand Down
7 changes: 0 additions & 7 deletions oo-bindgen/src/model/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -341,13 +341,6 @@ pub(crate) trait TypeExtractor {
_ => None,
}
}

fn get_enum_type(&self) -> Option<Handle<Enum<Unvalidated>>> {
match self.get_basic_type() {
Some(BasicType::Enum(x)) => Some(x.clone()),
_ => None,
}
}
}

impl TypeExtractor for FunctionArgStructField {
Expand Down
5 changes: 5 additions & 0 deletions packaging.json
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion tests/bindings/dotnet/foo.Tests/foo.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>

<IsPackable>false</IsPackable>
</PropertyGroup>
Expand Down
5 changes: 1 addition & 4 deletions tests/foo-ffi/src/lifetime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
Expand Down
2 changes: 1 addition & 1 deletion tests/foo-ffi/src/strings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
Loading