diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 02:57:58 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 02:57:58 +0000 |
commit | be1c7e50e1e8809ea56f2c9d472eccd8ffd73a97 (patch) | |
tree | 9754ff1ca740f6346cf8483ec915d4054bc5da2d /web/server/h2o/libh2o/deps/mruby/tasks | |
parent | Initial commit. (diff) | |
download | netdata-be1c7e50e1e8809ea56f2c9d472eccd8ffd73a97.tar.xz netdata-be1c7e50e1e8809ea56f2c9d472eccd8ffd73a97.zip |
Adding upstream version 1.44.3.upstream/1.44.3upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'web/server/h2o/libh2o/deps/mruby/tasks')
9 files changed, 823 insertions, 0 deletions
diff --git a/web/server/h2o/libh2o/deps/mruby/tasks/benchmark.rake b/web/server/h2o/libh2o/deps/mruby/tasks/benchmark.rake new file mode 100644 index 00000000..84e69ebe --- /dev/null +++ b/web/server/h2o/libh2o/deps/mruby/tasks/benchmark.rake @@ -0,0 +1,91 @@ +module MRuby + BENCHMARK_REPEAT = 4 +end + +$dat_files = [] + +def bm_files + Dir.glob("#{MRUBY_ROOT}/benchmark/bm_*.rb") +end + +def build_config_name + if ENV['MRUBY_CONFIG'] + File.basename(ENV['MRUBY_CONFIG'], '.rb').gsub('build_config_', '') + else + "build" + end +end + +def plot_file + File.join(MRUBY_ROOT, 'benchmark', "#{build_config_name}.png") +end + +def plot + opts_file = "#{MRUBY_ROOT}/benchmark/plot.gpl" + opts = File.read(opts_file).each_line.to_a.map(&:strip).join(';') + + dat_files = $dat_files.group_by {|f| File.dirname(f).split(File::SEPARATOR)[-1]} + + opts += ";set output '#{plot_file}'" + + opts += ';plot ' + + opts += dat_files.keys.map do |data_file| + %Q['-' u 2:3:4:xtic(1) w hist title columnheader(1)] + end.join(',') + opts += ';' + + cmd = %Q{gnuplot -p -e "#{opts}"} + + IO.popen(cmd, 'w') do |p| + dat_files.each do |target_name, bm_files| + p.puts target_name.gsub('_', '-') + bm_files.each do |bm_file| + p.write File.read(bm_file) + end + p.puts "e" + end + end +end + + +MRuby.each_target do |target| + next if target.name == 'host' + mruby_bin = "#{target.build_dir}/bin/mruby" + + bm_files.each do |bm_file| + bm_name = File.basename bm_file, ".rb" + + dat_dir = File.join('benchmark', build_config_name, target.name) + dat_file = File.join(dat_dir, "#{bm_name}.dat") + $dat_files << dat_file + + directory dat_dir + + file dat_file => [bm_file, dat_dir, mruby_bin] do |task| + print bm_name + puts "..." + + data = (0...MRuby::BENCHMARK_REPEAT).map do |n| + str = %x{(time -f "%e %S %U" #{mruby_bin} #{bm_file}) 2>&1 >/dev/null} + str.split(' ').map(&:to_f) + end + + File.open(task.name, "w") do |f| + data = data.map {|_,r,s| (r + s) / 2.0} + min = data.min + max = data.max + avg = data.inject(&:+) / data.size + f.puts "#{bm_name.gsub('_', '-')} #{avg} #{min} #{max}" + end + end + end +end + +file plot_file => $dat_files do + plot +end + +task :benchmark => plot_file do + plot +end diff --git a/web/server/h2o/libh2o/deps/mruby/tasks/gitlab.rake b/web/server/h2o/libh2o/deps/mruby/tasks/gitlab.rake new file mode 100644 index 00000000..47117237 --- /dev/null +++ b/web/server/h2o/libh2o/deps/mruby/tasks/gitlab.rake @@ -0,0 +1,118 @@ +CI_VERSION = '0.7'.freeze +CI_BASE = 'ubuntu:16.10'.freeze +CI_COMPILERS = ['gcc-4.7', + 'gcc-4.8', + 'gcc-4.9', + 'gcc-5', + 'gcc-6', + 'clang-3.5', + 'clang-3.6', + 'clang-3.7', + 'clang-3.8', + 'clang-3.9'].freeze + +def ci_image_tag(compiler) + compiler.tr('+', 'c').delete('-').delete('.') +end + +def ci_docker_tag(compiler) + tag = ci_image_tag(compiler) + "registry.gitlab.com/dabroz/mruby:#{tag}_#{CI_VERSION}" +end + +def run_cmd(cmd) + puts cmd + raise 'error' unless system cmd +end + +desc 'recreate docker images for GitLab builds' +task :gitlab_dockers do + CI_COMPILERS.each do |compiler| + tag = ci_image_tag(compiler) + filename = "Dockerfile.#{tag}" + File.open(filename, 'wb') do |f| + f << "# #{compiler} - #{tag}\n" + f << "FROM #{CI_BASE}\n" + f << "RUN apt-get update && apt-get install -y git ruby2.3 ruby2.3-dev bison\n" + f << "RUN apt-get update && apt-get install -y binutils manpages\n" + f << "RUN apt-get update && apt-get install -y #{compiler}\n" + if compiler['gcc'] + f << "RUN apt-get update && apt-get install -y libx32#{compiler}-dev\n" + f << "RUN apt-get update && apt-get install --no-install-recommends -y #{compiler}-multilib\n" + end + f << "RUN dpkg --add-architecture i386\n" + f << "RUN apt-get update && apt-get install -y linux-libc-dev:i386\n" + if compiler['clang'] + f << "RUN apt-get update && apt-get install --no-install-recommends -y libc6-dev-i386\n" + f << "RUN apt-get update && apt-get install -y gcc gcc-multilib\n" + end + end + docker_tag = ci_docker_tag(compiler) + cmd1 = "docker build -t #{docker_tag} -f #{filename} ." + cmd2 = "docker push #{docker_tag}" + run_cmd cmd1 + run_cmd cmd2 + File.delete(filename) + end +end + +desc 'create build configurations and update .gitlab-ci.yml' +task :gitlab_config do + require 'yaml' + + configs = [] + [true, false].each do |mode_32| + ['', 'MRB_USE_FLOAT'].each do |float_conf| + ['', 'MRB_INT16', 'MRB_INT64'].each do |int_conf| + ['', 'MRB_NAN_BOXING', 'MRB_WORD_BOXING'].each do |boxing_conf| + ['', 'MRB_UTF8_STRING'].each do |utf8_conf| + next if (float_conf == 'MRB_USE_FLOAT') && (boxing_conf == 'MRB_NAN_BOXING') + next if (int_conf == 'MRB_INT64') && (boxing_conf == 'MRB_NAN_BOXING') + next if (int_conf == 'MRB_INT16') && (boxing_conf == 'MRB_WORD_BOXING') + next if (int_conf == 'MRB_INT64') && (boxing_conf == 'MRB_WORD_BOXING') && mode_32 + env = [float_conf, int_conf, boxing_conf, utf8_conf].map do |conf| + conf == '' ? nil : "-D#{conf}=1" + end.compact.join(' ') + bit = mode_32 ? '-m32 ' : '' + _info = '' + _info += mode_32 ? '32bit ' : '64bit ' + _info += float_conf['USE'] ? 'float ' : '' + _info += int_conf['16'] ? 'int16 ' : '' + _info += int_conf['64'] ? 'int64 ' : '' + _info += boxing_conf['NAN'] ? 'nan ' : '' + _info += boxing_conf['word'] ? 'word ' : '' + _info += utf8_conf['UTF8'] ? 'utf8 ' : '' + _info = _info.gsub(/ +/, ' ').strip.tr(' ', '_') + configs << { '_info' => _info, 'CFLAGS' => "#{bit}#{env}", 'LDFLAGS' => bit.strip.to_s } + end + end + end + end + end + path = './.gitlab-ci.yml' + data = YAML.load_file(path) + data.keys.select do |key| + key.start_with? 'Test' + end.each do |key| + data.delete(key) + end + CI_COMPILERS.each do |compiler| + configs.each do |config| + name = "Test #{compiler} #{config['_info']}" + hash = { + 'CC' => compiler, + 'CXX' => compiler.gsub('gcc', 'g++').gsub('clang', 'clang++'), + 'LD' => compiler + } + hash = hash.merge(config) + hash.delete('_info') + data[name] = { + 'stage' => 'test', + 'image' => ci_docker_tag(compiler), + 'variables' => hash, + 'script' => 'env; ./minirake --verbose all test' + } + end + end + File.open(path, 'w') { |f| YAML.dump(data, f) } +end diff --git a/web/server/h2o/libh2o/deps/mruby/tasks/libmruby.rake b/web/server/h2o/libh2o/deps/mruby/tasks/libmruby.rake new file mode 100644 index 00000000..540aa3eb --- /dev/null +++ b/web/server/h2o/libh2o/deps/mruby/tasks/libmruby.rake @@ -0,0 +1,24 @@ +MRuby.each_target do + file libfile("#{build_dir}/lib/libmruby") => libmruby.flatten do |t| + archiver.run t.name, t.prerequisites + end + + 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}" + + 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)} #{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(' ')}" + + gem_libraries = gems.map { |g| g.linker.libraries } + f.puts "MRUBY_LIBS = #{linker.option_library % 'mruby'} #{linker.library_flags(gem_libraries)}" + + f.puts "MRUBY_LIBMRUBY_PATH = #{libfile("#{build_dir}/lib/libmruby")}" + end + end + task :all => "#{build_dir}/lib/libmruby.flags.mak" +end diff --git a/web/server/h2o/libh2o/deps/mruby/tasks/mrbgems.rake b/web/server/h2o/libh2o/deps/mruby/tasks/mrbgems.rake new file mode 100644 index 00000000..65368c30 --- /dev/null +++ b/web/server/h2o/libh2o/deps/mruby/tasks/mrbgems.rake @@ -0,0 +1,96 @@ +MRuby.each_target do + if enable_gems? + # set up all gems + gems.each(&:setup) + gems.check self + + # loader all gems + self.libmruby << objfile("#{build_dir}/mrbgems/gem_init") + file objfile("#{build_dir}/mrbgems/gem_init") => ["#{build_dir}/mrbgems/gem_init.c", "#{build_dir}/LEGAL"] + file "#{build_dir}/mrbgems/gem_init.c" => [MRUBY_CONFIG, __FILE__] do |t| + FileUtils.mkdir_p "#{build_dir}/mrbgems" + open(t.name, 'w') do |f| + gem_func_gems = gems.select { |g| g.generate_functions } + gem_func_decls = gem_func_gems.each_with_object('') do |g, s| + s << "void GENERATED_TMP_mrb_#{g.funcname}_gem_init(mrb_state*);\n" \ + "void GENERATED_TMP_mrb_#{g.funcname}_gem_final(mrb_state*);\n" + end + gem_init_calls = gem_func_gems.each_with_object('') do |g, s| + s << " GENERATED_TMP_mrb_#{g.funcname}_gem_init(mrb);\n" + end + gem_final_calls = gem_func_gems.each_with_object('') do |g, s| + s << " GENERATED_TMP_mrb_#{g.funcname}_gem_final(mrb);\n" + end + f.puts %Q[/*] + f.puts %Q[ * This file contains a list of all] + f.puts %Q[ * initializing methods which are] + f.puts %Q[ * necessary to bootstrap all gems.] + f.puts %Q[ *] + f.puts %Q[ * IMPORTANT:] + f.puts %Q[ * This file was generated!] + f.puts %Q[ * All manual changes will get lost.] + f.puts %Q[ */] + f.puts %Q[] + f.puts %Q[#include <mruby.h>] + f.puts %Q[] + f.write gem_func_decls + f.puts %Q[] + f.puts %Q[static void] + f.puts %Q[mrb_final_mrbgems(mrb_state *mrb) {] + f.write gem_final_calls + f.puts %Q[}] + f.puts %Q[] + f.puts %Q[void] + f.puts %Q[mrb_init_mrbgems(mrb_state *mrb) {] + f.write gem_init_calls + f.puts %Q[ mrb_state_atexit(mrb, mrb_final_mrbgems);] unless gem_final_calls.empty? + f.puts %Q[}] + end + end + end + + # legal documents + file "#{build_dir}/LEGAL" => [MRUBY_CONFIG, __FILE__] do |t| + open(t.name, 'w+') do |f| + f.puts <<LEGAL +Copyright (c) #{Time.now.year} mruby developers + +Permission is hereby granted, free of charge, to any person obtaining a +copy of this software and associated documentation files (the "Software"), +to deal in the Software without restriction, including without limitation +the rights to use, copy, modify, merge, publish, distribute, sublicense, +and/or sell copies of the Software, and to permit persons to whom the +Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. +LEGAL + + if enable_gems? + f.puts <<GEMS_LEGAL + +Additional Licenses + +Due to the reason that you choosed additional mruby packages (GEMS), +please check the following additional licenses too: +GEMS_LEGAL + + gems.map do |g| + authors = [g.authors].flatten.sort.join(", ") + f.puts + f.puts "GEM: #{g.name}" + f.puts "Copyright (c) #{Time.now.year} #{authors}" + f.puts "License: #{g.licenses}" + end + end + end + end +end diff --git a/web/server/h2o/libh2o/deps/mruby/tasks/toolchains/android.rake b/web/server/h2o/libh2o/deps/mruby/tasks/toolchains/android.rake new file mode 100644 index 00000000..c59da7fc --- /dev/null +++ b/web/server/h2o/libh2o/deps/mruby/tasks/toolchains/android.rake @@ -0,0 +1,321 @@ +class MRuby::Toolchain::Android + + DEFAULT_ARCH = 'armeabi' # TODO : Revise if arch should have a default + + DEFAULT_TOOLCHAIN = :clang + + DEFAULT_NDK_HOMES = %w{ + /usr/local/opt/android-sdk/ndk-bundle + /usr/local/opt/android-ndk + %LOCALAPPDATA%/Android/android-sdk/ndk-bundle + %LOCALAPPDATA%/Android/android-ndk + ~/Library/Android/sdk/ndk-bundle + ~/Library/Android/ndk + } + + TOOLCHAINS = [:clang, :gcc] + + ARCHITECTURES = %w{ + armeabi armeabi-v7a arm64-v8a + x86 x86_64 + mips mips64 + } + + class AndroidNDKHomeNotFound < StandardError + def message + <<-EOM +Couldn't find Android NDK Home. +Set ANDROID_NDK_HOME environment variable or set :ndk_home parameter + EOM + end + end + + class PlatformDirNotFound < StandardError + def message + <<-EOM +Couldn't find Android NDK platform directories. +Set ANDROID_PLATFORM environment variable or set :platform parameter + EOM + end + end + + attr_reader :params + + def initialize(params) + @params = params + end + + def bin_gcc(command) + command = command.to_s + + command = case arch + when /armeabi/ then 'arm-linux-androideabi-' + when /arm64-v8a/ then 'aarch64-linux-android-' + when /x86_64/ then 'x86_64-linux-android-' + when /x86/ then 'i686-linux-android-' + when /mips64/ then 'mips64el-linux-android-' + when /mips/ then 'mipsel-linux-android-' + end + command + + gcc_toolchain_path.join('bin', command).to_s + end + + def bin(command) + command = command.to_s + toolchain_path.join('bin', command).to_s + end + + def home_path + @home_path ||= Pathname( + params[:ndk_home] || + ENV['ANDROID_NDK_HOME'] || + DEFAULT_NDK_HOMES.find { |path| + path.gsub! '%LOCALAPPDATA%', ENV['LOCALAPPDATA'] || '%LOCALAPPDATA%' + path.gsub! '\\', '/' + path.gsub! '~', Dir.home || '~' + File.directory?(path) + } || raise(AndroidNDKHomeNotFound) + ) + end + + def toolchain + @toolchain ||= params.fetch(:toolchain){ DEFAULT_TOOLCHAIN } + end + + def toolchain_path + @toolchain_path ||= case toolchain + when :gcc + gcc_toolchain_path + when :clang + home_path.join('toolchains', 'llvm' , 'prebuilt', host_platform) + end + end + + def gcc_toolchain_path + if @gcc_toolchain_path === nil then + prefix = case arch + when /armeabi/ then 'arm-linux-androideabi-' + when /arm64-v8a/ then 'aarch64-linux-android-' + when /x86_64/ then 'x86_64-' + when /x86/ then 'x86-' + when /mips64/ then 'mips64el-linux-android-' + when /mips/ then 'mipsel-linux-android-' + end + + test = case arch + when /armeabi/ then 'arm-linux-androideabi-*' + when /arm64-v8a/ then 'aarch64-linux-android-*' + when /x86_64/ then 'x86_64-*' + when /x86/ then 'x86-*' + when /mips64/ then 'mips64el-linux-android-*' + when /mips/ then 'mipsel-linux-android-*' + end + + gcc_toolchain_version = Dir[home_path.join('toolchains', test)].map{|t| t.match(/-(\d+\.\d+)$/); $1.to_f }.max + @gcc_toolchain_path = home_path.join('toolchains', prefix + gcc_toolchain_version.to_s, 'prebuilt', host_platform) + end + @gcc_toolchain_path + end + + def host_platform + @host_platform ||= case RUBY_PLATFORM + when /cygwin|mswin|mingw|bccwin|wince|emx/i + path = home_path.join('toolchains', 'llvm' , 'prebuilt', 'windows*') + Dir.glob(path.to_s){ |item| + next if File.file?(item) + path = Pathname(item) + break + } + path.basename + when /x86_64-darwin/i + 'darwin-x86_64' + when /darwin/i + 'darwin-x86' + when /x86_64-linux/i + 'linux-x86_64' + when /linux/i + 'linux-x86' + else + raise NotImplementedError, "Unknown host platform (#{RUBY_PLATFORM})" + end + end + + def arch + @arch ||= (params[:arch] || ENV['ANDROID_ARCH'] || DEFAULT_ARCH).to_s + end + + def sysroot + @sysroot ||= home_path.join('platforms', platform, + case arch + when /armeabi/ then 'arch-arm' + when /arm64-v8a/ then 'arch-arm64' + when /x86_64/ then 'arch-x86_64' + when /x86/ then 'arch-x86' + when /mips64/ then 'arch-mips64' + when /mips/ then 'arch-mips' + end + ).to_s + end + + def platform + if @platform === nil then + @platform = params[:platform] || ENV['ANDROID_PLATFORM'] || nil + if @platform === nil + Dir.glob(home_path.join('platforms/android-*').to_s){ |item| + next if File.file?(item) + if @platform === nil + @platform = Integer(item.rpartition('-')[2]) + else + platform = Integer(item.rpartition('-')[2]) + @platform = platform > @platform ? platform : @platform + end + } + if @platform === nil + raise(PlatformDirNotFound) + else + @platform = "android-#{@platform}" + end + end + end + if Integer(@platform.rpartition('-')[2]) < 21 + case arch + when /arm64-v8a/, /x86_64/, /mips64/ + raise NotImplementedError, "Platform (#{@platform}) has no implementation for architecture (#{arch})" + end + end + @platform + end + + def armeabi_v7a_mfpu + @armeabi_v7a_mfpu ||= (params[:mfpu] || 'vfpv3-d16').to_s + end + + def armeabi_v7a_mfloat_abi + @armeabi_v7a_mfloat_abi ||= (params[:mfloat_abi] || 'softfp').to_s + end + + def no_warn_mismatch + if %W(soft softfp).include? armeabi_v7a_mfloat_abi + '' + else + ',--no-warn-mismatch' + end + end + + def cc + case toolchain + when :gcc then bin_gcc('gcc') + when :clang then bin('clang') + end + end + + def ar + case toolchain + when :gcc then bin_gcc('ar') + when :clang then bin_gcc('ar') + end + end + + def ctarget + flags = [] + + case toolchain + when :gcc + 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 /x86_64/ then flags += %W(-march=x86-64) + when /x86/ then flags += %W(-march=i686) + when /mips64/ then flags += %W(-march=mips64r6) + when /mips/ then flags += %W(-march=mips32) + end + when :clang + case arch + when /armeabi-v7a/ then flags += %W(-target armv7-none-linux-androideabi) + 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) + when /x86/ then flags += %W(-target i686-none-linux-android) + when /mips64/ then flags += %W(-target mips64el-none-linux-android) + when /mips/ then flags += %W(-target mipsel-none-linux-android) + end + end + + case arch + when /armeabi-v7a/ then flags += %W(-mfpu=#{armeabi_v7a_mfpu} -mfloat-abi=#{armeabi_v7a_mfloat_abi}) + when /armeabi/ then flags += %W(-mtune=xscale -msoft-float) + when /arm64-v8a/ then flags += %W() + when /x86_64/ then flags += %W() + when /x86/ then flags += %W() + when /mips64/ then flags += %W(-fmessage-length=0) + when /mips/ then flags += %W(-fmessage-length=0) + end + + flags + end + + def cflags + flags = [] + + flags += %W(-MMD -MP -D__android__ -DANDROID --sysroot="#{sysroot}") + flags += ctarget + case toolchain + when :gcc + when :clang + flags += %W(-gcc-toolchain "#{gcc_toolchain_path}" -Wno-invalid-command-line-argument -Wno-unused-command-line-argument) + end + flags += %W(-fpic -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 :gcc + case arch + when /armeabi-v7a/ then flags += %W(-Wl#{no_warn_mismatch}) + 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 -Wl,--fix-cortex-a8#{no_warn_mismatch}) + 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) + when /x86/ then flags += %W(-target i686-none-linux-android) + when /mips64/ then flags += %W(-target mips64el-none-linux-android) + 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| + android = MRuby::Toolchain::Android.new(params) + + toolchain android.toolchain + + [conf.cc, conf.cxx, conf.objc, conf.asm].each do |cc| + cc.command = android.cc + cc.flags = android.cflags + end + + conf.archiver.command = android.ar + conf.linker.command = android.cc + conf.linker.flags = android.ldflags + conf.linker.flags_before_libraries = android.ldflags_before_libraries +end diff --git a/web/server/h2o/libh2o/deps/mruby/tasks/toolchains/clang.rake b/web/server/h2o/libh2o/deps/mruby/tasks/toolchains/clang.rake new file mode 100644 index 00000000..c75fa030 --- /dev/null +++ b/web/server/h2o/libh2o/deps/mruby/tasks/toolchains/clang.rake @@ -0,0 +1,9 @@ +MRuby::Toolchain.new(:clang) do |conf, _params| + toolchain :gcc + + [conf.cc, conf.objc, conf.asm].each do |cc| + cc.command = ENV['CC'] || 'clang' + end + conf.cxx.command = ENV['CXX'] || 'clang++' + conf.linker.command = ENV['LD'] || 'clang' +end diff --git a/web/server/h2o/libh2o/deps/mruby/tasks/toolchains/gcc.rake b/web/server/h2o/libh2o/deps/mruby/tasks/toolchains/gcc.rake new file mode 100644 index 00000000..f370c0ab --- /dev/null +++ b/web/server/h2o/libh2o/deps/mruby/tasks/toolchains/gcc.rake @@ -0,0 +1,58 @@ +MRuby::Toolchain.new(:gcc) do |conf, _params| + [conf.cc, conf.objc, conf.asm].each do |cc| + cc.command = ENV['CC'] || 'gcc' + cc.flags = [ENV['CFLAGS'] || %w(-g -std=gnu99 -O3 -Wall -Werror-implicit-function-declaration -Wdeclaration-after-statement -Wwrite-strings)] + cc.defines = %w(DISABLE_GEMS) + 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' + cc.cxx_exception_flag = '-fexceptions' + end + + [conf.cxx].each do |cxx| + cxx.command = ENV['CXX'] || 'g++' + cxx.flags = [ENV['CXXFLAGS'] || ENV['CFLAGS'] || %w(-g -O3 -Wall -Werror-implicit-function-declaration)] + cxx.defines = %w(DISABLE_GEMS) + 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' + cxx.cxx_exception_flag = '-fexceptions' + end + + conf.linker do |linker| + linker.command = ENV['LD'] || 'gcc' + linker.flags = [ENV['LDFLAGS'] || %w()] + linker.libraries = %w(m) + linker.library_paths = [] + linker.option_library = '-l%s' + linker.option_library_path = '-L%s' + linker.link_options = '%{flags} -o %{outfile} %{objs} %{flags_before_libraries} %{libs} %{flags_after_libraries}' + end + + [[conf.cc, 'c'], [conf.cxx, 'c++']].each do |cc, lang| + cc.instance_variable_set :@header_search_language, lang + def cc.header_search_paths + if @header_search_command != command + result = `echo | #{build.filename command} -x#{@header_search_language} -Wp,-v - -fsyntax-only 2>&1` + result = `echo | #{command} -x#{@header_search_language} -Wp,-v - -fsyntax-only 2>&1` if $?.exitstatus != 0 + return include_paths if $?.exitstatus != 0 + + @frameworks = [] + @header_search_paths = result.lines.map { |v| + framework = v.match(/^ (.*)(?: \(framework directory\))$/) + if framework + @frameworks << framework[1] + next nil + end + + v.match(/^ (.*)$/) + }.compact.map { |v| v[1] }.select { |v| File.directory? v } + @header_search_paths += include_paths + @header_search_command = command + end + @header_search_paths + end + end +end diff --git a/web/server/h2o/libh2o/deps/mruby/tasks/toolchains/openwrt.rake b/web/server/h2o/libh2o/deps/mruby/tasks/toolchains/openwrt.rake new file mode 100644 index 00000000..1637f6d9 --- /dev/null +++ b/web/server/h2o/libh2o/deps/mruby/tasks/toolchains/openwrt.rake @@ -0,0 +1,38 @@ +# usage of environmental variables to set the +# cross compiling toolchain proper +MRuby::Toolchain.new(:openwrt) do |conf| + [conf.cc, conf.objc, conf.asm].each do |cc| + cc.command = ENV['TARGET_CC'] + cc.flags = ENV['TARGET_CFLAGS'] + cc.include_paths = ["#{MRUBY_ROOT}/include"] + cc.defines = %w(DISABLE_GEMS) + cc.option_include_path = '-I%s' + cc.option_define = '-D%s' + cc.compile_options = '%{flags} -MMD -o %{outfile} -c %{infile}' + end + + [conf.cxx].each do |cxx| + cxx.command = ENV['TARGET_CXX'] + cxx.flags = ENV['TARGET_CXXFLAGS'] + cxx.include_paths = ["#{MRUBY_ROOT}/include"] + cxx.defines = %w(DISABLE_GEMS) + cxx.option_include_path = '-I%s' + cxx.option_define = '-D%s' + cxx.compile_options = '%{flags} -MMD -o %{outfile} -c %{infile}' + end + + conf.linker do |linker| + linker.command = ENV['TARGET_CC'] + linker.flags = ENV['TARGET_LDFLAGS'] + linker.libraries = %w(m) + linker.library_paths = [] + linker.option_library = '-l%s' + linker.option_library_path = '-L%s' + linker.link_options = '%{flags} -o %{outfile} %{objs} %{flags_before_libraries} %{libs} %{flags_after_libraries}' + end + + conf.archiver do |archiver| + archiver.command = ENV['TARGET_AR'] + archiver.archive_options = 'rs %{outfile} %{objs}' + end +end diff --git a/web/server/h2o/libh2o/deps/mruby/tasks/toolchains/visualcpp.rake b/web/server/h2o/libh2o/deps/mruby/tasks/toolchains/visualcpp.rake new file mode 100644 index 00000000..5bc24a73 --- /dev/null +++ b/web/server/h2o/libh2o/deps/mruby/tasks/toolchains/visualcpp.rake @@ -0,0 +1,68 @@ +MRuby::Toolchain.new(:visualcpp) do |conf, _params| + conf.cc do |cc| + cc.command = ENV['CC'] || 'cl.exe' + # C4013: implicit function declaration + cc.flags = [ENV['CFLAGS'] || %w(/c /nologo /W3 /we4013 /Zi /MD /O2 /D_CRT_SECURE_NO_WARNINGS)] + cc.defines = %w(DISABLE_GEMS MRB_STACK_EXTEND_DOUBLING) + cc.option_include_path = '/I%s' + cc.option_define = '/D%s' + cc.compile_options = "%{flags} /Fo%{outfile} %{infile}" + cc.cxx_compile_flag = '/TP' + cc.cxx_exception_flag = '/EHs' + end + + conf.cxx do |cxx| + cxx.command = ENV['CXX'] || 'cl.exe' + cxx.flags = [ENV['CXXFLAGS'] || ENV['CFLAGS'] || %w(/c /nologo /W3 /Zi /MD /O2 /EHs /D_CRT_SECURE_NO_WARNINGS)] + cxx.defines = %w(DISABLE_GEMS MRB_STACK_EXTEND_DOUBLING) + cxx.option_include_path = '/I%s' + cxx.option_define = '/D%s' + cxx.compile_options = "%{flags} /Fo%{outfile} %{infile}" + cxx.cxx_compile_flag = '/TP' + cxx.cxx_exception_flag = '/EHs' + end + + conf.linker do |linker| + linker.command = ENV['LD'] || 'link.exe' + linker.flags = [ENV['LDFLAGS'] || %w(/NOLOGO /DEBUG /INCREMENTAL:NO /OPT:ICF /OPT:REF)] + linker.libraries = %w() + linker.library_paths = %w() + linker.option_library = '%s.lib' + linker.option_library_path = '/LIBPATH:%s' + linker.link_options = "%{flags} /OUT:%{outfile} %{objs} %{flags_before_libraries} %{libs} %{flags_after_libraries}" + end + + conf.archiver do |archiver| + archiver.command = ENV['AR'] || 'lib.exe' + archiver.archive_options = '/nologo /OUT:%{outfile} %{objs}' + end + + conf.yacc do |yacc| + yacc.command = ENV['YACC'] || 'bison.exe' + yacc.compile_options = '-o %{outfile} %{infile}' + end + + conf.gperf do |gperf| + gperf.command = 'gperf.exe' + gperf.compile_options = '-L ANSI-C -C -p -j1 -i 1 -g -o -t -N mrb_reserved_word -k"1,3,$" %{infile} > %{outfile}' + end + + conf.exts do |exts| + exts.object = '.obj' + exts.executable = '.exe' + exts.library = '.lib' + end + + conf.file_separator = '\\' + + if require 'open3' + Open3.popen3 conf.cc.command do |_, _, e, _| + if /Version (\d{2})\.\d{2}\.\d{5}/ =~ e.gets && $1.to_i <= 17 + m = "# VS2010/2012 support will be dropped after the next release! #" + h = "#" * m.length + puts h, m, h + end + end + end + +end |