Created
July 6, 2018 14:26
-
-
Save benknoble/fea301daeb427ab65fb3c80bd5095f63 to your computer and use it in GitHub Desktop.
Make dynamically generated targets (example/proof of concept)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
all: | |
$(MAKE) $(shell ./targets.sh) | |
one: | |
@echo one | |
two: | |
@echo two |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env bash | |
targets() { | |
local targets=( | |
one | |
two | |
) | |
echo "${targets[@]}" | |
} | |
main() { | |
targets | |
} | |
main |
Recursive make
s automatically inherit flags passed, so make -j
will run everything in parallel.
If the targets were long running build processes, say,
one:
@sleep 5
@echo one
two:
@sleep 5
@echo two
Then make -j
would only wait 5 seconds before outputting one
and two
(compared to 10 without -j
, as each target is serially built).
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Sample output: