Skip to content

Search for CCScript files in subdirectories of a project's ccscript folder #321

@PhoenixBound

Description

@PhoenixBound

CoilSnake passes an explicit list of all CCScript files in a project to the CCScript compiler extension module code:

# Compile scripts using CCScript
script_filenames = [os.path.join(project_path, "ccscript", x)
for x in os.listdir(os.path.join(project_path, "ccscript"))
if x.lower().endswith('.ccs')]
if script_filenames:
log.info("Compiling CCScript")
if not ccscript_offset:
ccscript_offset = "F10000"
elif type(ccscript_offset) == int:
ccscript_offset = "{:x}".format(ccscript_offset)

The use of os.listdir appears to mean that only .ccs files in the top-level ccscript directory, and not any of its subdirectories, will be added to the build. This has caused pain as people tried to put dialogue and important data, rather than just macros, in subfolders; explicit imports of these files are needed for them to be built.

It's also a potential source for non-determinism in the build -- the list of path entries returned "is in arbitrary order," rather than something predictable like alphabetical order. I think that means you could get a different result if you made a .zip of a project and then sent it to others and the .zip was extracted in alphabetical order. It would be best to squash that as well by sorting all the paths.

(I was curious how Visual CCScript handled this. It seems like .pkproj files contain an explicit list of all files to compile. It might be fair to label this CoilSnake "problem" as being inherited from the convention in the days of Visual CCScript -- notice how Zorkbound doesn't include anything from the Core folder in the project file itself -- but it's still kind of annoying nowadays.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions