summaryrefslogtreecommitdiffhomepage
path: root/Rakefile
diff options
context:
space:
mode:
author_Tradam <[email protected]>2022-04-05 02:10:43 -0400
committer_Tradam <[email protected]>2022-04-05 02:10:43 -0400
commit965cd651672090a6e5933f4466314ff56fd56b57 (patch)
tree2db52ede72d304739397d619ab4528e60011f1de /Rakefile
parent976ced04e889d48a652d544c635dafd7ff6f6100 (diff)
downloadFelFlameEngine-965cd651672090a6e5933f4466314ff56fd56b57.tar.gz
FelFlameEngine-965cd651672090a6e5933f4466314ff56fd56b57.zip
compiling game works, emscripten in progress
Diffstat (limited to 'Rakefile')
-rw-r--r--Rakefile107
1 files changed, 73 insertions, 34 deletions
diff --git a/Rakefile b/Rakefile
index 493d8f6..07a53f0 100644
--- a/Rakefile
+++ b/Rakefile
@@ -1,9 +1,36 @@
require 'fileutils'
+
+config_root = File.expand_path('.')
+config_core = File.expand_path("#{config_root}/core")
+
+config_build_config = File.expand_path("#{config_root}/core/mruby_build.rb")
+
+config_build_raylib_source = File.expand_path("#{config_root}/core/raylib/src")
+
+config_mruby = File.expand_path("#{config_root}/core/mruby")
+config_include_mruby = File.expand_path("#{config_mruby}/include")
+
+config_tux = File.expand_path("#{config_root}/vendor/tux")
+config_tux_include = File.expand_path("#{config_root}/vendor/tux/include")
+config_tux_lib = File.expand_path("#{config_root}/vendor/tux/lib")
+
+config_web = File.expand_path("#{config_root}/vendor/web")
+config_web_include = File.expand_path("#{config_root}/vendor/web/include")
+config_web_lib = File.expand_path("#{config_root}/vendor/web/lib")
+
+config_build = File.expand_path("#{config_root}/build")
+config_build_temp = File.expand_path("#{config_build}/temp")
+config_build_tux = File.expand_path("#{config_build}/tux")
+config_build_web = File.expand_path("#{config_build}/web")
+
+config_game = File.expand_path("#{config_root}/game")
+
namespace :build do
- @vendor_dir = '../vendor'
- @include_dir = "#{@vendor_dir}/include"
- @library_dir = "#{@vendor_dir}/lib"
- @bytecode_header_path = "../build/temp"
+
+ #@vendor_dir = '../vendor'
+ #@include_dir = "#{@vendor_dir}/include"
+ #@library_dir = "#{@vendor_dir}/lib"
+ #@bytecode_header_path = "../build/temp"
desc "Build the engine"
task :mruby do
Dir.chdir("core/mruby") do
@@ -15,71 +42,81 @@ namespace :build do
# end
# end
#end
- system('env MRUBY_CONFIG=../mruby_build.rb rake')
- #FileUtils.cp("build/web/lib/libmruby.a", "../../vendor/web/lib/mruby/")
- FileUtils.cp("build/host/lib/libmruby.a", "../../vendor/tux/lib/")
+ system("env MRUBY_CONFIG=#{config_build_config} rake")
+ FileUtils.cp("build/web/lib/libmruby.a", "#{config_web_lib}/")
+ FileUtils.cp("build/host/lib/libmruby.a", "#{config_tux_lib}/")
#FileUtils.cp("build/win/lib/libmruby.a", "../vendor/lib/win/mruby/")
end
end
desc "Build Raylib"
task :raylib do
- Dir.chdir("core/raylib/src") do
+ Dir.chdir(config_build_raylib_source) do
`make clean`
- puts 'building...'
+ puts 'building for tux...'
`make PLATFORM=PLATFORM_DESKTOP`
puts
+ Dir.mkdir(config_tux) unless File.exists?(config_tux)
puts 'installing, this should prompt you to enter password unless you are already in sudo'
- `sudo DESTDIR=#{File.expand_path('../../../vendor/tux')} make install`
+ `sudo DESTDIR=#{config_tux} make install`
+ `make clean`
+ puts 'building for web...'
+ `make PLATFORM=PLATFORM_WEB`
+ puts
+ Dir.mkdir(config_web) unless File.exists?(config_web)
+ puts 'installing, this should prompt you to enter password unless you are already in sudo'
+ `sudo DESTDIR=#{config_web} make install`
`make clean`
- #`make PLATFORM=PLATFORM_WEB`
- #`sudo DESTDIR=/path/u/want make install`
- #`make clean`
end
end
#desc 'Export to single file'
task :single_file do
result = ''
- main = File.read('game/main.rb')
+ main = File.read("#{config_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"
+ result += "#{File.read("#{config_game}/#{file[1, file.length - 2]}")}\n"
end
result += main.lines.reject do |line|
line.include? 'require '
end.join
- Dir.mkdir("build") unless File.exists?("build")
- Dir.mkdir("build/temp") unless File.exists?("build/temp")
- File.write('build/temp/main.rb', result)
+ Dir.mkdir(config_build) unless File.exists?(config_build)
+ Dir.mkdir(config_build_temp) unless File.exists?(config_build_temp)
+ File.write("#{config_build_temp}/main.rb", result)
end
#desc 'Compile the game to bytecode'
task :bytecode => :single_file do
- Dir.mkdir("build") unless File.exists?("build")
- Dir.mkdir("build/temp") unless File.exists?("build/temp")
- Dir.chdir("build/temp") do
- system("../../core/mruby/bin/mrbc -Bbytecode -obytecode.h main.rb")
+ Dir.mkdir(config_build) unless File.exists?(config_build)
+ Dir.mkdir(config_build_temp) unless File.exists?(config_build_temp)
+ Dir.chdir(config_build_temp) do
+ system("#{config_mruby}/bin/mrbc -Bbytecode -obytecode.h main.rb")
end
end
+
desc 'Build the game for web'
task :web => :bytecode do
- Dir.mkdir("build/web") unless File.exists?("build/web")
- #Dir.chdir("build/web") do
- Dir.chdir("game") do
- system("emcc -Os -Wall -I#{@include_dir}/raylib -I#{@include_dir}/mruby -I#{@bytecode_header_path} #{@vendor_dir}/boilerplate.c #{@library_dir}/web/mruby/libmruby.a #{@library_dir}/web/raylib/libraylib.a -o ../build/web/index.html -s USE_GLFW=3 -DPLATFORM_WEB --preload-file ./assets --shell-file #{@vendor_dir}/html/minshell.html -s TOTAL_MEMORY=268435456") # -s ASYNCIFY
+ Dir.mkdir(config_build) unless File.exists?(config_build)
+ Dir.mkdir(config_build_web) unless File.exists?(config_build_web)
+ Dir.chdir(config_game) do
+ system("emcc -Os -Wall -I#{config_web_include} -I#{config_include_mruby} -I#{config_build_temp} #{config_core}/boilerplate_entry.c #{config_web_lib}/libmruby.a #{config_web_lib}/libraylib.a -o #{config_build_web}/index.html -s USE_GLFW=3 -DPLATFORM_WEB --preload-file ./assets --shell-file #{config_core}/shell.html -s TOTAL_MEMORY=268435456") # -s ASYNCIFY
end
end
+
desc 'Build the game for Linux'
task :tux => :bytecode do
- Dir.mkdir("build/tux") unless File.exists?("build/tux")
+ Dir.mkdir(config_build) unless File.exists?(config_build)
+ Dir.mkdir(config_build_tux) unless File.exists?(config_build_tux)
#Dir.chdir("build/tux") do
- Dir.chdir("game") do
- system("zig cc -target native #{@vendor_dir}/boilerplate.c -o ../build/tux/game -lGL -lm -lpthread -ldl -lrt -lX11 -I#{@bytecode_header_path} -I#{@include_dir}/raylib -I#{@include_dir}/mruby #{@library_dir}/tux/mruby/libmruby.a #{@library_dir}/tux/raylib/libraylib.a")
- system("rsync -r ./assets ../build/tux")
+ Dir.chdir(config_game) do
+ system("zig cc -target native #{config_core}/boilerplate_entry.c -o #{config_build_tux}/game -lGL -lm -lpthread -ldl -lrt -lX11 -I#{config_build_temp} -I#{config_tux_include} -I#{config_include_mruby} #{config_tux_lib}/libmruby.a #{config_tux_lib}/libraylib.a")
+ end
+ if File.exists?("#{config_game}/assets")
+ system("rsync -r #{config_game}/assets #{config_build_tux}") # TODO: maybe get rid of this? copying assets can be costly
end
end
#desc 'Build the game for Window'
@@ -91,10 +128,10 @@ namespace :build do
#end
end
-desc 'Launch the game'
+desc 'Launch the game with the interpreter'
task :playtest => "build:single_file" do
Dir.chdir("game") do
- system("../core/mruby/build/host/bin/mruby ../build/temp/main.rb")
+ system("#{config_mruby}/build/host/bin/mruby #{config_build_temp}/main.rb")
end
end
task :p => :playtest
@@ -103,7 +140,7 @@ task :p => :playtest
namespace :clean do
desc "Clean the mruby build folders"
task :mruby do
- Dir.chdir("core/mruby") do
+ Dir.chdir(config_mruby) do
system('rake deep_clean')
end
end
@@ -111,7 +148,7 @@ namespace :clean do
puts 'Not implemented yet'
end
end
-
+=begin
desc "Create a server and open your game in your browser"
task :serve do
link = "http://localhost:8000/index.html"
@@ -125,3 +162,5 @@ task :serve do
`ruby -run -ehttpd build/web/ -p8000`
end
task :s => :serve
+=end
+