diff --git a/Rakefile b/Rakefile index 2a8e11d43..ef7d536c6 100644 --- a/Rakefile +++ b/Rakefile @@ -31,6 +31,7 @@ load "#{MRUBY_ROOT}/tasks/presym.rake" load "#{MRUBY_ROOT}/tasks/test.rake" load "#{MRUBY_ROOT}/tasks/benchmark.rake" load "#{MRUBY_ROOT}/tasks/doc.rake" +load "#{MRUBY_ROOT}/tasks/install.rake" ############################## # generic build targets, rules @@ -67,34 +68,6 @@ task :deep_clean => %w[clean doc:clean] do puts "Cleaned up mrbgems build folder" end -PREFIX = ENV['PREFIX'] || ENV['INSTALL_PREFIX'] || '/usr/local' - -desc "install compiled products" -task :install => :install_bin do - if host = MRuby.targets['host'] - install_D host.libmruby_static, File.join(PREFIX, "lib", File.basename(host.libmruby_static)) - # install mruby.h and mrbconf.h - Dir.glob(File.join(MRUBY_ROOT, "include", "*.h")) do |src| - install_D src, File.join(PREFIX, "include", File.basename(src)) - end - Dir.glob(File.join(MRUBY_ROOT, "include", "mruby", "*.h")) do |src| - install_D src, File.join(PREFIX, "include", "mruby", File.basename(src)) - end - Dir.glob(File.join(File.join(MRUBY_ROOT, "build", "host", "include", "mruby", "presym", "*.h"))) do |src| - install_D src, File.join(PREFIX, "include", "mruby", "presym", File.basename(src)) - end - end -end - -desc "install compiled executable (on host)" -task :install_bin => :all do - if host = MRuby.targets['host'] - Dir.glob(File.join(MRUBY_ROOT, "bin", "*")) do |src| - install_D src, File.join(PREFIX, "bin", File.basename(src)) - end - end -end - desc "run all pre-commit hooks against all files" task :check do sh "pre-commit run --all-files" diff --git a/lib/mruby/build.rb b/lib/mruby/build.rb index 4925cee33..e6298d71f 100644 --- a/lib/mruby/build.rb +++ b/lib/mruby/build.rb @@ -7,6 +7,8 @@ module MRuby autoload :Lockfile, "mruby/lockfile" autoload :Presym, "mruby/presym" + INSTALL_PREFIX = ENV['PREFIX'] || ENV['INSTALL_PREFIX'] || '/usr/local' + class << self def targets @targets ||= {} diff --git a/tasks/install.rake b/tasks/install.rake new file mode 100644 index 000000000..c83d30a4e --- /dev/null +++ b/tasks/install.rake @@ -0,0 +1,25 @@ +desc "install compiled products" +task :install => :install_bin do + if host = MRuby.targets['host'] + install_D host.libmruby_static, File.join(MRuby::INSTALL_PREFIX, "lib", File.basename(host.libmruby_static)) + # install mruby.h and mrbconf.h + Dir.glob(File.join(MRUBY_ROOT, "include", "*.h")) do |src| + install_D src, File.join(MRuby::INSTALL_PREFIX, "include", File.basename(src)) + end + Dir.glob(File.join(MRUBY_ROOT, "include", "mruby", "*.h")) do |src| + install_D src, File.join(MRuby::INSTALL_PREFIX, "include", "mruby", File.basename(src)) + end + Dir.glob(File.join(File.join(MRUBY_ROOT, "build", "host", "include", "mruby", "presym", "*.h"))) do |src| + install_D src, File.join(MRuby::INSTALL_PREFIX, "include", "mruby", "presym", File.basename(src)) + end + end +end + +desc "install compiled executable (on host)" +task :install_bin => :all do + if host = MRuby.targets['host'] + Dir.glob(File.join(MRUBY_ROOT, "bin", "*")) do |src| + install_D src, File.join(MRuby::INSTALL_PREFIX, "bin", File.basename(src)) + end + end +end