Class: Autoproj::CLI::Build

Inherits:
Update show all
Defined in:
lib/autoproj/cli/build.rb

Instance Attribute Summary

Attributes inherited from Base

#ws

Instance Method Summary collapse

Methods inherited from Update

#finish_loading_configuration, #normalize_osdeps_options, #setup_update_from, #update_packages

Methods inherited from Base

#export_env_sh, #initialize, #normalize_command_line_package_selection, #notify_env_sh_updated, #resolve_selection, #resolve_user_selection, validate_options, #validate_user_selection

Methods included from Ops::Tools

#common_options, #create_autobuild_package, #load_autoprojrc, #load_main_initrb

Constructor Details

This class inherits a constructor from Autoproj::CLI::Base

Instance Method Details

#run(selected_packages, **options) ⇒ Object



21
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
# File 'lib/autoproj/cli/build.rb', line 21

def run(selected_packages, **options)
    build_options, options = filter_options(
        options,
        force: false,
        rebuild: false,
        parallel: nil,
        confirm: true,
        not: Array.new
    )

    command_line_selection, source_packages, _osdep_packages =
        super(selected_packages,
              ignore_errors: options[:keep_going],
              checkout_only: true,
              report: false,
              **options)

    parallel = build_options[:parallel] || ws.config.parallel_build_level

    return if source_packages.empty?

    active_packages = source_packages - build_options[:not]

    # Disable all packages that are not selected
    ws.manifest.each_autobuild_package do |pkg|
        next if active_packages.include?(pkg.name)

        pkg.disable
    end

    Autobuild.ignore_errors = options[:keep_going]

    ops = Ops::Build.new(ws.manifest, report_path: ws.build_report_path)
    if build_options[:rebuild] || build_options[:force]
        packages_to_rebuild =
            if options[:deps] || command_line_selection.empty?
                source_packages
            else
                command_line_selection
            end

        if command_line_selection.empty?
            # If we don't have an explicit package selection, we want to
            # make sure that the user really wants this
            mode_name = if build_options[:rebuild] then "rebuild"
                        else
                            "force-build"
                        end
            if build_options[:confirm] != false
                opt = BuildOption.new(
                    "", "boolean",
                    {
                        doc: "this is going to trigger a #{mode_name} "\
                             "of all packages. Is that really what you want ?"
                    }, nil
                )
                raise Interrupt unless opt.ask(false)
            end

            if build_options[:rebuild]
                ops.rebuild_all
            else
                ops.force_build_all
            end
        elsif build_options[:rebuild]
            ops.rebuild_packages(packages_to_rebuild, source_packages)
        else
            ops.force_build_packages(packages_to_rebuild, source_packages)
        end
        return
    end

    Autobuild.do_build = true
    ops.build_packages(source_packages, parallel: parallel)
    Main.run_post_command_hook(:build, ws, source_packages: source_packages)
ensure
    # Update env.sh, but only if we managed to load the configuration
    export_env_sh if source_packages
end

#validate_options(selected_packages, options) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/autoproj/cli/build.rb', line 7

def validate_options(selected_packages, options)
    selected_packages, options =
        super(selected_packages, options.merge(
            checkout_only: true, aup: options[:amake]
        ))

    options[:deps] = false if options[:no_deps_shortcut]
    if options[:deps].nil?
        options[:deps] =
            !(options[:rebuild] || options[:force])
    end
    [selected_packages, options]
end