diff options
Diffstat (limited to 'tasks')
| -rw-r--r-- | tasks/libmruby.rake | 8 | ||||
| -rw-r--r-- | tasks/mrbgem_spec.rake | 20 | ||||
| -rw-r--r-- | tasks/mruby_build.rake | 5 | ||||
| -rw-r--r-- | tasks/mruby_build_commands.rake | 1 | ||||
| -rw-r--r-- | tasks/toolchains/android.rake | 51 | ||||
| -rw-r--r-- | tasks/toolchains/gcc.rake | 2 | ||||
| -rw-r--r-- | tasks/toolchains/visualcpp.rake | 2 |
7 files changed, 75 insertions, 14 deletions
diff --git a/tasks/libmruby.rake b/tasks/libmruby.rake index 095bedd52..23663d0a5 100644 --- a/tasks/libmruby.rake +++ b/tasks/libmruby.rake @@ -5,17 +5,17 @@ MRuby.each_target do file "#{build_dir}/lib/libmruby.flags.mak" => [__FILE__, libfile("#{build_dir}/lib/libmruby")] do |t| open(t.name, 'w') do |f| - f.puts "MRUBY_CFLAGS = #{cc.all_flags.gsub('"', '\\"')}" + f.puts "MRUBY_CFLAGS = #{cc.all_flags}" gem_flags = gems.map { |g| g.linker.flags } gem_library_paths = gems.map { |g| g.linker.library_paths } - f.puts "MRUBY_LDFLAGS = #{linker.all_flags(gem_library_paths, gem_flags).gsub('"', '\\"')} #{linker.option_library_path % "#{build_dir}/lib"}" + f.puts "MRUBY_LDFLAGS = #{linker.all_flags(gem_library_paths, gem_flags)} #{linker.option_library_path % "#{build_dir}/lib"}" gem_flags_before_libraries = gems.map { |g| g.linker.flags_before_libraries } - f.puts "MRUBY_LDFLAGS_BEFORE_LIBS = #{[linker.flags_before_libraries, gem_flags_before_libraries].flatten.join(' ').gsub('"', '\\"')}" + f.puts "MRUBY_LDFLAGS_BEFORE_LIBS = #{[linker.flags_before_libraries, gem_flags_before_libraries].flatten.join(' ')}" gem_libraries = gems.map { |g| g.linker.libraries } - f.puts "MRUBY_LIBS = #{linker.option_library % 'mruby'} #{linker.library_flags(gem_libraries).gsub('"', '\\"')}" + f.puts "MRUBY_LIBS = #{linker.option_library % 'mruby'} #{linker.library_flags(gem_libraries)}" end end task :all => "#{build_dir}/lib/libmruby.flags.mak" diff --git a/tasks/mrbgem_spec.rake b/tasks/mrbgem_spec.rake index 78d912980..1f7cde529 100644 --- a/tasks/mrbgem_spec.rake +++ b/tasks/mrbgem_spec.rake @@ -1,6 +1,7 @@ require 'pathname' require 'forwardable' require 'tsort' +require 'shellwords' module MRuby module Gem @@ -89,7 +90,9 @@ module MRuby build.libmruby << @objs instance_eval(&@build_config_initializer) if @build_config_initializer + end + def setup_compilers compilers.each do |compiler| compiler.define_rules build_dir, "#{dir}" compiler.defines << %Q[MRBGEM_#{funcname.upcase}_VERSION=#{version}] @@ -126,6 +129,21 @@ module MRuby "#{build_dir}/gem_test.c" end + def search_package(name, version_query=nil) + package_query = name + package_query += " #{version_query}" if version_query + _pp "PKG-CONFIG", package_query + escaped_package_query = Shellwords.escape(package_query) + if system("pkg-config --exists #{escaped_package_query}") + cc.flags += [`pkg-config --cflags #{escaped_package_query}`.strip] + cxx.flags += [`pkg-config --cflags #{escaped_package_query}`.strip] + linker.flags_before_libraries += [`pkg-config --libs #{escaped_package_query}`.strip] + true + else + false + end + end + def funcname @funcname ||= @name.gsub('-', '_') end @@ -403,6 +421,8 @@ module MRuby @ary = tsort_dependencies gem_table.keys, gem_table, true + each(&:setup_compilers) + each do |g| import_include_paths(g) end diff --git a/tasks/mruby_build.rake b/tasks/mruby_build.rake index cff45ddf8..bd911493d 100644 --- a/tasks/mruby_build.rake +++ b/tasks/mruby_build.rake @@ -120,6 +120,7 @@ module MRuby def enable_cxx_abi return if @cxx_exception_disabled or @cxx_abi_enabled compilers.each { |c| c.defines += %w(MRB_ENABLE_CXX_EXCEPTION) } + compilers.each { |c| c.flags << c.cxx_compile_flag } linker.command = cxx.command if toolchains.find { |v| v == 'gcc' } @cxx_abi_enabled = true end @@ -135,9 +136,13 @@ module MRuby #define __STDC_CONSTANT_MACROS #define __STDC_LIMIT_MACROS +#ifndef MRB_ENABLE_CXX_EXCEPTION extern "C" { +#endif #include "#{src}" +#ifndef MRB_ENABLE_CXX_EXCEPTION } +#endif #{src == "#{MRUBY_ROOT}/src/error.c"? 'mrb_int mrb_jmpbuf::jmpbuf_id = 0;' : ''} EOS diff --git a/tasks/mruby_build_commands.rake b/tasks/mruby_build_commands.rake index f4805f46d..d688077ff 100644 --- a/tasks/mruby_build_commands.rake +++ b/tasks/mruby_build_commands.rake @@ -41,6 +41,7 @@ module MRuby class Command::Compiler < Command attr_accessor :flags, :include_paths, :defines, :source_exts attr_accessor :compile_options, :option_define, :option_include_path, :out_ext + attr_accessor :cxx_compile_flag def initialize(build, source_exts=[]) super(build) diff --git a/tasks/toolchains/android.rake b/tasks/toolchains/android.rake index 0cc60a7a3..7759a3f9c 100644 --- a/tasks/toolchains/android.rake +++ b/tasks/toolchains/android.rake @@ -203,23 +203,53 @@ Set ANDROID_PLATFORM environment variable or set :platform parameter def cflags flags = [] - flags += %W(-D__android__ --sysroot="#{sysroot}") + flags += %W(-MMD -MP) + flags += %W(-D__android__ -DANDROID --sysroot="#{sysroot}") case toolchain when :gcc - flags += %W(-mandroid) case arch - when /armeabi-v7a/ then flags += %W(-march=armv7-a) - when /armeabi/ then flags += %W(-march=armv5te) - when /arm64-v8a/ then flags += %W(-march=armv8-a) + when /armeabi-v7a/ then flags += %W(-march=armv7-a -mfpu=vfpv3-d16 -mfloat-abi=softfp -fpic) + when /armeabi/ then flags += %W(-march=armv5te -mtune=xscale -msoft-float -fpic) + when /arm64-v8a/ then flags += %W(-march=armv8-a -fpic) when /x86_64/ then flags += %W(-march=x86-64) when /x86/ then flags += %W(-march=i686) - when /mips64/ then flags += %W(-march=mips64) - when /mips/ then flags += %W(-march=mips32) + when /mips64/ then flags += %W(-march=mips64r6 -fmessage-length=0 -fpic) + when /mips/ then flags += %W(-march=mips32 -fmessage-length=0 -fpic) end when :clang flags += %W(-gcc-toolchain "#{gcc_toolchain_path.to_s}") case arch - when /armeabi-v7a/ then flags += %W(-target armv7-none-linux-androideabi) + when /armeabi-v7a/ then flags += %W(-target armv7-none-linux-androideabi -fpic) + when /armeabi/ then flags += %W(-target armv5te-none-linux-androideabi -fpic) + when /arm64-v8a/ then flags += %W(-target aarch64-none-linux-android -fpic) + when /x86_64/ then flags += %W(-target x86_64-none-linux-android -fPIC) + when /x86/ then flags += %W(-target i686-none-linux-android -fPIC) + when /mips64/ then flags += %W(-target mips64el-none-linux-android -fmessage-length=0 -fpic) + when /mips/ then flags += %W(-target mipsel-none-linux-android -fmessage-length=0 -fpic) + end + flags += %W(-Wno-invalid-command-line-argument -Wno-unused-command-line-argument) + end + flags += %W(-ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes) + + flags + end + + def ldflags + flags = [] + + flags += %W(--sysroot="#{sysroot}") + + flags + end + + def ldflags_before_libraries + flags = [] + + case toolchain + when :clang + flags += %W(-gcc-toolchain "#{gcc_toolchain_path.to_s}") + case arch + when /armeabi-v7a/ then flags += %W(-target armv7-none-linux-androideabi -Wl,--fix-cortex-a8) when /armeabi/ then flags += %W(-target armv5te-none-linux-androideabi) when /arm64-v8a/ then flags += %W(-target aarch64-none-linux-android) when /x86_64/ then flags += %W(-target x86_64-none-linux-android) @@ -228,10 +258,10 @@ Set ANDROID_PLATFORM environment variable or set :platform parameter when /mips/ then flags += %W(-target mipsel-none-linux-android) end end + flags += %W(-no-canonical-prefixes) flags end - end MRuby::Toolchain.new(:android) do |conf, params| @@ -246,5 +276,6 @@ MRuby::Toolchain.new(:android) do |conf, params| conf.archiver.command = android.ar conf.linker.command = android.cc - conf.linker.flags = [] + conf.linker.flags = android.ldflags + conf.linker.flags_before_libraries = android.ldflags_before_libraries end diff --git a/tasks/toolchains/gcc.rake b/tasks/toolchains/gcc.rake index 4897e8c52..59ae015ac 100644 --- a/tasks/toolchains/gcc.rake +++ b/tasks/toolchains/gcc.rake @@ -6,6 +6,7 @@ MRuby::Toolchain.new(:gcc) do |conf, _params| cc.option_include_path = '-I%s' cc.option_define = '-D%s' cc.compile_options = '%{flags} -MMD -o %{outfile} -c %{infile}' + cc.cxx_compile_flag = '-x c++ -std=c++03' end [conf.cxx].each do |cxx| @@ -15,6 +16,7 @@ MRuby::Toolchain.new(:gcc) do |conf, _params| cxx.option_include_path = '-I%s' cxx.option_define = '-D%s' cxx.compile_options = '%{flags} -MMD -o %{outfile} -c %{infile}' + cxx.cxx_compile_flag = '-x c++ -std=c++03' end conf.linker do |linker| diff --git a/tasks/toolchains/visualcpp.rake b/tasks/toolchains/visualcpp.rake index 52820656b..5f5bab9c2 100644 --- a/tasks/toolchains/visualcpp.rake +++ b/tasks/toolchains/visualcpp.rake @@ -7,6 +7,7 @@ MRuby::Toolchain.new(:visualcpp) do |conf, _params| cc.option_include_path = '/I%s' cc.option_define = '/D%s' cc.compile_options = "%{flags} /Fo%{outfile} %{infile}" + cc.cxx_compile_flag = '/TP' end conf.cxx do |cxx| @@ -16,6 +17,7 @@ MRuby::Toolchain.new(:visualcpp) do |conf, _params| cxx.option_include_path = '/I%s' cxx.option_define = '/D%s' cxx.compile_options = "%{flags} /Fo%{outfile} %{infile}" + cxx.cxx_compile_flag = '/TP' end conf.linker do |linker| |
