diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..1908ecf --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,17 @@ +name: build +on: [pull_request] +jobs: + test: + runs-on: ubuntu-latest + strategy: + matrix: + mruby_version: ["3.0.0", "2.1.2"] + steps: + - uses: actions/checkout@v2 + - name: Install packages + run: | + sudo apt-get -qq update + sudo apt-get -qq install rake bison git gperf + - name: Test + run: MRUBY_VERSION=${{ matrix.mruby_version }} rake test + diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..11246db --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +mruby/ +build_config.rb.lock diff --git a/Rakefile b/Rakefile new file mode 100644 index 0000000..45acec2 --- /dev/null +++ b/Rakefile @@ -0,0 +1,31 @@ +MRUBY_CONFIG=File.expand_path(ENV["MRUBY_CONFIG"] || "build_config.rb") +MRUBY_VERSION=ENV["MRUBY_VERSION"] || "3.0.0" + +file :mruby do + sh "git clone --depth=1 git://github.com/mruby/mruby.git" + if MRUBY_VERSION != 'master' + Dir.chdir 'mruby' do + sh "git fetch --tags" + rev = %x{git rev-parse #{MRUBY_VERSION}} + sh "git checkout #{rev}" + end + end +end + +desc "compile binary" +task :compile => :mruby do + sh "cd mruby && rake all MRUBY_CONFIG=#{MRUBY_CONFIG}" +end + +desc "test" +task :test => :mruby do + sh "cd mruby && rake all test MRUBY_CONFIG=#{MRUBY_CONFIG}" +end + +desc "cleanup" +task :clean do + exit 0 unless File.directory?('mruby') + sh "cd mruby && rake deep_clean" +end + +task :default => :compile diff --git a/build_config.rb b/build_config.rb index d93dde3..3c6f30a 100644 --- a/build_config.rb +++ b/build_config.rb @@ -6,6 +6,7 @@ end conf.enable_debug + conf.enable_test conf.cc.flags << '-DMRB_INT64' diff --git a/rakelib/mruby.rake b/rakelib/mruby.rake deleted file mode 100644 index 478ade8..0000000 --- a/rakelib/mruby.rake +++ /dev/null @@ -1,44 +0,0 @@ -namespace :mruby do - task :setup_mruby_build_variables do - # When calling mruby rake tasks, use the local build_config.rb - ENV['MRUBY_CONFIG'] = Dir.pwd + '/build_config.rb' - - # Try to find MRuby on path if no MRUBY_HOME set - if !ENV['MRUBY_HOME'] - mruby_from_path = `which mruby`.strip - if mruby_from_path.length > 0 - ENV['MRUBY_HOME'] = File.absolute_path(mruby_from_path + '/../..') - end - - # Maybe MRuby is next to this gem? - ENV['MRUBY_HOME'] ||= Dir.pwd + '/../mruby' - end - - # Still no luck? Raise hell! - if !ENV['MRUBY_HOME'] || !File.directory?(ENV['MRUBY_HOME']) - raise 'Unable to find MRuby. Please set $MRUBY_HOME.' - end - end - - desc 'Clean the build artifacts' - task :clean => :setup_mruby_build_variables do - if File.directory?('build') - rm_rf 'build' - end - cd ENV['MRUBY_HOME'] { - sh 'rake clean' - } - end - - desc 'Build mruby with the local build_config' - task :build => :setup_mruby_build_variables do - if File.directory?('build') - rm_rf 'build' - end - mkdir 'build' - cd ENV['MRUBY_HOME'] { - sh 'rake default' - } - cp_r Dir["#{ENV['MRUBY_HOME']}/build/host/{bin,lib}"], 'build' - end -end