# -*- coding: UTF-8 -*- require 'build-tool/application' require 'build-tool/commands' module BuildTool; module Commands; # # BuildCommand # class Build < ModuleBasedCommand name "build" description "Build a module." long_description [ "Build the given modules. This is the all in one interface to build-tool." ] # Log this command if $noop is not active def log? ! $noop end def initialize_options options.banner = "Usage: #{fullname} [OPTIONS]... MODULE..." options.separator( "" ) options.separator( "Options" ) @clean = false @configure = false @from_scratch = false @build = true @install = true @reconfigure = false @update = false options.on( "--[no-]clean", "Make clean before building." ) { |t| @clean = t } options.on( "--[no-]install", "Do not install" ) { |t| @install = t } options.on( "--[no-]update", "Do not update from the repository" ) { |t| @update = t } options.on( "-c", "--configure", "Run the configuration step again" ) { |t| @configure = true } options.on( "--reconfigure", "Remove old configuration then run configuration again" ) { |t| @reconfigure = true } options.on( nil, "--from-scratch", "Rebuild from scratch" ) { |t| @from_scratch = true } @verbose_rebase = false options.on( nil, "--[no-]verbose-rebase", "Show the changes applied by rebase." ) { |t| @verbose_rebase = t } super end def applicable? BuildTool::Application.instance.has_recipe? end def is_module_ready?( mod ) isready = true @update && isready &= mod.ready_for_fetch @update && isready &= mod.ready_for_rebase if !@update and (@build or @install or @configure) if !mod.checkedout? warn( "#{mod.name}: is not checked out. Skipping (add -u for checkout)" ) end end @install && isready &= mod.prepare_for_installation return isready end # is_module_ready def prepare_module( mod ) isready = true @update && isready &= mod.prepare_for_fetch @update && isready &= mod.prepare_for_rebase return isready end # prepare_module def do_execute_module( mod ) if not ( $noop or mod.checkedout? or @update ) # If the module is not checked out or $noop is active skip the module warn( "Module is not checked out! Use -u to check it out." ) warn( "skipped!" ) return 0 end # fetch/rebase if @update if mod.checkedout? fetch( mod, @verbose_rebase ) rebase( mod, @verbose_rebase ) else clone( mod ) end end # clean/from-scratch if @from_scratch remove_build_directory( mod ) elsif @clean clean( mod ) end # configure if @configure or @reconfigure or !mod.configured? if @reconfigure reconfigure( mod ) else # See outer if. @configure or !mod.configured? configure( mod ) end end # build if @build make( mod ) end # install if @install install( mod, true ) end end # do_execute_module def teardown_command cleanup_after_vcs_access end end # class Build end; end # module BuildTool::Commands