#! /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' require 'pp' require 'highline' include Autoproj InputError = Autoproj::InputError module Autoproj @verbose = false @console = HighLine.new class << self attr_accessor :verbose attr_reader :console end end selected_packages = Autoproj::CmdLine.parse_arguments(ARGV.dup) def color(*args) Autoproj.console.color(*args) end def report(debug) Autobuild::Reporting.report do yield Autobuild::Reporting.success end rescue ConfigError => e STDERR.puts STDERR.puts color(e.message, :red, :bold) if debug then raise else exit 1 end rescue Interrupt STDERR.puts STDERR.puts color("Interrupted by user", :red, :bold) if debug then raise else exit 1 end end Autoproj::OSDependencies.autodetect_ruby # Find the autoproj root dir report(Autobuild.debug) do # 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 Autoproj::CmdLine.update_myself Autoproj::CmdLine.update_configuration 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 # If in verbose mode, or if we only update sources, list the sources if Autoproj.verbose || Autoproj::CmdLine.display_configuration? Autoproj::CmdLine.display_sources(manifest) end if Autoproj::CmdLine.only_config? exit(0) end selected_packages = Autoproj::CmdLine.resolve_user_selection(selected_packages) Autoproj.manifest.explicit_selection = selected_packages Autoproj::CmdLine.initial_package_setup if Autoproj::CmdLine.only_status? all_enabled_packages = Autoproj::CmdLine.import_packages(selected_packages) Autoproj::CmdLine.status(all_enabled_packages) exit(0) elsif Autoproj::CmdLine.check? all_enabled_packages = Autoproj::CmdLine.import_packages(selected_packages) Autoproj::CmdLine.check(all_enabled_packages) exit(0) elsif Autoproj::CmdLine.manifest_update? all_enabled_packages = Autoproj::CmdLine.import_packages(selected_packages) Autoproj::CmdLine.manifest_update(all_enabled_packages) exit(0) elsif Autoproj::CmdLine.snapshot? all_enabled_packages = Autoproj::CmdLine.import_packages(selected_packages) Autoproj::CmdLine.snapshot(Autoproj::CmdLine.snapshot_dir, all_enabled_packages) exit(0) end STDERR.puts STDERR.puts color("autoproj: importing and loading selected packages", :bold) # Install prepackaged dependencies needed to import and build the packages. # The required information is in the package sets configuration. if Autoproj::CmdLine.update_os_dependencies? osdeps = manifest.known_os_packages osdeps.install(Autoproj.build_system_dependencies) end begin # Now, we actually do the import. Unfortunately, at this stage, we need to # import the package and its dependencies ourselves so that we are able to # build the list of packages that have actually been selected on the command # line. all_enabled_packages = Autoproj::CmdLine.import_packages(selected_packages) if Autoproj::CmdLine.build? || Autoproj::CmdLine.doc? || Autoproj::CmdLine.update_os_dependencies? if all_enabled_packages.empty? STDERR.puts color("autoproj: nothing to do", :bold) elsif Autoproj::CmdLine.build? || Autoproj::CmdLine.doc? Autoproj::CmdLine.build_packages(selected_packages, all_enabled_packages) elsif Autoproj::CmdLine.update_os_dependencies? manifest.install_os_dependencies(all_enabled_packages) end # Now, do some sanity checks on the result prefixes = all_enabled_packages.inject(Set.new) do |set, pkg_name| set << Autobuild::Package[pkg_name].prefix end prefixes.each do |prefix| libdir = File.join(prefix, "lib") if File.directory?(libdir) Autoproj.validate_solib_dependencies(libdir) end end end ensure Autoproj.export_env_sh STDERR.puts color("autoproj: updated #{Autoproj.root_dir}/env.sh", :green) end end