| 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 && cd .. && echo $PWD`
|
|---|
| 10 |
|
|---|
| 11 | # Check command line arguments.
|
|---|
| 12 |
|
|---|
| 13 | if [ "$#" -gt 1 ] || [ "$#" -eq 1 -a "$1" != '--no-images' ]; then
|
|---|
| 14 | echo "Unknown command-line arguments."
|
|---|
| 15 | echo "Usage:"
|
|---|
| 16 | echo "\t$0 # Build everything."
|
|---|
| 17 | echo "\t$0 --no-images # Build all code, but don't create bootable images."
|
|---|
| 18 | exit 1
|
|---|
| 19 | fi
|
|---|
| 20 |
|
|---|
| 21 | if [ "$#" -eq 1 ]; then
|
|---|
| 22 | NO_IMAGES=true
|
|---|
| 23 | else
|
|---|
| 24 | NO_IMAGES=false
|
|---|
| 25 | fi
|
|---|
| 26 |
|
|---|
| 27 | # Make sure we don't make a mess in the source root.
|
|---|
| 28 | if [ "$PWD" = "$SOURCE_DIR" ]; then
|
|---|
| 29 | mkdir -p build_all
|
|---|
| 30 | cd build_all
|
|---|
| 31 | fi
|
|---|
| 32 |
|
|---|
| 33 | CONFIG_RULES="${SOURCE_DIR}/HelenOS.config"
|
|---|
| 34 | CONFIG_DEFAULTS="${SOURCE_DIR}/defaults"
|
|---|
| 35 |
|
|---|
| 36 | # Find all the leaf subdirectories in the defaults directory.
|
|---|
| 37 | PROFILES=`find ${CONFIG_DEFAULTS} -type d -links 2 -printf "%P\n" | sort`
|
|---|
| 38 |
|
|---|
| 39 |
|
|---|
| 40 | echo
|
|---|
| 41 | echo "###################### Configuring all profiles ######################"
|
|---|
| 42 |
|
|---|
| 43 | echo "Configuring profiles" $PROFILES
|
|---|
| 44 |
|
|---|
| 45 | for profile in $PROFILES; do
|
|---|
| 46 | # echo "Configuring profile ${profile}"
|
|---|
| 47 |
|
|---|
| 48 | mkdir -p ${profile} || exit 1
|
|---|
| 49 | script -q -e /dev/null -c "cd '${profile}' && '${SOURCE_DIR}/configure.sh' '${profile}' && ninja build.ninja" </dev/null >"${profile}/configure_output.log" 2>&1 &
|
|---|
| 50 | echo "$!" >"${profile}/configure.pid"
|
|---|
| 51 | done
|
|---|
| 52 |
|
|---|
| 53 | failed='no'
|
|---|
| 54 |
|
|---|
| 55 | for profile in $PROFILES; do
|
|---|
| 56 | if ! wait `cat "${profile}/configure.pid"`; then
|
|---|
| 57 | failed='yes'
|
|---|
| 58 | cat "${profile}/configure_output.log"
|
|---|
| 59 | echo
|
|---|
| 60 | echo "Configuration of profile ${profile} failed."
|
|---|
| 61 | echo
|
|---|
| 62 | fi
|
|---|
| 63 | done
|
|---|
| 64 |
|
|---|
| 65 | if [ "$failed" = 'yes' ]; then
|
|---|
| 66 | echo
|
|---|
| 67 | echo "Some configuration jobs failed."
|
|---|
| 68 | exit 1
|
|---|
| 69 | else
|
|---|
| 70 | echo "All profiles configured."
|
|---|
| 71 | fi
|
|---|
| 72 |
|
|---|
| 73 | echo
|
|---|
| 74 | echo "###################### Building all profiles ######################"
|
|---|
| 75 |
|
|---|
| 76 | for profile in $PROFILES; do
|
|---|
| 77 | echo
|
|---|
| 78 | ninja -C ${profile} || exit 1
|
|---|
| 79 | done
|
|---|
| 80 |
|
|---|
| 81 | if [ "$NO_IMAGES" = 'true' ]; then
|
|---|
| 82 | echo
|
|---|
| 83 | echo "Bootable images not built due to argument --no-images."
|
|---|
| 84 | exit 0
|
|---|
| 85 | fi
|
|---|
| 86 |
|
|---|
| 87 | echo
|
|---|
| 88 | echo "###################### Building all images ######################"
|
|---|
| 89 |
|
|---|
| 90 | for profile in $PROFILES; do
|
|---|
| 91 | echo
|
|---|
| 92 | ninja -C ${profile} image_path || exit 1
|
|---|
| 93 | done
|
|---|
| 94 |
|
|---|
| 95 | echo
|
|---|
| 96 | for profile in $PROFILES; do
|
|---|
| 97 | path=`cat ${profile}/image_path`
|
|---|
| 98 |
|
|---|
| 99 | if [ ! -z "$path" ]; then
|
|---|
| 100 | echo "built ${profile}/${path}"
|
|---|
| 101 | fi
|
|---|
| 102 | done
|
|---|