hostsupport/hostopenvg/genheader/bin2h.py
branchbug235_bringup_0
changeset 53 c2ef9095503a
parent 20 d2d6724aef32
equal deleted inserted replaced
52:39e5f73667ba 53:c2ef9095503a
       
     1 # Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
       
     2 #
       
     3 # Permission is hereby granted, free of charge, to any person obtaining a
       
     4 # copy of this software and /or associated documentation files
       
     5 # (the "Materials "), to deal in the Materials without restriction,
       
     6 # including without limitation the rights to use, copy, modify, merge,
       
     7 # publish, distribute, sublicense, and/or sell copies of the Materials,
       
     8 # and to permit persons to whom the Materials are furnished to do so,
       
     9 # subject to the following conditions:
       
    10 #
       
    11 # The above copyright notice and this permission notice shall be included
       
    12 # in all copies or substantial portions of the Materials.
       
    13 #
       
    14 # THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
       
    15 # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
       
    16 # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
       
    17 # IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
       
    18 # DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
       
    19 # OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE MATERIALS OR
       
    20 # THE USE OR OTHER DEALINGS IN THE MATERIALS.
       
    21 
       
    22 from c_utils import *
       
    23 import sys
       
    24 import array
       
    25 import os.path
       
    26 
       
    27 def doit():
       
    28     # \todo There's got to be some easier way to do this...
       
    29     inputname = sys.argv[1]
       
    30     arrayname = sys.argv[2]
       
    31     f = file(inputname, 'rb')
       
    32     d = f.read()
       
    33     f.close
       
    34     sz = len(d)
       
    35     i = 0
       
    36     items = []
       
    37     for x in d:
       
    38         items += [str(ord(x))]
       
    39 
       
    40     justname = os.path.split(inputname)[1]
       
    41     begin_include_guard(get_include_guard_name(justname + ".h"))
       
    42     make_generation_notice()
       
    43     make_array("static const", "unsigned char", arrayname, items, empty_format, 16)
       
    44     end_include_guard()
       
    45 
       
    46 if __name__ == '__main__':
       
    47     doit()
       
    48