2010-07-23 23:56:24 +04:00
|
|
|
# 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.
|
2010-07-26 02:47:39 +04:00
|
|
|
rule ExtractCatalogEntries target : sources : signature : regexp
|
2010-07-23 23:56:24 +04:00
|
|
|
{
|
|
|
|
# get compiler and defines for the platform
|
|
|
|
local headers ;
|
|
|
|
local sysHeaders ;
|
|
|
|
local cc ;
|
|
|
|
local defines ;
|
2013-05-14 00:42:13 +04:00
|
|
|
local includesSeparator ;
|
2010-07-23 23:56:24 +04:00
|
|
|
local localIncludesOption ;
|
|
|
|
local systemIncludesOption ;
|
|
|
|
|
|
|
|
on $(target) { # use on $(target) variable values
|
2012-04-16 02:03:28 +04:00
|
|
|
defines = $(DEFINES) ;
|
2010-07-23 23:56:24 +04:00
|
|
|
headers = $(HAIKU_CONFIG_HEADERS) $(SEARCH_SOURCE) $(SUBDIRHDRS)
|
|
|
|
$(HDRS) ;
|
2012-08-16 23:10:53 +04:00
|
|
|
sysHeaders = $(SUBDIRSYSHDRS) $(SYSHDRS) ;
|
2010-07-23 23:56:24 +04:00
|
|
|
|
|
|
|
if $(PLATFORM) = host {
|
|
|
|
sysHeaders += $(HOST_HDRS) ;
|
|
|
|
defines += $(HOST_DEFINES) ;
|
2013-05-14 00:42:13 +04:00
|
|
|
cc = $(HOST_CC) ;
|
2010-07-23 23:56:24 +04:00
|
|
|
if $(USES_BE_API) {
|
|
|
|
sysHeaders += $(HOST_BE_API_HEADERS) ;
|
|
|
|
}
|
2013-05-14 00:42:13 +04:00
|
|
|
|
|
|
|
includesSeparator = $(HOST_INCLUDES_SEPARATOR) ;
|
2010-07-23 23:56:24 +04:00
|
|
|
localIncludesOption = $(HOST_LOCAL_INCLUDES_OPTION) ;
|
|
|
|
systemIncludesOption = $(HOST_SYSTEM_INCLUDES_OPTION) ;
|
|
|
|
} else {
|
2013-08-01 10:51:16 +04:00
|
|
|
sysHeaders += $(TARGET_HDRS_$(TARGET_PACKAGING_ARCH)) ;
|
|
|
|
defines += $(TARGET_DEFINES_$(TARGET_PACKAGING_ARCH))
|
|
|
|
$(TARGET_DEFINES) ;
|
|
|
|
cc = $(TARGET_CC_$(TARGET_PACKAGING_ARCH)) ;
|
|
|
|
|
|
|
|
includesSeparator
|
|
|
|
= $(TARGET_INCLUDES_SEPARATOR_$(TARGET_PACKAGING_ARCH)) ;
|
|
|
|
localIncludesOption
|
|
|
|
= $(TARGET_LOCAL_INCLUDES_OPTION_$(TARGET_PACKAGING_ARCH)) ;
|
|
|
|
systemIncludesOption
|
|
|
|
= $(TARGET_SYSTEM_INCLUDES_OPTION_$(TARGET_PACKAGING_ARCH)) ;
|
2010-07-23 23:56:24 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
DEFINES on $(target) = $(defines) ;
|
|
|
|
CCDEFS on $(target) = [ FDefines $(defines) ] ;
|
|
|
|
HDRS on $(target) = [ FIncludes $(headers) : $(localIncludesOption) ]
|
|
|
|
$(includesSeparator)
|
|
|
|
[ FSysIncludes $(sysHeaders) : $(systemIncludesOption) ] ;
|
|
|
|
CC on $(target) = $(cc) ;
|
|
|
|
|
|
|
|
HAIKU_CATALOG_SIGNATURE on $(target) = $(signature) ;
|
|
|
|
if $(regexp) = "" {
|
|
|
|
HAIKU_CATALOG_REGEXP on $(target) = ;
|
|
|
|
} else {
|
|
|
|
HAIKU_CATALOG_REGEXP on $(target) = -r $(regexp) ;
|
|
|
|
}
|
|
|
|
|
2010-07-26 02:47:39 +04:00
|
|
|
SEARCH on $(sources) += $(SEARCH_SOURCE) ;
|
2010-07-23 23:56:24 +04:00
|
|
|
|
2012-04-16 02:03:28 +04:00
|
|
|
local subdir = [ on $(signature) return $(HAIKU_CATALOGS_SUBDIR) ] ;
|
|
|
|
MakeLocate $(target) : [ FDirName $(HAIKU_CATALOGS_OBJECT_DIR) $(subdir) ] ;
|
2010-07-26 02:47:39 +04:00
|
|
|
Depends $(target) : $(sources) <build>collectcatkeys ;
|
2010-07-23 23:56:24 +04:00
|
|
|
LocalClean clean : $(target).pre ;
|
2010-07-26 02:47:39 +04:00
|
|
|
ExtractCatalogEntries1 $(target) : <build>collectcatkeys $(sources) ;
|
2010-07-23 23:56:24 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
actions ExtractCatalogEntries1
|
|
|
|
{
|
|
|
|
$(HOST_ADD_BUILD_COMPATIBILITY_LIB_DIR)
|
2012-08-16 23:10:53 +04:00
|
|
|
cat "$(2[2-])" \
|
|
|
|
| $(CC) -E $(CCDEFS) -DB_COLLECTING_CATKEYS $(HDRS) - > "$(1)".pre
|
2010-07-26 02:47:39 +04:00
|
|
|
$(2[1]) $(HAIKU_CATALOG_REGEXP) -s $(HAIKU_CATALOG_SIGNATURE) \
|
|
|
|
-w -o "$(1)" "$(1)".pre
|
2010-07-23 23:56:24 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
rule LinkApplicationCatalog target : sources : signature : language
|
|
|
|
{
|
|
|
|
# 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.
|
|
|
|
|
2012-04-16 02:03:28 +04:00
|
|
|
local subdir = [ on $(signature) return $(HAIKU_CATALOGS_SUBDIR) ] ;
|
|
|
|
MakeLocate $(target) : [ FDirName $(HAIKU_CATALOGS_OBJECT_DIR) $(subdir) ] ;
|
2010-07-23 23:56:24 +04:00
|
|
|
Depends $(target) : $(sources) <build>linkcatkeys ;
|
|
|
|
LocalClean clean : $(target) ;
|
|
|
|
|
|
|
|
HAIKU_CATALOG_SIGNATURE on $(target) = $(signature) ;
|
|
|
|
HAIKU_CATALOG_LANGUAGE on $(target) = $(language) ;
|
|
|
|
LinkApplicationCatalog1 $(target) : <build>linkcatkeys $(sources) ;
|
|
|
|
}
|
|
|
|
|
|
|
|
actions LinkApplicationCatalog1
|
|
|
|
{
|
|
|
|
$(HOST_ADD_BUILD_COMPATIBILITY_LIB_DIR)
|
|
|
|
$(2[1]) "$(2[2-])" -l $(HAIKU_CATALOG_LANGUAGE) \
|
|
|
|
-s $(HAIKU_CATALOG_SIGNATURE) -o "$(1)"
|
|
|
|
}
|
|
|
|
|
2010-10-24 06:49:44 +04:00
|
|
|
rule DoCatalogs target : signature : sources : sourceLanguage : regexp
|
2010-07-23 23:56:24 +04:00
|
|
|
{
|
|
|
|
# DoCatalogs <target> : <signature> : <sources> [ : <sourceLanguage> ]
|
2010-10-24 06:49:44 +04:00
|
|
|
# [ : <regexp> ]
|
2010-07-23 23:56:24 +04:00
|
|
|
#
|
|
|
|
# Extracts the catkeys from a target's source files, generates the
|
|
|
|
# default catalog from them, and also generates catalogs for all
|
|
|
|
# translations.
|
|
|
|
#
|
|
|
|
# target: The target.
|
|
|
|
# signature: Application MIME signature (must match the one
|
|
|
|
# declared in the sourcecode).
|
|
|
|
# sources: List of cpp files where to search keys.
|
|
|
|
# sourceLanguage Short name of the language of used for the strings in
|
|
|
|
# the sources. Optional: default is "en".
|
|
|
|
# regexp The regular expression used to parse the files.
|
|
|
|
# Optional: default is matching be_catalog->GetString
|
2010-10-03 19:21:59 +04:00
|
|
|
|
2010-10-24 06:49:44 +04:00
|
|
|
local subdir ;
|
|
|
|
if [ on $(SUBDIR) return $(HAIKU_MULTIPLE_LOCALIZED_TARGETS) ] {
|
|
|
|
subdir = $(SUBDIR_TOKENS[2-]) $(target) ;
|
|
|
|
} else {
|
|
|
|
subdir = $(SUBDIR_TOKENS[2-]) ;
|
|
|
|
}
|
|
|
|
|
2010-10-03 19:21:59 +04:00
|
|
|
HAIKU_CATALOGS_SUBDIR on $(signature) = $(subdir) ;
|
2010-07-23 23:56:24 +04:00
|
|
|
|
2010-09-26 20:55:06 +04:00
|
|
|
local generatedCatalog
|
2010-10-24 05:21:07 +04:00
|
|
|
= $(sourceLanguage:G=$(signature):E=en:S=.catalog) ;
|
2010-09-26 20:55:06 +04:00
|
|
|
MakeLocate $(generatedCatalog)
|
2010-10-03 19:21:59 +04:00
|
|
|
: [ FDirName $(HAIKU_CATALOGS_OBJECT_DIR) $(subdir) ] ;
|
|
|
|
|
2010-07-23 23:56:24 +04:00
|
|
|
# generate catkeys file from sources
|
|
|
|
ExtractCatalogEntries $(generatedCatalog:S=.catkeys)
|
|
|
|
: [ FGristFiles $(sources) ] : $(signature) : $(regexp) ;
|
|
|
|
|
|
|
|
# find translations
|
|
|
|
local translationsDir
|
2010-10-07 04:34:12 +04:00
|
|
|
= [ FDirName $(HAIKU_TOP) data catalogs $(subdir) ] ;
|
2010-07-23 23:56:24 +04:00
|
|
|
local translations = [ Glob $(translationsDir) : *.catkeys ] ;
|
|
|
|
translations = [ FGristFiles $(translations:BS) ] ;
|
|
|
|
SEARCH on $(translations) += $(translationsDir) ;
|
|
|
|
|
|
|
|
# generate catalogs from all catkeys files
|
|
|
|
local catkeysFiles = $(generatedCatalog:S=.catkeys) $(translations) ;
|
|
|
|
for catkeysFile in $(catkeysFiles) {
|
|
|
|
LinkApplicationCatalog $(catkeysFile:S=.catalog) : $(catkeysFile)
|
|
|
|
: $(signature) : $(catkeysFile:B) ;
|
|
|
|
}
|
|
|
|
|
|
|
|
HAIKU_CATALOG_FILES on $(target) = $(catkeysFiles:S=.catalog) ;
|
|
|
|
HAIKU_CATALOG_SIGNATURE on $(target) = $(signature) ;
|
2010-10-24 07:31:34 +04:00
|
|
|
|
|
|
|
# For the pseudo-target LocalizedTargets
|
|
|
|
HAIKU_LOCALIZED_TARGETS += $(target) ;
|
|
|
|
|
|
|
|
# For the pseudo-target catalogs
|
2010-10-24 20:55:33 +04:00
|
|
|
HAIKU_LOCALE_CATALOGS += $(catkeysFiles:S=.catalog) ;
|
|
|
|
|
|
|
|
# For the pseudo-target catkeys
|
|
|
|
HAIKU_LOCALE_OUTPUT_CATKEYS += $(generatedCatalog:S=.catkeys) ;
|
2010-07-23 23:56:24 +04:00
|
|
|
}
|
2011-03-03 15:58:02 +03:00
|
|
|
|
|
|
|
rule AddCatalogEntryAttribute target
|
|
|
|
{
|
|
|
|
# AddCatalogEntryAttribute <target> : <attribute value> ;
|
|
|
|
#
|
|
|
|
# <attribute value> should be of the form
|
|
|
|
# "x-vnd.Haiku-App:context:string"
|
|
|
|
|
|
|
|
CATALOG_ENTRY on $(target) = "$(2)" ;
|
|
|
|
|
|
|
|
Depends $(target) : <build>addattr ;
|
|
|
|
|
|
|
|
AddCatalogEntryAttribute1 $(target)
|
|
|
|
: <build>addattr ;
|
|
|
|
}
|
|
|
|
|
|
|
|
actions AddCatalogEntryAttribute1
|
|
|
|
{
|
2011-03-04 00:56:56 +03:00
|
|
|
$(HOST_ADD_BUILD_COMPATIBILITY_LIB_DIR)
|
2011-03-03 15:58:02 +03:00
|
|
|
"$(2)" -t string "SYS:NAME" "$(CATALOG_ENTRY)" "$(1)"
|
|
|
|
}
|