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

Add support for OSX #96

Merged
merged 4 commits into from
Nov 13, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
added uname check to test scripts, renamed lib in dllimport statement
Signed-off-by: Christian Belloni <christianbelloni@Christians-Laptop.local>
  • Loading branch information
Christian Belloni authored and Christian Belloni committed Oct 10, 2024
commit 995547f41d488e0f78d7f5992bf4c775b07094c3
17 changes: 16 additions & 1 deletion bindgen/src/gen_cs/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,25 @@ impl Config {
}

pub fn cdylib_name(&self) -> String {
self.cdylib_name
#[cfg(target_os = "macos")]
arg0d marked this conversation as resolved.
Show resolved Hide resolved
return self
.cdylib_name
.as_ref()
.expect("`cdylib_name` not specified")
.clone()
+ ".dylib";
#[cfg(target_os = "windows")]
return self
.cdylib_name
.as_ref()
.expect("`cdylib_name` not specified")
.clone();
#[cfg(not(any(target_os = "macos", target_os = "windows")))]
return self
.cdylib_name
.as_ref()
.expect("`cdylib_name` not specified")
.clone();
}

pub fn access_modifier(&self) -> String {
Expand Down
12 changes: 11 additions & 1 deletion generate_bindings.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,14 @@ GEN_DIR="dotnet-tests/UniffiCS/gen"
rm -rf "$GEN_DIR"
mkdir -p "$GEN_DIR"

target/debug/uniffi-bindgen-cs target/debug/libuniffi_fixtures.so --library --out-dir="$GEN_DIR" --no-format
osname=$(uname)

libname=""

if [[ "$osname" == "Darwin" ]]; then
libname="libuniffi_fixtures.dylib"
elif [[ "$osname" == "Linux" ]]; then
libname="libuniffi_fixtures.so"
fi

target/debug/uniffi-bindgen-cs "target/debug/$libname" --library --out-dir="$GEN_DIR" --no-format
5 changes: 5 additions & 0 deletions test_bindings.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,10 @@ SCRIPT_DIR="${SCRIPT_DIR:-$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>
SOLUTION_DIR="dotnet-tests"

export LD_LIBRARY_PATH="$SCRIPT_DIR/target/debug/:${LD_LIBRARY_PATH:-}"

if [[ $(uname) == "Darwin" ]]; then
export DYLD_LIBRARY_PATH="$SCRIPT_DIR/target/debug/:${DYLD_LIBRARY_PATH:-}"
fi

cd $SOLUTION_DIR
dotnet test -l "console;verbosity=normal"