summaryrefslogtreecommitdiffhomepage
path: root/tasks/mruby_build_gem.rake
diff options
context:
space:
mode:
authorYukihiro "Matz" Matsumoto <[email protected]>2013-01-20 14:41:50 -0800
committerYukihiro "Matz" Matsumoto <[email protected]>2013-01-20 14:41:50 -0800
commit8e86ff2283d427b5cb2a02607e1aab998cb5090c (patch)
treebd40d166673b2290053f1742660d573d5586a974 /tasks/mruby_build_gem.rake
parentcc16bd7c0d70b326ddcf8de8a511116dae9fc30d (diff)
parentced80d2b4b1ed4ef0752a8bbaf0dbfe7aa6c6a95 (diff)
downloadmruby-8e86ff2283d427b5cb2a02607e1aab998cb5090c.tar.gz
mruby-8e86ff2283d427b5cb2a02607e1aab998cb5090c.zip
Merge pull request #755 from masuidrive/imprive_build_scripts
Improved build scripts and config files
Diffstat (limited to 'tasks/mruby_build_gem.rake')
-rw-r--r--tasks/mruby_build_gem.rake39
1 files changed, 39 insertions, 0 deletions
diff --git a/tasks/mruby_build_gem.rake b/tasks/mruby_build_gem.rake
new file mode 100644
index 000000000..ae0a79447
--- /dev/null
+++ b/tasks/mruby_build_gem.rake
@@ -0,0 +1,39 @@
+module MRuby
+ module LoadGems
+ def gem(gemdir, &block)
+ gemdir = load_external_gem(gemdir) if gemdir.is_a?(Hash)
+ load File.join(gemdir, "mrbgem.rake")
+ Gem.current.dir = gemdir
+ Gem.current.build = MRuby::Build.current
+ Gem.current.build_config_initializer = block
+ gems << Gem.current
+ Gem.current
+ end
+
+ def load_external_gem(params)
+ if params[:github]
+ params[:git] = "https://github.com/#{params[:github]}.git"
+ end
+
+ if params[:git]
+ url = params[:git]
+ gemdir = "build/mrbgems/#{url.match(/([-_\w]+)(\.[-_\w]+|)$/).to_a[1]}"
+ return gemdir if File.exists?(gemdir)
+
+ options = [params[:options]] || []
+ options << "--branch \"#{params[:branch]}\"" if params[:tag]
+
+ FileUtils.mkdir_p "build/mrbgems"
+ git.run_clone gemdir, url, options
+
+ gemdir
+ else
+ fail "unknown gem option #{params}"
+ end
+ end
+
+ def enable_gems?
+ end
+ end # LoadGems
+end # MRuby