bin/autoproj_bootstrap in autoproj-2.0.0.rc11 vs bin/autoproj_bootstrap in autoproj-2.0.0.rc12

- old
+ new

@@ -1,10 +1,13 @@ #! /usr/bin/ruby if RUBY_VERSION < "2.0.0" STDERR.puts "autoproj requires Ruby >= 2.0.0" exit 1 +elsif ENV['AUTOPROJ_CURRENT_ROOT'] && (ENV['AUTOPROJ_CURRENT_ROOT'] != Dir.pwd) + STDERR.puts "it seems that you've already loaded an env.sh script in this console, open a new console and try again" + exit 1 end require 'pathname' require 'optparse' require 'fileutils' @@ -26,27 +29,36 @@ attr_accessor :gemfile # The environment that is passed to the bundler installs attr_reader :env # The configuration hash attr_reader :config + # A set of options that should be passed to autoproj when calling it + # in a subprocess + attr_reader :autoproj_options def initialize(root_dir) @root_dir = root_dir if File.file?(autoproj_gemfile_path) @gemfile = File.read(autoproj_gemfile_path) else @gemfile = default_gemfile_contents end + @autoproj_options = Array.new + @env = Hash.new env['RUBYLIB'] = [] env['GEM_PATH'] = [] env['GEM_HOME'] = [] env['PATH'] = self.class.sanitize_env(ENV['PATH'] || "") env['BUNDLE_GEMFILE'] = [] load_config + if config['ruby_executable'] != Gem.ruby + raise "this autoproj installation was already bootstrapped using #{config['ruby_executable']}, but you are currently running under #{Gem.ruby}. Changing the ruby interpreter in a given workspace is not supported" + end + @local = false end def env_for_child result = env.inject(Hash.new) do |h, (k, v)| @@ -198,12 +210,23 @@ @gemfile = File.read(path) end opt.on '--prefer-os-independent-packages', 'prefer OS-independent packages (such as a RubyGem) over their OS-packaged equivalent (e.g. the thor gem vs. the ruby-thor debian package)' do @prefer_indep_over_os_packages = true end + opt.on '--[no-]color', 'do not use colored output (enabled by default if the terminal supports it)' do |color| + if color then autoproj_options << "--color" + else autoproj_options << '--no-color' + end + end + opt.on '--[no-]progress', 'do not use progress output (enabled by default if the terminal supports it)' do |color| + if color then autoproj_options << "--progress" + else autoproj_options << '--no-progress' + end + end end - options.parse(ARGV) + args = options.parse(ARGV) + autoproj_options + args end def install_bundler gem_program = guess_gem_program puts "Detected 'gem' to be #{gem_program}" @@ -444,11 +467,11 @@ File.join(autoproj_install_dir, 'bin', 'autoproj') end def run_autoproj(*args) system env_for_child.merge('BUNDLE_GEMFILE' => autoproj_gemfile_path), - Gem.ruby, autoproj_path, *args + Gem.ruby, autoproj_path, *args, *autoproj_options end def stage1 FileUtils.mkdir_p dot_autoproj save_config @@ -466,11 +489,13 @@ def stage2(*vars) require 'autobuild' puts "saving env.sh and .autoproj/env.sh" save_env_sh(*vars) - puts "calling autoproj envsh" - system(Gem.ruby, autoproj_path, 'envsh') + puts "calling autoproj envsh #{autoproj_options}" + if !system(Gem.ruby, autoproj_path, 'envsh', *autoproj_options) + exit 1 + end end end end end