From 942a710653f69e6569ad09b5a9962f966b9425ad Mon Sep 17 00:00:00 2001 From: Frederico Linhares Date: Wed, 5 Oct 2022 11:48:56 -0300 Subject: buil Configure compilatio for MinGW --- .gitignore | 1 + Rakefile | 33 ++++++++++++++++++++++++++++++--- ruby_build_config.rb | 8 ++++++++ ruby_build_config.rb.lock | 4 ++++ src/rotation_3d.cpp | 2 ++ 5 files changed, 45 insertions(+), 3 deletions(-) create mode 100644 ruby_build_config.rb create mode 100644 ruby_build_config.rb.lock diff --git a/.gitignore b/.gitignore index 023a29d..f1230bd 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ candy_gear +candy_gear.exe doc pkg diff --git a/Rakefile b/Rakefile index 69bdb84..46d6bfe 100644 --- a/Rakefile +++ b/Rakefile @@ -15,6 +15,12 @@ require 'rake/clean' require 'rake/loaders/makefile' +OS = if RUBY_PLATFORM == "x64-mingw32" + :windows +else + :linux +end + OBJ = 'candy_gear' VERSION = '0.1.0' @@ -48,9 +54,20 @@ LIBRARIES = [ 'SDL2_image', 'SDL2_mixer', 'm', - 'vulkan', 'yaml-cpp' ] +case OS +when :windows + LIBRARIES.concat([ + 'SDL2main', + 'mingw32', + 'vulkan-1.dll' + ]) +when :linux + LIBRARIES.concat([ + 'vulkan' + ]) +end CLEAN.include( FileList[ @@ -72,7 +89,10 @@ end # 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` } + Dir.chdir("mruby-#{MRUBY_VERSION}") do + ENV['MRUBY_CONFIG'] = '../ruby_build_config.rb' + `rake` + end end task :doc do @@ -109,7 +129,14 @@ end task build: CPP_OBJS + SPV_FILES + [MRUBY_STATIC_LIB] do libs = LIBRARIES.inject('') {_1 + "-l#{_2} "} - system("g++ -o #{OBJ} #{CPP_OBJS} #{MRUBY_STATIC_LIB} #{libs}") + flags = '' + case OS + when :windows + flags = '-w -Wl,-subsystem,windows' + when :linux + end + + system("g++ -o #{OBJ} #{CPP_OBJS} #{MRUBY_STATIC_LIB} #{flags} #{libs}") end task install: :build do diff --git a/ruby_build_config.rb b/ruby_build_config.rb new file mode 100644 index 0000000..3818f6e --- /dev/null +++ b/ruby_build_config.rb @@ -0,0 +1,8 @@ +MRuby::Build.new do |conf| + conf.toolchain + + conf.gembox 'default-no-stdio' + + conf.enable_bintest + conf.enable_test +end diff --git a/ruby_build_config.rb.lock b/ruby_build_config.rb.lock new file mode 100644 index 0000000..0b289fd --- /dev/null +++ b/ruby_build_config.rb.lock @@ -0,0 +1,4 @@ +--- +mruby: + version: 3.1.0 + release_no: 30100 diff --git a/src/rotation_3d.cpp b/src/rotation_3d.cpp index db0ce5a..0795859 100644 --- a/src/rotation_3d.cpp +++ b/src/rotation_3d.cpp @@ -14,6 +14,8 @@ * limitations under the License. */ +#define _USE_MATH_DEFINES + #include "rotation_3d.hpp" #include "vector_3d.hpp" -- cgit v1.2.3