1# Localization rules 2 3# Extract catalog entries from the sourcefile and put the output textfile in 4# target. This output file is then used to create the binary catalog with 5# linkcatkeys. 6rule ExtractCatalogEntries target : sources : signature : regexp 7{ 8 # get compiler and defines for the platform 9 local headers ; 10 local sysHeaders ; 11 local cc ; 12 local defines ; 13 local localIncludesOption ; 14 local systemIncludesOption ; 15 16 on $(target) { # use on $(target) variable values 17 headers = $(HAIKU_CONFIG_HEADERS) $(SEARCH_SOURCE) $(SUBDIRHDRS) 18 $(HDRS) ; 19 sysHeaders = $(SUBDIRSYSHDRS) $(SYSHDRS) ; 20 defines = $(DEFINES) ; 21 22 if $(PLATFORM) = host { 23 sysHeaders += $(HOST_HDRS) ; 24 defines += $(HOST_DEFINES) ; 25 26 if $(USES_BE_API) { 27 sysHeaders += $(HOST_BE_API_HEADERS) ; 28 } 29 30 defines += $(HOST_DEFINES) ; 31 cc = $(HOST_CC) ; 32 localIncludesOption = $(HOST_LOCAL_INCLUDES_OPTION) ; 33 systemIncludesOption = $(HOST_SYSTEM_INCLUDES_OPTION) ; 34 } else { 35 sysHeaders += $(TARGET_HDRS) ; 36 defines += $(TARGET_DEFINES) ; 37 defines += $(TARGET_DEFINES) ; 38 cc = $(TARGET_CC) ; 39 localIncludesOption = $(TARGET_LOCAL_INCLUDES_OPTION) ; 40 systemIncludesOption = $(TARGET_SYSTEM_INCLUDES_OPTION) ; 41 } 42 } 43 44 DEFINES on $(target) = $(defines) ; 45 CCDEFS on $(target) = [ FDefines $(defines) ] ; 46 HDRS on $(target) = [ FIncludes $(headers) : $(localIncludesOption) ] 47 $(includesSeparator) 48 [ FSysIncludes $(sysHeaders) : $(systemIncludesOption) ] ; 49 CC on $(target) = $(cc) ; 50 51 HAIKU_CATALOG_SIGNATURE on $(target) = $(signature) ; 52 if $(regexp) = "" { 53 HAIKU_CATALOG_REGEXP on $(target) = ; 54 } else { 55 HAIKU_CATALOG_REGEXP on $(target) = -r $(regexp) ; 56 } 57 58 SEARCH on $(sources) += $(SEARCH_SOURCE) ; 59 60 MakeLocate $(target) 61 : [ FDirName $(HAIKU_CATALOGS_OBJECT_DIR) $(signature) ] ; 62 Depends $(target) : $(sources) <build>collectcatkeys ; 63 LocalClean clean : $(target).pre ; 64 ExtractCatalogEntries1 $(target) : <build>collectcatkeys $(sources) ; 65} 66 67actions ExtractCatalogEntries1 68{ 69 $(HOST_ADD_BUILD_COMPATIBILITY_LIB_DIR) 70 cat "$(2[2-])" \ 71 | $(CC) -E $(CCDEFS) -DB_COLLECTING_CATKEYS $(HDRS) - > "$(1)".pre 72 $(2[1]) $(HAIKU_CATALOG_REGEXP) -s $(HAIKU_CATALOG_SIGNATURE) \ 73 -w -o "$(1)" "$(1)".pre 74} 75 76rule LinkApplicationCatalog target : sources : signature : language 77{ 78 # Link catalog entries from given catkey file into output compiled catalog 79 # file. Compiled catalog file will then be copied into the image, but only 80 # if the fingerprint matches the one from the untranslated catalog for the 81 # same file. 82 83 MakeLocate $(target) 84 : [ FDirName $(HAIKU_CATALOGS_OBJECT_DIR) $(signature) ] ; 85 Depends $(target) : $(sources) <build>linkcatkeys ; 86 LocalClean clean : $(target) ; 87 88 HAIKU_CATALOG_SIGNATURE on $(target) = $(signature) ; 89 HAIKU_CATALOG_LANGUAGE on $(target) = $(language) ; 90 LinkApplicationCatalog1 $(target) : <build>linkcatkeys $(sources) ; 91} 92 93actions LinkApplicationCatalog1 94{ 95 $(HOST_ADD_BUILD_COMPATIBILITY_LIB_DIR) 96 $(2[1]) "$(2[2-])" -l $(HAIKU_CATALOG_LANGUAGE) \ 97 -s $(HAIKU_CATALOG_SIGNATURE) -o "$(1)" 98} 99 100rule DoCatalogs target : signature : sources : sourceLanguage : regexp 101{ 102 # DoCatalogs <target> : <signature> : <sources> [ : <sourceLanguage> ] 103 # [ : <regexp> ] 104 # 105 # Extracts the catkeys from a target's source files, generates the 106 # default catalog from them, and also generates catalogs for all 107 # translations. 108 # 109 # target: The target. 110 # signature: Application MIME signature (must match the one 111 # declared in the sourcecode). 112 # sources: List of cpp files where to search keys. 113 # sourceLanguage Short name of the language of used for the strings in 114 # the sources. Optional: default is "en". 115 # regexp The regular expression used to parse the files. 116 # Optional: default is matching be_catalog->GetString 117 118 local generatedCatalog 119 = [ FGristFiles $(sourceLanguage:E=en:S=.catalog) ] ; 120 MakeLocate $(generatedCatalog) 121 : [ FDirName $(HAIKU_CATALOGS_OBJECT_DIR) $(signature) ] ; 122 123 # generate catkeys file from sources 124 ExtractCatalogEntries $(generatedCatalog:S=.catkeys) 125 : [ FGristFiles $(sources) ] : $(signature) : $(regexp) ; 126 127 # find translations 128 local translationsDir 129 = [ FDirName $(HAIKU_TOP) data catalogs $(SUBDIR_TOKENS[2-]) ] ; 130 local translations = [ Glob $(translationsDir) : *.catkeys ] ; 131 translations = [ FGristFiles $(translations:BS) ] ; 132 SEARCH on $(translations) += $(translationsDir) ; 133 134 # generate catalogs from all catkeys files 135 local catkeysFiles = $(generatedCatalog:S=.catkeys) $(translations) ; 136 for catkeysFile in $(catkeysFiles) { 137 LinkApplicationCatalog $(catkeysFile:S=.catalog) : $(catkeysFile) 138 : $(signature) : $(catkeysFile:B) ; 139 } 140 141 HAIKU_CATALOG_FILES on $(target) = $(catkeysFiles:S=.catalog) ; 142 HAIKU_CATALOG_SIGNATURE on $(target) = $(signature) ; 143} 144