|
|
@ -1,19 +1,26 @@ |
|
|
|
#!/bin/bash |
|
|
|
set -e |
|
|
|
|
|
|
|
# Utility |
|
|
|
is_git() { |
|
|
|
command -v git >/dev/null 2>&1 || return 1 |
|
|
|
command git rev-parse >/dev/null 2>&1 || return 1 |
|
|
|
|
|
|
|
return 0 |
|
|
|
} |
|
|
|
|
|
|
|
# Script settings |
|
|
|
version=$(grep APP_VERSION espurna/config/version.h | awk '{print $3}' | sed 's/"//g') |
|
|
|
|
|
|
|
(command -v git && git rev-parse --is-inside-work-tree) 2>&1>/dev/null |
|
|
|
if [ $? -eq 0 ]; then |
|
|
|
if is_git; then |
|
|
|
git_revision=$(git rev-parse --short HEAD) |
|
|
|
git_version=$(git describe --tags) |
|
|
|
git_version=${version}-${git_revision} |
|
|
|
else |
|
|
|
git_revision= |
|
|
|
git_version=$version |
|
|
|
fi |
|
|
|
|
|
|
|
par_build=0 |
|
|
|
par_build=false |
|
|
|
par_thread=${BUILDER_THREAD:-0} |
|
|
|
par_total_threads=${BUILDER_TOTAL_THREADS:-4} |
|
|
|
if [ ${par_thread} -ne ${par_thread} -o \ |
|
|
@ -27,8 +34,12 @@ if [ ${par_thread} -ge ${par_total_threads} ]; then |
|
|
|
fi |
|
|
|
|
|
|
|
# Available environments |
|
|
|
travis=$(grep env: platformio.ini | grep travis | sed 's/\[env://' | sed 's/\]/ /' | sort) |
|
|
|
available=$(grep env: platformio.ini | grep -v ota | grep -v ssl | grep -v travis | sed 's/\[env://' | sed 's/\]/ /' | sort) |
|
|
|
list_envs() { |
|
|
|
grep env: platformio.ini | sed 's/\[env:\(.*\)\]/\1/g' |
|
|
|
} |
|
|
|
|
|
|
|
travis=$(list_envs | grep travis | sort) |
|
|
|
available=$(list_envs | grep -Ev -- '-ota$|-ssl$|^travis' | sort) |
|
|
|
|
|
|
|
# Build tools settings |
|
|
|
export PLATFORMIO_BUILD_FLAGS="${PLATFORMIO_BUILD_FLAGS} -DAPP_REVISION='\"$git_revision\"'" |
|
|
@ -52,7 +63,7 @@ print_environments() { |
|
|
|
|
|
|
|
set_default_environments() { |
|
|
|
# Hook to build in parallel when using travis |
|
|
|
if [[ "${TRAVIS_BUILD_STAGE_NAME}" = "Release" ]] && [ ${par_build} ]; then |
|
|
|
if [[ "${TRAVIS_BUILD_STAGE_NAME}" = "Release" ]] && ${par_build}; then |
|
|
|
environments=$(echo ${available} | \ |
|
|
|
awk -v par_thread=${par_thread} -v par_total_threads=${par_total_threads} \ |
|
|
|
'{ for (i = 1; i <= NF; i++) if (++j % par_total_threads == par_thread ) print $i; }') |
|
|
@ -106,7 +117,7 @@ while getopts "lp" opt; do |
|
|
|
exit |
|
|
|
;; |
|
|
|
p) |
|
|
|
par_build=1 |
|
|
|
par_build=true |
|
|
|
;; |
|
|
|
esac |
|
|
|
done |
|
|
@ -125,7 +136,7 @@ if [ $# -eq 0 ]; then |
|
|
|
set_default_environments |
|
|
|
fi |
|
|
|
|
|
|
|
if [[ "${CI}" = true ]]; then |
|
|
|
if ${CI:-false}; then |
|
|
|
print_environments |
|
|
|
fi |
|
|
|
|
|
|
|