Changes in tools/autogen.py [795e2bf:147a066] in mainline


Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • tools/autogen.py

    r795e2bf r147a066  
    3434def usage():
    3535        print("%s - Automated structure and offsets generator" % sys.argv[0])
    36         print("%s file.ag probe|generate struct.ag" % sys.argv[0])
     36        print("%s file.ag depend|probe|generate struct.ag" % sys.argv[0])
    3737        sys.exit()
     38
     39def depend(struct):
     40        deps = ""
     41        for include in struct['includes']:
     42                if 'depends' in include.keys():
     43                        deps = deps + include['depends'] + "\n"
     44        return deps.strip()
    3845
    3946def generate_includes(struct):
     
    5259
    5360def generate_struct(struct):
     61        packed = ""
     62        if ('packed' in struct.keys() and struct['packed']):
     63                packed = "__attribute__ ((packed)) "
    5464        code = "typedef struct %s {\n" % struct['name']
    5565        for i in range(len(struct['members'])):
     
    5969                else:
    6070                        code = code + "\t%s %s;\n" % (member['type'], member['name'])
    61         code = code + "} %s_t;" % struct['name']
     71        code = code + "} %s%s_t;" % (packed, struct['name'])
    6272        return code
    6373
     
    157167                struct = yaml.load(fp)
    158168
    159         if sys.argv[1] == "probe":
     169        if sys.argv[1] == "depend":
     170                deps = depend(struct)
     171                print(deps)
     172        elif sys.argv[1] == "probe":
    160173                code = probe(struct)
    161174                print(code)
Note: See TracChangeset for help on using the changeset viewer.