|
1 #!/usr/bin/env python |
|
2 # -*- coding: utf-8 -*- |
|
3 # |
|
4 # ============================================================================ |
|
5 # Name : sync.py |
|
6 # Part of : Hb |
|
7 # Description : Hb themes sync script |
|
8 # Version : %version: % |
|
9 # |
|
10 # Copyright (c) 2008-2010 Nokia. All rights reserved. |
|
11 # This material, including documentation and any related computer |
|
12 # programs, is protected by copyright controlled by Nokia. All |
|
13 # rights are reserved. Copying, including reproducing, storing, |
|
14 # adapting or translating, any or all of this material requires the |
|
15 # prior written consent of Nokia. This material also contains |
|
16 # confidential information which may not be disclosed to others |
|
17 # without the prior written consent of Nokia. |
|
18 # ============================================================================ |
|
19 |
|
20 import os |
|
21 import re |
|
22 import sys |
|
23 import time |
|
24 import copy |
|
25 import shutil |
|
26 import fnmatch |
|
27 import zipfile |
|
28 import optparse |
|
29 import tempfile |
|
30 import posixpath |
|
31 if sys.version_info[0] == 2 and sys.version_info[1] < 4: |
|
32 # for scratchbox compatibility |
|
33 import popen2 |
|
34 else: |
|
35 import subprocess |
|
36 |
|
37 # ============================================================================ |
|
38 # Globals |
|
39 # ============================================================================ |
|
40 VERBOSE = False |
|
41 ARCHIVES = False |
|
42 INCLUDE = None |
|
43 EXCLUDE = None |
|
44 INPUT_DIR = os.getcwd() |
|
45 OUTPUT_DIR = os.getcwd() |
|
46 IBY_SOURCE_PREFIX = "ZRESOURCE/hb/themes" |
|
47 IBY_TARGET_PREFIX = "RESOURCE_FILES_DIR/hb/themes" |
|
48 BLD_HW_TARGET_PREFIX = "/epoc32/data/z/resource/hb/themes" |
|
49 BLD_EMU_TARGET_PREFIX = "/epoc32/winscw/c/resource/hb/themes" |
|
50 BLD_TARGET_PREFIXES = [] |
|
51 SYMBIAN = False |
|
52 EXIT_STATUS = 0 |
|
53 NAME = "themes" |
|
54 THEME_COMMON = "themecommon" |
|
55 THEME_SETTINGS_FILE = "theme.theme" |
|
56 ENCODER = "SVGTBinEncode.exe" |
|
57 NVG = True |
|
58 |
|
59 # ============================================================================ |
|
60 # OptionParser |
|
61 # ============================================================================ |
|
62 class OptionParser(optparse.OptionParser): |
|
63 def __init__(self): |
|
64 optparse.OptionParser.__init__(self) |
|
65 self.add_option("-v", "--verbose", action="store_true", dest="verbose", |
|
66 help="print verbose information about each step of the sync process") |
|
67 self.add_option("-q", "--quiet", action="store_false", dest="verbose", |
|
68 help="do not print information about each step of the sync process") |
|
69 self.add_option("-n", "--name", dest="name", metavar="name", |
|
70 help="specify the package <name> (default %s)" % NAME) |
|
71 self.add_option("--symbian", action="store_true", dest="symbian", |
|
72 help="work in Symbian mode") |
|
73 self.add_option("--nvg", action="store_true", dest="nvg", |
|
74 help="do convert svg to nvg") |
|
75 self.add_option("--no-nvg", action="store_false", dest="nvg", |
|
76 help="do not convert svg to nvg") |
|
77 |
|
78 group = optparse.OptionGroup(self, "Input/output options") |
|
79 self.add_option("-i", "--input", dest="input", metavar="dir", |
|
80 help="specify the input <dir> (default %s)" % INPUT_DIR) |
|
81 self.add_option("-o", "--output", dest="output", metavar="dir", |
|
82 help="specify the output <dir> (default %s)" % OUTPUT_DIR) |
|
83 self.add_option("-a", "--archives", action="store_true", dest="archives", |
|
84 help="export/install archives (default %s)" % ARCHIVES) |
|
85 self.add_option("--include", dest="include", action="append", metavar="pattern", |
|
86 help="specify the include <pattern> (default %s)" % INCLUDE) |
|
87 self.add_option("--exclude", dest="exclude", action="append", metavar="pattern", |
|
88 help="specify the exclude <pattern> (default %s)" % EXCLUDE) |
|
89 self.add_option_group(group) |
|
90 |
|
91 group = optparse.OptionGroup(self, "Prefix options") |
|
92 self.add_option("--iby-source-prefix", dest="ibysourceprefix", metavar="prefix", |
|
93 help="specify the iby source <prefix> (default %s)" % IBY_SOURCE_PREFIX) |
|
94 self.add_option("--iby-target-prefix", dest="ibytargetprefix", metavar="prefix", |
|
95 help="specify the iby target <prefix> (default %s)" % IBY_TARGET_PREFIX) |
|
96 self.add_option("--bld-hw-target-prefix", dest="bldhwtargetprefix", metavar="prefix", |
|
97 help="specify the bld harware target <prefix> (default %s)" % BLD_HW_TARGET_PREFIX) |
|
98 self.add_option("--bld-emu-target-prefix", dest="bldemutargetprefix", metavar="prefix", |
|
99 help="specify the bld emulator target <prefix> (default %s)" % BLD_EMU_TARGET_PREFIX) |
|
100 self.add_option("--bld-target-prefix", dest="bldtargetprefixes", action="append", metavar="prefix", |
|
101 help="specify an additional bld target <prefix>") |
|
102 self.add_option_group(group) |
|
103 |
|
104 # ============================================================================ |
|
105 # Utils |
|
106 # ============================================================================ |
|
107 if not hasattr(os.path, "relpath"): |
|
108 def relpath(path, start=os.curdir): |
|
109 abspath = os.path.abspath(path) |
|
110 absstart = os.path.abspath(start) |
|
111 if abspath == absstart: |
|
112 return "." |
|
113 i = len(absstart) |
|
114 if not absstart.endswith(os.path.sep): |
|
115 i += len(os.path.sep) |
|
116 if not abspath.startswith(absstart): |
|
117 i = 0 |
|
118 return abspath[i:] |
|
119 os.path.relpath = relpath |
|
120 |
|
121 def run_process(command, cwd=None): |
|
122 code = 0 |
|
123 output = "" |
|
124 try: |
|
125 if cwd != None: |
|
126 oldcwd = os.getcwd() |
|
127 os.chdir(cwd) |
|
128 if sys.version_info[0] == 2 and sys.version_info[1] < 4: |
|
129 process = popen2.Popen4(command) |
|
130 code = process.wait() |
|
131 output = process.fromchild.read() |
|
132 else: |
|
133 process = subprocess.Popen(command, stderr=subprocess.PIPE, stdout=subprocess.PIPE) |
|
134 (stdout, stderr) = process.communicate() |
|
135 code = process.returncode |
|
136 output = stdout + stderr |
|
137 if cwd != None: |
|
138 os.chdir(oldcwd) |
|
139 except Exception, e: |
|
140 print(e) |
|
141 code = -1 |
|
142 return [code, output] |
|
143 |
|
144 def make_target(path): |
|
145 # generate a compatible make target name from path |
|
146 target = os.path.splitdrive(path)[1].strip("\\/") |
|
147 return "_".join(re.split("[\\\/]+", target)) |
|
148 |
|
149 def zip_filelist(filepath): |
|
150 files = list() |
|
151 archive = zipfile.ZipFile(filepath) |
|
152 for entry in archive.namelist(): |
|
153 if not entry.endswith("/"): |
|
154 files.append(entry) |
|
155 return files |
|
156 |
|
157 class Theme: |
|
158 def __init__(self, name): |
|
159 self.name = name |
|
160 self.paths = [] |
|
161 self.files = {} |
|
162 self.archives = {} |
|
163 |
|
164 def initialize(self): |
|
165 for path in self.paths: |
|
166 for root, dirs, files in os.walk(path): |
|
167 for file in files: |
|
168 filepath = posixpath.join(root, file).replace("\\", "/") |
|
169 if self._include(filepath): |
|
170 extension = os.path.splitext(filepath)[1] |
|
171 if extension == ".zip": |
|
172 if root not in self.archives: |
|
173 self.archives[root] = list() |
|
174 self.archives[root].append(filepath) |
|
175 else: |
|
176 if root not in self.files: |
|
177 self.files[root] = list() |
|
178 self.files[root].append(filepath) |
|
179 |
|
180 def _write_zip_entry(self, archive, filepath): |
|
181 path, filename = os.path.split(filepath) |
|
182 oldcwd = os.getcwd() |
|
183 os.chdir(path) |
|
184 archive.write(filename) |
|
185 os.chdir(oldcwd) |
|
186 |
|
187 def encode(self): |
|
188 print "Encoding: %s" % self.name |
|
189 for path, archives in self.archives.iteritems(): |
|
190 relpath = os.path.relpath(path, INPUT_DIR) |
|
191 if not relpath.startswith("icons"): |
|
192 continue |
|
193 for archive in archives: |
|
194 # ensure that output dir exists |
|
195 outpath = os.path.join(OUTPUT_DIR, relpath) |
|
196 if not os.path.exists(outpath): |
|
197 os.makedirs(outpath) |
|
198 |
|
199 # extract to a temp dir |
|
200 tempdir = tempfile.mkdtemp() |
|
201 zip = zipfile.ZipFile(archive) |
|
202 for name in zip.namelist(): |
|
203 file = open(os.path.join(tempdir, name),'w') |
|
204 file.write(zip.read(name)) |
|
205 file.close() |
|
206 |
|
207 # convert & re-archive |
|
208 total = 0 |
|
209 converted = 0 |
|
210 tmpfile, tmpfilepath = tempfile.mkstemp(".zip") |
|
211 tmparchive = zipfile.ZipFile(tmpfilepath, 'w') |
|
212 for root, dirs, files in os.walk(tempdir): |
|
213 for file in files: |
|
214 filepath = os.path.join(root, file) |
|
215 basepath, extension = os.path.splitext(filepath) |
|
216 if extension == ".svg": |
|
217 total += 1 |
|
218 encoder = ENCODER |
|
219 if os.path.exists("/ext/tools/hbbins/bin/3rdparty/%s" % ENCODER): |
|
220 encoder = "/ext/tools/hbbins/bin/3rdparty/%s" % ENCODER |
|
221 res = run_process([encoder, "-v", "6", filepath, "-e", ".nvg"])[0] |
|
222 exists = os.path.exists(basepath + ".nvg") |
|
223 if not exists: |
|
224 self._write_zip_entry(tmparchive, filepath) |
|
225 else: |
|
226 converted += 1 |
|
227 self._write_zip_entry(tmparchive, basepath + ".nvg") |
|
228 |
|
229 # cleanup |
|
230 tmparchive.close() |
|
231 os.close(tmpfile) |
|
232 if converted > 0: |
|
233 shutil.move(tmpfilepath, os.path.join(outpath, os.path.basename(archive))) |
|
234 else: |
|
235 os.remove(tmpfilepath) |
|
236 shutil.rmtree(tempdir, True) |
|
237 print " %s (%s/%s)" % (os.path.join(relpath, os.path.basename(archive)), converted, total) |
|
238 |
|
239 def write_css(self, csspath): |
|
240 outpath = os.path.dirname(csspath) |
|
241 if not os.path.exists(outpath): |
|
242 os.makedirs(outpath) |
|
243 groupfile = open(csspath, "w") |
|
244 for path, files in copy.deepcopy(self.files.items()): |
|
245 for filepath in files: |
|
246 basename = os.path.basename(filepath) |
|
247 extension = os.path.splitext(basename)[1] |
|
248 if extension == ".css": |
|
249 if basename != os.path.basename(csspath): |
|
250 cssfile = open(filepath, "r") |
|
251 groupfile.write(cssfile.read()) |
|
252 cssfile.close() |
|
253 self.files[path].remove(filepath) |
|
254 groupfile.close() |
|
255 if outpath not in self.files: |
|
256 self.files[outpath] = list() |
|
257 if csspath not in self.files[outpath]: |
|
258 self.files[outpath].append(csspath) |
|
259 |
|
260 def write_iby(self, ibypath): |
|
261 global IBY_SOURCE_PREFIX, IBY_TARGET_PREFIX, EXIT_STATUS |
|
262 outpath = os.path.dirname(ibypath) |
|
263 if not os.path.exists(outpath): |
|
264 os.makedirs(outpath) |
|
265 out = open(ibypath, "w") |
|
266 out.write("#ifndef __%s_IBY__\n" % self.name.upper()) |
|
267 out.write("#define __%s_IBY__\n" % self.name.upper()) |
|
268 out.write("\n") |
|
269 out.write("#include <bldvariant.hrh>\n") |
|
270 out.write("\n") |
|
271 out.write("data=%s/%s.themeindex\t%s/%s.themeindex\n" % (IBY_SOURCE_PREFIX, self.name, IBY_TARGET_PREFIX, self.name)) |
|
272 written_entries = list() |
|
273 for path, files in self.files.iteritems(): |
|
274 relpath = os.path.relpath(path, INPUT_DIR).replace("\\", "/") |
|
275 for filepath in files: |
|
276 filename = os.path.basename(filepath) |
|
277 entry = posixpath.join(relpath, filename) |
|
278 if entry not in written_entries: |
|
279 written_entries.append(filepath) |
|
280 out.write("data=%s/%s\t%s/%s\n" % (IBY_SOURCE_PREFIX, entry, IBY_TARGET_PREFIX, entry)) |
|
281 else: |
|
282 print "ERROR: %s duplicate entry %s" % (ibypath, entry) |
|
283 EXIT_STATUS = -1 |
|
284 for path, archives in self.archives.iteritems(): |
|
285 relpath = os.path.relpath(path, INPUT_DIR).replace("\\", "/") |
|
286 for archive in archives: |
|
287 files = zip_filelist(archive) |
|
288 for filepath in files: |
|
289 entry = posixpath.join(relpath, filepath) |
|
290 if entry not in written_entries: |
|
291 written_entries.append(entry) |
|
292 out.write("data=%s/%s\t%s/%s\n" % (IBY_SOURCE_PREFIX, entry, IBY_TARGET_PREFIX, entry)) |
|
293 else: |
|
294 print "ERROR: %s duplicate entry %s" % (ibypath, entry) |
|
295 EXIT_STATUS = -1 |
|
296 out.write("\n") |
|
297 out.write("#endif __%s_IBY__\n" % self.name.upper()) |
|
298 out.close() |
|
299 |
|
300 def _include(self, filepath): |
|
301 result = True |
|
302 if INCLUDE != None: |
|
303 for pattern in INCLUDE: |
|
304 if not fnmatch.fnmatch(filepath, pattern): |
|
305 result = False |
|
306 if EXCLUDE != None: |
|
307 for pattern in EXCLUDE: |
|
308 if fnmatch.fnmatch(filepath, pattern): |
|
309 result = False |
|
310 return result |
|
311 |
|
312 def lookup_themes(path): |
|
313 themes = {} |
|
314 # base: effects, icons... |
|
315 for base in os.listdir(path): |
|
316 basepath = posixpath.join(path, base) |
|
317 if os.path.isdir(basepath): |
|
318 # theme: footheme, bartheme... |
|
319 for theme in os.listdir(basepath): |
|
320 themepath = posixpath.join(basepath, theme) |
|
321 if os.path.isdir(themepath): |
|
322 if theme not in themes: |
|
323 themes[theme] = Theme(theme) |
|
324 themes[theme].paths.append(themepath) |
|
325 return themes |
|
326 |
|
327 def write_txt(filepath, themes, prefixes): |
|
328 outpath = os.path.dirname(filepath) |
|
329 if not os.path.exists(outpath): |
|
330 os.makedirs(outpath) |
|
331 out = open(filepath, "w") |
|
332 for name, theme in themes.iteritems(): |
|
333 for prefix in prefixes: |
|
334 out.write("%s %s %s\n" % (name, prefix, prefix)) |
|
335 out.close() |
|
336 |
|
337 def write_pri(filepath, themes, prefixes, settingsfile_exists): |
|
338 outpath = os.path.dirname(filepath) |
|
339 if not os.path.exists(outpath): |
|
340 os.makedirs(outpath) |
|
341 outpath = os.path.splitdrive(OUTPUT_DIR)[1] |
|
342 out = open(filepath, "w") |
|
343 |
|
344 # clean & dist clean rules |
|
345 out.write("QMAKE_CLEAN += %s\n" % filepath) |
|
346 out.write("QMAKE_CLEAN += %s\n" % (os.path.splitext(filepath)[0] + ".txt")) |
|
347 if settingsfile_exists: |
|
348 out.write("QMAKE_CLEAN += %s.iby\n" % posixpath.join(outpath, THEME_COMMON)) |
|
349 for name, theme in themes.iteritems(): |
|
350 out.write("QMAKE_CLEAN += %s.iby\n" % posixpath.join(outpath, name)) |
|
351 for prefix in prefixes: |
|
352 out.write("QMAKE_CLEAN += %s.themeindex\n" % posixpath.join(prefix, name)) |
|
353 |
|
354 out.write("symbian {\n") |
|
355 out.write("\tBLD_INF_RULES.prj_exports += \"$${LITERAL_HASH}include <platform_paths.hrh>\"\n") |
|
356 |
|
357 if settingsfile_exists: |
|
358 # exporting theme settings file |
|
359 settingsPath = os.path.splitdrive(posixpath.join(INPUT_DIR,THEME_SETTINGS_FILE))[1] |
|
360 out.write("\tBLD_INF_RULES.prj_exports += \"%s\t%s/%s\"\n" % (settingsPath, BLD_HW_TARGET_PREFIX, THEME_SETTINGS_FILE)) |
|
361 out.write("\tBLD_INF_RULES.prj_exports += \"%s\t%s/%s\"\n" % (settingsPath, BLD_EMU_TARGET_PREFIX, THEME_SETTINGS_FILE)) |
|
362 out.write("\tBLD_INF_RULES.prj_exports += \"%s.iby\tCORE_MW_LAYER_IBY_EXPORT_PATH(%s.iby)\"\n" % (posixpath.join(outpath, THEME_COMMON), THEME_COMMON)) |
|
363 |
|
364 for name, theme in themes.iteritems(): |
|
365 ibyfile = "%s.iby" % name |
|
366 out.write("\tBLD_INF_RULES.prj_exports += \"%s\tCORE_MW_LAYER_IBY_EXPORT_PATH(%s)\"\n" % (posixpath.join(outpath, ibyfile), ibyfile)) |
|
367 for path, files in theme.files.iteritems(): |
|
368 relpath = os.path.relpath(path, INPUT_DIR).replace("\\", "/") |
|
369 for filepath in files: |
|
370 filepath = os.path.splitdrive(filepath)[1] |
|
371 filename = os.path.basename(filepath) |
|
372 out.write("\tBLD_INF_RULES.prj_exports += \"%s\t%s/%s\"\n" % (filepath, BLD_HW_TARGET_PREFIX, posixpath.join(relpath, filename))) |
|
373 out.write("\tBLD_INF_RULES.prj_exports += \"%s\t%s/%s\"\n" % (filepath, BLD_EMU_TARGET_PREFIX, posixpath.join(relpath, filename))) |
|
374 for path, archives in theme.archives.iteritems(): |
|
375 relpath = os.path.relpath(path, INPUT_DIR).replace("\\", "/") |
|
376 for filepath in archives: |
|
377 filepath = os.path.splitdrive(filepath)[1] |
|
378 filename = os.path.basename(filepath) |
|
379 if ARCHIVES: |
|
380 out.write("\tBLD_INF_RULES.prj_exports += \"%s\t%s/%s\"\n" % (filepath, BLD_HW_TARGET_PREFIX, posixpath.join(relpath, filename))) |
|
381 out.write("\tBLD_INF_RULES.prj_exports += \"%s\t%s/%s\"\n" % (filepath, BLD_EMU_TARGET_PREFIX, posixpath.join(relpath, filename))) |
|
382 else: |
|
383 out.write("\tBLD_INF_RULES.prj_exports += \":zip %s\t%s/%s\"\n" % (filepath, BLD_HW_TARGET_PREFIX, relpath)) |
|
384 out.write("\tBLD_INF_RULES.prj_exports += \":zip %s\t%s/%s\"\n" % (filepath, BLD_EMU_TARGET_PREFIX, relpath)) |
|
385 out.write("} else {\n") |
|
386 out.write("\tisEmpty(QMAKE_UNZIP):QMAKE_UNZIP = unzip -u -o\n") |
|
387 |
|
388 if settingsfile_exists: |
|
389 # installing theme settings file |
|
390 settingsPath = posixpath.join(INPUT_DIR,THEME_SETTINGS_FILE) |
|
391 out.write("\t%s.path += $$(HB_THEMES_DIR)/themes\n" % THEME_COMMON) |
|
392 out.write("\t%s.files += %s\n" % (THEME_COMMON, settingsPath)) |
|
393 out.write("\tINSTALLS += %s\n" % THEME_COMMON) |
|
394 |
|
395 for name, theme in themes.iteritems(): |
|
396 for path, files in theme.files.iteritems(): |
|
397 target = make_target(path) |
|
398 relpath = os.path.relpath(path, INPUT_DIR).replace("\\", "/") |
|
399 out.write("\t%s.CONFIG += no_build\n" % target) |
|
400 out.write("\t%s.path += $$(HB_THEMES_DIR)/themes/%s\n" % (target, relpath)) |
|
401 out.write("\t%s.files += %s\n" % (target, " ".join(files))) |
|
402 out.write("\tINSTALLS += %s\n" % target) |
|
403 for path, archives in theme.archives.iteritems(): |
|
404 target = make_target(path) |
|
405 relpath = os.path.relpath(path, INPUT_DIR).replace("\\", "/") |
|
406 out.write("\t%s_zip.CONFIG += no_build\n" % target) |
|
407 out.write("\t%s_zip.path += $$(HB_THEMES_DIR)/themes/%s\n" % (target, relpath)) |
|
408 if ARCHIVES: |
|
409 out.write("\t%s_zip.files += %s\n" % (target, " ".join(archives))) |
|
410 else: |
|
411 commands = [] |
|
412 for archive in archives: |
|
413 commands.append("$$QMAKE_UNZIP %s -d $$(HB_THEMES_DIR)/themes/%s" % (archive, relpath)) |
|
414 out.write("\t%s_zip.commands += %s\n" % (target, " && ".join(commands))) |
|
415 out.write("\t%s_zip.uninstall += -$(DEL_FILE) $$(HB_THEMES_DIR)/themes/%s/*\n" % (target, relpath)) |
|
416 out.write("\tINSTALLS += %s_zip\n" % target) |
|
417 out.write("}\n") |
|
418 out.close() |
|
419 |
|
420 |
|
421 def write_common_iby(path): |
|
422 global VERBOSE, IBY_SOURCE_PREFIX, IBY_TARGET_PREFIX, OUTPUT_DIR, INPUT_DIR |
|
423 global THEME_COMMON, THEME_SETTINGS_FILE |
|
424 |
|
425 # Create iby file for theme.theme if it is there |
|
426 theme_theme = posixpath.join(INPUT_DIR,THEME_SETTINGS_FILE) |
|
427 if os.path.isfile(theme_theme): |
|
428 if VERBOSE: |
|
429 print "Writing: %s.iby" % THEME_COMMON |
|
430 ibypath = posixpath.join(OUTPUT_DIR, THEME_COMMON + ".iby") |
|
431 outpath = os.path.dirname(ibypath) |
|
432 if not os.path.exists(outpath): |
|
433 os.makedirs(outpath) |
|
434 out = open(ibypath, "w") |
|
435 out.write("#ifndef __%s_IBY__\n" % THEME_COMMON.upper()) |
|
436 out.write("#define __%s_IBY__\n" % THEME_COMMON.upper()) |
|
437 out.write("\n") |
|
438 out.write("#include <bldvariant.hrh>\n") |
|
439 out.write("\n") |
|
440 out.write("data=%s/%s\t%s/%s\n" % (IBY_SOURCE_PREFIX, THEME_SETTINGS_FILE, IBY_TARGET_PREFIX, THEME_SETTINGS_FILE)) |
|
441 out.write("\n") |
|
442 out.write("#endif __%s_IBY__\n" % THEME_COMMON.upper()) |
|
443 return True |
|
444 |
|
445 # theme common iby not written, return false |
|
446 return False |
|
447 |
|
448 # ============================================================================ |
|
449 # main() |
|
450 # ============================================================================ |
|
451 def main(): |
|
452 global VERBOSE, ARCHIVES, INPUT_DIR, OUTPUT_DIR, INCLUDE, EXCLUDE, SYMBIAN, NAME, NVG |
|
453 global IBY_SOURCE_PREFIX, IBY_TARGET_PREFIX |
|
454 global BLD_HW_TARGET_PREFIX, BLD_EMU_TARGET_PREFIX, BLD_TARGET_PREFIXES |
|
455 |
|
456 parser = OptionParser() |
|
457 (options, args) = parser.parse_args() |
|
458 |
|
459 if options.verbose != None: |
|
460 VERBOSE = options.verbose |
|
461 if options.symbian != None: |
|
462 SYMBIAN = options.symbian |
|
463 if options.nvg != None: |
|
464 NVG = options.nvg |
|
465 if options.name != None: |
|
466 NAME = options.name |
|
467 if options.archives != None: |
|
468 ARCHIVES = options.archives |
|
469 if options.include != None: |
|
470 INCLUDE = options.include |
|
471 if options.exclude != None: |
|
472 EXCLUDE = options.exclude |
|
473 if options.input != None: |
|
474 INPUT_DIR = options.input |
|
475 if options.output != None: |
|
476 OUTPUT_DIR = options.output |
|
477 if options.ibysourceprefix != None: |
|
478 IBY_SOURCE_PREFIX = options.ibysourceprefix |
|
479 if options.ibytargetprefix != None: |
|
480 IBY_TARGET_PREFIX = options.ibytargetprefix |
|
481 if options.bldhwtargetprefix != None: |
|
482 BLD_HW_TARGET_PREFIX = options.bldhwtargetprefix |
|
483 if options.bldemutargetprefix != None: |
|
484 BLD_EMU_TARGET_PREFIX = options.bldemutargetprefix |
|
485 if options.bldtargetprefixes != None: |
|
486 BLD_TARGET_PREFIXES = options.bldtargetprefixes |
|
487 |
|
488 settingsfile_exists = write_common_iby(INPUT_DIR) |
|
489 |
|
490 themes = lookup_themes(INPUT_DIR) |
|
491 for name, theme in themes.iteritems(): |
|
492 theme.initialize() |
|
493 if SYMBIAN and NVG: |
|
494 theme.encode() |
|
495 if VERBOSE: |
|
496 print "Writing: %s/hbcolorgroup.css" % name |
|
497 theme.write_css(posixpath.join(OUTPUT_DIR, "style/%s/variables/color/hbcolorgroup.css" % name)) |
|
498 if VERBOSE: |
|
499 print "Writing: %s.iby" % name |
|
500 theme.write_iby(posixpath.join(OUTPUT_DIR, "%s.iby" % name)) |
|
501 |
|
502 if SYMBIAN: |
|
503 prefixes = [BLD_HW_TARGET_PREFIX, BLD_EMU_TARGET_PREFIX] |
|
504 prefixes += BLD_TARGET_PREFIXES |
|
505 else: |
|
506 prefixes = [posixpath.join(os.environ["HB_THEMES_DIR"], "themes")] |
|
507 |
|
508 if VERBOSE: |
|
509 print "Writing: %s.pri" % NAME |
|
510 write_pri(posixpath.join(OUTPUT_DIR, "%s.pri" % NAME), themes, prefixes, settingsfile_exists) |
|
511 if VERBOSE: |
|
512 print "Writing: %s.txt" % NAME |
|
513 write_txt(posixpath.join(OUTPUT_DIR, "%s.txt" % NAME), themes, prefixes) |
|
514 |
|
515 return EXIT_STATUS |
|
516 |
|
517 if __name__ == "__main__": |
|
518 sys.exit(main()) |