haiku/build/jam/PackageRules
Ingo Weinhold 577411006e Update requires entries for the packages we build
* Add build tool update_package_requires. Given a package info file and
  a repository cache file, it updates the minimum versions of the
  requires entries of the package info file according to what is
  provided by the repository.
* PreprocessPackageInfo rule: Use update_package_requires (with the
  HaikuPorts repository file).
2013-10-30 02:16:14 +01:00

262 lines
7.9 KiB
Plaintext

rule FHaikuPackageGrist package
{
local grist = [ Match "<(.*)>" : $(package:G) ] ;
return hpkg_$(grist:E="")-$(package:G=) ;
}
rule HaikuPackage package
{
local grist = [ FHaikuPackageGrist $(package) ] ;
HAIKU_CONTAINER_GRIST on $(package) = $(grist) ;
HAIKU_INCLUDE_IN_CONTAINER_VAR on $(package) = HAIKU_INCLUDE_IN_PACKAGES ;
HAIKU_INSTALL_TARGETS_VAR on $(package)
= $(grist)_HAIKU_PACKAGE_INSTALL_TARGETS ;
HAIKU_CONTAINER_SYSTEM_DIR_TOKENS on $(package) = ;
HAIKU_CURRENTLY_BUILT_HAIKU_PACKAGE = $(package) ;
if $(HAIKU_PACKAGES_UPDATE_ONLY) {
HAIKU_CONTAINER_UPDATE_ONLY on $(package) = 1 ;
HAIKU_CONTAINER_INHERIT_UPDATE_VARIABLE on $(package)
= HAIKU_INCLUDE_IN_IMAGE ;
} else if $(HAIKU_UPDATE_ALL_PACKAGES) {
HAIKU_INCLUDE_IN_IMAGE on $(package) = 1 ;
}
HAIKU_CONTAINER_ALWAYS_CREATE_DIRECTORIES on $(package) = 1 ;
}
rule PreprocessPackageInfo source : directory : architecture
: secondaryArchitecture
{
source = $(source:G=package-info-source) ;
SEARCH on $(source) +=
[ FDirName $(HAIKU_PACKAGE_INFOS_DIR) $(architecture) ]
[ FDirName $(HAIKU_PACKAGE_INFOS_DIR) any ]
[ FDirName $(HAIKU_PACKAGE_INFOS_DIR) generic ]
;
local target = $(source:BSG=package-info)-package-info ;
local defines = HAIKU_PACKAGING_ARCH=$(architecture) ;
local sedReplacements = %HAIKU_PACKAGING_ARCH%,$(architecture) ;
if $(HAIKU_BOOTSTRAP_BUILD) {
defines += HAIKU_BOOTSTRAP_BUILD ;
target = $(target)-bootstrap ;
}
if $(secondaryArchitecture) {
defines += HAIKU_SECONDARY_PACKAGING_ARCH=$(secondaryArchitecture) ;
sedReplacements
+= %HAIKU_SECONDARY_PACKAGING_ARCH%,$(secondaryArchitecture) ;
sedReplacements +=
%HAIKU_SECONDARY_PACKAGING_ARCH_SUFFIX%,_$(secondaryArchitecture) ;
} else {
sedReplacements
+= %HAIKU_SECONDARY_PACKAGING_ARCH_SUFFIX%, ;
}
local revisionFile = [ DetermineHaikuRevision ] ;
local updateRequiresFiles ;
local haikuPortsRepositoryFile ;
if ! $(HAIKU_BOOTSTRAP_BUILD) {
updateRequiresFiles =
<build>update_package_requires
[ on <repository>HaikuPorts return $(HAIKU_REPOSITORY_CACHE_FILE) ]
;
}
MakeLocate $(target) : $(directory) ;
Depends $(target) : $(source) $(revisionFile) $(updateRequiresFiles) ;
CCDEFS on $(target) = [ FDefines $(defines) ] ;
HAIKU_SED_REPLACEMENTS on $(target) = "-e s,$(sedReplacements),g" ;
PreprocessPackageInfo1 $(target) : $(source) $(revisionFile)
$(updateRequiresFiles) ;
return $(target) ;
}
actions PreprocessPackageInfo1
{
revision=`sed -n 's,^\(hrev[0-9]*\).*,\1,p' $(2[2])`
sed $(HAIKU_SED_REPLACEMENTS) \
-e s,%HAIKU_VERSION%,$(HAIKU_VERSION)_${revision:-0}-1, < $(2[1]) \
| $(HOST_CC) -E -w $(CCDEFS) - -o $(1)
if [ -n "$(2[4]:E)" ]; then
$(HOST_ADD_BUILD_COMPATIBILITY_LIB_DIR)
"$(2[3])" "$(1)" "$(2[4])" || exit 1
fi
}
rule BuildHaikuPackage package : packageInfo
{
local architecture = $(HAIKU_PACKAGING_ARCH) ;
local secondaryArchitecture ;
if $(TARGET_PACKAGING_ARCH) != $(architecture) {
secondaryArchitecture = $(TARGET_PACKAGING_ARCH) ;
}
local grist = [ FHaikuPackageGrist $(package) ] ;
local tempDir
= [ FDirName $(HAIKU_PACKAGES_BUILD_DIR_$(architecture)) $(grist) ] ;
local scriptDir = [ FDirName $(tempDir) scripts ] ;
# build the package info and locate the package
packageInfo = [ PreprocessPackageInfo $(packageInfo) : $(tempDir)
: $(architecture) : $(secondaryArchitecture) ] ;
MakeLocate $(package) : $(HAIKU_PACKAGES_DIR_$(architecture)) ;
Depends $(package) : $(packageInfo) ;
# prepare the script that initializes the shell variables
local initVariablesScript = <$(grist)>haiku.package-init-vars ;
MakeLocate $(initVariablesScript) : $(scriptDir) ;
Always $(initVariablesScript) ;
local script = $(initVariablesScript) ;
AddVariableToScript $(script) : sourceDir : $(HAIKU_TOP) ;
AddVariableToScript $(script) : outputDir : $(HAIKU_OUTPUT_DIR) ;
AddVariableToScript $(script) : tmpDir : $(tempDir) ;
AddVariableToScript $(script) : addBuildCompatibilityLibDir
: $(HOST_ADD_BUILD_COMPATIBILITY_LIB_DIR) ;
AddVariableToScript $(script) : compressionLevel
: [ on $(package) return $(HAIKU_PACKAGE_COMPRESSION_LEVEL) ] ;
AddVariableToScript $(script) : updateOnly
: [ on $(package) return $(HAIKU_CONTAINER_UPDATE_ONLY) ] ;
AddVariableToScript $(script) : cc : $(TARGET_CC_$(architecture)) ;
AddTargetVariableToScript $(script) : <build>addattr ;
AddTargetVariableToScript $(script) : <build>copyattr ;
AddTargetVariableToScript $(script) : <mimedb>mime_db : mimeDB ;
AddTargetVariableToScript $(script) : <build>mimeset ;
AddTargetVariableToScript $(script) : <build>package ;
AddTargetVariableToScript $(script) : <build>rc ;
AddTargetVariableToScript $(script) : <build>resattr ;
AddTargetVariableToScript $(script) : <build>unzip ;
if $(HOST_RM_ATTRS_TARGET) {
AddTargetVariableToScript $(script) : $(HOST_RM_ATTRS_TARGET)
: rmAttrs ;
} else {
AddVariableToScript $(script) : rmAttrs : rm ;
}
# create the other scripts
local makeDirsScript = <$(grist)>haiku.package-make-dirs ;
local copyFilesScript = <$(grist)>haiku.package-copy-files ;
local extractFilesScript = <$(grist)>haiku.package-extract-files ;
MakeLocate $(makeDirsScript) $(copyFilesScript) $(extractFilesScript)
: $(scriptDir) ;
CreateContainerMakeDirectoriesScript $(package) : $(makeDirsScript) ;
CreateContainerCopyFilesScript $(package) : $(copyFilesScript) ;
CreateContainerExtractFilesScript $(package) : $(extractFilesScript) ;
local scripts = $(initVariablesScript) $(makeDirsScript)
$(copyFilesScript) $(extractFilesScript) ;
# call the build actions
local mainScript = build_haiku_package ;
SEARCH on $(mainScript) = [ FDirName $(HAIKU_TOP) build scripts ] ;
LocalDepends $(package) : $(mainScript) $(scripts) ;
BuildHaikuPackage1 $(package) : $(mainScript) $(packageInfo) $(scripts) ;
}
actions BuildHaikuPackage1
{
$(2[1]) "$(1)" "$(2[2])" $(2[3-])
}
rule AddDirectoryToPackage directoryTokens : attributeFiles
{
return [ AddDirectoryToContainer $(HAIKU_CURRENTLY_BUILT_HAIKU_PACKAGE)
: $(directoryTokens) : $(attributeFiles) ] ;
}
rule AddFilesToPackage directory : targets : destName
{
AddFilesToContainer $(HAIKU_CURRENTLY_BUILT_HAIKU_PACKAGE) : $(directory)
: $(targets) : $(destName) ;
}
rule AddSymlinkToPackage directoryTokens : linkTarget : linkName
{
linkTarget = $(linkTarget:J=/) ;
AddSymlinkToContainer $(HAIKU_CURRENTLY_BUILT_HAIKU_PACKAGE)
: $(directoryTokens) : $(linkTarget) : $(linkName) ;
}
rule CopyDirectoryToPackage directoryTokens : sourceDirectory
: targetDirectoryName : excludePatterns : flags
{
CopyDirectoryToContainer $(HAIKU_CURRENTLY_BUILT_HAIKU_PACKAGE)
: $(directoryTokens) : $(sourceDirectory) : $(targetDirectoryName)
: $(excludePatterns) : $(flags) ;
}
rule AddHeaderDirectoryToPackage dirTokens : dirName : flags
{
AddHeaderDirectoryToContainer $(HAIKU_CURRENTLY_BUILT_HAIKU_PACKAGE)
: $(dirTokens) : $(dirName) : $(flags) ;
}
rule AddWifiFirmwareToPackage driver : subDirToExtract : archive
: extract
{
AddWifiFirmwareToContainer $(HAIKU_CURRENTLY_BUILT_HAIKU_PACKAGE)
: $(driver) : $(subDirToExtract) : $(archive) : $(extract) ;
}
rule ExtractArchiveToPackage dirTokens : archiveFile : flags : extractedSubDir
{
ExtractArchiveToContainer $(HAIKU_CURRENTLY_BUILT_HAIKU_PACKAGE)
: $(dirTokens) : $(archiveFile) : $(flags) : $(extractedSubDir) ;
}
rule AddDriversToPackage relativeDirectoryTokens : targets
{
AddDriversToContainer $(HAIKU_CURRENTLY_BUILT_HAIKU_PACKAGE)
: $(relativeDirectoryTokens) : $(targets) ;
}
rule AddNewDriversToPackage relativeDirectoryTokens : targets
{
AddNewDriversToContainer $(HAIKU_CURRENTLY_BUILT_HAIKU_PACKAGE)
: $(relativeDirectoryTokens) : $(targets) ;
}
rule AddBootModuleSymlinksToPackage targets
{
AddBootModuleSymlinksToContainer $(HAIKU_CURRENTLY_BUILT_HAIKU_PACKAGE)
: $(targets) ;
}
rule AddLibrariesToPackage directory : libs
{
AddLibrariesToContainer $(HAIKU_CURRENTLY_BUILT_HAIKU_PACKAGE)
: $(directory) : $(libs) ;
}
# default value for the package compression level
HAIKU_PACKAGE_COMPRESSION_LEVEL ?= 9 ;