72 lines
1.6 KiB
Crystal
72 lines
1.6 KiB
Crystal
|
|
# Configuration phase
|
|
#
|
|
# Backends:
|
|
# - autotools
|
|
# pass if no "configure" file
|
|
# - cmake
|
|
# pass if no "CMakeLists.txt" file
|
|
# Both backends quit if recipe.dirname doesn't exist.
|
|
|
|
class Package::Backend::Configure
|
|
|
|
def self.autotools : Backend::Building
|
|
Backend::Building.new "configure", "autotools" do |context, recipe|
|
|
unless Dir.exists? recipe.dirname
|
|
Baguette::Log.detail "no '#{recipe.dirname}' directory: pass"
|
|
next BuildStatus::Pass
|
|
end
|
|
|
|
Do.cd recipe.dirname
|
|
|
|
unless File.exists? "configure"
|
|
Baguette::Log.detail "no 'configure' file: pass"
|
|
next BuildStatus::Pass
|
|
end
|
|
|
|
options = [
|
|
"--prefix=#{recipe.prefix}",
|
|
recipe.options["configure"]? || ""
|
|
]
|
|
|
|
child = Do.sh "./configure #{options.join " "}"
|
|
if child.exit_status == 0
|
|
BuildStatus::Success
|
|
else
|
|
BuildStatus::Failed
|
|
end
|
|
end
|
|
end
|
|
|
|
def self.cmake : Backend::Building
|
|
Backend::Building.new "configure", "cmake" do |context, recipe|
|
|
unless Dir.exists? recipe.dirname
|
|
Baguette::Log.detail "no '#{recipe.dirname}' directory: pass"
|
|
next BuildStatus::Pass
|
|
end
|
|
|
|
Do.cd recipe.dirname
|
|
|
|
unless File.exists? "CMakeLists.txt"
|
|
Baguette::Log.detail "no 'CMakeLists.txt' file: pass"
|
|
next BuildStatus::Pass
|
|
end
|
|
|
|
ncores = recipe.options["build-cores"]? || context.build_cores
|
|
options = [
|
|
"-DCMAKE_INSTALL_PREFIX='#{recipe.prefix}'",
|
|
"-DCMAKE_BUILD_TYPE=Release #{recipe.options["cmake"]}",
|
|
"-- -j#{ncores}"
|
|
]
|
|
|
|
child = Do.sh "cmake . #{options.join " "}"
|
|
if child.exit_status == 0
|
|
BuildStatus::Success
|
|
else
|
|
BuildStatus::Failed
|
|
end
|
|
end
|
|
end
|
|
|
|
end
|