Class: BuildTool::Commands::Build

Inherits:
ModuleBasedCommand show all
Defined in:
lib/build-tool/commands/build.rb

Overview

BuildCommand

Instance Attribute Summary

Attributes inherited from Base

#cmd, #options, #parent

Instance Method Summary collapse

Methods inherited from ModuleBasedCommand

#clean, #clone, #configure, #do_execute, #fetch, #initialize, #install, #make, #rebase, #reconfigure, #remove_build_directory, #remove_source_directory, #summarize

Methods inherited from Standard

#complete_module, #complete_modules, #initialize, #log_directory, #while_logging_to

Methods inherited from Base

#<=>, #cleanup_after_vcs_access, #complete_arguments, #complete_readline, #configuration, #debug, #debug2, #do_complete, #do_execute, #each_option, #error, #execute, #fullname, #info, #initialize, #quiet, #setup_command, #setup_options, #show_help, #skip_command, #summarize, #trace, #usage, #verbose, #warn

Methods included from HelpText

#cmdalias, #description, included, #long_description, #name

Constructor Details

This class inherits a constructor from BuildTool::Commands::ModuleBasedCommand

Instance Method Details

#applicable?Boolean

Returns:

  • (Boolean)


67
68
69
# File 'lib/build-tool/commands/build.rb', line 67

def applicable?
    BuildTool::Application.instance.has_recipe?
end

#do_execute_module(mod) ⇒ Object

prepare_module



91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
# File 'lib/build-tool/commands/build.rb', line 91

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

#initialize_optionsObject



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/build-tool/commands/build.rb', line 22

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

#is_module_ready?(mod) ⇒ Boolean

Returns:

  • (Boolean)


71
72
73
74
75
76
77
78
79
80
81
82
# File 'lib/build-tool/commands/build.rb', line 71

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

#log?Boolean

Log this command if $noop is not active

Returns:

  • (Boolean)


18
19
20
# File 'lib/build-tool/commands/build.rb', line 18

def log?
    ! $noop
end

#prepare_module(mod) ⇒ Object

is_module_ready



84
85
86
87
88
89
# File 'lib/build-tool/commands/build.rb', line 84

def prepare_module( mod )
    isready = true
    @update  &&                         isready &= mod.prepare_for_fetch
    @update  &&                         isready &= mod.prepare_for_rebase
    return isready
end

#teardown_commandObject

do_execute_module



139
140
141
# File 'lib/build-tool/commands/build.rb', line 139

def teardown_command
    cleanup_after_vcs_access
end