blob: ee2e3532b7ef3737b579efeeddfcf5d381a46e8c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
namespace :build do
@vendor_dir = '../../vendor'
@include_dir = "#{@vendor_dir}/include"
@library_dir = "#{@vendor_dir}/lib"
@bytecode_header_path = "../temp"
desc "Build the engine"
task :mruby do
Dir.chdir("mruby") do
system('env MRUBY_CONFIG=build_config/felflame_linux.rb rake')
end
end
desc 'Compile the game to bytecode'
task :bytecode do
Dir.mkdir("build/temp") unless File.exists?("build/temp")
Dir.chdir("build/temp") do
system("../../mruby/bin/mrbc -Bbytecode -obytecode.h ../../game.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
system("emcc -s WASM=1 -Os -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 index.html --closure 1 -s USE_GLFW=3")
end
end
desc 'Build the game for Linux'
task :tux => :bytecode do
Dir.mkdir("build/tux") unless File.exists?("build/tux")
Dir.chdir("build/tux") do
system("zig cc -target native #{@vendor_dir}/boilerplate.c -o 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")
end
end
#desc 'Build the game for Window'
#task :win do
# Dir.mkdir("build/win") unless File.exists?("build/win")
# Dir.chdir("build/win") do
# system('zig cc -target x86_64-windows-gnu ../template/game.c -o game -lwinmm -lgdi32 -lopengl32 -I../../mruby/include -I../../raylib/src ../../raylib_lib_files/raylib.lib ../../mruby/build/host/lib/libmruby.a')
# end
#end
end
namespace :clean do
desc "Clean the mruby build folders"
task :mruby do
Dir.chdir("mruby") do
system('rake deep_clean')
end
end
end
desc "Create a server and open your game in your browser"
task :serve do
link = "http://localhost:8000/index.html"
if RbConfig::CONFIG['host_os'] =~ /mswin|mingw|cygwin/
system "start #{link}"
elsif RbConfig::CONFIG['host_os'] =~ /darwin/
system "open #{link}"
elsif RbConfig::CONFIG['host_os'] =~ /linux|bsd/
system "xdg-open #{link}"
end
`ruby -run -ehttpd build/web/ -p8000`
end
task :s => :serve
|