diff options
| author | realtradam <[email protected]> | 2022-04-06 04:02:39 -0400 |
|---|---|---|
| committer | realtradam <[email protected]> | 2022-04-06 04:02:39 -0400 |
| commit | ee790aa76abf11f04fe27358b4b2bd8f60480fe8 (patch) | |
| tree | af2d6fc123674a573317df6ac4a2d8e1e89c2194 | |
| parent | 21e9cf41c76047cabef60f64534a2768cd6809b5 (diff) | |
| download | FelFlameEngine-rework.tar.gz FelFlameEngine-rework.zip | |
working targetrework
| -rw-r--r-- | Gemfile | 9 | ||||
| -rw-r--r-- | Gemfile.lock | 15 | ||||
| -rw-r--r-- | Rakefile | 82 | ||||
| -rw-r--r-- | Readme.mdown | 68 | ||||
| -rw-r--r-- | core/mruby_build.rb | 81 |
5 files changed, 184 insertions, 71 deletions
@@ -0,0 +1,9 @@ +# frozen_string_literal: true + +source "https://rubygems.org" + +# gem "rails" + +gem "webrick", "~> 1.7" + +gem "rake", "~> 13.0" diff --git a/Gemfile.lock b/Gemfile.lock new file mode 100644 index 0000000..7be5a06 --- /dev/null +++ b/Gemfile.lock @@ -0,0 +1,15 @@ +GEM + remote: https://rubygems.org/ + specs: + rake (13.0.6) + webrick (1.7.0) + +PLATFORMS + x86_64-linux + +DEPENDENCIES + rake (~> 13.0) + webrick (~> 1.7) + +BUNDLED WITH + 2.3.7 @@ -20,57 +20,66 @@ config_web = File.expand_path("#{config_vendor}/web") config_web_include = File.expand_path("#{config_vendor}/web/include") config_web_lib = File.expand_path("#{config_vendor}/web/lib") +config_win = File.expand_path("#{config_vendor}/win") +config_win_include = File.expand_path("#{config_vendor}/win/include") +config_win_lib = File.expand_path("#{config_vendor}/win/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_build_win = File.expand_path("#{config_build}/win") 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" desc "Build the engine" task :mruby do Dir.chdir("core/mruby") do Dir.mkdir(config_vendor) unless File.exists?(config_vendor) - #Dir.each_child("build/repos") do |repo_dir| - # Dir.each_child("build/repos/#{repo_dir}") do |gem_dir| - # puts "Checking updates for: #{gem_dir}" - # Dir.chdir("build/repos/#{repo_dir}/#{gem_dir}") do - # system('git pull') - # end - # end - #end 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/") + FileUtils.cp("build/win/lib/libmruby.a", "#{config_win_lib}/") end end desc "Build Raylib" task :raylib do Dir.mkdir(config_vendor) unless File.exists?(config_vendor) + Dir.mkdir(config_tux) unless File.exists?(config_tux) + Dir.mkdir("#{config_tux_lib}") unless File.exists?("#{config_tux_lib}") + Dir.mkdir("#{config_tux_include}") unless File.exists?("#{config_tux_include}") + Dir.mkdir(config_web) unless File.exists?(config_web) + Dir.mkdir("#{config_web_lib}") unless File.exists?("#{config_web_lib}") + Dir.mkdir("#{config_web_include}") unless File.exists?("#{config_web_include}") + Dir.mkdir(config_win) unless File.exists?(config_win) + Dir.mkdir("#{config_win_lib}") unless File.exists?("#{config_win_lib}") + Dir.mkdir("#{config_win_include}") unless File.exists?("#{config_win_include}") + #puts 'installing, this should prompt you to enter password unless you are already in sudo' Dir.chdir(config_build_raylib_source) do `make clean` 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=#{config_tux} make install` + FileUtils.cp("raylib.h", "#{config_tux_include}/") + FileUtils.cp("raymath.h", "#{config_tux_include}/") + FileUtils.cp("rlgl.h", "#{config_tux_include}/") + # copy libraylib.a to lib + FileUtils.cp("libraylib.a", "#{config_tux_lib}/") `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 PLATFORM=PLATFORM_WEB -e` + FileUtils.cp("raylib.h", "#{config_web_include}/") + FileUtils.cp("raymath.h", "#{config_web_include}/") + FileUtils.cp("rlgl.h", "#{config_web_include}/") + FileUtils.cp("libraylib.a", "#{config_web_lib}/") `make clean` + `zig build -Dtarget=x86_64-windows-gnu` + FileUtils.cp("raylib.h", "#{config_win_include}/") + FileUtils.cp("raymath.h", "#{config_win_include}/") + FileUtils.cp("rlgl.h", "#{config_win_include}/") + FileUtils.cp("zig-out/lib/raylib.lib", "#{config_win_lib}/") end end #desc 'Export to single file' @@ -107,7 +116,11 @@ namespace :build do 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 + if File.exists?('assets') + 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") + else + 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 --shell-file #{config_core}/shell.html -s TOTAL_MEMORY=268435456 -s ASYNCIFY") + end end end @@ -123,13 +136,14 @@ namespace :build do 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' - #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 + desc 'Build the game for Window' + task :win do + Dir.mkdir(config_build) unless File.exists?(config_build) + Dir.mkdir(config_build_win) unless File.exists?(config_build_win) + Dir.chdir(config_build_win) do + system("zig cc -target x86_64-windows-gnu #{config_core}/boilerplate_entry.c -o #{config_build_win}/game -lwinmm -lgdi32 -lopengl32 -lws2_32 -I#{config_build_temp} -I#{config_win_include} -I#{config_include_mruby} #{config_win_lib}/libmruby.a #{config_win_lib}/raylib.lib") + end + end end desc 'Launch the game with the interpreter' @@ -151,8 +165,11 @@ namespace :clean do task :raylib do puts 'Not implemented yet' end + task :game 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" @@ -163,8 +180,7 @@ task :serve do elsif RbConfig::CONFIG['host_os'] =~ /linux|bsd/ system "xdg-open #{link}" end - `ruby -run -ehttpd build/web/ -p8000` + `ruby -run -ehttpd #{config_build_web} -p8000` end task :s => :serve -=end diff --git a/Readme.mdown b/Readme.mdown index f41d4c7..d3bb4bf 100644 --- a/Readme.mdown +++ b/Readme.mdown @@ -1,52 +1,72 @@ -# FelFlame Engine -FelFlame Engine is a modular "library-style" Ruby game engine. It allows you to consists of a core set of libraries(mruby + raylib) which you can freely add your own mruby or C libraries on top of to be compiled into a single game or engine. Currently it exports to Linux and Web but more platforms are possible and planned. + +[](https://github.com/realtradam/FelFlameEngine/blob/master/LICENSE) +[](https://ko-fi.com/tradam) + +--- + +FelFlame Engine is a modular "library-style" Ruby game engine. It consists of a core set of libraries(mruby + Raylib) which you can freely add your own mruby or C libraries on top of to be compiled into a single game or interpreter. Currently it exports to Windows, Web and Linux. ## How to build -Currently building only tested/used on Linux(Arch and OpenSUSE) -No support for building on windows is planned but you are welcome to add it yourself ;) +Currently building only tested/used on Linux(Artix/Arch and OpenSUSE). If you are on windows you could try using WSL but this is currently untested. +You need to have any requirements for compiling [Raylib](https://github.com/raysan5/raylib) installed. You must also have Zig and Emscripten installed(it is recommended to use [asdf](https://asdf-vm.com/) to install these) + +1. Clone the repository and install gems ```sh +git clone --recursive [email protected]:realtradam/FelFlameEngine.git +cd FelFlameEngine +bundler install +``` -# building libraries + engine +2. Build the underlying libraries +```sh rake build:raylib rake build:mruby +``` +###### At this point you could play around with the interpreters at `core/mruby/bin/mirb` and `core/mruby/bin/mruby` -# you can now access the interpreters under [add url here] +3. Playtest your game +```sh +rake play +# or +rake p +``` +###### This will execute your game located here: `game/main.rb` -# if you have a game under 'game/main.rb': -# build for linux -rake build:tux -# build for web -rake build:web +4. Build your game +```sh +rake build:win # build for windows +rake build:web # build for web +rake build:tux # build for linux +``` +###### The binaries are located under `build` in their respective directories -# you can then try your game with: -# Desktop: -rake play -# Web: +5. Test the web export of your game +```sh rake serve - -# building for windows planned for the future +# or +rake s ``` ## Directories Explained: -### core/ -Contains the core git-submodules which are needed for the engine(mruby for the Ruby language and Raylib for rendering). Also contains some template files used during compilation. +### mrbgems/ +Here are all the gems you wish to be compiled into the engine. Any directories in this directory will be treated as a gem to be included into the compilation process however you may still need to edit the [build file] to add the appropriate flags if necessary. + +### game/ +All your game files. `main.rb` is the "entry point" of your game and the assets directory is where your assets should go as they are bundled for the web export. ### vendor/ The location of any compiled libraries and headers. These are 'included' into the engine or game when it is compiled. -### game/ -All your game files. `main.rb` is the "entry point" of your game and the assets directory is where your assets should go as they are bundled for the web export. +### core/ +Contains the core git-submodules which are needed for the engine(mruby for the Ruby language and Raylib for rendering). Also contains some template and configuration files used during compilation. ### build/ Where your game is exported to when it is compiled. -### mrbgems/ -Here are all the gems you wish to be compiled into the engine. Any directories in this directory will be treated as a gem to be included into the compilation process however you may still need to edit the [build file] to add the appropriate flags if necessary. - ## Extras: By default this engine comes with just Ruby and Raylib. Here are some additional gems you could use if you want more: diff --git a/core/mruby_build.rb b/core/mruby_build.rb index 8a440c9..a0d0a56 100644 --- a/core/mruby_build.rb +++ b/core/mruby_build.rb @@ -75,24 +75,19 @@ MRuby::Build.new do |conf| # C compiler settings conf.cc do |cc| cc.command = 'zig cc -target native -O2' + cc.include_paths << ["#{configure_project_root}/vendor/tux/include"] end # Linker settings conf.linker do |linker| #linker.command = ENV['LD'] || 'gcc' linker.command = 'zig c++ -target native -O2' - end - - conf.cxx.command = 'zig c++ -target native -O2' - - conf.cc do |cc| - cc.include_paths << ["#{configure_project_root}/vendor/tux/include"] - end - conf.linker do |linker| linker.flags << ['-lraylib -lGL -lm -lpthread -ldl -lrt -lX11'] linker.library_paths << ["#{configure_project_root}/vendor/tux/lib"] end + conf.cxx.command = 'zig c++ -target native -O2' + # Turn on `enable_debug` for better debugging # conf.enable_debug conf.enable_bintest @@ -158,32 +153,90 @@ MRuby::CrossBuild.new("tux") do |conf| conf.cxx.command = "zig c++ -target x86_64-linux-gnu" end =end -=begin MRuby::CrossBuild.new("win") do |conf| conf.toolchain :clang disable_lock # disables being stuck on a single commit - # include the GEM box - conf.gembox 'felflame' + # -- CORE GEMS -- + conf.gembox "stdlib" + conf.gembox "stdlib-ext" + conf.gembox "math" + conf.gembox "metaprog" + #conf.gembox "stdlib-io" + + # Use standard IO/File class + conf.gem :core => "mruby-io" + + # TODO: this gem doesnt current work + # with windows export + #conf.gem :core => "mruby-socket" + + # Use standard print/puts/p + conf.gem :core => "mruby-print" + + # Generate mrbc command + conf.gem :core => "mruby-bin-mrbc" + + # Generate mirb command + conf.gem :core => "mruby-bin-mirb" + + # Generate mruby command + conf.gem :core => "mruby-bin-mruby" + + # Generate mruby-strip command + conf.gem :core => "mruby-bin-strip" + + # Generate mruby-config command + conf.gem :core => "mruby-bin-config" + + # -- POTENTIAL GEMS -- + # gems that we may want incorperated + + # Simple Http + #conf.gem :git => 'https://github.com/matsumotory/mruby-simplehttp' + + # Memory Profiler + #conf.gem :git => 'https://github.com/iij/mruby-memprof' + + # Testing Framework + #conf.gem :git => 'https://github.com/iij/mruby-mtest' + + # Regex + #conf.gem :git => 'https://github.com/iij/mruby-regexp-pcre' + + # JSON + #conf.gem :git => 'https://github.com/iij/mruby-iijson' + + # Dir + #conf.gem :git => 'https://github.com/iij/mruby-dir' + + # -- YOUR GEMS -- + # gems added into the mrbgems directory + + puts "HERE: #{File.expand_path(configure_mrbgem_dir)}" + Dir.each_child(configure_mrbgem_dir) do |mrb_gem| + conf.gem "#{configure_mrbgem_dir}/#{mrb_gem}" + end + + # --- conf.host_target = "x86_64-w64-mingw32" conf.cc do |cc| cc.command = 'zig cc -target x86_64-windows-gnu' - cc.include_paths = ["#{root}/include", '../raylib/src'] + cc.include_paths << ["#{configure_project_root}/vendor/win/include"] end conf.linker do |linker| linker.command = 'zig cc -target x86_64-windows-gnu' linker.flags = ['-lraylib -lwinmm -lgdi32 -lopengl32' ] - linker.library_paths = ['../raylib_lib_files'] + linker.library_paths << ["#{configure_project_root}/vendor/win/lib"] end conf.cxx.command = "zig c++ -target x86_64-windows-gnu" end -=end MRuby::CrossBuild.new("web") do |conf| conf.toolchain :clang |
