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
6 rule ExtractCatalogEntries target : sources : signature : regexp
8 # get compiler and defines for the platform
13 local includesSeparator ;
14 local localIncludesOption ;
15 local systemIncludesOption ;
17 on $(target) { # use on $(target) variable values
18 defines = $(DEFINES) ;
19 headers = $(HAIKU_CONFIG_HEADERS) $(SEARCH_SOURCE) $(SUBDIRHDRS)
21 sysHeaders = $(SUBDIRSYSHDRS) $(SYSHDRS) ;
23 if $(PLATFORM) = host {
24 sysHeaders += $(HOST_HDRS) ;
25 defines += $(HOST_DEFINES) ;
28 sysHeaders += $(HOST_BE_API_HEADERS) ;
31 includesSeparator = $(HOST_INCLUDES_SEPARATOR) ;
32 localIncludesOption = $(HOST_LOCAL_INCLUDES_OPTION) ;
33 systemIncludesOption = $(HOST_SYSTEM_INCLUDES_OPTION) ;
35 sysHeaders += [ FStandardHeaders $(TARGET_PACKAGING_ARCH) ]
36 $(TARGET_HDRS_$(TARGET_PACKAGING_ARCH)) ;
37 defines += $(TARGET_DEFINES_$(TARGET_PACKAGING_ARCH))
39 cc = $(TARGET_CC_$(TARGET_PACKAGING_ARCH)) ;
42 = $(TARGET_INCLUDES_SEPARATOR_$(TARGET_PACKAGING_ARCH)) ;
44 = $(TARGET_LOCAL_INCLUDES_OPTION_$(TARGET_PACKAGING_ARCH)) ;
46 = $(TARGET_SYSTEM_INCLUDES_OPTION_$(TARGET_PACKAGING_ARCH)) ;
50 DEFINES on $(target) = $(defines) ;
51 CCDEFS on $(target) = [ FDefines $(defines) ] ;
52 HDRS on $(target) = [ FIncludes $(headers) : $(localIncludesOption) ]
54 [ FSysIncludes $(sysHeaders) : $(systemIncludesOption) ] ;
55 CC on $(target) = $(cc) ;
57 HAIKU_CATALOG_SIGNATURE on $(target) = $(signature) ;
59 HAIKU_CATALOG_REGEXP on $(target) = ;
61 HAIKU_CATALOG_REGEXP on $(target) = -r $(regexp) ;
64 SEARCH on $(sources) += $(SEARCH_SOURCE) ;
66 local subdir = [ on $(signature) return $(HAIKU_CATALOGS_SUBDIR) ] ;
67 MakeLocate $(target) : [ FDirName $(HAIKU_CATALOGS_OBJECT_DIR) $(subdir) ] ;
68 Depends $(target) : $(sources) <build>collectcatkeys ;
69 LocalClean clean : $(target).pre ;
70 ExtractCatalogEntries1 $(target) : <build>collectcatkeys $(sources) ;
73 actions ExtractCatalogEntries1
75 $(HOST_ADD_BUILD_COMPATIBILITY_LIB_DIR)
77 | $(CC) -E $(CCDEFS) -DB_COLLECTING_CATKEYS $(HDRS) - > "$(1)".pre
78 $(2[1]) $(HAIKU_CATALOG_REGEXP) -s $(HAIKU_CATALOG_SIGNATURE) \
79 -w -o "$(1)" "$(1)".pre
82 rule LinkApplicationCatalog target : sources : signature : language
84 # Link catalog entries from given catkey file into output compiled catalog
85 # file. Compiled catalog file will then be copied into the image, but only
86 # if the fingerprint matches the one from the untranslated catalog for the
89 local subdir = [ on $(signature) return $(HAIKU_CATALOGS_SUBDIR) ] ;
90 MakeLocate $(target) : [ FDirName $(HAIKU_CATALOGS_OBJECT_DIR) $(subdir) ] ;
91 Depends $(target) : $(sources) <build>linkcatkeys ;
92 LocalClean clean : $(target) ;
94 HAIKU_CATALOG_SIGNATURE on $(target) = $(signature) ;
95 HAIKU_CATALOG_LANGUAGE on $(target) = $(language) ;
96 LinkApplicationCatalog1 $(target) : <build>linkcatkeys $(sources) ;
99 actions LinkApplicationCatalog1
101 $(HOST_ADD_BUILD_COMPATIBILITY_LIB_DIR)
102 $(2[1]) "$(2[2-])" -l $(HAIKU_CATALOG_LANGUAGE) \
103 -s $(HAIKU_CATALOG_SIGNATURE) -o "$(1)"
106 rule DoCatalogs target : signature : sources : sourceLanguage : regexp
108 # DoCatalogs <target> : <signature> : <sources> [ : <sourceLanguage> ]
111 # Extracts the catkeys from a target's source files, generates the
112 # default catalog from them, and also generates catalogs for all
115 # target: The target.
116 # signature: Application MIME signature (must match the one
117 # declared in the sourcecode).
118 # sources: List of cpp files where to search keys.
119 # sourceLanguage Short name of the language of used for the strings in
120 # the sources. Optional: default is "en".
121 # regexp The regular expression used to parse the files.
122 # Optional: default is matching be_catalog->GetString
125 if [ on $(SUBDIR) return $(HAIKU_MULTIPLE_LOCALIZED_TARGETS) ] {
126 subdir = $(SUBDIR_TOKENS[2-]) $(target) ;
128 subdir = $(SUBDIR_TOKENS[2-]) ;
131 HAIKU_CATALOGS_SUBDIR on $(signature) = $(subdir) ;
133 local generatedCatalog
134 = $(sourceLanguage:G=$(signature):E=en:S=.catalog) ;
135 MakeLocate $(generatedCatalog)
136 : [ FDirName $(HAIKU_CATALOGS_OBJECT_DIR) $(subdir) ] ;
138 # generate catkeys file from sources
139 ExtractCatalogEntries $(generatedCatalog:S=.catkeys)
140 : [ FGristFiles $(sources) ] : $(signature) : $(regexp) ;
143 local translationsDir
144 = [ FDirName $(HAIKU_TOP) data catalogs $(subdir) ] ;
145 local translations = [ Glob $(translationsDir) : *.catkeys ] ;
146 translations = [ FGristFiles $(translations:BS) ] ;
147 SEARCH on $(translations) += $(translationsDir) ;
149 # generate catalogs from all catkeys files
150 local catkeysFiles = $(generatedCatalog:S=.catkeys) $(translations) ;
151 for catkeysFile in $(catkeysFiles) {
152 LinkApplicationCatalog $(catkeysFile:S=.catalog) : $(catkeysFile)
153 : $(signature) : $(catkeysFile:B) ;
156 HAIKU_CATALOG_FILES on $(target) = $(catkeysFiles:S=.catalog) ;
157 HAIKU_CATALOG_SIGNATURE on $(target) = $(signature) ;
159 # For the pseudo-target LocalizedTargets
160 HAIKU_LOCALIZED_TARGETS += $(target) ;
162 # For the pseudo-target catalogs
163 HAIKU_LOCALE_CATALOGS += $(catkeysFiles:S=.catalog) ;
165 # For the pseudo-target catkeys
166 HAIKU_LOCALE_OUTPUT_CATKEYS += $(generatedCatalog:S=.catkeys) ;
169 rule AddCatalogEntryAttribute target
171 # AddCatalogEntryAttribute <target> : <attribute value> ;
173 # <attribute value> should be of the form
174 # "x-vnd.Haiku-App:context:string"
176 CATALOG_ENTRY on $(target) = "$(2)" ;
178 Depends $(target) : <build>addattr ;
180 AddCatalogEntryAttribute1 $(target)
184 actions AddCatalogEntryAttribute1
186 $(HOST_ADD_BUILD_COMPATIBILITY_LIB_DIR)
187 "$(2)" -t string "SYS:NAME" "$(CATALOG_ENTRY)" "$(1)"