2 # -*- coding: utf-8 -*-
7 def print_array(name
, values
):
10 list = ", ".join(values
)
11 print(" .%s = ((const char*[]){ %s, NULL })," % (name
, list))
18 for item
in line
.split():
19 if item
== "MODINFO_START":
22 if item
.startswith("MODINFO_END"):
35 def generate(name
, lines
):
41 if line
.find("MODINFO_START") != -1:
42 (kind
, data
) = parse_line(line
)
52 print("unknown:", kind
)
55 print(" .name = \"%s\"," % name
)
57 print(" .arch = %s," % arch
)
58 print_array("objs", objs
)
59 print_array("deps", deps
)
60 print_array("opts", opts
)
65 print("/* generated by scripts/modinfo-generate.py */")
66 print("#include \"qemu/osdep.h\"")
67 print("#include \"qemu/module.h\"")
68 print("const QemuModinfo qemu_modinfo[] = {{")
71 print(" /* end of list */")
78 with
open(modinfo
) as f
:
80 print(" /* %s */" % modinfo
)
81 (basename
, ext
) = os
.path
.splitext(modinfo
)
82 deps
[basename
] = generate(basename
, lines
)
85 flattened_deps
= {flat
.strip('" ') for dep
in deps
.values() for flat
in dep
}
87 for dep
in flattened_deps
:
88 if dep
not in deps
.keys():
89 print("Dependency {} cannot be satisfied".format(dep
),
96 if __name__
== "__main__":