Main Autobuild module. This module includes the build configuration options (see Autobuild::DEFAULT_OPTIONS) for the default values)
the nice value at which we should spawn subprocesses
the base source directory. If a package defines a relative srcdir, then
it is defined relatively to Autobuild.srcdir. Defaults to the current directory.
the base install directory. If a package defines a relative prefix, then
it is defined relatively to Autobuild.prefix.
if true, displays all subprocesses output
more verbose than ‘verbose’: displays Rake’s debugging output
if we should update the packages
if we should build the packages
if we should forcefully trigger all the packages build phases
if we should cleanly rebuild every packages
if we should produce the documentation
if errors during the documentation generation are treated as errors
if the build should go into daemon mode (only if the daemons gem is available)
remove all logs before starting the build
a list of packages to build specifically
the list of packages to build if Autobuild.packages is empty.
It this array is empty too, build all defined packages.
if true, new runs will be appended to existing logfiles.
Otherwise, the existing logfile contents is erased.
This class is the base class for objects that are used to get the source
from various RCS into the package source directory. A list of patches to
apply after the import can be given in the :patches option.
For backwards compatibility
A HighLine object that allows to colorize the output
List of files that should be sourced in the generated environment variable setting shell scripts
List of files that should be sourced in the generated environment variable setting shell scripts
List of the environment that should be set before calling a subcommand
It is a map from environment variable name to the corresponding value. If the value is an array, it is joined using the path separator ‘:’
The set of global ignores for SourceTreeTask
Regular expressions added to this set will be used to determine if a source tree has or has not changed
In generated environment update shell files, indicates whether an environment variable should be overriden by the shell script, or simply updated
If inherited_environment is true, the generated shell script will contain
export VARNAME=new_value:new_value:$VARNAME
otherwise
export VARNAME=new_value:new_value
The directory in which logs are saved. Defaults to PREFIX/log.
Mailing configuration. It is a hash with the following keys (as symbols)
the mail destination. Defaults to HOSTNAME at USER, where HOSTNAME at USER is the username of autobuild’s caller, and HOSTNAME the hostname of the current machine.
the mail origin. Defaults to the same value than :to
the hostname of the SMTP server, defaults to localhost
the port of the SMTP server, defauts to 22
mail only on errors. Defaults to false.
Sets the level of parallelism during the build
See parallel_build_level for detailed information
Configure the programs used by different packages
# File lib/autobuild/subcommand.rb, line 30 def self.add_stat(package, phase, duration) if !@statistics[package] @statistics[package] = { phase => duration } elsif !@statistics[package][phase] @statistics[package][phase] = duration else @statistics[package][phase] += duration end end
# File lib/autobuild/config.rb, line 242 def self.apply(packages, buildname = "autobuild") if Autobuild.mail[:to] if !Autobuild::HAS_RMAIL Autobuild.warn "RMail is not available. Mail notification is disabled" else Reporting << MailReporter.new(Autobuild.mail) end end if Autobuild.do_rebuild packages.each do |pkg_name| Autobuild::Package[pkg_name].prepare_for_rebuild end # And delete the prefix ! FileUtils.rm_rf Autobuild.prefix elsif Autobuild.do_forced_build packages.each do |pkg_name| Autobuild::Package[pkg_name].prepare_for_forced_build end end if Autobuild.only_doc phases = ['doc'] else phases = ['import'] phases += ['prepare', 'build'] if Autobuild.do_build phases << 'doc' if Autobuild.do_doc end phases.each do |phase| # We create a dummy task listing what needs to be done, and then we # call it targets = if packages.empty? phase else packages. find_all { |pkg| Rake.application.lookup("#{pkg}-#{phase}") }. map { |pkg| "#{pkg}-#{phase}" } end task "#{buildname}-#{phase}" => targets end begin invoker = Autobuild::RakeTaskParallelism.new Autobuild.parallel_task_manager = invoker phases.each do |phase| invoker.invoke_parallel([Rake::Task["#{buildname}-#{phase}"]]) end ensure Autobuild.parallel_task_manager = nil end end
# File lib/autobuild/config.rb, line 100 def self.apply_post_install(pkg, info) return unless info case info when Array args = info.dup tool = Autobuild.tool(args.shift) pkg.run 'post-install', tool, *args when Proc if info.arity == 1 info.call(pkg) else info.call end end end
# File lib/autobuild/environment.rb, line 328 def self.arch_names if @arch_names return @arch_names end result = Set.new if File.file?('/usr/bin/dpkg-architecture') arch = %x/usr/bin/dpkg-architecture`.split.grep(/DEB_BUILD_MULTIARCH/).first if arch result << arch.chomp.split('=').last end end @arch_names = result end
# File lib/autobuild/environment.rb, line 316 def self.arch_size if @arch_size return @arch_size end @arch_size = if RbConfig::CONFIG['host_cpu'] =~ /64/ 64 else 32 end end
Creates an importer which downloads a tarball from source and
unpacks it. The allowed values in options are described in Autobuild::ArchiveImporter.new.
# File lib/autobuild/import/archive.rb, line 250 def self.archive(source, options = {}) ArchiveImporter.new(source, options) end
Returns the number of CPUs present on this system
# File lib/autobuild/subcommand.rb, line 69 def self.autodetect_processor_count if @processor_count return @processor_count end #No parralel build on windows yet, since CPU detection is not easy do able if(RbConfig::CONFIG["host_os"] =~%r(msdos|mswin|djgpp|mingw|[Ww]indows)!) return 1 end if File.file?('/proc/cpuinfo') cpuinfo = File.readlines('/proc/cpuinfo') physical_ids, core_count, processor_ids = [], [], [] cpuinfo.each do |line| case line when /^processor\s+:\s+(\d+)$/ processor_ids << Integer($1) when /^physical id\s+:\s+(\d+)$/ physical_ids << Integer($1) when /^cpu cores\s+:\s+(\d+)$/ core_count << Integer($1) end end # Try to count the number of physical cores, not the number of # logical ones. If the info is not available, fallback to the # logical count if (physical_ids.size == core_count.size) && (physical_ids.size == processor_ids.size) info = Array.new while (id = physical_ids.shift) info[id] = core_count.shift end @processor_count = info.inject(&:+) else @processor_count = processor_ids.size end else result = Open3.popen3("sysctl", "-n", "hw.ncpu") do |_, io, _| io.read end if !result.empty? @processor_count = Integer(result.chomp.strip) end end # The format of the cpuinfo file is ... let's say not very standardized. # If the cpuinfo detection fails, inform the user and set it to 1 if !@processor_count # Hug... What kind of system is it ? Autobuild.message "INFO: cannot autodetect the number of CPUs on this sytem" @processor_count = 1 end @processor_count end
# File lib/autobuild/packages/autotools.rb, line 10 def self.autotools(opts, &proc) Autotools.new(opts, &proc) end
Removes all log files
# File lib/autobuild/config.rb, line 154 def clean_log! Reporting.each_log do |file| FileUtils.rm_f file end end
# File lib/autobuild/subcommand.rb, line 8 def self.clear_logfiles @logfiles.clear end
# File lib/autobuild/packages/cmake.rb, line 5 def self.cmake(options, &block) CMake.new(options, &block) end
# File lib/autobuild/config.rb, line 66 def self.color(*args) if color? console.color(*args) else args.first end end
# File lib/autobuild/config.rb, line 60 def color? !!@color end
Gets autobuild options from the command line and returns the remaining elements
# File lib/autobuild/config.rb, line 172 def commandline(args) parser = OptionParser.new do |opts| opts.separator "Path specification" opts.on("--srcdir PATH", "sources are installed in PATH") do |v| Autobuild.srcdir=v end opts.on("--prefix PATH", "built packages are installed in PATH") do |v| Autobuild.prefix = v end opts.on("--logdir PATH", "logs are saved in PATH (default: <prefix>/autobuild)") do |v| Autobuild.logdir = v end opts.separator "" opts.separator "General behaviour" opts.on('--nice NICE', Integer, 'nice the subprocesses to the given value') do |v| Autobuild.nice = v end opts.on("-h", "--help", "Show this message") do puts opts exit end if defined? Daemons opts.on("--[no-]daemon", "go into daemon mode") do |v| Autobuild.daemonize = v end end opts.on("--no-update", "update already checked-out sources") do |v| Autobuild.do_update = v end opts.on("--no-build", "only prepare packages, do not build them") do |v| Autobuild.do_build = v end opts.on("--forced-build", "force the trigger of all the build commands") do |v| Autobuild.do_forced_build = v end opts.on("--rebuild", "clean and rebuild") do |v| Autobuild.do_forced_build = v end opts.on("--only-doc", "only generate documentation") do |v| Autobuild.only_doc = v end opts.on("--no-doc", "don't generate documentation") do |v| Autobuild.do_doc = v end opts.on("--doc-errors", "treat documentation failure as error") do |v| Autobuild.doc_errors = v end opts.separator "" opts.separator "Program output" opts.on("--[no-]verbose", "display output of commands on stdout") do |v| Autobuild.verbose = v end opts.on("--[no-]debug", "debug information (for debugging purposes)") do |v| Autobuild.debug = v end opts.on("--keep-oldlogs", "old logs will be kept, new program output being appended") do |v| Autobuild.keep_oldlogs = v end opts.on('--version', "displays autobuild version and then exits") do puts "autobuild v#{Autobuild::VERSION}" exit 0 end opts.separator "" opts.separator "Mail reports" opts.on("--mail-from EMAIL", String, "From: field of the sent mails") do |from_email| mail[:from] = from_email end opts.on("--mail-to EMAILS", String, "comma-separated list of emails to which the reports should be sent") do |emails| mail[:to] ||= [] mail[:to] += emails.split(',') end opts.on("--mail-subject SUBJECT", String, "Subject: field of the sent mails") do |subject_email| mail[:subject] = subject_email end opts.on("--mail-smtp HOSTNAME", String, " address of the mail server written as hostname[:port]") do |smtp| raise "invalid SMTP specification #{smtp}" unless smtp =~ /^([^:]+)(?::(\d+))?$/ mail[:smtp] = $1 mail[:port] = Integer($2) if $2 && !$2.empty? end opts.on("--mail-only-errors", "send mail only on errors") do mail[:only_errors] = true end end parser.parse!(args) if !args[0] puts parser exit end Rake.application.options.trace = debug args[0..-1] end
Returns the CVS importer which will get the name module in
repository repo. The allowed values in options
are described in Autobuild::CVSImporter.new.
# File lib/autobuild/import/cvs.rb, line 78 def self.cvs(module_name, options = {}, backward_compatibility = nil) if backward_compatibility backward_compatibility[:module] = options CVSImporter.new(module_name, backward_compatibility) else CVSImporter.new(module_name, options) end end
Returns the Darcs importer which will get the source from the Darcs
repository source. The allowed values in options
are described in Autobuild::DarcsImporter.new.
# File lib/autobuild/import/darcs.rb, line 47 def self.darcs(source, options = {}) DarcsImporter.new(source, options) end
# File lib/autobuild/reporting.rb, line 53 def self.display_message(*args) msg = if args.empty? then "" else "#{color(*args)}" end if !Autobuild.progress_display_enabled? puts msg return end size = if @last_progress_msg then @last_progress_msg.size else 0 end puts "\r#{msg}#{" " * [size - msg.size, 0].max}" if @last_progress_msg print "#{@last_progress_msg}" end end
# File lib/autobuild/reporting.rb, line 228 def self.display_progress msg = format_progress_message(progress_messages.map(&:last)) last_msg_length = if @last_progress_msg then @last_progress_msg.length else 0 end if msg.empty? blank = " " * last_msg_length @last_progress_msg = nil else msg = " #{msg}" blank = " " * [last_msg_length - msg.length, 0].max @last_progress_msg = msg end if !silent? if Autobuild.progress_display_enabled? print "\r#{msg}#{blank}" print "\r#{msg}" elsif @last_progress_msg puts msg end end end
# File lib/autobuild/packages/dummy.rb, line 2 def self.dummy(spec) DummyPackage.new(spec) end
# File lib/autobuild/environment.rb, line 289 def self.each_env_search_path(prefix, patterns) arch_names = self.arch_names arch_size = self.arch_size seen = Set.new patterns.each do |base_path| paths = [] if base_path =~ /ARCHSIZE/ base_path = base_path.gsub('ARCHSIZE', arch_size.to_s) end if base_path =~ /ARCH/ arch_names.each do |arch| paths << base_path.gsub('ARCH', arch) end else paths << base_path end paths.each do |p| p = File.join(prefix, *p.split('/')) if !seen.include?(p) && File.directory?(p) yield(p) seen << p end end end end
Adds a new value to an environment variable
# File lib/autobuild/environment.rb, line 174 def self.env_add(name, *values) set = if environment.has_key?(name) environment[name] end if !inherited_environment.has_key?(name) env_init_from_env(name) end if !set set = Array.new elsif !set.respond_to?(:to_ary) set = [set] end values.concat(set) @environment[name] = values env_update_var(name) end
# File lib/autobuild/environment.rb, line 202 def self.env_add_path(name, *paths) oldpath = environment[name] || Array.new paths.reverse.each do |path| next if oldpath.include?(path) env_add(name, path) oldpath << path if name == 'RUBYLIB' $LOAD_PATH.unshift path end end end
Unsets any value on the environment variable name, including
inherited value.
In a bourne shell, this would be equivalent to doing
unset name
# File lib/autobuild/environment.rb, line 100 def self.env_clear(name = nil) if name environment[name] = nil inherited_environment[name] = nil env_update_var(name) else environment.keys.each do |name| env_clear(name) end end end
Declare that the given environment variable must not be reset by the env.sh script, but that new values should simply be prepended to it.
See Autoproj.env_inherit?
# File lib/autobuild/environment.rb, line 147 def self.env_inherit(*names) @env_inherited_variables |= names names.each do |env_name| env_init_from_env(env_name) end end
If true (the default), the environment variables that are marked as inherited will be inherited from the global environment (during the build as well as in the generated env.sh files)
Otherwise, only the environment that is explicitely set in autobuild will be passed on to subcommands, and saved in the environment scripts.
# File lib/autobuild/environment.rb, line 136 def self.env_inherit=(value) @env_inherit = value inherited_environment.keys.each do |env_name| env_init_from_env(env_name) end end
Returns true if the given environment variable must not be reset by the env.sh script, but that new values should simply be prepended to it.
See Autoproj.env_inherit
# File lib/autobuild/environment.rb, line 125 def self.env_inherit?(name) @env_inherit && @env_inherited_variables.include?(name) end
# File lib/autobuild/environment.rb, line 154 def self.env_init_from_env(name) if env_inherit?(name) && (parent_env = ORIGINAL_ENV[name]) inherited_environment[name] = parent_env.split(ENV_LIST_SEPARATOR) else inherited_environment[name] = Array.new end env_update_var(name) end
# File lib/autobuild/environment.rb, line 163 def self.env_push(name, *values) if current = environment[name] current = current.dup env_set(name, *values) env_add(name, *current) else env_add(name, *values) end end
# File lib/autobuild/environment.rb, line 215 def self.env_push_path(name, *values) if current = environment[name] current = current.dup env_clear(name) env_add_path(name, *values) env_add_path(name, *current) else env_add_path(name, *values) end end
Resets the value of name to its original value. If it is
inherited from the
# File lib/autobuild/environment.rb, line 81 def self.env_reset(name = nil) if name environment.delete(name) inherited_environment.delete(name) env_init_from_env(name) else environment.keys.each do |name| env_reset(name) end end end
Set a new environment variable
# File lib/autobuild/environment.rb, line 113 def self.env_set(name, *values) env_reset(name) env_add(name, *values) end
Require that generated environment variable scripts source the given shell script
# File lib/autobuild/environment.rb, line 228 def self.env_source_file(file) env_source_after(file) end
# File lib/autobuild/environment.rb, line 194 def self.env_update_var(name) if !environment[name] && !inherited_environment[name] ENV.delete(name) else ENV[name] = ((environment[name] || []) + (inherited_environment[name] || [])).join(ENV_LIST_SEPARATOR) end end
Displays an error message
# File lib/autobuild/reporting.rb, line 81 def self.error(message) Autobuild.message(" ERROR: #{message}", :red, :bold) end
Generates a shell script that sets the environment variable listed in ::environment, following the inheritance setting listed in ::inherited_environment.
It also sources the files added by ::env_source_file
# File lib/autobuild/environment.rb, line 249 def self.export_env_sh(io) @env_source_before.each do |path| io.puts SHELL_SOURCE_SCRIPT % path end variables = [] Autobuild.environment.each do |name, value| variables << name if value shell_line = SHELL_SET_COMMAND % [name, value.join(ENV_LIST_SEPARATOR)] else shell_line = SHELL_UNSET_COMMAND % [name] end if env_inherit?(name) if value.empty? next else shell_line << "#{ENV_LIST_SEPARATOR}$#{name}" end end io.puts shell_line end variables.each do |var| io.puts SHELL_EXPORT_COMMAND % [var] end @env_source_after.each do |path| io.puts SHELL_SOURCE_SCRIPT % [path] end end
# File lib/autobuild/reporting.rb, line 164 def self.find_common_prefix(msg, other_msg) msg = msg.split(" ") other_msg = other_msg.split(" ") msg.each_with_index do |token, idx| if other_msg[idx] != token prefix = msg[0..(idx - 1)].join(" ") if !prefix.empty? prefix << " " end return prefix end end return msg end
# File lib/autobuild/reporting.rb, line 179 def self.format_progress_message(messages) messages = messages.sort groups = Array.new groups << ["", (0...messages.size)] messages.each_with_index do |msg, idx| prefix, grouping = nil, false messages[(idx + 1)..-1].each_with_index do |other_msg, other_idx| other_idx += idx + 1 prefix ||= find_common_prefix(msg, other_msg) break if !other_msg.start_with?(prefix) if grouping break if prefix != groups.last[0] groups.last[1] << other_idx else current_prefix, current_group = groups.last if prefix.size > current_prefix.size # create a new group from there groups.last[1] = (current_group.first..[idx-1,current_group.last].min) groups << [prefix, [idx, other_idx]] grouping = true else break end end end end if groups.last.last.last < messages.size groups << ["", (groups.last.last.last + 1)...(messages.size)] end result = [] groups.each do |prefix, indexes| if prefix.empty? indexes.each do |index| result << messages[index] end else grouped_messages = [] indexes.each do |index| grouped_messages << messages[index][(prefix.size)..-1] end if !grouped_messages.empty? result << "#{prefix}#{grouped_messages.join(", ")}" end end end result.join(" | ") end
True if we build and if the build is applied on all packages
# File lib/autobuild/config.rb, line 51 def full_build? do_build && !only_doc && packages.empty? end
# File lib/autobuild/packages/genom.rb, line 6 def self.genom(opts, &proc) GenomModule.new(opts, &proc) end
# File lib/autobuild/timestamps.rb, line 83 def self.get_stamp(stampfile) return Time.at(0) if !File.exists?(stampfile) return File.mtime(stampfile) end
Creates a git importer which gets the source for the given repository and
branch URL source. The allowed values in options
are described in Autobuild::SVN.new.
# File lib/autobuild/import/git.rb, line 428 def self.git(repository, branch = nil, options = {}) Git.new(repository, branch, options) end
# File lib/autobuild/timestamps.rb, line 88 def self.hires_modification_time? if @hires_modification_time.nil? Tempfile.open('test') do |io| io.flush p_time = File.mtime(io.path) @hires_modification_time = (p_time.tv_usec != 0) end end @hires_modification_time end
Add a file and/or a regular expression to the ignore list
The matching paths will not be considered when looking if a source tree has been updated or not.
# File lib/autobuild/timestamps.rb, line 22 def self.ignore(path) if path.kind_of?(Regexp) ignored_files << path else ignored_files << Regexp.new("^#{Regexp.quote(path)}") end end
# File lib/autobuild/packages/import.rb, line 5 def self.import(spec, &proc) ImporterPackage.new(spec, &proc) end
# File lib/autobuild/packages/pkgconfig.rb, line 25 def self.installed_pkgconfig(name, &block) InstalledPkgConfig.new(name, &block) end
The directory in which logs are saved
# File lib/autobuild/config.rb, line 151 def logdir; @logdir || "#{prefix}/log" end
# File lib/autobuild/subcommand.rb, line 12 def self.logfiles @logfiles end
# File lib/autobuild/environment.rb, line 16 def self.macos? @macos end
# File lib/autobuild/packages/gnumake.rb, line 17 def self.make_has_gnumake_jobserver?(path = Autobuild.tool(:make)) make_is_gnumake?(path) end
# File lib/autobuild/packages/gnumake.rb, line 13 def self.make_has_j_option?(path = Autobuild.tool(:make)) make_is_gnumake?(path) end
# File lib/autobuild/packages/gnumake.rb, line 2 def self.make_is_gnumake?(path = Autobuild.tool(:make)) @make_is_gnumake ||= Hash.new if @make_is_gnumake.has_key?(path) @make_is_gnumake[path] else result = %x#{path} --version` @make_is_gnumake[path] = $?.success? && (result.split("\n").first =~ /GNU Make/) end end
# File lib/autobuild/packages/gnumake.rb, line 21 def self.make_subcommand(pkg, phase, *options, &block) reserved = nil cmd_path = Autobuild.tool(:make) cmd = [cmd_path] if make_has_j_option?(cmd_path) && pkg.parallel_build_level != 1 if manager = Autobuild.parallel_task_manager job_server = manager.job_server if !make_has_gnumake_jobserver?(cmd_path) || (pkg.parallel_build_level != Autobuild.parallel_build_level) reserved = pkg.parallel_build_level job_server.get(reserved - 1) # We already have one token taken by autobuild itself cmd << "-j#{pkg.parallel_build_level}" else cmd << "--jobserver-fds=#{job_server.rio.fileno},#{job_server.wio.fileno}" << "-j" end else cmd << "-j#{pkg.parallel_build_level}" end end cmd.concat(options) Subprocess.run(pkg, phase, *cmd, &block) ensure if reserved job_server.put(reserved) end end
# File lib/autobuild/reporting.rb, line 46 def self.message(*args) return if silent? display_lock.synchronize do display_message(*args) end end
# File lib/autobuild/packages/orogen.rb, line 2 def self.orogen(opts, &proc) Orogen.new(opts, &proc) end
# File lib/autobuild/package.rb, line 667 def self.package_set(spec) spec.each do |name, packages| Autobuild::TARGETS.each do |target| task "#{name}-#{target}" => packages.map { |dep| "#{dep}-#{target}" } end end end
Returns the number of processes that can run in parallel during the build. This is a system-wide value that can be overriden in a per-package fashion by using Autobuild::Package#parallel_build_level.
If not set, defaults to the number of CPUs on the system
See also parallel_build_level=
# File lib/autobuild/subcommand.rb, line 55 def parallel_build_level if @parallel_build_level.nil? # No user-set value, return the count of processors on this # machine autodetect_processor_count elsif !@parallel_build_level || @parallel_build_level <= 0 1 else @parallel_build_level end end
DEPRECATED: use ::env_add_path instead
# File lib/autobuild/environment.rb, line 280 def self.pathvar(path, varname) if File.directory?(path) if block_given? return unless yield(path) end env_add_path(varname, path) end end
# File lib/autobuild/config.rb, line 87 def self.post_install(*args, &block) if args.empty? @post_install_handlers << block elsif !block @post_install_handlers << args else raise ArgumentError, "cannot set both arguments and block" end end
Gets or updates a message to be displayed on success. Can either be a string or a block, in which case the block must return the message string.
# File lib/autobuild/config.rb, line 136 def post_success_message(*args, &block) if args.empty? && !block if @post_success_message.respond_to?(:to_str) @post_success_message.to_str elsif @post_success_message @post_success_message.call end elsif block @post_success_message = block else @post_success_message = args.first.to_str end end
# File lib/autobuild/reporting.rb, line 121 def self.progress(key, *args) found = false display_lock.synchronize do progress_messages.map! do |msg_key, msg| if msg_key == key found = true [msg_key, color(*args)] else [msg_key, msg] end end if !found progress_messages << [key, color(*args)] end return if !Autobuild.progress_display_enabled? display_progress end end
# File lib/autobuild/reporting.rb, line 40 def self.progress_display_enabled=(value) @progress_display_enabled = value end
# File lib/autobuild/reporting.rb, line 36 def self.progress_display_enabled? @progress_display_enabled end
# File lib/autobuild/reporting.rb, line 142 def self.progress_done(key, display_last = true) found = false display_lock.synchronize do last_msg = nil progress_messages.delete_if do |msg_key, msg| if msg_key == key found = true last_msg = msg end end if found if display_last display_message(" #{last_msg}") end if @last_progress_msg display_progress end end end found end
# File lib/autobuild/reporting.rb, line 91 def self.progress_start(key, *args) if args.last.kind_of?(Hash) options = Kernel.validate_options args.pop, :done_message => nil else options = Hash.new end progress_done(key) display_lock.synchronize do progress_messages << [key, color(*args)] if Autobuild.progress_display_enabled? display_progress else display_message(" " + color(*args)) end end if block_given? begin yield if options[:done_message] progress(key, *options[:done_message]) end progress_done(key, true) rescue Exception => e progress_done(key, false) raise end end end
# File lib/autobuild/subcommand.rb, line 16 def self.register_logfile(path) @logfiles << path end
# File lib/autobuild/subcommand.rb, line 20 def self.registered_logfile?(logfile) @logfiles.include?(logfile) end
# File lib/autobuild/subcommand.rb, line 27 def self.reset_statistics @statistics = Hash.new end
# File lib/autobuild/reporting.rb, line 29 def self.silent Autobuild.silent, silent = true, Autobuild.silent? yield ensure Autobuild.silent = silent end
# File lib/autobuild/reporting.rb, line 21 def silent? @silent end
# File lib/autobuild/timestamps.rb, line 77 def self.source_tree(path, &block) task = SourceTreeTask.define_task(path) block.call(task) unless !block task end
# File lib/autobuild/subcommand.rb, line 24 def self.statistics @statistics end
Creates a subversion importer which import the source for the Subversion
URL source. The allowed values in options are
described in Autobuild::SVN.new.
# File lib/autobuild/import/svn.rb, line 67 def self.svn(source, options = {}) SVN.new(source, options) end
DEPRECATED. Use ::archive instead.
# File lib/autobuild/import/archive.rb, line 255 def self.tar(source, options = {}) ArchiveImporter.new(source, options) end
Get a given program, using its name as default value. For instance
tool('automake')
will return ‘automake’ unless the autobuild script defined another automake program in ::programs by doing
Autobuild.programs['automake'] = 'automake1.9'
# File lib/autobuild/config.rb, line 166 def tool(name) programs[name.to_sym] || programs[name.to_s] || name.to_s end
# File lib/autobuild/timestamps.rb, line 99 def self.touch_stamp(stampfile) Autobuild.message "Touching #{stampfile}" if Autobuild.debug dir = File.dirname(stampfile) if File.exists?(dir) && !File.directory?(dir) raise "#{dir} exists and is not a directory" elsif !File.exists?(dir) FileUtils.mkdir_p dir end FileUtils.touch(stampfile) if !hires_modification_time? # File modification times on most Unix filesystems have a granularity of # one second, so we (unfortunately) have to sleep 1s to make sure that # time comparisons will work as expected. sleep(1) end end
# File lib/autobuild/timestamps.rb, line 30 def self.tree_timestamp(path, *exclude) # Exclude autobuild timestamps exclude.each { |rx| raise unless Regexp === rx } exclude << (/#{Regexp.quote(STAMPFILE)}$/) Autobuild.message "getting tree timestamp for #{path}" if Autobuild.debug latest = Time.at(0) latest_file = "" Find.find(path) { |p| Find.prune if File.basename(p) =~ /^\./ exclude.each { |pattern| if p =~ pattern Autobuild.message " excluding #{p}" if Autobuild.debug Find.prune end } next if !File.file?(p) p_time = File.mtime(p) if latest < p_time latest = p_time latest_file = p end } Autobuild.message " newest file: #{latest_file} at #{latest}" if Autobuild.debug return latest_file, latest end
Updates the environment when a new prefix has been added
# File lib/autobuild/environment.rb, line 344 def self.update_environment(newprefix, includes = nil) if !includes || includes.include?('PATH') if File.directory?("#{newprefix}/bin") env_add_path('PATH', "#{newprefix}/bin") end end if !includes || includes.include?('PKG_CONFIG_PATH') pkg_config_search = ['lib/pkgconfig', 'lib/ARCH/pkgconfig', 'libARCHSIZE/pkgconfig'] each_env_search_path(newprefix, pkg_config_search) do |path| env_add_path('PKG_CONFIG_PATH', path) end end if !includes || includes.include?('LD_LIBRARY_PATH') ld_library_search = ['lib', 'lib/ARCH', 'libARCHSIZE'] each_env_search_path(newprefix, ld_library_search) do |path| if !Dir.glob(File.join(path, "lib*.so")).empty? env_add_path('LD_LIBRARY_PATH', path) end end end # Validate the new rubylib path if !includes || includes.include?('RUBYLIB') new_rubylib = "#{newprefix}/lib" if File.directory?(new_rubylib) && !File.directory?(File.join(new_rubylib, "ruby")) && !Dir["#{new_rubylib}/**/*.rb"].empty? env_add_path('RUBYLIB', new_rubylib) end require 'rbconfig' ruby_arch = File.basename(RbConfig::CONFIG['archdir']) candidates = %w{rubylibdir archdir sitelibdir sitearchdir vendorlibdir vendorarchdir}. map { |key| RbConfig::CONFIG[key] }. map { |path| path.gsub(/.*lib(?:32|64)?\/(\w*ruby\/)/, '\1') }. each do |subdir| if File.directory?("#{newprefix}/lib/#{subdir}") env_add_path("RUBYLIB", "#{newprefix}/lib/#{subdir}") end end end end
Displays a warning message
# File lib/autobuild/reporting.rb, line 86 def self.warn(message) Autobuild.message(" WARN: #{message}", :magenta) end
# File lib/autobuild/environment.rb, line 11 def self.windows? @windows end