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 MakeLocatePlatform $(target) ; 61 Depends $(target) : $(sources) <build>collectcatkeys ; 62 LocalClean clean : $(target).pre ; 63 ExtractCatalogEntries1 $(target) : <build>collectcatkeys $(sources) ; 64} 65 66actions ExtractCatalogEntries1 67{ 68 $(HOST_ADD_BUILD_COMPATIBILITY_LIB_DIR) 69 mkdir -p "$(1:D)" 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 MakeLocateArch $(target) ; 84 Depends $(target) : $(sources) <build>linkcatkeys ; 85 LocalClean clean : $(target) ; 86 87 HAIKU_CATALOG_SIGNATURE on $(target) = $(signature) ; 88 HAIKU_CATALOG_LANGUAGE on $(target) = $(language) ; 89 LinkApplicationCatalog1 $(target) : <build>linkcatkeys $(sources) ; 90} 91 92actions LinkApplicationCatalog1 93{ 94 $(HOST_ADD_BUILD_COMPATIBILITY_LIB_DIR) 95 mkdir -p "$(1:D)" 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 : folder 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 # folder Subfolder where to put the generated files. Optional. 118 119 local generatedCatalog = [ FGristFiles $(sourceLanguage:E=en:S=.catalog:D=$(folder)) ] ; 120 121 # generate catkeys file from sources 122 ExtractCatalogEntries $(generatedCatalog:S=.catkeys) 123 : [ FGristFiles $(sources) ] : $(signature) : $(regexp) ; 124 125 # find translations 126 local translationsDir 127 = [ FDirName $(HAIKU_TOP) data catalogs $(SUBDIR_TOKENS[2-]) ] ; 128 local translations = [ Glob $(translationsDir) : *.catkeys ] ; 129 translations = [ FGristFiles $(translations:BS) ] ; 130 SEARCH on $(translations) += $(translationsDir) ; 131 132 # generate catalogs from all catkeys files 133 local catkeysFiles = $(generatedCatalog:S=.catkeys) $(translations) ; 134 for catkeysFile in $(catkeysFiles) { 135 LinkApplicationCatalog $(catkeysFile:S=.catalog) : $(catkeysFile) 136 : $(signature) : $(catkeysFile:B) ; 137 } 138 139 HAIKU_CATALOG_FILES on $(target) = $(catkeysFiles:S=.catalog) ; 140 HAIKU_CATALOG_SIGNATURE on $(target) = $(signature) ; 141} 142