Created
April 28, 2020 03:29
-
-
Save arika/38daeec40b67d8e9042e5234b4720927 to your computer and use it in GitHub Desktop.
mrbgemのためのRakefile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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