mruby/mruby

Custom install directory

Closed this issue · 5 comments

When we run minirake, commands (e.g., mrbc) will be installed locally in a repository under bin directly. I'd like to control the location where these commands are installed.
The use case is make distcheck of libtools[1] when mruby is imported to autotools managed project.
make distcheck will first make a distribution archive, usually .tar.gz, and then untar it in temporary directory. And make its source tree read-only, and write resulting object files in another locations.
For mruby, it is almost working. Currently we can control where the object files are built via conf.build_dir. But built commands, like mrbc, is still installed under source tree, which is read-only in make distcheck, and it fails. It looks like we have no override for that path.

Perhaps the easiest workaround is something like the following:

diff --git a/Rakefile b/Rakefile
index 8a8912a..3e03b10 100644
--- a/Rakefile
+++ b/Rakefile
@@ -32,7 +32,7 @@ load "#{MRUBY_ROOT}/tasks/benchmark.rake"
 # generic build targets, rules
 task :default => :all

-bin_path = "#{MRUBY_ROOT}/bin"
+bin_path = ENV['INSTALL_DIR'] || "#{MRUBY_ROOT}/bin"
 FileUtils.mkdir_p bin_path, { :verbose => $verbose }

 depfiles = MRuby.targets['host'].bins.map do |bin|
@@ -71,7 +71,7 @@ MRuby.each_target do |target|
       end

       if target == MRuby.targets['host']
-        install_path = MRuby.targets['host'].exefile("#{MRUBY_ROOT}/bin/#{bin}")
+        install_path = MRuby.targets['host'].exefile("#{bin_path}/#{bin}")

         file install_path => exec do |t|
           FileUtils.rm_f t.name, { :verbose => $verbose }
@@ -80,7 +80,7 @@ MRuby.each_target do |target|
         depfiles += [ install_path ]
       elsif target == MRuby.targets['host-debug']
         unless MRuby.targets['host'].gems.map {|g| g.bins}.include?([bin])
-          install_path = MRuby.targets['host-debug'].exefile("#{MRUBY_ROOT}/bin/#{bin}")
+          install_path = MRuby.targets['host-debug'].exefile("#{bin_path}/#{bin}")

           file install_path => exec do |t|
             FileUtils.rm_f t.name, { :verbose => $verbose }

And let host application control the installation directory using INSTALL_DIR environment variable.

What do you think about this? If you agree, then I'm happy to make a PR.

[1] http://www.gnu.org/software/automake/manual/html_node/Checking-the-Distribution.html

zzak commented

LGTM

matz commented

send us PR

Thank you for super quick replies. Will make a PR momentarily.

PR created #2949. Thank you.

matz commented

#2949 merged