Commit f91d528d authored by Ben Avison's avatar Ben Avison Committed by ROOL
Browse files

Improvements to `!Common.sh` script (for cross-compiling)

* `make` is changed from an alias to a function. This allows many CI scripts
  to be simplified, since they will no longer require `shopt expand_aliases`.
  It also allows us to be `source`d from within a subshell, when alias
  definitions have no effect, which is useful in certain special cases.
* `mk` function now uses `trap` to clean up whatever the manner in which it
  is exited. It also runs in `-e` mode (and uses an OR operator to avoid
  `grep` failures being considered fatal) so that `mk` behaves the same,
  whether the calling shell was in `-e` mode or not. (This is useful because
  CI scripts are run in `-e` mode by default.)
* `mk` now builds the `make` arguments using an array, to avoid any issues
  with special characters in any of the strings used.
* Now passes ShellCheck tests.
* Set correct tool options for cross-compiling Raspberry Pi ROMs (reflects
  addition of `Machine=RPi` from Library-1_76).

Version 1.47. Tagged as 'Env-1_47'
parent 040a8fcb
......@@ -51,7 +51,7 @@ elif [ "$APCS" = "APCS-32" ]; then
NCC_TOOLOPTIONS="-APCS 3/32bit/fpe3 -cpu 5TE -memaccess +L22+S22+L41"
OBJASM_TOOLOPTIONS="-APCS 3/32bit -cpu 5TE"
;;
'ARM11ZF')
'ARM11ZF' | 'RPi')
GCC_TOOLOPTIONS="-march=armv6 -mfpu=fpe3"
NCC_TOOLOPTIONS="-APCS 3/32bit/fpe3 -cpu 6 -memaccess +L22+S22-L41"
OBJASM_TOOLOPTIONS="-APCS 3/32bit/fpe3 -cpu 6Z --fpu VFPv2"
......@@ -94,7 +94,9 @@ export LIBDIR=$APCSEXPORTDIR/Lib
export HDR_PATH=$HDRDIR/Global:$HDRDIR/Interface
# This enables you to simply type "make all" from the command line
alias make="make -I\"\$MAKEFILEDIR\" --no-print-directory"
make () {
command make -I"$MAKEFILEDIR" --no-print-directory "$@"
}
# This is similar, but infers COMPONENT, TARGET and INSTDIR from the ModuleDB
# if possible. Where a source directory occurs multiple times within the
......@@ -103,8 +105,17 @@ alias make="make -I\"\$MAKEFILEDIR\" --no-print-directory"
# from the environment also override those from the ModuleDB. You can also
# use the -C switch to avoid having to cd to a component first, just like
# with make. Any additional arguments (make targets etc) are passed to make.
mk ()
{(
mk () (
on_exit() {
trap - EXIT
rm -f "$MYTMP"
exit "$1"
}
MYTMP=$(mktemp)
trap 'on_exit $?' EXIT
set -e
COMPONENTDIR=$(pwd)
if [ "$1" = "-C" ]; then
COMPONENTDIR="$(cd "$2" && pwd)"
......@@ -112,31 +123,30 @@ mk ()
shift
fi
RELPATH=$(echo "${COMPONENTDIR#*$BUILDDIR/}" | tr / .)
MYTMP=$(mktemp)
NOT_FOUND=
if [ -n "$COMPONENT" ]; then
grep "^$COMPONENT " "$BUILDDIR/BuildSys/ModuleDB" > "$MYTMP"
grep "^$COMPONENT " "$BUILDDIR/BuildSys/ModuleDB" > "$MYTMP" || NOT_FOUND=1
else
grep "$RELPATH\( \|$\)" "$BUILDDIR/BuildSys/ModuleDB" > "$MYTMP"
grep "$RELPATH\( \|$\)" "$BUILDDIR/BuildSys/ModuleDB" > "$MYTMP" || NOT_FOUND=1
fi
if [ $? -ne 0 ]; then
if [ -n "$NOT_FOUND" ]; then
# Component not found in ModuleDB - can't infer anything
make -C "$COMPONENTDIR" "$@" || { rm "$MYTMP"; exit 1; }
make -C "$COMPONENTDIR" "$@"
else
while read -r DB_COMPONENT _ _ DB_INSTDIR DB_TARGET; do
ARGS=""
ARGS=("-C" "$COMPONENTDIR")
if [ -z "$COMPONENT" ]; then
ARGS="$ARGS COMPONENT=$DB_COMPONENT"
ARGS+=("COMPONENT=$DB_COMPONENT")
fi
if [ -z "$TARGET" ] && [ -n "$DB_TARGET" ]; then
ARGS="$ARGS TARGET=$DB_TARGET"
ARGS+=("TARGET=$DB_TARGET")
fi
if [ -z "$INSTDIR" ] && [ -n "$DB_INSTDIR" ]; then
ARGS="$ARGS INSTDIR=\"$INSTALLDIR/$DB_INSTDIR\""
ARGS+=("INSTDIR=$INSTALLDIR/$DB_INSTDIR")
fi
make -C "$COMPONENTDIR" $ARGS "$@" || { rm "$MYTMP"; exit 1; }
make "${ARGS[@]}" "$@"
done < "$MYTMP"
fi
rm "$MYTMP"
)}
)
/* (1.46)
/* (1.47)
*
* This file is automatically maintained by srccommit, do not edit manually.
*
*/
#define Module_MajorVersion_CMHG 1.46
#define Module_MajorVersion_CMHG 1.47
#define Module_MinorVersion_CMHG
#define Module_Date_CMHG 19 Apr 2021
#define Module_Date_CMHG 16 Jun 2021
#define Module_MajorVersion "1.46"
#define Module_Version 146
#define Module_MajorVersion "1.47"
#define Module_Version 147
#define Module_MinorVersion ""
#define Module_Date "19 Apr 2021"
#define Module_Date "16 Jun 2021"
#define Module_ApplicationDate "19-Apr-21"
#define Module_ApplicationDate "16-Jun-21"
#define Module_ComponentName "Env"
#define Module_FullVersion "1.46"
#define Module_HelpVersion "1.46 (19 Apr 2021)"
#define Module_LibraryVersionInfo "1:46"
#define Module_FullVersion "1.47"
#define Module_HelpVersion "1.47 (16 Jun 2021)"
#define Module_LibraryVersionInfo "1:47"
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment