summaryrefslogtreecommitdiffhomepage
path: root/samples/13_rust_extensions/01_basics/pre.sh
diff options
context:
space:
mode:
authorMike Martin <[email protected]>2020-11-26 23:14:52 -0600
committerAmir Rajan <[email protected]>2020-12-06 09:49:41 -0600
commit01b16c4244de5232a76713bfd196e34328504021 (patch)
treecc80c22b17cb890da0fe869d79547b647c069596 /samples/13_rust_extensions/01_basics/pre.sh
parentee69d1ef44889a8e22752c6d466b10765b3461ca (diff)
downloaddragonruby-game-toolkit-contrib-01b16c4244de5232a76713bfd196e34328504021.tar.gz
dragonruby-game-toolkit-contrib-01b16c4244de5232a76713bfd196e34328504021.zip
Adds basic sample app that utilizes Rust extensions
Diffstat (limited to 'samples/13_rust_extensions/01_basics/pre.sh')
-rwxr-xr-xsamples/13_rust_extensions/01_basics/pre.sh25
1 files changed, 25 insertions, 0 deletions
diff --git a/samples/13_rust_extensions/01_basics/pre.sh b/samples/13_rust_extensions/01_basics/pre.sh
new file mode 100755
index 0000000..daf23f9
--- /dev/null
+++ b/samples/13_rust_extensions/01_basics/pre.sh
@@ -0,0 +1,25 @@
+#!/bin/sh
+
+OSTYPE=`uname -s`
+if [ "x$OSTYPE" = "xDarwin" ]; then
+ PLATFORM=macos
+ DLLEXT=dylib
+else
+ PLATFORM=linux-amd64
+ DLLEXT=so
+fi
+
+DRB_ROOT=../../..
+mkdir -p native/$PLATFORM
+
+pushd rust-basic-crate
+cargo build --release
+cbindgen --config cbindgen.toml --crate rust-basic-crate --output ../app/ext.h
+popd
+
+$DRB_ROOT/dragonruby-bind --output=native/ext-bindings.c app/ext.h
+echo "\nIgnore the above error about #include\n"
+clang \
+ -isystem $DRB_ROOT/include -I. \
+ -fPIC -shared native/ext-bindings.c rust-basic-crate/target/release/librust_basic_crate.$DLLEXT -o native/$PLATFORM/ext.$DLLEXT
+