haiku/build/jam/FileRules

449 lines
12 KiB
Plaintext
Raw Normal View History

rule Copy
{
if $(2) {
SEARCH on $(2) += $(SEARCH_SOURCE) ;
Depends $(1) : <build>copyattr $(2) ;
Copy1 $(1) : <build>copyattr $(2) ;
}
}
actions Copy1
{
$(HOST_ADD_BUILD_COMPATIBILITY_LIB_DIR)
"$(2[1])" -d "$(2[2-])" "$(1)"
}
rule SymLink
{
# SymLink <target> : <source> : <makeDefaultDependencies> ;
# Links <target> to <source>.
# <source> is the exact link contents. No binding is done.
# <makeDefaultDependencies> If true, <target> will be made a dependency
# of the `all' pseudo target, i.e. it will be made by default, and removed
# on `jam clean'.
local target = $(1) ;
local source = $(2) ;
local makeDefaultDependencies = $(3) ;
if ! $(makeDefaultDependencies) {
makeDefaultDependencies = true ;
}
LINKCONTENTS on $(target) = $(source) ;
SymLink1 $(target) ;
if $(makeDefaultDependencies) = true {
LocalDepends files : $(target) ;
LocalClean clean : $(target) ;
}
}
actions SymLink1
{
$(RM) "$(1)" && $(LN) -s "$(LINKCONTENTS)" "$(1)"
}
rule RelSymLink
{
# RelSymLink <link> : <link target> : <makeDefaultDependencies> ;
# Creates a relative symbolic link from <link> to <link target>.
# <link> and <link target> can be usual targets. They may have a grist
# and don't need to have any dirname. Their LOCATE variables are used to
# find their locations.
# <makeDefaultDependencies> If true (which is the default), <link> will be
# made a dependency of the `files' pseudo target, i.e. it will be made by
# default, and removed on `jam clean'.
local target = $(1) ;
local source = $(2) ;
local makeDefaultDependencies = $(3) ;
local targetDir = [ on $(target) FDirName $(LOCATE[1]) $(target:D) ] ;
local sourceDir = [ on $(source) FDirName $(LOCATE[1]) $(source:D) ] ;
local sourcePath = $(source:G=) ;
sourcePath = $(sourcePath:D=$(sourceDir)) ;
local targetDirComponents = [ FSplitPath $(targetDir) ] ;
local sourceComponents = [ FSplitPath $(sourcePath) ] ;
SymLink $(target)
: [ FRelPath $(targetDirComponents) : $(sourceComponents) ]
: $(makeDefaultDependencies) ;
NOUPDATE $(target) ;
Depends $(target) : $(source) ;
}
rule AbsSymLink
{
# AbsSymLink <link> : <link target> : <link dir>
# : <makeDefaultDependencies> ;
# Creates an absolute symbolic link from <link> to <link target>.
# <link> and <link target> must be usual targets. If <link dir> is
# given, then it is set as LOCATE directory on <link>.
# <makeDefaultDependencies> If true (which is the default), <link> will be
# made a dependency of the `files' pseudo target, i.e. it will be made by
# default, and removed on `jam clean'.
local makeDefaultDependencies = $(4) ;
if ! $(makeDefaultDependencies) {
makeDefaultDependencies = true ;
}
Depends $(1) : $(2) ;
if $(3) {
MakeLocate $(1) : $(3) ;
}
SEARCH on $(2) += $(SEARCH_SOURCE) ;
if $(makeDefaultDependencies) = true {
LocalDepends files : $(1) ;
LocalClean clean : $(1) ;
}
}
actions AbsSymLink
{
target="$(2)"
case "$target" in
/*) ;;
*) target=`pwd`/"$target";;
esac
$(RM) "$(1)" && $(LN) -s "$target" "$(1)"
}
rule HaikuInstall installAndUninstall : dir : sources : installgrist
: installRule : targets
{
# Usage: HaikuInstall <[ install [ and uninstall ] pseudotarget ]>
# : <directory> : <sources to install> : [ <installgrist> ]
# : [ <install rule> ] : [ <targets> ] ;
local install = $(installAndUninstall[1]) ;
install ?= install ;
local uninstall = $(installAndUninstall[2]) ;
uninstall ?= un$(install) ;
installgrist ?= $(INSTALLGRIST) ;
installRule ?= Install ;
targets ?= $(sources) ;
targets = $(targets:G=$(installgrist)) ;
NotFile $(install) ;
NotFile $(uninstall) ;
Depends $(install) : $(targets) ;
Clean $(uninstall) : $(targets) ;
SEARCH on $(sources) += $(SEARCH_SOURCE) ;
MakeLocate $(targets) : $(dir) ;
local source ;
for source in $(sources) {
local target = $(targets[1]) ;
targets = $(targets[2-]) ;
Depends $(target) : $(source) ;
$(installRule) $(target) : $(source) ;
if [ on $(target) return $(MODE) ] {
Chmod $(target) ;
}
if $(OWNER) && $(CHOWN) {
Chown $(target) ;
OWNER on $(target) = $(OWNER) ;
}
if $(GROUP) && $(CHGRP) {
Chgrp $(target) ;
GROUP on $(target) = $(GROUP) ;
}
}
}
rule InstallAbsSymLinkAdapter
{
# InstallAbsSymLinkAdapter <link> : <link target>
if ! [ on $(2) return $(TARGET) ] {
TARGET on $(2) = [ on $(2) return $(SEARCH) ] ;
}
AbsSymLink $(1) : $(2) : : false ;
}
rule HaikuInstallAbsSymLink
{
# Usage: HaikuInstallAbsSymLink <[ install [ and uninstall ] pseudotarget ]>
# : <directory> : <sources to install>
# : [ <installgrist> ] ;
HaikuInstall $(1) : $(2) : $(3) : $(4) : InstallAbsSymLinkAdapter ;
}
rule InstallRelSymLinkAdapter
{
# InstallRelSymLinkAdapter <link> : <link target>
if ! [ on $(2) return $(TARGET) ] {
TARGET on $(2) = [ on $(2) return $(SEARCH) ] ;
}
RelSymLink $(1) : $(2) : false ;
}
rule HaikuInstallRelSymLink
{
# Usage: HaikuInstallRelSymLink <[ install [ and uninstall ] pseudotarget ]>
# : <directory> : <sources to install>
# : [ <installgrist> ] ;
HaikuInstall $(1) : $(2) : $(3) : $(4) : InstallRelSymLinkAdapter ;
}
rule UnarchiveObjects
{
# UnarchiveObjects <target objects> : <static object>
MakeLocateArch $(1) ;
Depends $(1) : $(2) ;
SEARCH on $(2) = $(SEARCH_SOURCE) ;
}
actions UnarchiveObjects
{
( cd $(1[1]:D) && $(TARGET_AR_$(TARGET_PACKAGING_ARCH)) \
$(TARGET_UNARFLAGS_$(TARGET_PACKAGING_ARCH)) "$(2)" $(1:BS) )
}
rule ExtractArchive directory : entries : archiveFile : grist
{
# ExtractArchive <directory> : <entries> : <archiveFile> [ : <grist> ]
#
# Extract the archive file target <archiveFile> to directory <directory>.
# The rule can be called multiple times for different <entries> for the same
# <directory> and <archiveFile> combo.
#
# <directory> - The directory into which to extract the archive file. The
2012-07-04 03:15:26 +04:00
# directory is created by this rule and it is the target
# that the extract action is associated with.
# <entries> - The entries of the archive file one is interested in. The
# rule always extracts the complete archive file, from the
# given entries the rule creates targets (using <grist>)
# representing the extracted entries. Those targets are
# returned by the rule.
# <archiveFile> - The archive file target to extract.
# <grist> - The grist used to create targets from <entries>. Defaults to
# "extracted".
grist ?= extracted ;
# Turn the entries into targets to build.
local targets ;
local entry ;
for entry in $(entries) {
local target = $(entry:G=$(grist)) ;
targets += $(target) ;
}
LOCATE on $(targets) = $(directory:G=) ;
Depends $(targets) : $(directory) $(archiveFile) ;
NoUpdate $(targets) ;
# one-time initialization for the main target (the directory)
if ! [ on $(directory) return $(INITIALIZED) ] {
# make sure the parent dir exists
local parentDir = $(directory:PG=dir) ;
Depends $(directory) : $(parentDir) ;
MkDir $(parentDir) ;
NoUpdate $(directory) ;
Depends $(directory) : $(archiveFile) ;
switch $(archiveFile:S)
{
2011-06-20 00:18:55 +04:00
case .zip :
ExtractZipArchive1 $(directory) : $(archiveFile) ;
2011-06-20 00:18:55 +04:00
case .tgz :
ExtractTarArchive1 $(directory) : $(archiveFile) ;
2011-06-20 00:18:55 +04:00
case .hpkg :
Depends $(directory) : <build>package ;
ExtractHPKGArchive1 $(directory)
: <build>package $(archiveFile) ;
2011-06-20 00:18:55 +04:00
Merge branch 'master' into package-management Additional changes: * Add src/system/kernel/lib/zlib, which builds a kernel version of zlib, needed by packagefs. * BuildFeatures: Add a build feature "gcc2" to allow for easier checks. * Referenceable.cpp: Include <OS.h> instead of <debugger.h>. The latter is not needed and prevents building for the build platform. * zlib/zutil.h: Fix gcc 2 build. We really should use the external package instead. Conflicts: .gitignore build/jam/BuildSetup build/jam/FileRules build/jam/FloppyBootImage build/jam/HaikuImage build/jam/ImageRules build/jam/KernelRules build/jam/NetBootArchive build/jam/OptionalBuildFeatures build/jam/OptionalLibPackages build/jam/OptionalPackageDependencies build/jam/OptionalPackages build/scripts/build_haiku_image configure data/bin/installoptionalpackage data/system/boot/Bootscript headers/os/app/Message.h headers/os/package/PackageInfo.h headers/os/package/PackageInfoAttributes.h headers/os/package/PackageInfoSet.h headers/os/package/PackageRoster.h headers/os/package/PackageVersion.h headers/os/package/hpkg/PackageInfoAttributeValue.h headers/os/storage/FindDirectory.h headers/os/storage/Node.h headers/os/support/StringList.h headers/private/system/directories.h src/add-ons/kernel/drivers/audio/ac97/es1370/Jamfile src/add-ons/kernel/file_systems/packagefs/AttributeIndex.cpp src/add-ons/kernel/file_systems/packagefs/Jamfile src/add-ons/kernel/file_systems/packagefs/Package.cpp src/add-ons/kernel/file_systems/packagefs/Package.h src/add-ons/kernel/file_systems/packagefs/PackageDomain.cpp src/add-ons/kernel/file_systems/packagefs/PackageDomain.h src/add-ons/kernel/file_systems/packagefs/PackageFSRoot.cpp src/add-ons/kernel/file_systems/packagefs/PackageLinkDirectory.cpp src/add-ons/kernel/file_systems/packagefs/PackageLinkDirectory.h src/add-ons/kernel/file_systems/packagefs/PackageLinkSymlink.cpp src/add-ons/kernel/file_systems/packagefs/PackageLinkSymlink.h src/add-ons/kernel/file_systems/packagefs/PackageLinksDirectory.cpp src/add-ons/kernel/file_systems/packagefs/PackageNode.h src/add-ons/kernel/file_systems/packagefs/ResolvableFamily.cpp src/add-ons/kernel/file_systems/packagefs/Version.cpp src/add-ons/kernel/file_systems/packagefs/Version.h src/add-ons/kernel/file_systems/packagefs/Volume.cpp src/add-ons/kernel/file_systems/packagefs/Volume.h src/add-ons/kernel/file_systems/packagefs/kernel_interface.cpp src/add-ons/kernel/file_systems/userlandfs/shared/driver_settings.c src/apps/deskbar/BarApp.cpp src/apps/deskbar/BarMenuBar.cpp src/apps/deskbar/BarMenuBar.h src/apps/deskbar/BarView.cpp src/apps/deskbar/BarView.h src/apps/deskbar/BarWindow.cpp src/apps/deskbar/BarWindow.h src/apps/deskbar/DeskbarMenu.cpp src/apps/deskbar/DeskbarMenu.h src/apps/deskbar/DeskbarUtils.cpp src/apps/deskbar/DeskbarUtils.h src/apps/deskbar/ExpandoMenuBar.cpp src/apps/deskbar/ExpandoMenuBar.h src/apps/deskbar/TeamMenu.cpp src/apps/processcontroller/ProcessController.cpp src/apps/remotedesktop/RemoteDesktop.cpp src/bin/bash/config-top.h src/bin/finddir.c src/bin/package/Jamfile src/bin/package/command_add.cpp src/bin/package/command_create.cpp src/bin/package/command_list.cpp src/bin/package_repo/command_list.cpp src/bin/pkgman/command_refresh.cpp src/build/libbe/support/Jamfile src/build/libpackage/Jamfile src/build/libroot/Jamfile src/build/libroot/fs.cpp src/build/libroot/remapped_functions.h src/kits/locale/MutableLocaleRoster.cpp src/kits/opengl/GLRendererRoster.cpp src/kits/package/PackageInfo.cpp src/kits/package/PackageInfoSet.cpp src/kits/package/PackageRoster.cpp src/kits/package/PackageVersion.cpp src/kits/package/RepositoryCache.cpp src/kits/package/hpkg/PackageWriterImpl.cpp src/kits/package/hpkg/ReaderImplBase.cpp src/kits/package/hpkg/WriterImplBase.cpp src/kits/print/PrintTransport.cpp src/kits/print/Printer.cpp src/kits/screensaver/ScreenSaverRunner.cpp src/kits/support/StringList.cpp src/kits/tracker/ContainerWindow.cpp src/kits/tracker/DeskWindow.cpp src/kits/tracker/PoseView.cpp src/libs/print/libprint/Transport.cpp src/preferences/printers/AddPrinterDialog.cpp src/preferences/screensaver/ScreenSaverWindow.cpp src/servers/debug/DebugServer.cpp src/servers/input/AddOnManager.cpp src/servers/media_addon/MediaAddonServer.cpp src/system/boot/Jamfile src/system/boot/loader/Jamfile src/system/boot/loader/loader.cpp src/system/boot/loader/vfs.cpp src/system/kernel/fs/vfs.cpp src/system/kernel/fs/vfs_boot.cpp src/system/libroot/os/find_directory.cpp src/system/runtime_loader/runtime_loader.cpp src/tools/package/Jamfile
2013-05-05 17:02:57 +04:00
case "" :
Exit "ExtractArchive: No archive passed" ;
2011-06-20 00:18:55 +04:00
case * :
Exit "ExtractArchive: Unhandled archive extension:"
"$(archiveFile:S)" ;
}
INITIALIZED on $(directory) = 1 ;
}
return $(targets) ;
}
2011-06-20 00:18:55 +04:00
actions ExtractZipArchive1
{
mkdir -p $(1)
unzip -q -u -o -d $(1) $(2)
}
actions ExtractTarArchive1
{
mkdir -p $(1)
tar -C $(1) -xf $(2)
}
2011-06-20 00:18:55 +04:00
actions ExtractHPKGArchive1
{
mkdir -p "$(1)"
2011-06-20 00:18:55 +04:00
$(HOST_ADD_BUILD_COMPATIBILITY_LIB_DIR)
$(2[1]) extract -C "$(1)" "$(2[2])"
2011-06-20 00:18:55 +04:00
}
rule ObjectReference
{
# ObjectReference <reference object> : <source object>
# Makes <reference object> refer to the same file as <source object>.
# The filenames must of course be identical.
# <source object> must have already been LOCATEd.
local ref = $(1) ;
local source = $(2) ;
if $(ref) != $(source) {
Depends $(ref) : $(source) ;
LOCATE on $(ref) = [ on $(source) return $(LOCATE) ] ;
}
}
rule ObjectReferences
{
# ObjectReferences <source objects>
# Creates local references to <source objects>, i.e. identifiers with the
# current grist referring to the same files. <source objects> must have
# already been LOCATEd.
local source ;
for source in $(1) {
ObjectReference [ FGristFiles $(source) ] : $(source) ;
}
}
rule CopySetHaikuRevision target : source
{
# CopySetHaikuRevision <target> : <source>
#
# Copy <source> to <target>, writing the SVN revision of the working root
# directory into the haiku revision section of <target>.
#
# <target> - Output file target. Gristed and located target.
# <source> - ELF object to be copied. Gristed and located target.
# If existent, make the target depend on the .svn/entries file in the
# root directory, so it gets updated when the revision changes due to
# "svn up".
if [ Glob [ FDirName $(HAIKU_TOP) .svn ] : entries ] {
local svnEntries = <haiku-rootdir-svn>entries ;
SEARCH on $(svnEntries) = [ FDirName $(HAIKU_TOP) .svn ] ;
Depends $(target) : $(svnEntries) ;
} else if [ Glob [ FDirName $(HAIKU_TOP) .git ] : index ] {
local gitIndex = <haiku-rootdir-git>index ;
SEARCH on $(gitIndex) = [ FDirName $(HAIKU_TOP) .git ] ;
Depends $(target) : $(gitIndex) ;
} else if [ Glob [ FDirName $(HAIKU_TOP) .hg ] : store ] {
local hgStore = <haiku-rootdir-hg>store ;
SEARCH on $(hgStore) = [ FDirName $(HAIKU_TOP) .hg ] ;
Depends $(target) : $(hgStore) ;
}
PropagateContainerUpdateTargetFlags $(target) : $(source) ;
Depends $(target) : <build>copyattr <build>set_haiku_revision $(source) ;
CopySetHaikuRevision1 $(target)
: <build>copyattr <build>set_haiku_revision $(source) ;
}
actions CopySetHaikuRevision1
{
$(HOST_ADD_BUILD_COMPATIBILITY_LIB_DIR)
. $(HAIKU_TOP)/build/scripts/determine_haiku_revision
determineHaikuRevision $(HAIKU_TOP) $(HAIKU_BUILD_OUTPUT_DIR)
$(2[1]) --data $(2[3]) $(1) &&
$(2[2]) $(1) ${revision}
}
rule DataFileToSourceFile sourceFile : dataFile : dataVariable : sizeVariable
{
sourceFile = [ FGristFiles $(sourceFile) ] ;
MakeLocateCommonPlatform $(sourceFile) ;
sizeVariable ?= $(dataVariable)Size ;
DATA_VARIABLE on $(sourceFile) = $(dataVariable) ;
SIZE_VARIABLE on $(sourceFile) = $(sizeVariable) ;
Depends $(sourceFile) : <build>data_to_source $(dataFile) ;
DataFileToSourceFile1 $(sourceFile) : <build>data_to_source $(dataFile) ;
LocalClean clean : $(sourceFile) ;
}
actions DataFileToSourceFile1
{
$(HOST_ADD_BUILD_COMPATIBILITY_LIB_DIR)
$(2[1]) $(DATA_VARIABLE) $(SIZE_VARIABLE) $(2[2]) $(1)
}
rule DownloadLocatedFile target : url : source
{
# DownloadLocatedFile <target> : <url> [ : <source> ] ;
#
# <source> is an optional target that <target> will be made dependent on.
# Its resolved path can be used in <url> via '$source'.
URL on $(target) = $(url) ;
if $(source) {
Depends $(target) : $(source) ;
}
DownloadLocatedFile1 $(target) : $(source) ;
}
actions DownloadLocatedFile1
{
source="$(2)"
wget -O "$(1)" $(URL)
touch "$(1)"
}
rule DownloadFile file : url : source
{
# DownloadFile <file> : <url> [ : <source> ] ;
#
# <source> is an optional target that the target will be made dependent on.
# Its resolved path can be used in <url> via '$source'.
file = $(file:G=download) ;
# Request the download only once.
if [ on $(file) return $(HAIKU_FILE_DOWNLOAD) ] {
return $(file) ;
}
HAIKU_FILE_DOWNLOAD on $(file) = 1 ;
MakeLocate $(file) : $(HAIKU_DOWNLOAD_DIR) ;
DownloadLocatedFile $(file) : $(url) : $(source) ;
return $(file) ;
}
2013-07-06 04:19:51 +04:00
actions ChecksumFileSHA256
{
$(HOST_SHA256) $(2) | sed -r 's,([^[:space:]]*).*,\1,' > $(1)
# The sed part is only necessary for sha256sum, but it doesn't harm for
# sha256 either.
}