summaryrefslogtreecommitdiffhomepage
path: root/Rakefile
diff options
context:
space:
mode:
Diffstat (limited to 'Rakefile')
-rw-r--r--Rakefile25
1 files changed, 22 insertions, 3 deletions
diff --git a/Rakefile b/Rakefile
index ee2e353..d9d6a64 100644
--- a/Rakefile
+++ b/Rakefile
@@ -9,11 +9,30 @@ namespace :build do
system('env MRUBY_CONFIG=build_config/felflame_linux.rb rake')
end
end
- desc 'Compile the game to bytecode'
- task :bytecode do
+ #desc 'Export to single file'
+ task :single_file do
+ result = ''
+ main = File.read('game/main.rb')
+ tmp = main.lines(chomp: true).select do |line|
+ line.include? 'require '
+ end
+ tmp.each do |file|
+ file.delete_prefix!('require ')
+ result += "#{File.read("game/#{file[1, file.length - 2]}")}\n"
+ end
+
+ result += main.lines.reject do |line|
+ line.include? 'require '
+ end.join
+
+ Dir.mkdir("build/temp") unless File.exists?("build/temp")
+ File.write('build/temp/main.rb', result)
+ end
+ #desc 'Compile the game to bytecode'
+ task :bytecode => :single_file do
Dir.mkdir("build/temp") unless File.exists?("build/temp")
Dir.chdir("build/temp") do
- system("../../mruby/bin/mrbc -Bbytecode -obytecode.h ../../game.rb")
+ system("../../mruby/bin/mrbc -Bbytecode -obytecode.h main.rb")
end
end
desc 'Build the game for web'