diff options
| author | Amir Rajan <[email protected]> | 2020-09-22 06:27:46 -0500 |
|---|---|---|
| committer | Amir Rajan <[email protected]> | 2020-09-22 06:27:46 -0500 |
| commit | 20d5b4057b44ffcf92478b2a8e9476ace2fdc0f5 (patch) | |
| tree | b4742e4f9acfd5400a04f314164812606a71df9f /samples/12_c_extensions | |
| parent | 5b2311900072cfff9582bb0296140cfb354cb911 (diff) | |
| download | dragonruby-game-toolkit-contrib-20d5b4057b44ffcf92478b2a8e9476ace2fdc0f5.tar.gz dragonruby-game-toolkit-contrib-20d5b4057b44ffcf92478b2a8e9476ace2fdc0f5.zip | |
synced with 1.22
Diffstat (limited to 'samples/12_c_extensions')
| -rw-r--r-- | samples/12_c_extensions/01_basics/.gitignore | 1 | ||||
| -rw-r--r-- | samples/12_c_extensions/01_basics/app/ext.c | 4 | ||||
| -rw-r--r-- | samples/12_c_extensions/01_basics/app/main.rb | 7 | ||||
| -rw-r--r-- | samples/12_c_extensions/01_basics/license-for-sample.txt | 9 | ||||
| -rw-r--r-- | samples/12_c_extensions/01_basics/metadata/game_metadata.txt | 5 | ||||
| -rw-r--r-- | samples/12_c_extensions/01_basics/pre.bat | 4 | ||||
| -rwxr-xr-x | samples/12_c_extensions/01_basics/pre.sh | 10 |
7 files changed, 40 insertions, 0 deletions
diff --git a/samples/12_c_extensions/01_basics/.gitignore b/samples/12_c_extensions/01_basics/.gitignore new file mode 100644 index 0000000..4a0a124 --- /dev/null +++ b/samples/12_c_extensions/01_basics/.gitignore @@ -0,0 +1 @@ +build.dir diff --git a/samples/12_c_extensions/01_basics/app/ext.c b/samples/12_c_extensions/01_basics/app/ext.c new file mode 100644 index 0000000..a087919 --- /dev/null +++ b/samples/12_c_extensions/01_basics/app/ext.c @@ -0,0 +1,4 @@ +int square(int x) { + return x * x; +} + diff --git a/samples/12_c_extensions/01_basics/app/main.rb b/samples/12_c_extensions/01_basics/app/main.rb new file mode 100644 index 0000000..537b9b1 --- /dev/null +++ b/samples/12_c_extensions/01_basics/app/main.rb @@ -0,0 +1,7 @@ +$gtk.ffi_misc.gtk_dlopen("./samples/12_c_extensions/01_basics/build.dir/ext.lib") +include FFI::CExt + +def tick args + args.outputs.labels << [460, 600, "square(42) = #{square(42)}"] +end + diff --git a/samples/12_c_extensions/01_basics/license-for-sample.txt b/samples/12_c_extensions/01_basics/license-for-sample.txt new file mode 100644 index 0000000..100dcec --- /dev/null +++ b/samples/12_c_extensions/01_basics/license-for-sample.txt @@ -0,0 +1,9 @@ +Copyright 2019 DragonRuby LLC + +MIT License + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/samples/12_c_extensions/01_basics/metadata/game_metadata.txt b/samples/12_c_extensions/01_basics/metadata/game_metadata.txt new file mode 100644 index 0000000..a8772d0 --- /dev/null +++ b/samples/12_c_extensions/01_basics/metadata/game_metadata.txt @@ -0,0 +1,5 @@ +devid=dragonruby +devtitle=DragonRuby LLC +gameid=cbasics +gametitle=C Basics +version=1.0 diff --git a/samples/12_c_extensions/01_basics/pre.bat b/samples/12_c_extensions/01_basics/pre.bat new file mode 100644 index 0000000..3b3e27d --- /dev/null +++ b/samples/12_c_extensions/01_basics/pre.bat @@ -0,0 +1,4 @@ +set DRB_ROOT=..\..\..\ +md build.dir +%DRB_ROOT%\dragonruby-bind.exe --output=build.dir\ext-bind.c app\ext.c +clang -shared .\build.dir\ext-bind.c --sysroot=C:\mingw-w64\x86_64-8.1.0\mingw64 --target=x86_64-w64-mingw32 -fuse-ld=lld -isystem %DRB_ROOT%\include -I. -o build.dir\ext.lib diff --git a/samples/12_c_extensions/01_basics/pre.sh b/samples/12_c_extensions/01_basics/pre.sh new file mode 100755 index 0000000..8aa9eb7 --- /dev/null +++ b/samples/12_c_extensions/01_basics/pre.sh @@ -0,0 +1,10 @@ +#!/bin/sh +DRB_ROOT=../../.. +mkdir -p build.dir + +$DRB_ROOT/dragonruby-bind --output=build.dir/ext-bindings.c app/ext.c +clang \ + -isystem $DRB_ROOT/include -I. \ + -undefined dynamic_lookup \ + -fPIC -shared build.dir/ext-bindings.c -o build.dir/ext.lib + |
