scripts: build.sh compiles all Packer components in parallel
This commit is contained in:
parent
3eb744249f
commit
6511b1892c
|
@ -35,21 +35,44 @@ fi
|
||||||
echo -e "${OK_COLOR}--> Installing dependencies to speed up builds...${NO_COLOR}"
|
echo -e "${OK_COLOR}--> Installing dependencies to speed up builds...${NO_COLOR}"
|
||||||
go get ./...
|
go get ./...
|
||||||
|
|
||||||
|
# This function waits for all background tasks to complete
|
||||||
|
waitAll() {
|
||||||
|
RESULT=0
|
||||||
|
for job in `jobs -p`; do
|
||||||
|
wait $job
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
RESULT=1
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
if [ $RESULT -ne 0 ]; then
|
||||||
|
exit $RESULT
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
echo -e "${OK_COLOR}--> NOTE: Compilation of components will be done in parallel.${NO_COLOR}"
|
||||||
|
|
||||||
# Compile the main Packer app
|
# Compile the main Packer app
|
||||||
echo -e "${OK_COLOR}--> Compiling Packer${NO_COLOR}"
|
echo -e "${OK_COLOR}--> Compiling Packer${NO_COLOR}"
|
||||||
|
(
|
||||||
go build \
|
go build \
|
||||||
${PACKER_RACE} \
|
${PACKER_RACE} \
|
||||||
-ldflags "-X github.com/mitchellh/packer/packer.GitCommit ${GIT_COMMIT}${GIT_DIRTY}" \
|
-ldflags "-X github.com/mitchellh/packer/packer.GitCommit ${GIT_COMMIT}${GIT_DIRTY}" \
|
||||||
-v \
|
-v \
|
||||||
-o bin/packer${EXTENSION} .
|
-o bin/packer${EXTENSION} .
|
||||||
|
) &
|
||||||
|
|
||||||
# Go over each plugin and build it
|
# Go over each plugin and build it
|
||||||
for PLUGIN in $(find ./plugin -mindepth 1 -maxdepth 1 -type d); do
|
for PLUGIN in $(find ./plugin -mindepth 1 -maxdepth 1 -type d); do
|
||||||
PLUGIN_NAME=$(basename ${PLUGIN})
|
PLUGIN_NAME=$(basename ${PLUGIN})
|
||||||
echo -e "${OK_COLOR}--> Compiling Plugin: ${PLUGIN_NAME}${NO_COLOR}"
|
echo -e "${OK_COLOR}--> Compiling Plugin: ${PLUGIN_NAME}${NO_COLOR}"
|
||||||
|
(
|
||||||
go build \
|
go build \
|
||||||
${PACKER_RACE} \
|
${PACKER_RACE} \
|
||||||
-ldflags "-X github.com/mitchellh/packer/packer.GitCommit ${GIT_COMMIT}${GIT_DIRTY}" \
|
-ldflags "-X github.com/mitchellh/packer/packer.GitCommit ${GIT_COMMIT}${GIT_DIRTY}" \
|
||||||
-v \
|
-v \
|
||||||
-o bin/packer-${PLUGIN_NAME}${EXTENSION} ${PLUGIN}
|
-o bin/packer-${PLUGIN_NAME}${EXTENSION} ${PLUGIN}
|
||||||
|
) &
|
||||||
done
|
done
|
||||||
|
|
||||||
|
waitAll
|
||||||
|
|
Loading…
Reference in New Issue