Class: Autoproj::Ops::Build

Inherits:
Object
  • Object
show all
Defined in:
lib/autoproj/ops/build.rb

Overview

Operations related to building packages

Note that these do not perform import or osdeps installation. It is assumed that the packages that should be built have been cleanly imported

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(manifest, report_path: nil) ⇒ Build

Returns a new instance of Build.

Parameters:

  • report_dir (String)

    the log directory in which to build the build report. If left to nil, no report will be generated



16
17
18
19
# File 'lib/autoproj/ops/build.rb', line 16

def initialize(manifest, report_path: nil)
    @manifest = manifest
    @report_path = report_path
end

Instance Attribute Details

#manifestManifest (readonly)

The manifest on which we operate

Returns:



12
13
14
# File 'lib/autoproj/ops/build.rb', line 12

def manifest
  @manifest
end

Instance Method Details

#build_packages(all_enabled_packages, options = Hash.new) ⇒ void

This method returns an undefined value.

Builds the listed packages

Only build steps that are actually needed will be performed. See #force_build_packages and #rebuild_packages to override this

Parameters:

  • all_enabled_packages (Array<String>)

    the list of package names of the packages that should be rebuilt



88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
# File 'lib/autoproj/ops/build.rb', line 88

def build_packages(all_enabled_packages, options = Hash.new)
    if @report_path
        reporting = Ops::PhaseReporting.new(
            "build", @report_path, method(:package_metadata)
        )
    end

    Autobuild.do_rebuild = false
    Autobuild.do_forced_build = false
    reporting&.initialize_incremental_report
    begin
        Autobuild.apply(
            all_enabled_packages,
            "autoproj-build", ["build"], options
        ) do |pkg, phase|
            reporting&.report_incremental(pkg) if phase == "build"
        end
    ensure
        packages = all_enabled_packages.map do |name|
            @manifest.find_autobuild_package(name)
        end
        reporting&.create_report(packages)
    end
end

#force_build_allObject

Triggers a force-build of all packages

Unlike a rebuild, a force-build forces the package to go through all build steps (even if they are not needed) but does not clean the current build byproducts beforehand



53
54
55
56
# File 'lib/autoproj/ops/build.rb', line 53

def force_build_all
    packages = manifest.all_layout_packages
    rebuild_packages(packages, packages)
end

#force_build_packages(selected_packages, all_enabled_packages) ⇒ void

This method returns an undefined value.

Triggers a force-build of a subset of all packages

Unlike a rebuild, a force-build forces the package to go through all build steps (even if they are not needed) but does not clean the current build byproducts beforehand

This method force-builds of all packages declared in the manifest’s layout

Parameters:

  • selected_packages (Array<String>)

    the list of package names that should be rebuilt

  • all_enabled_packages (Array<String>)

    the list of package names for which a build should be triggered (usually selected_packages plus dependencies)



73
74
75
76
77
78
# File 'lib/autoproj/ops/build.rb', line 73

def force_build_packages(selected_packages, all_enabled_packages)
    selected_packages.each do |pkg_name|
        Autobuild::Package[pkg_name].prepare_for_forced_build
    end
    build_packages(all_enabled_packages)
end

#package_metadata(autobuild_package) ⇒ Object



113
114
115
116
117
118
# File 'lib/autoproj/ops/build.rb', line 113

def (autobuild_package)
    {
        invoked: !!autobuild_package.install_invoked?,
        success: !!autobuild_package.installed?
    }
end

#rebuild_allObject

Triggers a rebuild of all packages

It rebuilds (i.e. does a clean + build) of all packages declared in the manifest’s layout. It also performs a reinstall of all non-OS-specific managers that support it (e.g. RubyGems) if update_os_packages? is set to true (the default)



27
28
29
30
# File 'lib/autoproj/ops/build.rb', line 27

def rebuild_all
    packages = manifest.all_layout_packages
    rebuild_packages(packages, packages)
end

#rebuild_packages(selected_packages, all_enabled_packages) ⇒ void

This method returns an undefined value.

Triggers a rebuild of a subset of all packages

Parameters:

  • selected_packages (Array<String>)

    the list of package names that should be rebuilt

  • all_enabled_packages (Array<String>)

    the list of package names for which a build should be triggered (usually selected_packages plus dependencies)



40
41
42
43
44
45
# File 'lib/autoproj/ops/build.rb', line 40

def rebuild_packages(selected_packages, all_enabled_packages)
    selected_packages.each do |pkg_name|
        Autobuild::Package[pkg_name].prepare_for_rebuild
    end
    build_packages(all_enabled_packages)
end