summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore5
-rw-r--r--Rakefile31
2 files changed, 30 insertions, 6 deletions
diff --git a/.gitignore b/.gitignore
index 546cc23..023a29d 100644
--- a/.gitignore
+++ b/.gitignore
@@ -2,6 +2,9 @@ candy_gear
doc
pkg
+mruby-*
+mruby-*.zip
+
*.mrb
*.o
-*.spv \ No newline at end of file
+*.spv
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