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