Skip to content

Commit

Permalink
Merge pull request #13 from toch/check-rake-environment
Browse files Browse the repository at this point in the history
  • Loading branch information
hone committed Nov 20, 2015
2 parents 0827f1b + 8566b62 commit eef2885
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 0 deletions.
32 changes: 32 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ load "#{mruby_root}/Rakefile"

desc "compile all the binaries"
task :compile => [:all] do
MRuby.each_target do |target|
`#{target.cc.command} --version`
abort("Command #{target.cc.command} for #{target.name} is missing.") unless $?.success?
end
%W(#{mruby_root}/build/x86_64-pc-linux-gnu/bin/#{APP_NAME} #{mruby_root}/build/i686-pc-linux-gnu/#{APP_NAME}").each do |bin|
sh "strip --strip-unneeded #{bin}" if File.exist?(bin)
end
Expand Down Expand Up @@ -103,3 +107,31 @@ task :release => :compile do
end
end
end

namespace :local do
desc "show help"
task :version do
require_relative 'mrblib/mruby-cli/version'
puts "mruby-cli #{MRubyCLI::Version::VERSION}"
end
end

def is_in_a_docker_container?
`grep -q docker /proc/self/cgroup`
$?.success?
end

Rake.application.tasks.each do |task|
next if ENV["MRUBY_CLI_LOCAL"]
unless task.name.start_with?("local:")
# Inspired by rake-hooks
# https://github.com/guillermo/rake-hooks
old_task = Rake.application.instance_variable_get('@tasks').delete(task.name)
desc old_task.full_comment
task old_task.name => old_task.prerequisites do
abort("Not running in docker, you should type \"docker-compose run <task>\".") \
unless is_in_a_docker_container?
old_task.invoke
end
end
end
33 changes: 33 additions & 0 deletions mrblib/mruby-cli/setup.rb
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,11 @@ def rakefile
desc "compile binary"
task :compile => [:all] do
MRuby.each_target do |target|
`\#{target.cc.command} --version`
abort("Command \#{target.cc.command} for \#{target.name} is missing.") unless $?.success?
end
%W(\#{mruby_root}/build/x86_64-pc-linux-gnu/bin/\#{APP_NAME} \#{mruby_root}/build/i686-pc-linux-gnu/\#{APP_NAME}").each do |bin|
sh "strip --strip-unneeded \#{bin}" if File.exist?(bin)
end
Expand Down Expand Up @@ -377,6 +382,34 @@ def clean_env(envs)
task :clean do
sh "rake deep_clean"
end
namespace :local do
desc "show help"
task :version do
require_relative 'mrblib/mruby-cli/version'
puts "mruby-cli \#{MRubyCLI::Version::VERSION}"
end
end
def is_in_a_docker_container?
`grep -q docker /proc/self/cgroup`
$?.success?
end
Rake.application.tasks.each do |task|
next if ENV["MRUBY_CLI_LOCAL"]
unless task.name.start_with?("local:")
# Inspired by rake-hooks
# https://github.com/guillermo/rake-hooks
old_task = Rake.application.instance_variable_get('@tasks').delete(task.name)
desc old_task.full_comment
task old_task.name => old_task.prerequisites do
abort("Not running in docker, you should type \\"docker-compose run <task>\\".") \
unless is_in_a_docker_container?
old_task.invoke
end
end
end
RAKEFILE
end
end
Expand Down

0 comments on commit eef2885

Please sign in to comment.