1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
|
"""
dol2asm.py - Script for splitting .dol and .rel binaries into C++ and .s code.
This script only calls the underlaying libdol2asm code that does the heavy-lifting.
"""
import sys
from pathlib import Path
try:
import click
import libdol2asm
import libdol2asm.util
except ImportError as e:
MISSING_PREREQUISITES = (
f"Missing prerequisite python module {e}.\n"
f"Run `python3 -m pip install --user -r tools/requirements.txt` to install prerequisites."
)
print(MISSING_PREREQUISITES, file=sys.stderr)
sys.exit(1)
@click.command()
@click.version_option(libdol2asm.VERSION)
@click.option("--debug/--no-debug", help="enable/disable debug logging", default=False)
@click.option(
"--game",
"game_path",
help=f"Path to extracted game files. (same directory as 'main.dol' is in)",
required=False,
type=libdol2asm.util.PathPath(file_okay=False, dir_okay=True),
default="game/",
)
@click.option(
"--lib-path",
"lib_path",
help="Where to put generated library source files.",
required=False,
type=libdol2asm.util.PathPath(file_okay=False, dir_okay=True),
default="libs/",
)
@click.option(
"--src-path",
"src_path",
help="Where to put generated source files.",
required=False,
type=libdol2asm.util.PathPath(file_okay=False, dir_okay=True),
default="src/",
)
@click.option(
"--asm-path",
"asm_path",
help="Where to put generated asm files.",
required=False,
type=libdol2asm.util.PathPath(file_okay=False, dir_okay=True),
default="asm/",
)
@click.option(
"--rel-path",
"rel_path",
help="Where to put generated rel source files.",
required=False,
type=libdol2asm.util.PathPath(file_okay=False, dir_okay=True),
default="rel/",
)
@click.option(
"--include-path",
"inc_path",
help="Where to put generated include files.",
required=False,
type=libdol2asm.util.PathPath(file_okay=False, dir_okay=True),
default="include/",
)
@click.option("--cpp/--no-cpp", "cpp_gen", default=True)
@click.option("--asm/--no-asm", "asm_gen", default=True)
@click.option("--makefile/--no-makefile", "mk_gen", default=True)
@click.option("--symbols/--no-symbols", "sym_gen", default=True)
@click.option("--rels/--no-rels", "rel_gen", default=True)
@click.option("--threads", "-j", "process_count", default=8)
@click.option(
"--select-module",
"-g",
"select_modules",
help="Select what modules to generate. Default is everything.",
multiple=True,
)
@click.option("--select-asm", "-n", "select_asm", multiple=True)
@click.option("--select-tu", "-t", "select_tu", multiple=True)
def main(
debug,
game_path,
asm_path,
lib_path,
src_path,
rel_path,
inc_path,
mk_gen,
cpp_gen,
asm_gen,
sym_gen,
rel_gen,
process_count,
select_modules,
select_tu,
select_asm,
):
return libdol2asm.split(
debug,
game_path,
lib_path,
src_path,
asm_path,
rel_path,
inc_path,
mk_gen,
cpp_gen,
asm_gen,
sym_gen,
rel_gen,
process_count,
select_modules,
select_tu,
select_asm,
)
if __name__ == "__main__":
main()
|