| 1 | #!/bin/sh
|
|---|
| 2 |
|
|---|
| 3 | # Find out the path to the script.
|
|---|
| 4 | SOURCE_DIR=`which -- "$0" 2>/dev/null`
|
|---|
| 5 | # Maybe we are running bash.
|
|---|
| 6 | [ -z "$SOURCE_DIR" ] && SOURCE_DIR=`which -- "$BASH_SOURCE"`
|
|---|
| 7 | [ -z "$SOURCE_DIR" ] && exit 1
|
|---|
| 8 | SOURCE_DIR=`dirname -- "$SOURCE_DIR"`
|
|---|
| 9 | SOURCE_DIR=`cd $SOURCE_DIR && echo $PWD`
|
|---|
| 10 |
|
|---|
| 11 | # Make sure we don't make a mess in the source root.
|
|---|
| 12 | if [ "$PWD" = "$SOURCE_DIR" ]; then
|
|---|
| 13 | mkdir -p build_all
|
|---|
| 14 | cd build_all
|
|---|
| 15 | fi
|
|---|
| 16 |
|
|---|
| 17 | CONFIG_RULES="${SOURCE_DIR}/HelenOS.config"
|
|---|
| 18 | CONFIG_DEFAULTS="${SOURCE_DIR}/defaults"
|
|---|
| 19 |
|
|---|
| 20 | # Find all the leaf subdirectories in the defaults directory.
|
|---|
| 21 | PROFILES=`find ${CONFIG_DEFAULTS} -type d -links 2 -printf "%P\n" | sort`
|
|---|
| 22 |
|
|---|
| 23 |
|
|---|
| 24 | echo
|
|---|
| 25 | echo "###################### Configuring all profiles ######################"
|
|---|
| 26 |
|
|---|
| 27 | echo "Configuring profiles" $PROFILES
|
|---|
| 28 |
|
|---|
| 29 | for profile in $PROFILES; do
|
|---|
| 30 | # echo "Configuring profile ${profile}"
|
|---|
| 31 |
|
|---|
| 32 | mkdir -p ${profile} || exit 1
|
|---|
| 33 | script -q -e /dev/null -c "cd '${profile}' && '${SOURCE_DIR}/configure.sh' '${profile}' && ninja build.ninja" </dev/null >"${profile}/configure_output.log" 2>&1 &
|
|---|
| 34 | echo "$!" >"${profile}/configure.pid"
|
|---|
| 35 | done
|
|---|
| 36 |
|
|---|
| 37 | failed='no'
|
|---|
| 38 |
|
|---|
| 39 | for profile in $PROFILES; do
|
|---|
| 40 | if ! wait `cat "${profile}/configure.pid"`; then
|
|---|
| 41 | failed='yes'
|
|---|
| 42 | cat "${profile}/configure_output.log"
|
|---|
| 43 | echo
|
|---|
| 44 | echo "Configuration of profile ${profile} failed."
|
|---|
| 45 | echo
|
|---|
| 46 | fi
|
|---|
| 47 | done
|
|---|
| 48 |
|
|---|
| 49 | if [ "$failed" = 'yes' ]; then
|
|---|
| 50 | echo
|
|---|
| 51 | echo "Some configuration jobs failed."
|
|---|
| 52 | exit 1
|
|---|
| 53 | else
|
|---|
| 54 | echo "All profiles configured."
|
|---|
| 55 | fi
|
|---|
| 56 |
|
|---|
| 57 | echo
|
|---|
| 58 | echo "###################### Building all profiles ######################"
|
|---|
| 59 |
|
|---|
| 60 | for profile in $PROFILES; do
|
|---|
| 61 | echo
|
|---|
| 62 | ninja -C ${profile} || exit 1
|
|---|
| 63 | done
|
|---|
| 64 |
|
|---|
| 65 |
|
|---|
| 66 | if [ "$#" -eq 1 ] && [ "$1" = 'images' ]; then
|
|---|
| 67 | echo
|
|---|
| 68 | echo "###################### Building all images ######################"
|
|---|
| 69 |
|
|---|
| 70 | for profile in $PROFILES; do
|
|---|
| 71 | echo
|
|---|
| 72 | ninja -C ${profile} image_path || exit 1
|
|---|
| 73 | done
|
|---|
| 74 |
|
|---|
| 75 | echo
|
|---|
| 76 | for profile in $PROFILES; do
|
|---|
| 77 | path=`cat ${profile}/image_path`
|
|---|
| 78 |
|
|---|
| 79 | if [ ! -z "$path" ]; then
|
|---|
| 80 | echo "built ${profile}/${path}"
|
|---|
| 81 | fi
|
|---|
| 82 | done
|
|---|
| 83 | else
|
|---|
| 84 | echo
|
|---|
| 85 | echo "Bootable images not built."
|
|---|
| 86 | echo "Run '$0 images' to build them as well."
|
|---|
| 87 | fi
|
|---|