haiku/build/jam/BeOSRules
Adrien Destugues 0a255c0c6a Cleanup of the locale kit tools :
-Jamrule for collectcatkeys no longer print all the strings, only a message when it can't parse one (happens for TR(variable) basically)
-Added fingerprint check in the plaintext catalog ReadFromFile. However, the adler checksum is different each time the catalog is loaded because it relies on the string being iterated always in the same order, but this is not always the case with an HashMap ! Some rethinking is needed, so disabled the check for now so it does not breaks the build
-Some try to debug the bluetooth preflet localization. Still buggy, but I wanted to commit all this mess before I break everything up again.
-Also sorted the fr.catkeys files to be in the same order as the autogenerated en.catkeys (this is useless but makes them easier to check) and updated their fingerprint even if they are still not checked.
-Miscelaneous style fixes, small bugfixes, more error checking and error messages saying where they come from.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33322 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-09-27 21:19:52 +00:00

386 lines
11 KiB
Plaintext

# BeOS specific rules
rule AddFileDataAttribute target : attrName : attrType : dataFile
{
# AddFileAttribute <target> : <attrName> : <attrType> : <dataFile> ;
# Adds a single attribute to a file, retrieving the attribute data from
# a separate file.
# <target>: The file to which the attribute shall be added.
# <attrName>: The name of the attribute.
# <attrType>: Attribute type as supported by addattr (string, int, etc.)
# <dataFile>: The data to be written to the attribute will be read from
# that file.
# Note that this is supposed to be a build target, not a path
# name - if you need to add a data file in a different path,
# you have to locate it first.
#
# We need to create a temporary file in which we store the attribute name
# and type. Otherwise we wouldn't have these data available in the
# addattr actions.
local id = [ NextID ] ;
local attrMetaFile
= [ FGristFiles $(target:G=)-attr-$(attrName)-$(attrType)-$(id) ] ;
ATTRIBUTE_NAME on $(attrMetaFile) = $(attrName) ;
ATTRIBUTE_TYPE on $(attrMetaFile) = $(attrType) ;
MakeLocateArch $(attrMetaFile) ;
CreateAttributeMetaFile $(attrMetaFile) ;
Depends $(target) : <build>addattr $(attrMetaFile) $(dataFile) ;
AddFileDataAttribute1 $(target)
: <build>addattr $(attrMetaFile) $(dataFile) ;
}
actions CreateAttributeMetaFile
{
echo "-t $(ATTRIBUTE_TYPE)" "$(ATTRIBUTE_NAME)" > "$(1)"
}
actions AddFileDataAttribute1
{
$(HOST_ADD_BUILD_COMPATIBILITY_LIB_DIR)
$(2[1]) -f $(2[3]) `cat $(2[2])` $(1)
}
rule AddStringDataResource
{
# AddStringDataResource <target> : <resourceID> : <dataString>
# Adds a single resource to the resources of an executable/library.
# <target>: The executable/library.
# <resourceID>: A resource ID string as understood by xres (type:id[:name]).
# <dataString>: The string <dataString> will be written to the resource.
# Defaults to "".
#
local target = $(1) ;
local resourceID = $(2) ;
local dataString = $(3:E="") ;
# the resource file
local resources
= [ FGristFiles $(target:B)-added-string-data-resources.rsrc ] ;
# add the resource file to the target, if not yet done
if ! [ on $(resources) return $(RESOURCES_ADDED) ] {
RESOURCES_ADDED on $(resources) = true ;
MakeLocateArch $(resources) ;
Depends $(resources) : <build>xres ;
AddStringDataResource1 $(resources) : <build>xres ;
AddResources $(target) : $(resources) ;
}
RESOURCE_STRINGS on $(resources)
+= "-a "$(resourceID)" -s \""$(dataString)"\"" ;
}
actions together AddStringDataResource1
{
$(HOST_ADD_BUILD_COMPATIBILITY_LIB_DIR)
$(2[1]) -o "$(1)" $(RESOURCE_STRINGS)
}
rule AddFileDataResource
{
# AddFileDataResource <target> : <resourceID> : [ <dataFile> ]
# Adds a single resource to the resources of an executable/library.
# <target>: The executable/library.
# <resourceID>: A resource ID string as understood by xres (type:id[:name]).
# <dataFile>: The data to be written into the resource will be read from
# that file.
# Note that this is supposed to be a build target, not a path
# name - if you need to add a data file in a different path, you
# have to locate it first.
#
local target = $(1) ;
local resourceID = $(2) ;
local dataFile = $(3) ;
# the resource file
local resources
= <added-resources>file-data-$(resourceID)-$(dataFile).rsrc ;
# add it to the resources of the given target
AddResources $(target) : $(resources) ;
# if the rule for creating the resource file has not been invoked yet, do it
if ! [ on $(resources) return $(RESOURCES_DEFINED) ] {
RESOURCES_DEFINED on $(resources) = true ;
RESOURCE_ID on $(resources) = $(resourceID) ;
MakeLocateArch $(resources) ;
Depends $(resources) : <build>xres $(dataFile) ;
AddFileDataResource1 $(resources) : <build>xres $(dataFile) ;
}
}
actions AddFileDataResource1
{
$(HOST_ADD_BUILD_COMPATIBILITY_LIB_DIR)
$(2[1]) -o "$(1)" -a "$(RESOURCE_ID)" "$(2[2])" ;
}
rule XRes
{
# XRes <target> : <resource files>
if $(2)
{
Depends $(1) : <build>xres $(2) ;
XRes1 $(1) : <build>xres $(2) ;
}
}
actions XRes1
{
$(HOST_ADD_BUILD_COMPATIBILITY_LIB_DIR)
$(2[1]) -o "$(1)" "$(2[2-])" ;
}
rule SetVersion
{
# SetVersion <target>
Depends $(1) : <build>setversion ;
SetVersion1 $(1) : <build>setversion ;
}
actions SetVersion1
{
$(HOST_ADD_BUILD_COMPATIBILITY_LIB_DIR)
$(2[1]) "$(1)" -system $(HAIKU_BUILD_VERSION) -short "$(HAIKU_BUILD_DESCRIPTION)" ;
}
rule SetType
{
# SetType <target>
Depends $(1) : <build>settype ;
SetType1 $(1) : <build>settype ;
}
actions SetType1
{
$(HOST_ADD_BUILD_COMPATIBILITY_LIB_DIR)
$(2[1]) -t $(TARGET_EXECUTABLE_MIME_TYPE) "$(1)" ;
}
rule MimeSet
{
# MimeSet <target>
Depends $(1) : <build>mimeset ;
MimeSet1 $(1) : <build>mimeset ;
}
actions MimeSet1
{
$(HOST_ADD_BUILD_COMPATIBILITY_LIB_DIR)
$(2[1]) -f "$(1)" ;
}
rule ResComp
{
# ResComp <resource file> : <rdef file> ;
#
# <resource file> and <rdef file> must be gristed.
# get compiler and defines for the platform
local cc ;
local defines ;
local localIncludesOption ;
on $(1) { # use on $(1) variable values
defines = $(DEFINES) ;
if $(PLATFORM) = host {
defines += $(HOST_DEFINES) ;
cc = $(HOST_CC) ;
localIncludesOption = $(HOST_LOCAL_INCLUDES_OPTION) ;
} else {
defines += $(TARGET_DEFINES) ;
cc = $(TARGET_CC) ;
localIncludesOption = $(TARGET_LOCAL_INCLUDES_OPTION) ;
}
}
DEFINES on $(1) = $(defines) ;
CCDEFS on $(1) = [ FDefines $(defines) ] ;
HDRS on $(1) = [ FIncludes $(SEARCH_SOURCE) $(SUBDIRHDRS) $(HDRS)
: $(localIncludesOption) ] ;
RCHDRS on $(1) = [ FIncludes $(SEARCH_SOURCE) $(SUBDIRHDRS) $(HDRS)
: "-I " ] ;
CC on $(1) = $(cc) ;
# set up other vars
SEARCH on $(2) += $(SEARCH_SOURCE) ;
MakeLocateArch $(1) ;
Depends $(1) : $(2) <build>rc ;
LocalClean clean : $(1) ;
ResComp1 $(1) : <build>rc $(2) ;
}
# Note: We pipe the input files into the preprocessor, since *.rdef files are
# considered linker scripts, and thus we can use preprocessor features.
actions ResComp1
{
$(HOST_ADD_BUILD_COMPATIBILITY_LIB_DIR)
cat "$(2[2-])" | $(CC) -E $(CCDEFS) $(HDRS) - | egrep -v '^#' | $(2[1]) $(RCHDRS) --auto-names -o "$(1)" -
}
rule ResAttr attributeFile : _resourceFiles : deleteAttributeFile
{
# ResAttr <attribute file> : <resource files> [ : <delete file> ] ;
#
# <attribute file> and <resource files> must be gristed.
# <resource files> can also be .rdef files -- they will be compiled first in
# this case.
# <clear file> is a boolean that specifies wether or not the target file
# should be removed before writing. Defaults to true.
local resourceFiles ;
local resourceFile ;
deleteAttributeFile ?= true ;
deleteAttributeFile1 on $(1) = $(deleteAttributeFile) ;
for resourceFile in $(_resourceFiles) {
# if the specified resource file is an .rdef file, we compile it first
if $(resourceFile:S) = ".rdef" {
local rdefFile = $(resourceFile) ;
resourceFile = $(rdefFile:S=.rsrc) ;
ResComp $(resourceFile) : $(rdefFile) ;
} else {
SEARCH on $(resourceFile) += $(SEARCH_SOURCE) ;
}
resourceFiles += $(resourceFile) ;
}
MakeLocateArch $(attributeFile) ;
Depends $(attributeFile) : $(resourceFiles) <build>resattr ;
LocalClean clean : $(attributeFile) ;
ResAttr1 $(attributeFile) : <build>resattr $(resourceFiles) ;
}
actions ResAttr1
{
$(HOST_ADD_BUILD_COMPATIBILITY_LIB_DIR)
if [ \\"$(deleteAttributeFile1)\\" = "true" ]; then
$(RM) $(1)
fi
$(2[1]) -O -o "$(1)" "$(2[2-])"
}
# Localization rules
# Extract catalog entries from the sourcefile and put the output textfile in
# target. This output file is then used to create the binary catalog with
# linkcatkeys.
rule ExtractCatalogEntries target : source : signature
{
# get compiler and defines for the platform
local headers ;
local sysHeaders ;
local cc ;
local defines ;
local localIncludesOption ;
local systemIncludesOption ;
on $(target) { # use on $(target) variable values
headers = $(HAIKU_CONFIG_HEADERS) $(SEARCH_SOURCE) $(SUBDIRHDRS)
$(HDRS) ;
sysHeaders = $(SUBDIRSYSHDRS) $(SYSHDRS) ;
defines = $(DEFINES) ;
if $(PLATFORM) = host {
sysHeaders += $(HOST_HDRS) ;
defines += $(HOST_DEFINES) ;
if $(USES_BE_API) {
sysHeaders += $(HOST_BE_API_HEADERS) ;
}
defines += $(HOST_DEFINES) ;
cc = $(HOST_CC) ;
localIncludesOption = $(HOST_LOCAL_INCLUDES_OPTION) ;
systemIncludesOption = $(HOST_SYSTEM_INCLUDES_OPTION) ;
} else {
sysHeaders += $(TARGET_HDRS) ;
defines += $(TARGET_DEFINES) ;
defines += $(TARGET_DEFINES) ;
cc = $(TARGET_CC) ;
localIncludesOption = $(TARGET_LOCAL_INCLUDES_OPTION) ;
systemIncludesOption = $(TARGET_SYSTEM_INCLUDES_OPTION) ;
}
}
DEFINES on $(target) = $(defines) ;
CCDEFS on $(target) = [ FDefines $(defines) ] ;
HDRS on $(target) = [ FIncludes $(headers) : $(localIncludesOption) ]
$(includesSeparator)
[ FSysIncludes $(sysHeaders) : $(systemIncludesOption) ] ;
CC on $(target) = $(cc) ;
LOCALE_KIT_SIGNATURE on $(target) = $(signature) ;
SEARCH on $(source) += $(SEARCH_SOURCE) ;
MakeLocatePlatform $(target) ;
Depends $(target) : $(source) <build>collectcatkeys ;
LocalClean clean : $(target) ;
ExtractCatalogEntries1 $(target) : <build>collectcatkeys $(source) ;
}
actions ExtractCatalogEntries1
{
$(HOST_ADD_BUILD_COMPATIBILITY_LIB_DIR)
cat "$(2[2-])" | $(CC) -E $(CCDEFS) $(HDRS) - > "$(1)".pre
$(2[1]) -s $(LOCALE_KIT_SIGNATURE) -w -o "$(1)" "$(1)".pre
}
# Link catalog entries from given catkey file into output compiled catalog file.
# Compiled catalog file will then be copied into the image, but only if the
# fingerprint matches the one from the untranslated catalog for the same file.
rule LinkApplicationCatalog target : sources : signature : language
{
MakeLocateArch $(target) ;
LOCALE_KIT_SIGNATURE on $(target) = $(signature) ;
Depends $(target) : $(sources) <build>linkcatkeys ;
LocalClean clean : $(target) ;
LinkApplicationCatalog1 $(target)
: <build>linkcatkeys $(language) $(sources) ;
}
actions LinkApplicationCatalog1
{
$(HOST_ADD_BUILD_COMPATIBILITY_LIB_DIR)
$(2[1]) "$(2[3-])" -l $(2[2]:B) -v -s $(LOCALE_KIT_SIGNATURE) -o "$(1)"
}
# General rules to invoke from jamfiles and that do (almost) everything related
# to localization
rule DoCatalogs appName # Application name
: signature # Application MIME signature (must match the one
# declared in the sourcecode)
: sources # List of cpp files where to search keys
: generatedCatalog # Name of the generated catalog (most probably
# english.catalog)
: translatedCatalogs # List of available translations
{
genCat = [ FGristFiles $(generatedCatalog) ] ;
trans = [ FGristFiles $(translatedCatalogs) ] ;
SEARCH on $(trans) += $(SEARCH_SOURCE) ;
ExtractCatalogEntries $(genCat:S=.catkeys) : $(sources) : $(signature) ;
LinkApplicationCatalog $(genCat) : $(genCat:S=.catkeys)
: $(signature) : $(genCat:B) ;
for catalog in $(trans)
{
LinkApplicationCatalog $(catalog:S=.catalog) : $(catalog)
: $(signature) : $(catalog:B) ;
}
AddFilesToHaikuImage system etc locale catalogs $(signature) :
$(genCat) $(trans:S=.catalog) ;
}