summaryrefslogtreecommitdiffstats
path: root/core/bin/setup_target
diff options
context:
space:
mode:
authorJonathan Bauer2019-12-10 13:19:29 +0100
committerJonathan Bauer2019-12-10 15:59:07 +0100
commit5d530e0d9aa030cb01679037b1417e3d64885555 (patch)
tree9e5b82bdfdf0528f515887607dc781989884aafd /core/bin/setup_target
parentchroot.inc: fix broken || (diff)
downloadmltk-5d530e0d9aa030cb01679037b1417e3d64885555.tar.gz
mltk-5d530e0d9aa030cb01679037b1417e3d64885555.tar.xz
mltk-5d530e0d9aa030cb01679037b1417e3d64885555.zip
[*] support target within targets
Diffstat (limited to 'core/bin/setup_target')
-rwxr-xr-xcore/bin/setup_target28
1 files changed, 25 insertions, 3 deletions
diff --git a/core/bin/setup_target b/core/bin/setup_target
index a895a38a..55e6e4de 100755
--- a/core/bin/setup_target
+++ b/core/bin/setup_target
@@ -317,7 +317,7 @@ generate_target_real() {
mkdir -p "$TARGET_BUILD_DIR" || perror "Failed to create $TARGET_BUILD_DIR"
prepare_usr_split "${TARGET_BUILD_DIR}"
- # if no arguments assume all.
+ # Set modules first, assume all if no arguments is given.
if [ "x$1" = "x" -o "x$1" = "xall" ]; then
MODULES=$( ls "${TARGET_DIR}" )
set -- $MODULES
@@ -326,16 +326,38 @@ generate_target_real() {
MODULES=$@
fi
+ # Now detect sub-targets
+ declare -A SUBTARGETS=()
+ for mod in $MODULES; do
+ SUBTARGET_DIR="${ROOT_DIR}/core/targets/${mod}"
+ if [ -d "$SUBTARGET_DIR" ]; then
+ SUBTARGETS["$mod"]="$(ls $SUBTARGET_DIR)"
+ fi
+ done
+
pinfo "Activated modules in '${TARGET}':"
pinfo "\t$(echo ${MODULES})"
+ if [ -n "${SUBTARGETS[*]}" ]; then
+ pinfo "From subtargets '${!SUBTARGETS[*]}':"
+ pinfo "\t$(echo ${SUBTARGETS[*]})"
+ fi
# copy basic libs
pinfo "Copying libc and ld-linux used by ${SHELL}"
tarcopy "$(list_basic_libs)" "${TARGET_BUILD_DIR}"
- # now iterate over given tools and copy them
+ # now iterate over modules and/or subtargets and process them
+ MAINTARGET_DIR="$TARGET_DIR"
while (( "$#" )); do
- process_module "$1"
+ if [ -n "${SUBTARGETS["$1"]}" ]; then
+ TARGET_DIR="${ROOT_DIR}/core/targets/${1}"
+ for submod in ${SUBTARGETS["$1"]}; do
+ process_module "$submod"
+ done
+ else
+ TARGET_DIR="$MAINTARGET_DIR"
+ process_module "$1"
+ fi
shift
done