summaryrefslogtreecommitdiffhomepage
path: root/tasks/mruby_build_gem.rake
diff options
context:
space:
mode:
authorYuichiro MASUI <[email protected]>2013-01-20 22:48:42 +0900
committerYuichiro MASUI <[email protected]>2013-01-20 22:48:42 +0900
commitced80d2b4b1ed4ef0752a8bbaf0dbfe7aa6c6a95 (patch)
treed49c0d0f0b6139ad4c79c3e4b417d65941e97a4f /tasks/mruby_build_gem.rake
parent583983385b81c21f82704b116eab52d606a609f4 (diff)
downloadmruby-ced80d2b4b1ed4ef0752a8bbaf0dbfe7aa6c6a95.tar.gz
mruby-ced80d2b4b1ed4ef0752a8bbaf0dbfe7aa6c6a95.zip
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