buildframework/helium/sf/python/pythoncore/lib/convertpkg.py
changeset 628 7c4a911dc066
child 645 b8d81fa19e7d
equal deleted inserted replaced
588:c7c26511138f 628:7c4a911dc066
       
     1 #============================================================================ 
       
     2 #Name        : .py 
       
     3 #Part of     : Helium 
       
     4 
       
     5 #Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     6 #All rights reserved.
       
     7 #This component and the accompanying materials are made available
       
     8 #under the terms of the License "Eclipse Public License v1.0"
       
     9 #which accompanies this distribution, and is available
       
    10 #at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
    11 #
       
    12 #Initial Contributors:
       
    13 #Nokia Corporation - initial contribution.
       
    14 #
       
    15 #Contributors:
       
    16 #
       
    17 #Description:
       
    18 #===============================================================================
       
    19 import sys
       
    20 import os
       
    21 from distutils import dir_util # pylint: disable-msg=E0611
       
    22 
       
    23 def main():
       
    24     if len(sys.argv) < 3:
       
    25         print 'Usage: ' + sys.argv[0] + ' pkgsrc pkgdst test_type'
       
    26         sys.exit(1)
       
    27     convertpkg(sys.argv[1], sys.argv[2], sys.argv[3])
       
    28 
       
    29 def convertpkg(srcs, dst, testtype):
       
    30     i = 1
       
    31     
       
    32     bldfile = open(os.path.join(dst, 'bld.inf'), 'w')
       
    33     
       
    34     for src in srcs.split(' '):
       
    35         bldfile.write('#include "' + str(i) + '/group/bld.inf"\n')
       
    36         srcfile = open(src)
       
    37         os.makedirs(os.path.join(dst, str(i), 'group'))
       
    38         dstfile = open(os.path.join(dst, str(i), 'group', os.path.basename(src)), 'w')
       
    39         for line in srcfile:
       
    40             if line.startswith('"') and not line.startswith('"\\') and not line.startswith('"/'):
       
    41                 line = line.replace('"', '"' + os.path.dirname(src) + os.sep, 1)
       
    42             dstfile.write(line)
       
    43         srcfile.close()
       
    44         dstfile.close()
       
    45         
       
    46         customdir = os.path.join(os.path.dirname(src), 'custom')
       
    47         if os.path.exists(customdir):
       
    48             dir_util.copy_tree(customdir, os.path.join(dst, str(i), 'group', 'custom'))
       
    49         
       
    50         subbldfile = open(os.path.join(dst, str(i), 'group', 'bld.inf'), 'w')
       
    51         subbldfile.write('PRJ_TESTMMPFILES\n')
       
    52         subbldfile.write('test.mmp\n')
       
    53         subbldfile.close()
       
    54         
       
    55         submmpfile = open(os.path.join(dst, str(i), 'group', 'test.mmp'), 'w')
       
    56         submmpfile.write('TARGET        fake.exe\n')
       
    57         submmpfile.write('TARGETTYPE    exe\n')
       
    58         
       
    59         if testtype == 'tef':
       
    60             submmpfile.write('LIBRARY testexecuteutils.lib\n')
       
    61         elif testtype == 'mtf':
       
    62             submmpfile.write('LIBRARY testframeworkclient.lib\n')
       
    63         elif testtype == 'rtest':
       
    64             submmpfile.write('//rtest\n')
       
    65         elif testtype == 'stif':
       
    66             submmpfile.write('LIBRARY stiftestinterface.lib\n')
       
    67         else:
       
    68             raise Exception('Test type unknown: ' + testtype)
       
    69         submmpfile.close()
       
    70         
       
    71         i += 1
       
    72         
       
    73     bldfile.close()
       
    74     
       
    75 if __name__ == "__main__":
       
    76     main()