Sha256: 993a1143b4a45560ff973b1e817e59caa7514f3ba4df6b382b09aa2d06f6c7d8

Contents?: true

Size: 1.63 KB

Versions: 67

Compression:

Stored size: 1.63 KB

Contents

module Autobuild
    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 = `#{path} --version`
            @make_is_gnumake[path] = $?.success? &&
                (result.split("\n").first =~ /GNU Make/)
        end
    end

    def self.make_has_j_option?(path = Autobuild.tool(:make))
        make_is_gnumake?(path)
    end

    def self.make_has_gnumake_jobserver?(path = Autobuild.tool(:make))
        make_is_gnumake?(path)
    end

    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
end

Version data entries

67 entries across 67 versions & 1 rubygems

Version Path
autobuild-1.8.3 lib/autobuild/packages/gnumake.rb
autobuild-1.8.2 lib/autobuild/packages/gnumake.rb
autobuild-1.8.1 lib/autobuild/packages/gnumake.rb
autobuild-1.8.0 lib/autobuild/packages/gnumake.rb
autobuild-1.7.12.rc6 lib/autobuild/packages/gnumake.rb
autobuild-1.7.12.rc5 lib/autobuild/packages/gnumake.rb
autobuild-1.7.12.rc4 lib/autobuild/packages/gnumake.rb
autobuild-1.7.12.rc3 lib/autobuild/packages/gnumake.rb
autobuild-1.7.12.rc2 lib/autobuild/packages/gnumake.rb
autobuild-1.7.12.rc1 lib/autobuild/packages/gnumake.rb
autobuild-1.7.12.b1 lib/autobuild/packages/gnumake.rb
autobuild-1.7.11 lib/autobuild/packages/gnumake.rb
autobuild-1.7.11.rc7 lib/autobuild/packages/gnumake.rb
autobuild-1.7.11.rc6 lib/autobuild/packages/gnumake.rb
autobuild-1.7.11.rc5 lib/autobuild/packages/gnumake.rb
autobuild-1.7.11.rc4 lib/autobuild/packages/gnumake.rb
autobuild-1.7.11.rc3 lib/autobuild/packages/gnumake.rb
autobuild-1.7.11.rc2 lib/autobuild/packages/gnumake.rb
autobuild-1.7.11.rc1 lib/autobuild/packages/gnumake.rb
autobuild-1.7.10 lib/autobuild/packages/gnumake.rb