build/buildutils/createstubfiles.py
branchRCL_3
changeset 19 04becd199f91
equal deleted inserted replaced
16:f5050f1da672 19:04becd199f91
       
     1 #
       
     2 # Copyright (c) 2009 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: 
       
    15 #
       
    16 
       
    17 import sys, os
       
    18 import traceback
       
    19 from optparse import OptionParser
       
    20 
       
    21 def main():
       
    22     parser = OptionParser(
       
    23         usage = "Usage: %prog <component root> <javah files> <javah root>")
       
    24 
       
    25 
       
    26     (opts, args) = parser.parse_args()
       
    27 
       
    28     try:
       
    29         componentRoot = args[0]
       
    30         javahFiles = args[1]
       
    31         javahRoot = args[2]
       
    32         
       
    33         # Generate empty jxe.c file if doesn't exist.
       
    34         jxeFile = componentRoot + "/jxe.c"
       
    35         if not os.path.exists(jxeFile):
       
    36             fout = open(jxeFile, 'w')
       
    37             content = """
       
    38 // This prevents warnings of literal treated as \"unsigned long long
       
    39 // coming from compilation of jxe.c (J9 romized classes).
       
    40 #ifndef __WINS__
       
    41 #pragma diag_suppress 1135
       
    42 #endif
       
    43 
       
    44 #ifdef _DEBUG
       
    45 #include \"jxe_debug.c\"
       
    46 #else
       
    47 #include \"jxe_release.c\"
       
    48 #endif
       
    49 """
       
    50             fout.write(content)
       
    51             fout.close()
       
    52 
       
    53         # Generate empty jxe_<debug/release>.c files if doesn't exist.
       
    54         createUnexistingFile(componentRoot + "/jxe_debug.c")
       
    55         createUnexistingFile(componentRoot + "/jxe_release.c")
       
    56 
       
    57         # Generate empty lookup.c if doesn't exist.
       
    58         createUnexistingFile(componentRoot + "/lookup.cpp")
       
    59 
       
    60         # Generate empty javah file if the component has defined such.
       
    61         # The javahFiles will contain a comma separated list of java files
       
    62         # that should be 'javah'ed'. In here we need to tweak names a little 
       
    63         # bit. If the component doesnt havy any files to be 'javah'ed' them
       
    64         # the value of javahFiles is ${javah.classnames}
       
    65         if not javahFiles.startswith("$"):
       
    66             # Split a string to list.
       
    67             javahFilesList = javahFiles.split(',')
       
    68 
       
    69             # Loop all the files. Convert '.' to '_ and add '.h' extension.
       
    70             for item in javahFilesList:
       
    71                 javahFile = item.strip().replace('.', '_') + ".h"
       
    72                 
       
    73                 # Create empty file if doesn't exist.
       
    74                 createUnexistingFile(javahRoot + "/" + javahFile)
       
    75         
       
    76     except:
       
    77         print "Error in s60init"
       
    78         traceback.print_exc()
       
    79         sys.exit(1)
       
    80 
       
    81 def createUnexistingFile(file):
       
    82     if not os.path.exists(file):
       
    83         fout = open(file, 'w')
       
    84         fout.close()
       
    85         
       
    86         
       
    87 if __name__ == "__main__":
       
    88     main()
       
    89