|
42 | 42 |
|
43 | 43 |
|
44 | 44 | # read included asset data |
45 | | -def ootGetIncludedAssetData(basePath: str, currentPaths: list[str], data: str) -> str: |
| 45 | +def ootGetIncludedAssetData( |
| 46 | + basePath: Union[str, os.PathLike, list[Union[str, os.PathLike]]], currentPaths: list[str], data: str |
| 47 | +) -> str: |
46 | 48 | includeData = "" |
| 49 | + basePaths = basePath if isinstance(basePath, list) else [basePath] |
47 | 50 | searchedPaths = currentPaths[:] |
48 | 51 |
|
49 | 52 | print("Included paths:") |
50 | 53 | extracted_path = f"{bpy.context.scene.fast64.oot.get_extracted_path()}/" |
51 | 54 |
|
52 | 55 | # search assets |
53 | 56 | for includeMatch in re.finditer(r"\#include\s*\"(assets/objects/(.*?)\.h)\"", data): |
54 | | - h_p = Path(basePath) / includeMatch.group(1) |
55 | | - print("", str(h_p)) |
56 | | - includeData += getImportData([str(h_p)]) + "\n" |
57 | | - for path_p in h_p.parent.glob("*.c"): |
58 | | - path = str(path_p) |
59 | | - if path in searchedPaths: |
60 | | - continue |
61 | | - searchedPaths.append(path) |
62 | | - subIncludeData = getImportData([path]) + "\n" |
63 | | - includeData += subIncludeData |
64 | | - print(" ", path) |
65 | | - |
66 | | - for subIncludeMatch in re.finditer(r"\#include\s*\"(((?![/\"]).)*\.[ch])\"", subIncludeData): |
67 | | - sub_inc_p = Path(path).parent / subIncludeMatch.group(1) |
68 | | - subPath = str(sub_inc_p) |
69 | | - if subPath in searchedPaths: |
| 57 | + for basePathItem in basePaths: |
| 58 | + h_p = Path(basePathItem) / includeMatch.group(1) |
| 59 | + print("", str(h_p)) |
| 60 | + includeData += getImportData([str(h_p)]) + "\n" |
| 61 | + for path_p in h_p.parent.glob("*.c"): |
| 62 | + path = str(path_p) |
| 63 | + if path in searchedPaths: |
70 | 64 | continue |
71 | | - searchedPaths.append(subPath) |
72 | | - print(" ", subPath) |
73 | | - includeData += getImportData([subPath]) + "\n" |
| 65 | + searchedPaths.append(path) |
| 66 | + subIncludeData = getImportData([path]) + "\n" |
| 67 | + includeData += subIncludeData |
| 68 | + print(" ", path) |
| 69 | + |
| 70 | + for subIncludeMatch in re.finditer(r"\#include\s*\"(((?![/\"]).)*\.[ch])\"", subIncludeData): |
| 71 | + sub_inc_p = Path(path).parent / subIncludeMatch.group(1) |
| 72 | + subPath = str(sub_inc_p) |
| 73 | + if subPath in searchedPaths: |
| 74 | + continue |
| 75 | + searchedPaths.append(subPath) |
| 76 | + print(" ", subPath) |
| 77 | + includeData += getImportData([subPath]) + "\n" |
74 | 78 |
|
75 | 79 | print("More included paths:") |
76 | 80 |
|
|
0 commit comments