()
| 87 | |
| 88 | |
| 89 | def main(): |
| 90 | parser = argparse.ArgumentParser( |
| 91 | description="""Create a context file which can be used for decomp.me""" |
| 92 | ) |
| 93 | parser.add_argument( |
| 94 | "c_file", |
| 95 | help="""File from which to create context""", |
| 96 | ) |
| 97 | parser.add_argument( |
| 98 | "-o", |
| 99 | "--output", |
| 100 | help="""Output file""", |
| 101 | default="ctx.c", |
| 102 | ) |
| 103 | parser.add_argument( |
| 104 | "-d", |
| 105 | "--depfile", |
| 106 | help="""Dependency file""", |
| 107 | ) |
| 108 | parser.add_argument( |
| 109 | "-I", |
| 110 | "--include", |
| 111 | help="""Include directory""", |
| 112 | action="append", |
| 113 | ) |
| 114 | args = parser.parse_args() |
| 115 | |
| 116 | if args.include is None: |
| 117 | exit("No include directories specified") |
| 118 | global include_dirs |
| 119 | include_dirs = args.include |
| 120 | output = import_c_file(args.c_file) |
| 121 | |
| 122 | with open(os.path.join(root_dir, args.output), "w", encoding="utf-8") as f: |
| 123 | f.write(output) |
| 124 | |
| 125 | if args.depfile: |
| 126 | with open(os.path.join(root_dir, args.depfile), "w", encoding="utf-8") as f: |
| 127 | f.write(sanitize_path(args.output) + ":") |
| 128 | for dep in deps: |
| 129 | path = sanitize_path(dep) |
| 130 | f.write(f" \\\n\t{path}") |
| 131 | |
| 132 | |
| 133 | if __name__ == "__main__": |
no test coverage detected