Bläddra i källkod

Adds possibility to specify target platforms via env-variable TARGETS

The variable takes a space separated list of platforms for which images
should be created. If unset, images for all target platforms in
${CODEDIR}/targets/ will be build.
Stefan Laudemann 9 år sedan
förälder
incheckning
8865ed00d1
2 ändrade filer med 59 tillägg och 15 borttagningar
  1. 1 0
      ReadMe.md
  2. 58 15
      build.sh

+ 1 - 0
ReadMe.md

@@ -19,6 +19,7 @@ Rufe `build.sh` auf und übergebe folgende Umgebungsvariablen:
 * **VERSION** wird die Versions-Nr. der neuen Firmware (kann bei BRANCH=experimental) weggelassen werden
 * **BROKEN** falls "1", erzeuge ebenfalls Firmware-Images für ungetestete Plattformen (default: "0")
 * **MAKEJOBS** spezifiziert die Anzahl der parallel laufenden Compiler-Prozesse (falls nicht angegeben, wird ein Prozess pro CPU/Kern gestartet)
+* **TARGET** ein Liste durch Leerzeichen separierter Hardware-Zielplattformen (falls nicht angegeben, werden Images für alle bekannten Plattformen erzeugt)
 
 ```bash
 # Baut eine testing-Firmware auf Basis von Gluon 2014.4

+ 58 - 15
build.sh

@@ -11,8 +11,20 @@
 # BUILD_TS  = build timestamp (format: %Y-%m-%d %H:%M:%S)
 # BROKEN    = 0 (default) or 1, build the untested hardware model firmwares, too
 # MAKEJOBS  = number of compiler processes running in parallel (default: number of CPUs/Cores)
+# TARGETS   = a space separated list of target platforms (if unset, all platforms will be build)
 #
 
+function get_all_supported_platforms()
+{
+    local buffer;
+    for val in $(ls ${1}) ; do
+        [ -d "./${1}/${val}" ] || continue
+	buffer="${buffer} ${val}"
+    done
+    echo ${buffer}
+}
+
+
 if [ "_$BRANCH" == "_" ]; then
 	echo "Please specify BRANCH environment variable." >&2
 	exit 1
@@ -77,30 +89,52 @@ cd ..
 
 ### CLEAN
 if [ "$BRANCH" != "experimental" ]; then
-	progress "Cleaning your build environment ..."
-	make clean
+    progress "Cleaning your build environment ..."
+    make dirclean
 fi
 
 ### PREPARE
-[ -n "${MAKEJOBS}" ] || MAKEJOBS=$(grep -c "^processor" /proc/cpuinfo)
 progress "Preparing the build environment (make update) ..."
 make update
 [ "$?" -eq "0" ] || abort "Failed to update the build environment, mimimi."
 
-### BUILD TOOLCHAIN
-progress "Building toolchain if necessary (this is not possible on a fresh build) ..."
-faketime "$BUILD_TS" make toolchain -j ${MAKEJOBS}
-
 ### BUILD FIRMWARE
 progress "Building the firmware - please stand by!"
-[ "_$BROKEN" == "_" ] && export BROKEN=0
-if [ "$BRANCH" != "experimental" ]; then
-	GLUON_BRANCH=$BRANCH GLUON_RELEASE=$VERSION BROKEN=$BROKEN faketime "$BUILD_TS" make -j ${MAKEJOBS}
-else
-	GLUON_BRANCH=experimental faketime "$BUILD_TS" make -j ${MAKEJOBS}
+[ -n "${BROKEN}" ] || BROKEN=0
+[ -n "${MAKEJOBS}" ] || MAKEJOBS=$(grep -c "^processor" /proc/cpuinfo)
+[ -n "${TARGETS}" ] || TARGETS=$(get_all_supported_platforms "./targets")
+
+if [ "${BRANCH}" == "experimental" -a -z "${VERSION}" ] ; then
+    default_release_pattern=$( awk -F" := " '/^DEFAULT_GLUON_RELEASE/ { gsub("shell ", "", $2); print $2; }' ./site/site.mk )
+    VERSION=$(eval echo ${default_release_pattern})
 fi
 
-[ "$?" -eq "0" ] || abort "Failed to build the firmware, mimimi."
+for target in ${TARGETS} ; do
+    # configure build environment for our current target
+    export GLUON_TARGET="${target}"
+    gluon_build_env_vars="GLUON_TARGET=\"${target}\" GLUON_BRANCH=\"${BRANCH}\" GLUON_RELEASE=\"${VERSION}\" BROKEN=\"${BROKEN}\""
+
+    # prepare build environment for our current target
+    progress "Preparing build environment for target ${target}."
+    [ "${BRANCH}" == "experimental" ] || make clean
+    make -j ${MAKEJOBS} prepare-target
+
+    # need to have a toolchain for the particular target 
+    progress "Building toolchain for target ${target}."
+    make -j ${MAKEJOBS} toolchain/install
+    [ "$?" -eq "0" ] || abort "Unable to build toolchain for target. Aborting."
+
+    # now we can start building the images for the target platform
+    progress "Building FFPB-flavoured Gluon firmware for target ${target}. You'd better go and fetch some c0ffee!"
+    make_targets="prepare"
+    eval "${gluon_build_env_vars} faketime \"$BUILD_TS\" make -j ${MAKEJOBS} ${make_targets}"
+    [ "$?" -eq "0" ] || abort "Failed to build firmware for target-platform ${target}."
+
+    # finally compile the firmware binaries
+    progress "Compiling binary firmware images."
+    faketime "$BUILD_TS" make images
+    [ "$?" -eq "0" ] || abort "Failed to assemble images for target-platform ${target}."
+done
 
 cd ..
 
@@ -119,10 +153,19 @@ progress "Assembling images.7z ..."
 [ -e "output/${BRANCH}/images.7z" ] && rm "output/${BRANCH}/images.7z"
 7z a "output/${BRANCH}/images.7z" ${CODE_DIR}/images/sysupgrade/*.bin ${CODE_DIR}/images/factory/*.bin || abort "Failed to assemble images (did you install p7zip-full?)."
 
-# generate and copy manifest
+# generate, franken-merge, and copy manifests
 progress "Generating and copying manifest ..."
 pushd $CODE_DIR
-GLUON_BRANCH=$BRANCH make manifest || abort "Failed to generate the manifest, try running 'make manifest' in '$CODE_DIR' directory manually."
+for target in ${TARGETS} ; do
+    GLUON_TARGET="${target}" GLUON_BRANCH=$BRANCH make manifest || abort "Failed to generate the manifest, try running 'make manifest' in '$CODE_DIR' directory manually."
+    mv ./images/sysupgrade/${BRANCH}.manifest ./images/sysupgrade/${target}.${BRANCH}.manifest
+done
+frankenmerge_manifest_file="./images/sysupgrade/${BRANCH}.manifest"
+echo "BRANCH=${BRANCH}" > ${frankenmerge_manifest_file}
+echo "DATE=${BUILD_TS}" >> ${frankenmerge_manifest_file}
+echo "PRIORITY=0" >> ${frankenmerge_manifest_file}
+echo "" >> ${frankenmerge_manifest_file}
+grep -hE "*.bin$" ./images/sysupgrade/*.${BRANCH}.manifest | sort >> ${frankenmerge_manifest_file}
 popd
 cp "${CODE_DIR}/images/sysupgrade/${BRANCH}.manifest" "output/${BRANCH}/"