tools: fix import sorter

This commit is contained in:
Marcin Kurczewski 2024-10-05 23:10:36 +02:00
parent 38d377dc4d
commit 6c4ffcdcda
No known key found for this signature in database
GPG key ID: CC65E6FD28CAE42A
4 changed files with 19 additions and 10 deletions

View file

@ -2,6 +2,7 @@
#include "game/clock.h"
#include "game/console/common.h"
#include "game/text.h"
#include "game/ui/common.h"
#include "game/ui/events.h"
#include "game/ui/widgets/label.h"
@ -11,7 +12,6 @@
#include "memory.h"
#include "strings.h"
#include "utils.h"
#include "game/text.h"
#include <string.h>

View file

@ -9,12 +9,12 @@
#include "global/types.h"
#include "global/vars.h"
#include <libtrx/memory.h>
#include <assert.h>
#include <stdio.h>
#include <string.h>
#include <libtrx/memory.h>
#define TEXT_BOX_OFFSET 2
#define TEXT_MAX_STRINGS 100
#define TRIANGLE_SYM 93

View file

@ -16,7 +16,7 @@ def custom_sort(source: list[str], forced_order: list[str]) -> list[str]:
return sorted(source, key=key_func)
def sort_imports(
def sort_imports_single_file(
path: Path,
root_dir: Path,
own_include_map: dict[str, str],
@ -87,7 +87,7 @@ def sort_imports(
forced_order: list[str],
) -> None:
for path in paths:
sort_imports(
sort_imports_single_file(
path,
root_dir=root_dir,
own_include_map=own_include_map,

View file

@ -1,4 +1,5 @@
#!/usr/bin/env python3
from pathlib import Path
import argparse
from shared.import_sorter import sort_imports
@ -23,7 +24,9 @@ def main() -> None:
]
sort_imports(
paths=[path for path in paths if path.is_relative_to(TR1Paths.src_dir)],
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={
@ -45,7 +48,9 @@ def main() -> None:
)
sort_imports(
paths=[path for path in paths if path.is_relative_to(TR2Paths.src_dir)],
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={
@ -68,9 +73,9 @@ def main() -> None:
"log_unknown.c": "log.h",
"log_linux.c": "log.h",
"log_windows.c": "log.h",
"engine/audio.c": "audio.h",
"engine/audio_sample.c": "audio.h",
"engine/audio_stream.c": "audio.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=[
@ -79,3 +84,7 @@ def main() -> None:
"<tlhelp32.h>",
],
)
if __name__ == "__main__":
main()