watchman-make: provide multiple pattern-to-script mappings
- Dominant language
- C++
- Stars
- 13.7k
- Forks
- 1.1k
- PR merge metrics
- No merged PRs in 30d
Description
`watchman-make` allows the definition of distinct `make` targets for different patterns; for example (from [the docs](https://facebook.github.io/watchman/docs/watchman-make.html)):
```sh
$ watchman-make -p '*.c' '*.h' 'Makefile*' -t all \
-p 'tests/**/*.py' 'tests/**/*.c' -t integration
# Relative to /path/
# Changes to files matching *.c *.h Makefile* will execute `make all`
# Changes to files matching tests/**/*.py tests/**/*.c will execute `make integration`
# waiting for changes
```
On the other hand, it does not allow distinct `--run` scripts for different patterns; only the last pattern/script pair is used:
```sh
$ watchman-make -p '*.c' '*.h' 'build-script.sh' -r ./build-script.sh \
-p 'tests/**/*.py' 'tests/**/*.c' -r ./integration-script.sh
# Relative to /path/
# Changes to files matching tests/**/*.py tests/**/*.c will execute `./integration-script.sh`
```
This syntax would offer consistency between the `-t` and `-r` options (even if their usage remains mutually exclusive); I think `watchman-make`'s argument parsing could be modified to support it.
Alternatively, the `--run` documentation could be expanded to specify that only a single pattern/script pair is supported.
One note: there exists a work-around analogous to the one used for single scripts in #232, the issue that let to the addition of the `--run` option. The work-around in action:
```sh
$ watchman-make -p '*.c' '*.h' 'build-script.sh' --make ./build-script.sh -t '' \
-p 'tests/**/*.py' 'tests/**/*.c' --make ./integration-script.sh -t ''
# Relative to /path/
# Changes to files matching *.c *.h build-script.sh will execute `./build-script.sh `
# Changes to files matching tests/**/*.py tests/**/*.c will execute `./integration-script.sh `
```
Contributor guide
Research direction
Start at the watchman-make argument parsing for the -p, -r, and -t options, then compare the behavior described in the watchman-make documentation. Done means multiple pattern/script pairs execute their corresponding --run scripts, or the documentation clearly states that only one pair is supported; verify both examples and the existing workaround.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- cli
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100