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 ;
|
|
|
|
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) ;
|
|
|
|
|
|
|
|
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
|
|
|
|
2010-10-03 19:21:59 +04:00
|
|
|
local subdir
|
|
|
|
= [ on $(signature) return $(HAIKU_CATALOGS_SUBDIR) ] ;
|
2010-09-26 20:55:06 +04:00
|
|
|
MakeLocate $(target)
|
2010-10-03 19:21:59 +04:00
|
|
|
: [ 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)
|
2010-07-26 02:47:39 +04:00
|
|
|
cat "$(2[2-])" \
|
|
|
|
| $(CC) -E $(CCDEFS) -DB_COLLECTING_CATKEYS $(HDRS) - > "$(1)".pre
|
|
|
|
$(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.
|
|
|
|
|
2010-10-03 19:21:59 +04:00
|
|
|
local subdir
|
|
|
|
= [ on $(signature) return $(HAIKU_CATALOGS_SUBDIR) ] ;
|
2010-09-26 20:55:06 +04:00
|
|
|
MakeLocate $(target)
|
2010-10-03 19:21:59 +04:00
|
|
|
: [ 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
|
|
|
}
|