mirror of
https://github.com/LostArtefacts/TRX.git
synced 2025-04-28 20:58:07 +03:00
97 lines
2.9 KiB
Python
Executable file
97 lines
2.9 KiB
Python
Executable file
#!/usr/bin/env python3
|
|
import argparse
|
|
from pathlib import Path
|
|
|
|
from shared.files import find_versioned_files, is_binary_file
|
|
from shared.import_sorter import sort_imports
|
|
from shared.paths import SHARED_SRC_DIR, SRC_DIR, TR1Paths, TR2Paths
|
|
|
|
|
|
def parse_args() -> argparse.Namespace:
|
|
parser = argparse.ArgumentParser()
|
|
parser.add_argument("path", type=Path, nargs="*")
|
|
return parser.parse_args()
|
|
|
|
|
|
def main() -> None:
|
|
args = parse_args()
|
|
if args.path:
|
|
paths = [path.absolute() for path in args.path]
|
|
else:
|
|
paths = [
|
|
path
|
|
for path in find_versioned_files(SRC_DIR)
|
|
if path.suffix in [".c", ".h"]
|
|
]
|
|
|
|
sort_imports(
|
|
paths=[
|
|
path for path in paths if path.is_relative_to(TR1Paths.src_dir)
|
|
],
|
|
root_dir=TR1Paths.src_dir,
|
|
system_include_dirs=[SRC_DIR],
|
|
own_include_map={
|
|
"game/game/game.c": "game/game.h",
|
|
"game/game/game_cutscene.c": "game/game.h",
|
|
"game/game/game_demo.c": "game/game.h",
|
|
"game/game/game_draw.c": "game/game.h",
|
|
"game/game/game_pause.c": "game/game.h",
|
|
"game/gun/gun.c": "game/gun.h",
|
|
"game/inventry.c": "game/inv.h",
|
|
"game/invfunc.c": "game/inv.h",
|
|
"game/invvars.c": "game/inv.h",
|
|
"game/lara/lara.c": "game/lara.h",
|
|
"game/option/option.c": "game/option.h",
|
|
"game/savegame/savegame.c": "game/savegame.h",
|
|
},
|
|
fix_map={"libavcodec/version_major.h": "libavcodec/version.h"},
|
|
forced_order=[],
|
|
)
|
|
|
|
sort_imports(
|
|
paths=[
|
|
path for path in paths if path.is_relative_to(TR2Paths.src_dir)
|
|
],
|
|
root_dir=TR2Paths.src_dir,
|
|
system_include_dirs=[SRC_DIR],
|
|
own_include_map={
|
|
"game/music/music_main.c": "game/music.h",
|
|
},
|
|
fix_map={},
|
|
forced_order=[
|
|
"<mmeapi.h>",
|
|
"<dsound.h>",
|
|
"<ddrawi.h>",
|
|
"<d3dhal.h>"
|
|
],
|
|
)
|
|
|
|
sort_imports(
|
|
paths=[path for path in paths if path.is_relative_to(SHARED_SRC_DIR)],
|
|
root_dir=SHARED_SRC_DIR,
|
|
system_include_dirs=[],
|
|
own_include_map={
|
|
"json/bson_write.c": "bson.h",
|
|
"json/bson_parse.c": "bson.h",
|
|
"json/json_base.c": "json.h",
|
|
"json/json_write.c": "json.h",
|
|
"json/json_parse.c": "json.h",
|
|
"log_unknown.c": "log.h",
|
|
"log_linux.c": "log.h",
|
|
"log_windows.c": "log.h",
|
|
"engine/audio.c": "audio_internal.h",
|
|
"engine/audio_sample.c": "audio_internal.h",
|
|
"engine/audio_stream.c": "audio_internal.h",
|
|
},
|
|
fix_map={},
|
|
forced_order=[
|
|
"<dsound.h>",
|
|
"<windows.h>",
|
|
"<dbghelp.h>",
|
|
"<tlhelp32.h>",
|
|
],
|
|
)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|