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