build-cores, logs
parent
72aceb035d
commit
a4c53f2b8c
|
@ -18,7 +18,7 @@ def pkginfo(package)
|
||||||
|
|
||||||
lines = [] of String
|
lines = [] of String
|
||||||
|
|
||||||
lines << "# Generated by `package`."
|
lines << "# Generated by `packaging`."
|
||||||
lines << "pkgname = #{package.name}"
|
lines << "pkgname = #{package.name}"
|
||||||
lines << "pkgver = #{package.version}-r#{package.release}"
|
lines << "pkgver = #{package.version}-r#{package.release}"
|
||||||
lines << "url = #{package.url || ""} "
|
lines << "url = #{package.url || ""} "
|
||||||
|
@ -62,11 +62,17 @@ class Package::Context
|
||||||
# = where to search for binaries and libraries for the build
|
# = where to search for binaries and libraries for the build
|
||||||
property prefixes = ["/usr", "/", "/usr/baguette"]
|
property prefixes = ["/usr", "/", "/usr/baguette"]
|
||||||
|
|
||||||
|
# By default, building a package only uses one core
|
||||||
|
property build_cores = 1
|
||||||
|
|
||||||
# list of environment variables we want to have when building
|
# list of environment variables we want to have when building
|
||||||
property environment = {} of String => String
|
property environment = {} of String => String
|
||||||
|
|
||||||
property verbosity = 0
|
property verbosity = 0
|
||||||
|
|
||||||
|
property recipe : Recipe? = nil
|
||||||
|
|
||||||
|
|
||||||
def initialize
|
def initialize
|
||||||
@packaging_backends << ApkBackend.new
|
@packaging_backends << ApkBackend.new
|
||||||
@packaging_backends << BaguetteBackend.new
|
@packaging_backends << BaguetteBackend.new
|
||||||
|
@ -101,7 +107,8 @@ class Package::Context
|
||||||
|
|
||||||
options = [
|
options = [
|
||||||
"-DCMAKE_INSTALL_PREFIX='#{recipe.prefix}'",
|
"-DCMAKE_INSTALL_PREFIX='#{recipe.prefix}'",
|
||||||
"-DCMAKE_BUILD_TYPE=Release #{recipe.options["cmake"]}"
|
"-DCMAKE_BUILD_TYPE=Release #{recipe.options["cmake"]}",
|
||||||
|
"-- -j#{context.build_cores}"
|
||||||
]
|
]
|
||||||
|
|
||||||
child = context.sh "cmake . #{options.join " "}"
|
child = context.sh "cmake . #{options.join " "}"
|
||||||
|
@ -120,7 +127,7 @@ class Package::Context
|
||||||
next BuildStatus::Pass
|
next BuildStatus::Pass
|
||||||
end
|
end
|
||||||
|
|
||||||
child = context.sh "make #{recipe.options["make"]? || ""}"
|
child = context.sh "make -j#{context.build_cores} #{recipe.options["make"]? || ""}"
|
||||||
|
|
||||||
if child.exit_status == 0
|
if child.exit_status == 0
|
||||||
BuildStatus::Success
|
BuildStatus::Success
|
||||||
|
@ -188,9 +195,27 @@ class Package::Context
|
||||||
|
|
||||||
if @verbosity < -1
|
if @verbosity < -1
|
||||||
output = Process::Redirect::Close
|
output = Process::Redirect::Close
|
||||||
|
else
|
||||||
|
# log sub-commands outputs
|
||||||
|
logfile_path = "#{@working_directory}/#{@recipe.not_nil!.working_uuid}.log"
|
||||||
|
output = File.open logfile_path, "a"
|
||||||
|
STDOUT.puts "logging command #{command} #{args}"
|
||||||
|
STDOUT.puts "in " + logfile_path.colorize(:blue).mode(:bright).to_s
|
||||||
|
|
||||||
|
output.puts ""
|
||||||
|
output.puts ""
|
||||||
|
output.puts "logging command $ #{command}"
|
||||||
|
output.puts " parameters $ #{args}"
|
||||||
end
|
end
|
||||||
|
|
||||||
Process.run command, args, chdir: chdir, output: output, error: output, env: @environment
|
c = Process.run command, args, chdir: chdir, output: output, error: output, env: @environment
|
||||||
|
|
||||||
|
case output
|
||||||
|
when File
|
||||||
|
output.close
|
||||||
|
end
|
||||||
|
|
||||||
|
c
|
||||||
end
|
end
|
||||||
|
|
||||||
def run(command, args)
|
def run(command, args)
|
||||||
|
@ -235,7 +260,8 @@ class Package::Context
|
||||||
end
|
end
|
||||||
|
|
||||||
def read_recipe(filename : String)
|
def read_recipe(filename : String)
|
||||||
Recipe.new self, filename
|
@recipe = Recipe.new self, filename
|
||||||
|
@recipe.not_nil!
|
||||||
end
|
end
|
||||||
|
|
||||||
def find_recipe(name : String) : Recipe?
|
def find_recipe(name : String) : Recipe?
|
||||||
|
@ -267,6 +293,10 @@ class Package::Context
|
||||||
when "prefixes"
|
when "prefixes"
|
||||||
# Prefixes during the build process.
|
# Prefixes during the build process.
|
||||||
@prefixes = value.as_a_or_s
|
@prefixes = value.as_a_or_s
|
||||||
|
when "build-cores"
|
||||||
|
# NB of cores used to compile applications.
|
||||||
|
@build_cores = value.as_s.to_i
|
||||||
|
|
||||||
when "environment"
|
when "environment"
|
||||||
# Environment variables during the build process.
|
# Environment variables during the build process.
|
||||||
value.as_a_or_s.each do |entry|
|
value.as_a_or_s.each do |entry|
|
||||||
|
@ -280,7 +310,11 @@ class Package::Context
|
||||||
|
|
||||||
key, value = match
|
key, value = match
|
||||||
@environment[key] = value
|
@environment[key] = value
|
||||||
|
if @verbosity > 0
|
||||||
|
STDOUT.puts "environment: #{key} => #{value}"
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
when "package-manager"
|
when "package-manager"
|
||||||
# Targeted package manager (default: package, for BaguetteOS).
|
# Targeted package manager (default: package, for BaguetteOS).
|
||||||
begin
|
begin
|
||||||
|
|
|
@ -49,8 +49,8 @@ class Package::Recipe
|
||||||
property description : String?
|
property description : String?
|
||||||
|
|
||||||
# Informations not specific to individual packages.
|
# Informations not specific to individual packages.
|
||||||
getter sources : Sources
|
getter sources = Sources.new
|
||||||
getter packages : Array(Package)
|
getter packages = Array(Package).new
|
||||||
|
|
||||||
property packager : String?
|
property packager : String?
|
||||||
property maintainer : String?
|
property maintainer : String?
|
||||||
|
@ -68,16 +68,13 @@ class Package::Recipe
|
||||||
getter instructions = Instructions.new
|
getter instructions = Instructions.new
|
||||||
getter options = Hash(String, String).new
|
getter options = Hash(String, String).new
|
||||||
|
|
||||||
getter sources = Sources.new
|
|
||||||
getter packages = Array(Package).new
|
|
||||||
|
|
||||||
getter watch_script : String?
|
getter watch_script : String?
|
||||||
|
|
||||||
@prefix : String?
|
@prefix : String?
|
||||||
|
|
||||||
property recipe_directory = "."
|
property recipe_directory = "."
|
||||||
|
|
||||||
@working_uuid : UUID = UUID.random
|
getter working_uuid : UUID = UUID.random
|
||||||
|
|
||||||
def initialize(@context, @name, @version)
|
def initialize(@context, @name, @version)
|
||||||
end
|
end
|
||||||
|
@ -152,6 +149,7 @@ class Package::Recipe
|
||||||
value.as_a_or_s.each do |atom|
|
value.as_a_or_s.each do |atom|
|
||||||
@provides << atom
|
@provides << atom
|
||||||
end
|
end
|
||||||
|
|
||||||
when "options"
|
when "options"
|
||||||
value.as_a_or_s.each do |option|
|
value.as_a_or_s.each do |option|
|
||||||
match = option.split(':').map(
|
match = option.split(':').map(
|
||||||
|
@ -309,6 +307,7 @@ class Package::Recipe
|
||||||
do_splits
|
do_splits
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# TODO: do not search within source files.
|
||||||
private def do_strip
|
private def do_strip
|
||||||
@context.info "Stripping binaries"
|
@context.info "Stripping binaries"
|
||||||
|
|
||||||
|
|
Reference in New Issue