Skip to content
This repository has been archived by the owner on Jan 6, 2023. It is now read-only.

Commit

Permalink
docker scripts: Allow passing arguments.
Browse files Browse the repository at this point in the history
Current docker scripts are building only CI targets. This makes it hard to use
these sripts for builing local custom targets.

Instead this chagne allows to pass argument(s) to local-build.sh what to build.
If no arguments, then fallback to find CI targets.

This also allows to pass all bitbake arguments to scripts.

Signed-off-by: Amarnath Valluri <[email protected]>
  • Loading branch information
avalluri committed Oct 5, 2016
1 parent 2d29de2 commit 043e380
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 24 deletions.
52 changes: 29 additions & 23 deletions docker/build-project.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ set -o pipefail
# FIXME: debug
env | sort

BUILD_TARGET="$@"

# bitbake started to depend on a locale with UTF-8 support
# when migrating to Python3.
export LC_ALL=en_US.UTF-8
Expand Down Expand Up @@ -92,30 +94,34 @@ fi
export BUILD_ID=${CI_BUILD_ID}
export BB_ENV_EXTRAWHITE="$BB_ENV_EXTRAWHITE BUILD_ID"

# Let's try to fetch build targets from configuration files
bitbake -e >bb_e_out 2>bb_e_err || (cat bb_e_err && false)
grep -E "^OSTROPROJECT_CI" bb_e_out > ${WORKSPACE}/ostroproject_ci_vars || true
_bitbake_targets=""
OSTROPROJECT_CI_BUILD_TARGETS_TASK=""
OSTROPROJECT_CI_SDK_TARGETS_TASK="do_populate_sdk"
OSTROPROJECT_CI_ESDK_TARGETS_TASK="do_populate_sdk_ext"
OSTROPROJECT_CI_TEST_EXPORT_TARGETS_TASK="do_test_iot_export"
for ci_var in `perl -pe "s/^([A-Z_]+)=.+/\1/g" ${WORKSPACE}/ostroproject_ci_vars`; do
ci_var_task="${ci_var}_TASK"
if [ -v "$ci_var_task" ]; then
for img in `grep ${ci_var} ${WORKSPACE}/ostroproject_ci_vars | perl -pe 's/.+="(.*)"/\1/g; s/[^ a-zA-Z0-9_-]//g'`; do
if [ -n "${!ci_var_task}" ]; then
_bitbake_targets="$_bitbake_targets $img:${!ci_var_task}"
else
_bitbake_targets="$_bitbake_targets $img"
fi
done
if [ -z "$BUILD_TARGET" ]; then
# Let's try to fetch build targets from configuration files
bitbake -e >bb_e_out 2>bb_e_err || (cat bb_e_err && false)
grep -E "^OSTROPROJECT_CI" bb_e_out > ${WORKSPACE}/ostroproject_ci_vars || true
_bitbake_targets=""
OSTROPROJECT_CI_BUILD_TARGETS_TASK=""
OSTROPROJECT_CI_SDK_TARGETS_TASK="do_populate_sdk"
OSTROPROJECT_CI_ESDK_TARGETS_TASK="do_populate_sdk_ext"
OSTROPROJECT_CI_TEST_EXPORT_TARGETS_TASK="do_test_iot_export"
for ci_var in `perl -pe "s/^([A-Z_]+)=.+/\1/g" ${WORKSPACE}/ostroproject_ci_vars`; do
ci_var_task="${ci_var}_TASK"
if [ -v "$ci_var_task" ]; then
for img in `grep ${ci_var} ${WORKSPACE}/ostroproject_ci_vars | perl -pe 's/.+="(.*)"/\1/g; s/[^ a-zA-Z0-9_-]//g'`; do
if [ -n "${!ci_var_task}" ]; then
_bitbake_targets="$_bitbake_targets $img:${!ci_var_task}"
else
_bitbake_targets="$_bitbake_targets $img"
fi
done
fi
done
if [ -z "$_bitbake_targets" ]; then
# Autodetection failed.
echo "ERROR: can't detect build targets. Check that OSTROPROJECT_CI_*_TARGETS defined in your configs."
exit 1
fi
done
if [ -z "$_bitbake_targets" ]; then
# Autodetection failed.
echo "ERROR: can't detect build targets. Check that OSTROPROJECT_CI_*_TARGETS defined in your configs."
exit 1
else
_bitbake_targets="$BUILD_TARGET"
fi

if [ -v JOB_NAME ]; then
Expand Down
2 changes: 1 addition & 1 deletion docker/local-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -58,5 +58,5 @@ docker run -it --rm "${RUN_ARGS[@]}" \
-v $BUILD_CACHE_DIR:$BUILD_CACHE_DIR:rw \
-v $WORKSPACE:$WORKSPACE:rw \
-w $WORKSPACE \
$CURRENT_PROJECT $WORKSPACE/docker/build-project.sh
$CURRENT_PROJECT $WORKSPACE/docker/build-project.sh "$@"

1 comment on commit 043e380

@kad
Copy link
Contributor

@kad kad commented on 043e380 Oct 5, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

split that commit to separate PR. it looks good to be standalone.
Generally, it's easy to re-define OSTROPROJECT_CI___TARGETS / OSTROPROJECT_CI___TARGETS_TASK variables in conf/local.conf, but passing argument directly to local-build.sh is also good approach.

Please sign in to comment.