11 if __name__ == "__main__":
12 parser = argparse.ArgumentParser()
13 parser.add_argument("--api-raw")
14 parser.add_argument("--gapi-fixup")
15 parser.add_argument("--metadata")
16 parser.add_argument("--gapi-codegen")
17 parser.add_argument("--abi-includes", default="")
18 parser.add_argument("--abi-cs-usings", default="")
19 parser.add_argument("--assembly-name")
20 parser.add_argument("--extra-includes", action='append', default=[])
21 parser.add_argument("--out")
22 parser.add_argument("--files")
23 parser.add_argument("--symbols")
24 parser.add_argument("--schema")
25 parser.add_argument("--fake", action='store_true')
27 opts = parser.parse_args()
31 api_xml = os.path.join(opts.out, os.path.basename(
32 opts.api_raw).replace('.raw', '.xml'))
34 shutil.copyfile(opts.api_raw, api_xml)
36 if shutil.which('mono'):
37 launcher = ['mono', '--debug']
41 cmd = [opts.gapi_fixup, "--api=" + api_xml]
43 cmd += ["--metadata=" + opts.metadata]
45 cmd.extend(['--symbols=' + opts.symbols])
46 subprocess.check_call(launcher + cmd)
49 opts.gapi_codegen, '--generate', api_xml,
50 '--outdir=' + opts.out,
51 '--assembly-name=' + opts.assembly_name,
52 '--glue-includes=' + opts.abi_includes,
54 os.path.join(opts.out, opts.assembly_name + "-abi.c"),
55 '--abi-cs-filename=' +
56 os.path.join(opts.out, opts.assembly_name + "-abi.cs"),
60 cmd += ['--schema=' + opts.schema]
62 if opts.abi_cs_usings:
63 cmd += ['--abi-cs-usings=' + opts.abi_cs_usings]
65 cmd += ['-I' + i for i in opts.extra_includes]
67 subprocess.check_call(launcher + cmd)
69 # WORKAROUND: Moving files into the out directory with special names
70 # as meson doesn't like path separator in output names.
71 regex = re.compile('_')
73 expected_files = set(opts.files.split(';'))
74 for _f in expected_files:
75 dirs.add(os.path.dirname(_f))
77 generated = set(glob.glob(os.path.join('*/*.cs')))
79 not_listed = generated - expected_files
81 print("Following files were generated but not listed:\n %s" %
82 '\n '.join(["'%s/%s'," % (m.split(os.path.sep)[-2], m.split(os.path.sep)[-1])
83 for m in not_listed]))
86 not_generated = expected_files - generated
88 print("Following files were generated but not listed:\n %s" %
89 '\n '.join(["'%s/%s'," % (m.split(os.path.sep)[-2], m.split(os.path.sep)[-1])
90 for m in not_generated]))
94 generated = sorted(list(generated))
95 print("List of files to use in `meson.build`:\n %s" %
96 '\n '.join(["'%s/%s'," % (m.split(os.path.sep)[-2], m.split(os.path.sep)[-1])