#! /usr/bin/env ruby if RUBY_VERSION < "1.8.7" STDERR.puts "autoproj requires Ruby >= 1.8.7" exit 1 end require 'autoproj' require 'autoproj/autobuild' require 'open-uri' require 'autoproj/cmdline' include Autoproj InputError = Autoproj::InputError def color(*args) Autoproj.console.color(*args) end def report Autobuild::Reporting.report do yield end Autobuild::Reporting.success rescue ConfigError => e STDERR.puts STDERR.puts color(e.message, :red, :bold) if Autoproj.in_autoproj_installation?(Dir.pwd) root_dir = /^#{Regexp.quote(Autoproj.root_dir)}(?!\/\.gems)/ e.backtrace.find_all { |path| path =~ root_dir }. each do |path| STDERR.puts color(" in #{path}", :red, :bold) end end if Autobuild.debug then raise else exit 1 end rescue Interrupt STDERR.puts STDERR.puts color("Interrupted by user", :red, :bold) if Autobuild.debug then raise else exit 1 end end Autoproj::OSDependencies.autodetect_ruby # Check the first element of ARGV. If a tool called autoproj-VALUE exists, just # pass the hand to it prefix = File.expand_path(__FILE__) if File.file?("#{prefix}-#{ARGV.first}") binary = "#{prefix}-#{ARGV.shift}" # RubyGems have a BIG performance problem when $LOADED_PATH starts to be # big. # # So, if the sub-script is Ruby-based, just load it and exit if File.readlines(binary).first =~ /ruby/ load binary exit else exec(binary, *ARGV) end end # Find the autoproj root dir report do selected_packages = begin Autoproj::CmdLine.parse_arguments(ARGV.dup) rescue RuntimeError => e if Autoproj::CmdLine.bootstrap? && !Autoproj.in_autoproj_installation?(Dir.pwd) STDERR.puts < where 'vcs_type' is git, svn, darcs, cvs 'vcs_url' is the vcs-specific URL to the repository, and 'vcs_options' are optional values that can be given to the chosen VCS EOTEXT end raise end # Expand directories in the selected_packages set, before we chdir to the # autoproj root root_dir = Autoproj.root_dir selected_packages.map! do |name| if File.directory?(name) File.expand_path(name) else name end end Dir.chdir(root_dir) # Basic initialization Autoproj::CmdLine.initialize if selected_packages.empty? Autoproj::CmdLine.update_myself Autoproj::CmdLine.update_configuration else begin old_value = Autobuild.do_update Autobuild.do_update = false Autoproj::CmdLine.update_configuration ensure Autobuild.do_update = old_value end end Autoproj::CmdLine.load_configuration manifest = Autoproj.manifest # Once thing left to do: handle the Autoproj.auto_update configuration # parameter # # Namely, we must check if Autobuild.do_update has been explicitely set to # true or false. If that is the case, don't do anything. Otherwise, set it # to the value of Autoproj.auto_update if Autobuild.do_update.nil? Autobuild.do_update = Autoproj.auto_update? end Autoproj::CmdLine.setup_all_package_directories # resolve_user_selection auto-adds packages present on disk but not listed # in the manifest. However, since we have not yet loaded overrides / # package blocks, it is possible that it contains excluded / ignored # packages # # First do the resolution to get auto-add, finalize the package # configuration, and then re-resolve Autoproj::CmdLine.resolve_user_selection(selected_packages) # Now load the rest of the configuration, and filter out exclusions Autoproj::CmdLine.finalize_package_setup resolved_selected_packages = Autoproj::CmdLine.resolve_user_selection(selected_packages) if !selected_packages.empty? command_line_selection = resolved_selected_packages.dup else command_line_selection = Array.new end Autoproj.manifest.explicit_selection = resolved_selected_packages selected_packages = resolved_selected_packages # If in verbose mode, or if we only update sources, list the sources if Autoproj.verbose || Autoproj::CmdLine.display_configuration? Autoproj::CmdLine.display_configuration(manifest, selected_packages) end if Autoproj::CmdLine.bootstrap? STDERR.puts <