-
Notifications
You must be signed in to change notification settings - Fork 570
Description
Summary
Support purs compile path/to/file/containing/source-globs
Motivation
AFAIU, Windows' cmd.exe is the only way to start a process on Windows. Unfortunately, cmd.exe has a character limitation of 8191 characters, unlike *nix shells. Moreover, there really isn't a workaround to this limit besides passing in such information via a file. In some recent work on the Spago rewrite, we hit that limit due to escaping some special characters, probably unnecessarily.
While we can fix that on the Spago side, the Spago rewrite enables (and thereby encourages to some degree) the usage of subpackages. On some very large projects, I imagine running spago on Windows would hit this issue at some point.
Proposal
By passing information to purs via a file, one might wonder whether we should pass additional information besides the source globs via a file. The answer is no and such a change is outside the scope of this proposal. None of the flags/arguments that purs currently supports can "grow" as large as the source globs. So, there's no reason to make such a change.
Moreover, passing source globs to purs as it is done now doesn't need to change or be removed. It still works on *nix shells, so there's no reason to interrupt such workflows with what would be a breaking change.
Instead, I propose an additive change. In addition to passing source globs as it is currently done, we also allow passing source globs via a text file. We would update the CLI to use the --source-globs FILE argument to indicate which file contains the source globs. When this command is used, any globs passed in through the normal method produces an non-zero exit with an error explaining why.
Since the globs are just a list of text values, the file is a text file. Other formats are not used (e.g. JSON) because we don't need the additional structure.
The text file shall follow these requirements:
- When reading the file,
purswill split the text into lines, regardless of which OS-specific line separator was used when writing the file. - Each line consists of one of three values:
- an empty line (ignored)
- a line starting with
#(a comment; ignored) - a single source glob (default)
- Each source glob must specify a path that is relative to the directory from which
pursis called.
The usage of --source-globs FILE may not be the best name to use when we make the compiler package aware (i.e. #3493). But since I believe that would be a breaking change anyways, I don't think it would matter in the mean time.
Examples
# This still works
purs compile src/**/*.purs .spago/packages/prelude-6.0.1/src/**/*.purs
# But this now also works
purs compile --source-globs .spago/source-globswhere .spago/source-globs' file contains the following:
# This file is automatically generated by Spago.
# Do not edit by hand!
src/**/*.purs
.spago/packages/prelude-6.0.1/src/**/*.purs