From 9352ce5720602828fe26e4e23f391feb881cd015 Mon Sep 17 00:00:00 2001 From: Timm Fitschen <t.fitschen@indiscale.com> Date: Tue, 15 Jun 2021 12:24:51 +0200 Subject: [PATCH] ADD build properties AUTO_DISCOVER_MODULES, JS_DIST_BUNDLE --- Makefile | 2 +- build.properties.d/00_default.properties | 12 ++++++++++++ misc/merge_js.sh | 16 +++++++++------- 3 files changed, 22 insertions(+), 8 deletions(-) diff --git a/Makefile b/Makefile index f63274c3..d45ade7a 100644 --- a/Makefile +++ b/Makefile @@ -69,7 +69,7 @@ merge_xsl: merge_js: for f in ${BUILDFILELIST} ; do source "$$f" ; done ; \ - BUILD_JS_DIST_BUNDLE=$${BUILD_JS_DIST_BUNDLE} misc/merge_js.sh $${MODULE_DEPENDENCIES[*]} + JS_DIST_BUNDLE=$${JS_DIST_BUNDLE} AUTO_DISCOVER_MODULES=$$AUTO_DISCOVER_MODULES misc/merge_js.sh $${MODULE_DEPENDENCIES[*]} EXCLUDE_EXPR = %~ %.backup BUILDFILELIST = $(filter-out $(EXCLUDE_EXPR),$(wildcard build.properties.d/*)) diff --git a/build.properties.d/00_default.properties b/build.properties.d/00_default.properties index 36d29678..40d2610c 100644 --- a/build.properties.d/00_default.properties +++ b/build.properties.d/00_default.properties @@ -91,6 +91,18 @@ BUILD_CUSTOM_IMPRINT='<p> Put an imprint note here </p>' ############################################################################## BUILD_MODULE_EXT_TRIGGER_CRAWLER_FORM_TOOLBOX="Tools" +############################################################################## +# Build a dist file containing all JS code from the files in the +# MODULE_DEPENDENCIES array. +############################################################################## +JS_DIST_BUNDLE=TRUE +############################################################################## +# TRUE means that all javascript sources which are no mentioned in the +# MODULE_DEPENDENCIES array will be added in no particular order into the +# build. If you need to guarantee a specific order (in which the are loaded or +# appear in the dit file) you need to add them to the MODULE_DEPENDENCIES. +############################################################################## +AUTO_DISCOVER_MODULES=TRUE ############################################################################## # Module dependencies # Override or extend to specify the order of js files in the resulting diff --git a/misc/merge_js.sh b/misc/merge_js.sh index 2e674a51..506a6586 100755 --- a/misc/merge_js.sh +++ b/misc/merge_js.sh @@ -41,7 +41,7 @@ ALL_SOURCES=() _create_jsheader () { _JS_INCLUDE= - if [ "$BUILD_JS_DIST_BUNDLE" == "TRUE" ] ; then + if [ "$JS_DIST_BUNDLE" == "TRUE" ] ; then _SIZE=$(( $(wc -c ${DIST_BUNDLE_TARGET} | awk '{print $1}')/1024)) echo "including ${DIST_BUNDLE} (${_SIZE}kB) into ${JSHEADER_TARGET}" _JS_INCLUDE=" @@ -85,7 +85,7 @@ _create_jsheader () { } function _merge () { - if [ "$BUILD_JS_DIST_BUNDLE" != "TRUE" ] ; then + if [ "$JS_DIST_BUNDLE" != "TRUE" ] ; then return 0 fi _SOURCE=$2 @@ -110,11 +110,13 @@ for _SOURCE in ${CORE_MODULES[@]} ; do _merge "core" "${PUBLIC_JS_DIR}${_SOURCE}" $DIST_BUNDLE_TARGET done -# load other js files but exclude any subdirectory -for _SOURCE in $(find ${PUBLIC_JS_DIR}* -prune -iname "*.js") ; do - [[ ! " ${ALL_SOURCES[@]} " =~ " ${_SOURCE} " ]] && ALL_SOURCES+=(${_SOURCE}) - _merge "extension" ${_SOURCE} $DIST_BUNDLE_TARGET -done +if [ "$AUTO_DISCOVER_MODULES" == "TRUE" ] ; then + # load other js files but exclude any subdirectory + for _SOURCE in $(find ${PUBLIC_JS_DIR}* -prune -iname "*.js") ; do + [[ ! " ${ALL_SOURCES[@]} " =~ " ${_SOURCE} " ]] && ALL_SOURCES+=(${_SOURCE}) + _merge "extension" ${_SOURCE} $DIST_BUNDLE_TARGET + done +fi # for `make test` for _SOURCE in $(find ${PUBLIC_JS_DIR} -ipath "${PUBLIC_JS_DIR}modules/*.js") ; do -- GitLab