summaryrefslogtreecommitdiff
path: root/Rakefile
diff options
context:
space:
mode:
authorFrederico Linhares <fred@linhares.blue>2022-09-30 16:05:15 -0300
committerFrederico Linhares <fred@linhares.blue>2022-09-30 17:58:56 -0300
commit30c8d2b144bae1e5f95936c5af1b4432bcfdc7b4 (patch)
tree36fa89c6756228c557a565f9d627be138c0f253a /Rakefile
parentd7d79214a93bc96b38ac018aad4c8d5ee88d51ca (diff)
refa Use static linking for mruby
Diffstat (limited to 'Rakefile')
-rw-r--r--Rakefile31
1 files changed, 26 insertions, 5 deletions
diff --git a/Rakefile b/Rakefile
index ee510f5..69bdb84 100644
--- a/Rakefile
+++ b/Rakefile
@@ -19,6 +19,10 @@ OBJ = 'candy_gear'
VERSION = '0.1.0'
+MRUBY_VERSION = '3.1.0'
+MRUBY_ZIP_FILE = "mruby-#{MRUBY_VERSION}.zip"
+MRUBY_STATIC_LIB = "mruby-#{MRUBY_VERSION}/build/host/lib/libmruby.a"
+
DATA_DIR = '/usr/local/share/candy_gear'
CPP_H_FILES = FileList[
@@ -44,7 +48,6 @@ LIBRARIES = [
'SDL2_image',
'SDL2_mixer',
'm',
- 'mruby',
'vulkan',
'yaml-cpp'
]
@@ -55,12 +58,30 @@ CLEAN.include(
]
)
+file MRUBY_ZIP_FILE do
+ system("wget https://github.com/mruby/mruby/archive/#{MRUBY_VERSION}.zip "\
+ "-O #{MRUBY_ZIP_FILE}")
+end
+
+directory "mruby-#{MRUBY_VERSION}"
+file "mruby-#{MRUBY_VERSION}" => MRUBY_ZIP_FILE do
+ `unzip #{MRUBY_ZIP_FILE}`
+end
+
+# Candy Gear aims to be portable to several platforms. The language is embedded
+# inside the engine to ensure all versions of the engine have precisely the
+# same features.
+file MRUBY_STATIC_LIB => ["mruby-#{MRUBY_VERSION}"] do
+ Dir.chdir("mruby-#{MRUBY_VERSION}") { `rake` }
+end
+
task :doc do
`doxygen Doxyfile`
end
-rule '.o' => ['.cpp'] do |t|
- `g++ -D DEBUG=1 -c -std=c++17 #{t.source} -o #{t.name}`
+rule '.o' => ['.cpp', "mruby-#{MRUBY_VERSION}"] do |t|
+ system("g++ -D DEBUG=1 -c -std=c++17 -Imruby-#{MRUBY_VERSION}/include/ "\
+ "#{t.source} -o #{t.name}")
end
task :pkg do
@@ -85,10 +106,10 @@ rule '.spv' => ['.glsl'] do |t|
system("glslangValidator -V #{t.source} -o #{t.name}")
end
-task build: CPP_OBJS + SPV_FILES do
+task build: CPP_OBJS + SPV_FILES + [MRUBY_STATIC_LIB] do
libs = LIBRARIES.inject('') {_1 + "-l#{_2} "}
- `g++ -o #{OBJ} #{CPP_OBJS} #{libs}`
+ system("g++ -o #{OBJ} #{CPP_OBJS} #{MRUBY_STATIC_LIB} #{libs}")
end
task install: :build do