Changeset 8fb1bf82 in mainline for tools/autotool.py


Ignore:
Timestamp:
2010-11-25T13:42:50Z (13 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
8df8415
Parents:
a93d79a (diff), eb667613 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge mainline changes.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tools/autotool.py

    ra93d79a r8fb1bf82  
    4949
    5050PACKAGE_BINUTILS = "usually part of binutils"
    51 PACKAGE_GCC = "preferably version 4.4.3 or newer"
     51PACKAGE_GCC = "preferably version 4.5.1 or newer"
    5252PACKAGE_CROSS = "use tools/toolchain.sh to build the cross-compiler toolchain"
    5353
    5454COMPILER_FAIL = "The compiler is probably not capable to compile HelenOS."
    5555
    56 PROBE_HEAD = """#define AUTOTOOL_DECLARE(category, subcategory, tag, name, value) \\
     56PROBE_HEAD = """#define AUTOTOOL_DECLARE(category, subcategory, tag, name, strc, conc, value) \\
    5757        asm volatile ( \\
    58                 "AUTOTOOL_DECLARE\\t" category "\\t" subcategory "\\t" tag "\\t" name "\\t%[val]\\n" \\
     58                "AUTOTOOL_DECLARE\\t" category "\\t" subcategory "\\t" tag "\\t" name "\\t" strc "\\t" conc "\\t%[val]\\n" \\
    5959                : \\
    6060                : [val] "n" (value) \\
    6161        )
    6262
    63 #define DECLARE_INTSIZE(tag, type) \\
    64         AUTOTOOL_DECLARE("intsize", "unsigned", tag, #type, sizeof(unsigned type)); \\
    65         AUTOTOOL_DECLARE("intsize", "signed", tag, #type, sizeof(signed type))
     63#define DECLARE_INTSIZE(tag, type, strc, conc) \\
     64        AUTOTOOL_DECLARE("intsize", "unsigned", tag, #type, strc, conc, sizeof(unsigned type)); \\
     65        AUTOTOOL_DECLARE("intsize", "signed", tag, #type, strc, conc, sizeof(signed type));
    6666
    6767int main(int argc, char *argv[])
     
    7575        "Read HelenOS build configuration"
    7676       
    77         inf = file(fname, 'r')
     77        inf = open(fname, 'r')
    7878       
    7979        for line in inf:
     
    191191        check_common(common, "CC")
    192192       
    193         outf = file(PROBE_SOURCE, 'w')
     193        outf = open(PROBE_SOURCE, 'w')
    194194        outf.write(PROBE_HEAD)
    195195       
    196196        for typedef in sizes:
    197                 outf.write("\tDECLARE_INTSIZE(\"%s\", %s);\n" % (typedef['tag'], typedef['type']))
     197                outf.write("\tDECLARE_INTSIZE(\"%s\", %s, %s, %s);\n" % (typedef['tag'], typedef['type'], typedef['strc'], typedef['conc']))
    198198       
    199199        outf.write(PROBE_TAIL)
     
    212212        if (not os.path.isfile(PROBE_OUTPUT)):
    213213                sys.stderr.write("failed\n")
    214                 print output[1]
     214                print(output[1])
    215215                print_error(["Error executing \"%s\"." % " ".join(args),
    216216                             "The compiler did not produce the output file \"%s\"." % PROBE_OUTPUT,
     
    221221        sys.stderr.write("ok\n")
    222222       
    223         inf = file(PROBE_OUTPUT, 'r')
     223        inf = open(PROBE_OUTPUT, 'r')
    224224        lines = inf.readlines()
    225225        inf.close()
     
    231231        signed_tags = {}
    232232       
     233        unsigned_strcs = {}
     234        signed_strcs = {}
     235       
     236        unsigned_concs = {}
     237        signed_concs = {}
     238       
    233239        for j in range(len(lines)):
    234240                tokens = lines[j].strip().split("\t")
     
    236242                if (len(tokens) > 0):
    237243                        if (tokens[0] == "AUTOTOOL_DECLARE"):
    238                                 if (len(tokens) < 5):
     244                                if (len(tokens) < 7):
    239245                                        print_error(["Malformed declaration in \"%s\" on line %s." % (PROBE_OUTPUT, j), COMPILER_FAIL])
    240246                               
     
    243249                                tag = tokens[3]
    244250                                name = tokens[4]
    245                                 value = tokens[5]
     251                                strc = tokens[5]
     252                                conc = tokens[6]
     253                                value = tokens[7]
    246254                               
    247255                                if (category == "intsize"):
     
    263271                                                unsigned_sizes[name] = value_int
    264272                                                unsigned_tags[tag] = value_int
     273                                                unsigned_strcs[strc] = value_int
     274                                                unsigned_concs[conc] = value_int
    265275                                        elif (subcategory == "signed"):
    266276                                                signed_sizes[name] = value_int
    267277                                                signed_tags[tag] = value_int
     278                                                signed_strcs[strc] = value_int
     279                                                signed_concs[conc] = value_int
    268280                                        else:
    269281                                                print_error(["Unexpected keyword \"%s\" in \"%s\" on line %s." % (subcategory, PROBE_OUTPUT, j), COMPILER_FAIL])
    270282       
    271         return {'unsigned_sizes' : unsigned_sizes, 'signed_sizes' : signed_sizes, 'unsigned_tags': unsigned_tags, 'signed_tags': signed_tags}
     283        return {'unsigned_sizes': unsigned_sizes, 'signed_sizes': signed_sizes, 'unsigned_tags': unsigned_tags, 'signed_tags': signed_tags, 'unsigned_strcs': unsigned_strcs, 'signed_strcs': signed_strcs, 'unsigned_concs': unsigned_concs, 'signed_concs': signed_concs}
    272284
    273285def detect_uints(probe, bytes):
     
    279291        for b in bytes:
    280292                fnd = False
    281                 newtype = "uint%s_t" % (b * 8)
    282                
    283293                for name, value in probe['unsigned_sizes'].items():
    284294                        if (value == b):
    285                                 oldtype = "unsigned %s" % name
    286                                 typedefs.append({'oldtype' : oldtype, 'newtype' : newtype})
    287                                 fnd = True
    288                                 break
    289                
    290                 if (not fnd):
    291                         print_error(['Unable to find appropriate integer type for %s' % newtype,
     295                                typedefs.append({'oldtype': "unsigned %s" % name, 'newtype': "uint%u_t" % (b * 8)})
     296                                fnd = True
     297                                break
     298               
     299                if (not fnd):
     300                        print_error(['Unable to find appropriate unsigned integer type for %u bytes' % b,
    292301                                     COMPILER_FAIL])
    293302               
    294303               
    295304                fnd = False
    296                 newtype = "int%s_t" % (b * 8)
    297                
    298305                for name, value in probe['signed_sizes'].items():
    299306                        if (value == b):
    300                                 oldtype = "signed %s" % name
    301                                 typedefs.append({'oldtype' : oldtype, 'newtype' : newtype})
    302                                 fnd = True
    303                                 break
    304                
    305                 if (not fnd):
    306                         print_error(['Unable to find appropriate integer type for %s' % newtype,
     307                                typedefs.append({'oldtype': "signed %s" % name, 'newtype': "int%u_t" % (b * 8)})
     308                                fnd = True
     309                                break
     310               
     311                if (not fnd):
     312                        print_error(['Unable to find appropriate signed integer type for %u bytes' % b,
     313                                     COMPILER_FAIL])
     314               
     315               
     316                fnd = False
     317                for name, value in probe['unsigned_strcs'].items():
     318                        if (value == b):
     319                                macros.append({'oldmacro': "\"%so\"" % name, 'newmacro': "PRIo%u" % (b * 8)})
     320                                macros.append({'oldmacro': "\"%su\"" % name, 'newmacro': "PRIu%u" % (b * 8)})
     321                                macros.append({'oldmacro': "\"%sx\"" % name, 'newmacro': "PRIx%u" % (b * 8)})
     322                                macros.append({'oldmacro': "\"%sX\"" % name, 'newmacro': "PRIX%u" % (b * 8)})
     323                                fnd = True
     324                                break
     325               
     326                if (not fnd):
     327                        print_error(['Unable to find appropriate unsigned printf formatter for %u bytes' % b,
     328                                     COMPILER_FAIL])
     329               
     330               
     331                fnd = False
     332                for name, value in probe['signed_strcs'].items():
     333                        if (value == b):
     334                                macros.append({'oldmacro': "\"%sd\"" % name, 'newmacro': "PRId%u" % (b * 8)})
     335                                fnd = True
     336                                break
     337               
     338                if (not fnd):
     339                        print_error(['Unable to find appropriate signed printf formatter for %u bytes' % b,
     340                                     COMPILER_FAIL])
     341               
     342               
     343                fnd = False
     344                for name, value in probe['unsigned_concs'].items():
     345                        if (value == b):
     346                                if ((name.startswith('@')) or (name == "")):
     347                                        macros.append({'oldmacro': "c ## U", 'newmacro': "UINT%u_C(c)" % (b * 8)})
     348                                else:
     349                                        macros.append({'oldmacro': "c ## U%s" % name, 'newmacro': "UINT%u_C(c)" % (b * 8)})
     350                                fnd = True
     351                                break
     352               
     353                if (not fnd):
     354                        print_error(['Unable to find appropriate unsigned literal macro for %u bytes' % b,
     355                                     COMPILER_FAIL])
     356               
     357               
     358                fnd = False
     359                for name, value in probe['signed_concs'].items():
     360                        if (value == b):
     361                                if ((name.startswith('@')) or (name == "")):
     362                                        macros.append({'oldmacro': "c", 'newmacro': "INT%u_C(c)" % (b * 8)})
     363                                else:
     364                                        macros.append({'oldmacro': "c ## %s" % name, 'newmacro': "INT%u_C(c)" % (b * 8)})
     365                                fnd = True
     366                                break
     367               
     368                if (not fnd):
     369                        print_error(['Unable to find appropriate unsigned literal macro for %u bytes' % b,
    307370                                     COMPILER_FAIL])
    308371       
     
    343406        "Create makefile output"
    344407       
    345         outmk = file(mkname, 'w')
     408        outmk = open(mkname, 'w')
    346409       
    347410        outmk.write('#########################################\n')
     
    357420        "Create header output"
    358421       
    359         outhd = file(hdname, 'w')
     422        outhd = open(hdname, 'w')
    360423       
    361424        outhd.write('/***************************************\n')
     
    508571                probe = probe_compiler(common,
    509572                        [
    510                                 {'type': 'char', 'tag': 'CHAR'},
    511                                 {'type': 'short int', 'tag': 'SHORT'},
    512                                 {'type': 'int', 'tag': 'INT'},
    513                                 {'type': 'long int', 'tag': 'LONG'},
    514                                 {'type': 'long long int', 'tag': 'LLONG'}
     573                                {'type': 'char', 'tag': 'CHAR', 'strc': '"hh"', 'conc': '"@@"'},
     574                                {'type': 'short int', 'tag': 'SHORT', 'strc': '"h"', 'conc': '"@"'},
     575                                {'type': 'int', 'tag': 'INT', 'strc': '""', 'conc': '""'},
     576                                {'type': 'long int', 'tag': 'LONG', 'strc': '"l"', 'conc': '"L"'},
     577                                {'type': 'long long int', 'tag': 'LLONG', 'strc': '"ll"', 'conc': '"LL"'}
    515578                        ]
    516579                )
Note: See TracChangeset for help on using the changeset viewer.