Skip to content

Commit

Permalink
fixed consecutive directives newline issue and build dirname
Browse files Browse the repository at this point in the history
  • Loading branch information
Yanis002 committed Apr 21, 2024
1 parent 06b776a commit 2323d71
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion fast64_internal/oot/scene/exporter/to_c/spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
from ....oot_utility import ExportInfo, getSceneDirFromLevelName


# either "$(BUILD_DIR)", "$(BUILD)" or "build"
buildDirectory = None


class CommandType(enum.Enum):
"""This class defines the different spec command types"""

Expand Down Expand Up @@ -59,6 +63,7 @@ class SpecEntry:

def __post_init__(self):
if self.original is not None:
global buildDirectory
# parse the commands from the existing data
prefix = ""
for line in self.original:
Expand All @@ -80,6 +85,9 @@ def __post_init__(self):
else:
content = ""

if buildDirectory is None and (content.startswith('"build') or content.startswith('"$(BUILD')):
buildDirectory = content.split("/")[0].removeprefix('"')

self.commands.append(
SpecEntryCommand(
CommandType.from_string(command),
Expand All @@ -89,6 +97,9 @@ def __post_init__(self):
)
prefix = ""
else:
if prefix.startswith("#") and line.startswith("#"):
# add newline if there's two consecutive preprocessor directives
prefix += "\n"
prefix += (f"\n{indent}" if not dontHaveComments else "") + line
# if there's a prefix it's the remaining data after the last entry
if len(prefix) > 0:
Expand Down Expand Up @@ -203,8 +214,10 @@ def editSpecFile(
specFile.remove(entry.segmentName)

if isScene:
global buildDirectory
assert buildDirectory is not None
isSingleFile = bpy.context.scene.ootSceneExportSettings.singleFile
includeDir = "$(BUILD_DIR)/"
includeDir = f"{buildDirectory}/"
if exportInfo.customSubPath is not None:
includeDir += f"{exportInfo.customSubPath + sceneName}"
else:
Expand Down

0 comments on commit 2323d71

Please sign in to comment.