Skip to content

Instantly share code, notes, and snippets.

@arika
Created April 28, 2020 03:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arika/38daeec40b67d8e9042e5234b4720927 to your computer and use it in GitHub Desktop.
Save arika/38daeec40b67d8e9042e5234b4720927 to your computer and use it in GitHub Desktop.
mrbgemのためのRakefile
# frozen-string-literal: true
vendor_dir = "#{__dir__}/vendor"
ENV['MRUBY_ROOT'] = "#{vendor_dir}/mruby"
ENV['MRUBY_CONFIG'] = "#{__dir__}/build_config.rb"
namespace :mruby do
if ENV['LOAD_MRUBY_RAKEFILE']
load "#{ENV['MRUBY_ROOT']}/Rakefile"
else
task all: %w[mruby_rakefile!]
task test: %w[mruby_rakefile!]
task clean: %w[mruby_rakefile]
task deep_clean: %w[mruby_rakefile]
end
end
def exec_rake_with_mruby_rakefile(auto_setup: false)
return if ENV['LOAD_MRUBY_RAKEFILE']
Rake::Task['setup'].invoke if !File.exist?(ENV['MRUBY_ROOT']) && auto_setup
ENV['LOAD_MRUBY_RAKEFILE'] = '1'
exec 'rake', *ARGV
end
task :mruby_rakefile! do
exec_rake_with_mruby_rakefile(auto_setup: true)
end
task :mruby_rakefile do
exec_rake_with_mruby_rakefile if File.exist?(ENV['MRUBY_ROOT'])
end
desc 'setup'
task setup: %w[setup_mruby]
task :setup_mruby do
# tarballをvendor_dirに展開するとかgit submodule update --initするとか
end
desc 'compile binary'
task compile: %w[mruby:all]
task default: %w[compile]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment