Unverified Commit a5ad768c authored by Yukihiro "Matz" Matsumoto's avatar Yukihiro "Matz" Matsumoto Committed by GitHub

Merge pull request #4204 from shuujii/fix-yacc-running-multiple-times

Fix Yacc running multiple times.
parents 37d795de 482b2ea0
...@@ -52,6 +52,8 @@ module MRuby ...@@ -52,6 +52,8 @@ module MRuby
end end
def setup def setup
return if defined?(@linker) # return if already set up
MRuby::Gem.current = self MRuby::Gem.current = self
MRuby::Build::COMMANDS.each do |command| MRuby::Build::COMMANDS.each do |command|
instance_variable_set("@#{command}", @build.send(command).clone) instance_variable_set("@#{command}", @build.send(command).clone)
...@@ -334,26 +336,26 @@ module MRuby ...@@ -334,26 +336,26 @@ module MRuby
end end
def generate_gem_table build def generate_gem_table build
gem_table = @ary.reduce({}) { |res,v| res[v.name] = v; res } gem_table = each_with_object({}) { |spec, h| h[spec.name] = spec }
default_gems = [] default_gems = {}
each do |g| each do |g|
g.dependencies.each do |dep| g.dependencies.each do |dep|
default_gems << default_gem_params(dep) unless gem_table.key? dep[:gem] default_gems[dep[:gem]] ||= default_gem_params(dep)
end end
end end
until default_gems.empty? until default_gems.empty?
def_gem = default_gems.pop def_name, def_gem = default_gems.shift
next if gem_table[def_name]
spec = build.gem def_gem[:default] spec = gem_table[def_name] = build.gem(def_gem[:default])
fail "Invalid gem name: #{spec.name} (Expected: #{def_gem[:gem]})" if spec.name != def_gem[:gem] fail "Invalid gem name: #{spec.name} (Expected: #{def_name})" if spec.name != def_name
spec.setup spec.setup
spec.dependencies.each do |dep| spec.dependencies.each do |dep|
default_gems << default_gem_params(dep) unless gem_table.key? dep[:gem] default_gems[dep[:gem]] ||= default_gem_params(dep)
end end
gem_table[spec.name] = spec
end end
each do |g| each do |g|
...@@ -428,7 +430,8 @@ module MRuby ...@@ -428,7 +430,8 @@ module MRuby
end end
def import_include_paths(g) def import_include_paths(g)
gem_table = @ary.reduce({}) { |res,v| res[v.name] = v; res } gem_table = each_with_object({}) { |spec, h| h[spec.name] = spec }
g.dependencies.each do |dep| g.dependencies.each do |dep|
dep_g = gem_table[dep[:gem]] dep_g = gem_table[dep[:gem]]
# We can do recursive call safely # We can do recursive call safely
......
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