From: Piotr Tworek Date: Thu, 18 Dec 2014 13:07:35 +0000 (+0100) Subject: Minor improvements of desktop build scripts. X-Git-Tag: submit/tizen/20201118.160233~1472 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=661ea3791ff17601d2e4b4fcff73d0da047ddb13;p=platform%2Fframework%2Fweb%2Fchromium-efl.git Minor improvements of desktop build scripts. This is a collection of small fixes I've recently made while playing with chromium-efl build_desktop.sh script. Those are: 1. Improve argument parsing. Previous code needed 2 forks and a pipe to parse every single argument passed to the script. The same functionality can be achieved by only using shell built-in commands. It's more efficient and IMO easier to read. 2. Use integer comparison operations for variables which are supposed to have only integer values. 3. Clean-up script help message. 4. Use find instead of inefficient for loop to find files newer than jhbuild stamp. Bug: http://107.108.218.239/bugzilla/show_bug.cgi?id=9215 Reviewed by: Antonio Gomes, Kamil Klimek Change-Id: If390100b05a362f4ac33a63684210d7990533068 Signed-off-by: Piotr Tworek --- diff --git a/tizen_src/build/build_desktop.sh b/tizen_src/build/build_desktop.sh index 5dfa313..3d05888 100755 --- a/tizen_src/build/build_desktop.sh +++ b/tizen_src/build/build_desktop.sh @@ -17,21 +17,15 @@ parseHostBuildScriptParams desktop $@ JHBUILD_STAMPFILE="${GYP_GENERATOR_OUTPUT}/Dependencies/Root/jhbuild.stamp" shouldForceJHBuild() { - if echo "$@" | grep -cq '\-\-force-jhbuild'; then + if [[ $FORCE_JHBUILD == 1 ]]; then return 1 fi # Check if anything in jhbuild is more recent than stamp file. - for i in $(find "$SCRIPTDIR/jhbuild"); do - if [ -f "$i" -a "$JHBUILD_STAMPFILE" -ot "$i" ]; then - return 1 - fi - done - - return 0 + return $(find $SCRIPTDIR/jhbuild -type f -newer $JHBUILD_STAMPFILE -print | wc -l) } -if [ "$(shouldForceJHBuild $@)" == "1" ]; then +if [[ $(shouldForceJHBuild) > 0 ]]; then rm -f $JHBUILD_STAMPFILE fi @@ -46,7 +40,7 @@ export PKG_CONFIG_PATH="${JHBUILD_DEPS}/${_LIBDIR}/pkgconfig" if [ ! -f "$JHBUILD_STAMPFILE" ]; then jhbuild --no-interact -f ${SCRIPTDIR}/jhbuild/jhbuildrc - if [ "$?" == "0" ]; then + if [[ $? == 0 ]]; then echo "Yay! jhbuild done!" > $JHBUILD_STAMPFILE fi fi diff --git a/tizen_src/build/common.sh b/tizen_src/build/common.sh index 121d60c..3c83b0f 100644 --- a/tizen_src/build/common.sh +++ b/tizen_src/build/common.sh @@ -52,14 +52,14 @@ usage: $1 [OPTIONS] Build non gbs version of chromium-efl OPTIONS: - -h, --help Show this message - --skip-gyp Skip restore_gyp, jhbuild and gyp_chromium steps - --ccache configure ccache installed in your system - --content-shell Build content_shell application - --skip-ninja Skip ninja step - --build-ewk-unittests build ewk unittests - --debug build debug version of chromium-efl (in $GYP_GENERATOR_OUTPUT/Debug instead of default $GYP_GENERATOR_OUTPUT/Release) - -jN set number of jobs, just like with make or ninja + -h, --help Show this message + --build-ewk-unittests Build ewk unittests + --ccache Configure ccache installed in your system + --content-shell Build content_shell application + --debug Build debug version of chromium-efl (out.${host_arch}/Debug instead of out.${host_arch}/Release) + -jN Set number of jobs, just like with make or ninja + --skip-gyp Skip restore_gyp, jhbuild and gyp_chromium steps + --skip-ninja Skip ninja step examples: $0 --skip-gyp @@ -73,56 +73,68 @@ function parseHostBuildScriptParams() { export SKIP_GYP=0 export USE_CCACHE=0 + export FORCE_JHBUILD=0 export SKIP_NINJA=0 + export BUILD_EWK_UNITTESTS=0 + export BUILD_CONTENT_SHELL=0 export BUILD_SUBDIRECTORY=Release - if echo "$@" | grep -cq '\(\(\-\-help\)\|\(\-h\)\)'; then - hostBuldScriptUsage ${0} - fi - - if echo "$@" | grep -cq '\-\-skip-gyp'; then - export SKIP_GYP=1 - fi - - if echo "$@" | grep -cq '\-\-skip-ninja'; then - export SKIP_NINJA=1 - fi - - if echo "$@" | grep -cq '\-\-content_shell'; then - export BUILD_CONTENT_SHELL=1 - fi - - if echo "$@" | grep -cq '\-\-ccache'; then - export USE_CCACHE=1 - echo using ccache - source $TOPDIR/build/ccache_env.sh ${1} - fi - - if echo "$@" | grep -cq '\-\-build-ewk-unittests'; then - export BUILD_EWK_UNITTESTS=1 - fi - if echo "$@" | grep -cq '\-\-debug'; then - export BUILD_SUBDIRECTORY=Debug - fi - # Will be empty string if -j not specified or ill-formatted, otherwise -j and the number argument together. - # \grep because folks often alias grep but we want the vanilla behavior. - export JOBS=$(echo "$@" | \grep -Eo '\-j\s*[1-9]([0-9]*)') + local platform="$1" + shift + while [[ $# > 0 ]]; do + case "$1" in + -h|--help) + hostBuldScriptUsage ${0} + ;; + --skip-gyp) + export SKIP_GYP=1 + ;; + --ccache) + echo using ccache + export USE_CCACHE=1 + source $TOPDIR/build/ccache_env.sh ${platform} + ;; + --content-shell) + export BUILD_CONTENT_SHELL=1 + ;; + --force-jhbuild) + export FORCE_JHBUILD=1 + ;; + --skip-ninja) + export SKIP_NINJA=1 + ;; + --build-ewk-unittests) + export BUILD_EWK_UNITTESTS=1 + ;; + --debug) + export BUILD_SUBDIRECTORY="Debug" + ;; + -j*) + export JOBS="$1" + ;; + *) + echo "Unknown argument: $1" + exit 1 + ;; + esac + shift; + done } function hostGypChromiumEfl() { - if [ "$SKIP_GYP" == "0" ]; then + if [[ $SKIP_GYP == 0 ]]; then ${TOPDIR}/build/gyp_chromiumefl.sh $@ fi } function hostNinja() { - if [ "$SKIP_NINJA" == "0" ]; then + if [[ $SKIP_NINJA == 0 ]]; then TARGETS="chromium-efl efl_webprocess chromium-ewk efl_webview_app" - if [ "$BUILD_EWK_UNITTESTS" == "1" ]; then + if [[ $BUILD_EWK_UNITTESTS == 1 ]]; then TARGETS="$TARGETS ewk_unittests" fi - if [ "$BUILD_CONTENT_SHELL" == "1" ]; then + if [[ $BUILD_CONTENT_SHELL == 1 ]]; then TARGETS="$TARGETS content_shell_efl" fi BUILDDIR=${GYP_GENERATOR_OUTPUT}/${BUILD_SUBDIRECTORY}