Commit 09cc90ae authored by Ben Avison's avatar Ben Avison
Browse files

Refactor cross-compilation environment scripts

Detail:
  In tentative efforts to support cross-compilation to date, a few
  components have had mk.sh scripts inserted. These are functionally
  equivalent to the !Mk* TaskObey files, in that they are a convenience for
  developers working on that component in isolation. However, unlike their
  RISC OS equivalents, the nature of shell scripts means that they are
  relatively complex, and are therefore relatively burdensome to create and
  maintain. This commit replaces this mechanism with a shell function which
  is defined when you source the Env file. This enables a build phase to be
  applied to the component at the working directory to be built with a
  simple "mk export", "mk install", "mk rom", "mk clean" and so on.
  Previously, the build variables COMPONENT, TARGET and INSTDIR were encoded
  in the mk.sh script, and where a component had multiple targets, the mk.sh
  script would run the phase on all such components; now the mk function
  scans the ModuleDB to locate this information instead. You can even target
  a component in another directory using the -C switch (chosen to match
  make's equivalent switch). Some efforts have also been made to support
  Posix shells other than bash. The only feature dropped is the ability to
  build the component using a different environment within a subshell.
  However it's relatively simple to construct this at the command line if
  desired.

Version 1.38. Tagged as 'Env-1_38'
parent 864ec3ee
......@@ -4,7 +4,6 @@
[ "$MACHINE" != "" ] || { echo "No build selected - Run an Env file"; exit 1; }
export BUILDDIR=`pwd`
export TOOLSDIR=$BUILDDIR/Library
export ROOL_BIN=/opt/rool/bin
......@@ -18,14 +17,14 @@ export MAKEFILEDIR=$BUILDDIR/BuildSys/GNUmakefiles
#export SRCDIR=$BUILDDIR/Sources
export INSTALLDIR=$BUILDDIR/Install
if [ "$APCS" == "APCS-R" ]; then
if [ "$APCS" = "APCS-R" ]; then
TOOLOPTIONS="-26bit"
ASASM_TOOLOPTIONS="-apcs26 -apcsfpv2"
CMUNGE_TOOLOPTIONS="-26bit -apcs 3/26bit/fpe2"
GCC_TOOLOPTIONS="-mapcs-26 -march=armv2 -mfpu=fpe2"
NCC_TOOLOPTIONS="-APCS 3/26bit/fpe2"
OBJASM_TOOLOPTIONS="-APCS 3/26bit"
elif [ "$APCS" == "APCS-32" ]; then
elif [ "$APCS" = "APCS-32" ]; then
TOOLOPTIONS="-32bit"
ASASM_TOOLOPTIONS="-apcs32 -apcsfpv3"
CMUNGE_TOOLOPTIONS="-32bit -apcs 3/32bit/fpe3"
......@@ -93,3 +92,48 @@ export LIBDIR=$APCSEXPORTDIR/Lib
# This enables you to simply type "make all" from the command line
alias make="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
# ModuleDB, make is invoked once for each possible COMPONENT, unless a single
# COMPONENT is specified in the environment. Settings of TARGET and INSTDIR
# 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 ()
{(
COMPONENTDIR=`pwd`
if [ "$1" = "-C" ]; then
COMPONENTDIR="$(cd $2 && pwd)"
shift
shift
fi
RELPATH=`echo ${COMPONENTDIR#*$BUILDDIR/} | tr / .`
MYTMP=$(mktemp)
if [ -n "$COMPONENT" ]; then
grep "^$COMPONENT " $BUILDDIR/BuildSys/ModuleDB > $MYTMP
else
grep "$RELPATH" $BUILDDIR/BuildSys/ModuleDB | grep -v "$RELPATH\." > $MYTMP
fi
if [ $? -ne 0 ]; then
# Component not found in ModuleDB - can't infer anything
make -C $COMPONENTDIR $@
else
while read -r DB_COMPONENT _ _ DB_INSTDIR DB_TARGET; do
ARGS=""
if [ -z "$COMPONENT" ]; then
ARGS="$ARGS COMPONENT=$DB_COMPONENT"
fi
if [ -z "$TARGET" ]; then
ARGS="$ARGS TARGET=$DB_TARGET"
fi
if [ -z "$INSTDIR" ]; then
ARGS="$ARGS INSTDIR=$INSTALLDIR/$DB_INSTDIR"
fi
make -C $COMPONENTDIR $ARGS $@
done < $MYTMP
fi
rm $MYTMP
)}
#!/bin/bash
# Environment to build ROM for Raspberry Pi (BCM2835-based board)
#
# This can either be applied to the current shell using the "source" command,
# or executed directly. In the latter case, you will want to describe a
# a command to be executed by a subshell using the parameters to this script.
# In either case, the working directory must be set to the root of your sandbox on entry.
# This script is applied to the current shell using the "." or "source" builtin shell commands.
export LOCALE=UK
export KEYBOARD=All
......@@ -17,6 +13,14 @@ export HALSIZE=64K
export BUILD=ROOL/BCM2835
export APCS=APCS-32
. Env/!Common.sh
# Get the location of this script when sourced from a variety of common Posix shells: bash, dash, ksh or zsh
[ -z "$@" ] || bash -c "$@"
if [ -n "$BASH" ]; then script=$BASH_SOURCE
elif [ -n "$TMOUT" ]; then script=${.sh.file}
elif [ -n "$ZSH_NAME" ]; then script=${(%):-%x}
elif [ ${0##*/} = dash ]; then x=$(lsof -p $$ -Fn0 | tail -1); script=${x#*n}
fi
export BUILDDIR="$(cd $(dirname $(readlink -f "$script"))/../../../.. && pwd)"
. $BUILDDIR/Env/!Common.sh
#!/bin/bash
# Environment to build core parts of the build environment - executed by the host RISC OS system
#
# This can either be applied to the current shell using the "source" command,
# or executed directly. In the latter case, you will want to describe a
# a command to be executed by a subshell using the parameters to this script.
# In either case, the working directory must be set to the root of your sandbox on entry.
# This script is applied to the current shell using the "." or "source" builtin shell commands.
export LOCALE=UK
export KEYBOARD=All
......@@ -17,6 +13,14 @@ export HALSIZE=64K
export BUILD=ROOL/CTools
export APCS=APCS-32
. Env/!Common.sh
# Get the location of this script when sourced from a variety of common Posix shells: bash, dash, ksh or zsh
[ -z "$@" ] || bash -c "$@"
if [ -n "$BASH" ]; then script=$BASH_SOURCE
elif [ -n "$TMOUT" ]; then script=${.sh.file}
elif [ -n "$ZSH_NAME" ]; then script=${(%):-%x}
elif [ ${0##*/} = dash ]; then x=$(lsof -p $$ -Fn0 | tail -1); script=${x#*n}
fi
export BUILDDIR="$(cd $(dirname $(readlink -f "$script"))/../../../.. && pwd)"
. $BUILDDIR/Env/!Common.sh
#!/bin/bash
# Environment to build cross-compiling versions of the toolchain
#
# This can either be applied to the current shell using the "source" command,
# or executed directly. In the latter case, you will want to describe a
# a command to be executed by a subshell using the parameters to this script.
# In either case, the working directory must be set to the root of your sandbox on entry.
# This script is applied to the current shell using the "." or "source" builtin shell commands.
export LOCALE=UK
export KEYBOARD=All
......@@ -18,6 +14,14 @@ export BUILD=ROOL/CrossTools
export APCS=Host
export TOOLCHAIN=GNU
. Env/!Common.sh
# Get the location of this script when sourced from a variety of common Posix shells: bash, dash, ksh or zsh
[ -z "$@" ] || bash -c "$@"
if [ -n "$BASH" ]; then script=$BASH_SOURCE
elif [ -n "$TMOUT" ]; then script=${.sh.file}
elif [ -n "$ZSH_NAME" ]; then script=${(%):-%x}
elif [ ${0##*/} = dash ]; then x=$(lsof -p $$ -Fn0 | tail -1); script=${x#*n}
fi
export BUILDDIR="$(cd $(dirname $(readlink -f "$script"))/../../../.. && pwd)"
. $BUILDDIR/Env/!Common.sh
#!/bin/bash
# Environment to build user disc image (also useful for any other soft-loadable binaries)
#
# This can either be applied to the current shell using the "source" command,
# or executed directly. In the latter case, you will want to describe a
# a command to be executed by a subshell using the parameters to this script.
# In either case, the working directory must be set to the root of your sandbox on entry.
# This script is applied to the current shell using the "." or "source" builtin shell commands.
export LOCALE=UK
export KEYBOARD=All
......@@ -17,6 +13,14 @@ export HALSIZE=64K
export BUILD=ROOL/Disc
export APCS=APCS-32
. Env/!Common.sh
# Get the location of this script when sourced from a variety of common Posix shells: bash, dash, ksh or zsh
[ -z "$@" ] || bash -c "$@"
if [ -n "$BASH" ]; then script=$BASH_SOURCE
elif [ -n "$TMOUT" ]; then script=${.sh.file}
elif [ -n "$ZSH_NAME" ]; then script=${(%):-%x}
elif [ ${0##*/} = dash ]; then x=$(lsof -p $$ -Fn0 | tail -1); script=${x#*n}
fi
export BUILDDIR="$(cd $(dirname $(readlink -f "$script"))/../../../.. && pwd)"
. $BUILDDIR/Env/!Common.sh
/* (1.37)
/* (1.38)
*
* This file is automatically maintained by srccommit, do not edit manually.
* Last processed by srccommit version: 1.1.
*
*/
#define Module_MajorVersion_CMHG 1.37
#define Module_MajorVersion_CMHG 1.38
#define Module_MinorVersion_CMHG
#define Module_Date_CMHG 21 Jan 2017
#define Module_Date_CMHG 11 Apr 2018
#define Module_MajorVersion "1.37"
#define Module_Version 137
#define Module_MajorVersion "1.38"
#define Module_Version 138
#define Module_MinorVersion ""
#define Module_Date "21 Jan 2017"
#define Module_Date "11 Apr 2018"
#define Module_ApplicationDate "21-Jan-17"
#define Module_ApplicationDate "11-Apr-18"
#define Module_ComponentName "Env"
#define Module_ComponentPath "castle/RiscOS/Env"
#define Module_FullVersion "1.37"
#define Module_HelpVersion "1.37 (21 Jan 2017)"
#define Module_LibraryVersionInfo "1:37"
#define Module_FullVersion "1.38"
#define Module_HelpVersion "1.38 (11 Apr 2018)"
#define Module_LibraryVersionInfo "1:38"
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