Consists of two tasks:
- incwatch
Only does one thing very well, watch the files that have changed since a certain time reference point. - incbuild
Builds/recompiles only what's needed. It configures tasks based on what's built/changed so that the tasks only act on what's needed.
incbuild
makes use of incwatch
to perform an incremental build?
Notes:
- Method used to track changes between tasks should be completedly independent of the build and watch tasks. Right now, the use of a temporary
.inc-watch-<target>
file is naive and primitive. It's a stopgap measure until grunt provides better ways to do this.
Let C = Changed files
C Union filesdependon(C)
For each task
Match its source files with the C, the dest files gets added into C
Remove dest mappings that do not have a corresponding matched file in C
C Union filesdependon(C)
Continue to next task
Run all tasks
Leave change tracking on between each task and accumulate changes and alter each task on-the-fly. This seems to be more deterministic and doesn't just rely on the files
option to specify all dest files that will be changed.
For each task
C = Changed files so far
C Union filesdependon(C)
Match its source files with the C, the dest files gets added into C
Remove dest mappings that do not have a corresponding matched file in C
Run task
For many-to-one mappings:
Retain the source glob
Create the destination file using all of the required source files
For one-to-one mappings:
Reduce the glob into one-to-one file to dest file mapping
Only need to create that one dest file
-
How to support dependencies?
Dependencies can be added as a function into the inc-watch task as an option. They can be resolved and flattened using a Union-Find algorithm. -
Behavior for changed files:
If file is one-to-one mapped: Regenerate dest file
If file is many-to-one mapped: Regenerate dest file with original patterns/globs in the src. -
Behavior for added files:
If file is one-to-one mapped: Add a new file
If file is many-to-one mapped: Regenerate dest file with original patterns/globs in the src. -
Behavior for deleted files:
If file is one-to-one mapped: Remove the dest file, since it will no longer be generated.
If file is many-to-one mapped: Regenerate dest file with original patterns/globs in the src. -
Check if files are one-to-one mapped.
-
Changed file list will be cleared only on successful completion. Otherwise, it will be added upon. The same file may appear more than once in the change file list. This is fine as only the last one occurrence will be used on the read (use a map to implement?).