Commit 7c3f06dd authored by William Light's avatar William Light

Implement gembox-relative gemdir paths

In the case where a relative path is specified to a gembox from
build_config.rb, it was previously tricky to specify relative gem paths
from inside that gembox.

For example, consider a project in which mruby is checked out as a
submodule in the project root:

	+- project_root
	   |
	   +- mruby/
	   |  |
	   |  +- build_config.rb
	   |  |
	   |  +- ...
	   |
	   +- my_gembox/
	      |
	      +- my_gembox.gembox
	      |
	      +- my_gem/
	         |
	         +- mrbgem.rake
	         |
	         +- ...

If build_config.rb refers to my_gembox with a relative path, it's
difficult for my_gembox to then refer to my_gem. With this proposed
change, my_gembox.gembox can look like this:

	MRuby::GemBox.new do |conf|
	  conf.gem "my_gem"
	end
parent e06a0e39
......@@ -297,6 +297,8 @@ module MRuby
GemBox = Object.new
class << GemBox
attr_accessor :path
def new(&block); block.call(self); end
def config=(obj); @config = obj; end
def gem(gemdir, &block); @config.gem(gemdir, &block); end
......
......@@ -3,7 +3,10 @@ module MRuby
def gembox(gemboxfile)
gembox = File.expand_path("#{gemboxfile}.gembox", "#{MRUBY_ROOT}/mrbgems")
fail "Can't find gembox '#{gembox}'" unless File.exists?(gembox)
GemBox.config = self
GemBox.path = gembox
instance_eval File.read(gembox)
end
......@@ -11,6 +14,8 @@ module MRuby
caller_dir = File.expand_path(File.dirname(/^(.*?):\d/.match(caller.first).to_a[1]))
if gemdir.is_a?(Hash)
gemdir = load_special_path_gem(gemdir)
elsif gemdir.is_a?(String)
gemdir = "#{File.dirname(GemBox.path)}/#{gemdir}"
else
gemdir = File.expand_path(gemdir, caller_dir)
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment