Commit c8229dbd authored by Yukihiro "Matz" Matsumoto's avatar Yukihiro "Matz" Matsumoto

Merge pull request #2846 from take-cheeze/mgem_mrbgem

Add :mgem gem loading.
parents 7cf94bac 078d24d4
......@@ -26,6 +26,15 @@ conf.gem :github => 'masuidrive/mrbgems-example', :branch => 'master'
conf.gem :bitbucket => 'mruby/mrbgems-example', :branch => 'master'
```
To use mrbgem from [mgem-list](https://github.com/mruby/mgem-list) use `:mgem` option:
```ruby
conf.gem :mgem => 'mruby-yaml'
conf.gem :mgem => 'yaml' # 'mruby-' prefix could be ignored
```
If there is missing dependencies, mrbgem dependencies solver will reference
mrbgem from core or mgem-list.
To pull all gems from remote GIT repository on build, call ```./minirake -p```,
or ```./minirake --pull-gems```.
......
......@@ -304,7 +304,14 @@ module MRuby
default_gems = []
each do |g|
g.dependencies.each do |dep|
default_gems << dep if dep[:default] and not gem_table.key? dep[:gem]
unless gem_table.key? dep[:gem]
if dep[:default]; default_gems << dep
elsif File.exist? "#{root}/mrbgems/#{dep[:gem]}" # check core
default_gems << { :gem => dep[:gem], :default => { :core => dep[:gem] } }
else # fallback to mgem-list
default_gems << { :gem => dep[:gem], :default => { :mgem => dep[:gem] } }
end
end
end
end
......@@ -316,7 +323,11 @@ module MRuby
spec.setup
spec.dependencies.each do |dep|
default_gems << dep if dep[:default] and not gem_table.key? dep[:gem]
unless gem_table.key? dep[:gem]
if dep[:default]; default_gems << dep
else default_gems << { :gem => dep[:gem], :default => { :mgem => dep[:gem] } }
end
end
end
gem_table[spec.name] = spec
end
......
......@@ -52,6 +52,26 @@ module MRuby
else
params[:git] = "https://bitbucket.org/#{params[:bitbucket]}.git"
end
elsif params[:mgem]
mgem_list_dir = "#{gem_clone_dir}/mgem-list"
mgem_list_url = 'https://github.com/mruby/mgem-list.git'
if File.exist? mgem_list_dir
git.run_pull mgem_list_dir, mgem_list_url if $pull_gems
else
FileUtils.mkdir_p mgem_list_dir
git.run_clone mgem_list_dir, mgem_list_url
end
require 'yaml'
conf_path = "#{mgem_list_dir}/#{params[:mgem]}.gem"
conf_path = "#{mgem_list_dir}/mruby-#{params[:mgem]}.gem" unless File.exist? conf_path
fail "mgem not found: #{params[:mgem]}" unless File.exist? conf_path
conf = YAML.load File.read conf_path
fail "unknown mgem protocol: #{conf['protocol']}" if conf['protocol'] != 'git'
params[:git] = conf['repository']
params[:branch] = conf['branch"] if conf["branch']
end
if params[:core]
......
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