summaryrefslogtreecommitdiffhomepage
path: root/samples/13_rust_extensions/01_basics/pre.sh
blob: daf23f9ea26bd6f712e9d9784ae7105e26c96b5a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
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