1 | #!/bin/sh
|
---|
2 | #
|
---|
3 | # SPDX-FileCopyrightText: 2019 Jiří Zárevúcky
|
---|
4 | #
|
---|
5 | # SPDX-License-Identifier: BSD-3-Clause
|
---|
6 | #
|
---|
7 |
|
---|
8 | # Find out the path to the script.
|
---|
9 | SOURCE_DIR=`which -- "$0" 2>/dev/null`
|
---|
10 | # Maybe we are running bash.
|
---|
11 | [ -z "$SOURCE_DIR" ] && SOURCE_DIR=`which -- "$BASH_SOURCE"`
|
---|
12 | [ -z "$SOURCE_DIR" ] && exit 1
|
---|
13 | SOURCE_DIR=`dirname -- "$SOURCE_DIR"`
|
---|
14 | SOURCE_DIR=`cd $SOURCE_DIR && cd .. && echo $PWD`
|
---|
15 |
|
---|
16 | # Check command line arguments.
|
---|
17 |
|
---|
18 | if [ "$#" -gt 1 ] || ( [ "$#" -eq 1 ] && [ "$1" != '--no-images' ] ); then
|
---|
19 | echo "Unknown command-line arguments."
|
---|
20 | echo "Usage:"
|
---|
21 | echo " $0 # Build everything."
|
---|
22 | echo " $0 --no-images # Build all code, but don't create bootable images."
|
---|
23 | exit 1
|
---|
24 | fi
|
---|
25 |
|
---|
26 | if [ "$#" -eq 1 ]; then
|
---|
27 | NO_IMAGES=true
|
---|
28 | else
|
---|
29 | NO_IMAGES=false
|
---|
30 | fi
|
---|
31 |
|
---|
32 | # Make sure we don't make a mess in the source root.
|
---|
33 | if [ "$PWD" = "$SOURCE_DIR" ]; then
|
---|
34 | mkdir -p build_all
|
---|
35 | cd build_all
|
---|
36 | fi
|
---|
37 |
|
---|
38 | CONFIG_RULES="${SOURCE_DIR}/HelenOS.config"
|
---|
39 |
|
---|
40 | PROFILES=`sh ${SOURCE_DIR}/tools/list_profiles.sh`
|
---|
41 |
|
---|
42 | echo
|
---|
43 | echo "###################### Configuring all profiles ######################"
|
---|
44 |
|
---|
45 | echo "Configuring profiles" $PROFILES
|
---|
46 |
|
---|
47 | for profile in $PROFILES; do
|
---|
48 | # echo "Configuring profile ${profile}"
|
---|
49 |
|
---|
50 | mkdir -p ${profile} || exit 1
|
---|
51 | script -q -e /dev/null -c "cd '${profile}' && '${SOURCE_DIR}/configure.sh' '${profile}' && ninja build.ninja" </dev/null >"${profile}/configure_output.log" 2>&1 &
|
---|
52 | echo "$!" >"${profile}/configure.pid"
|
---|
53 | done
|
---|
54 |
|
---|
55 | failed='no'
|
---|
56 |
|
---|
57 | for profile in $PROFILES; do
|
---|
58 | if ! wait `cat "${profile}/configure.pid"`; then
|
---|
59 | failed='yes'
|
---|
60 | cat "${profile}/configure_output.log"
|
---|
61 | echo
|
---|
62 | echo "Configuration of profile ${profile} failed."
|
---|
63 | echo
|
---|
64 | fi
|
---|
65 | done
|
---|
66 |
|
---|
67 | if [ "$failed" = 'yes' ]; then
|
---|
68 | echo
|
---|
69 | echo "Some configuration jobs failed."
|
---|
70 | exit 1
|
---|
71 | else
|
---|
72 | echo "All profiles configured."
|
---|
73 | fi
|
---|
74 |
|
---|
75 | echo
|
---|
76 | echo "###################### Building all profiles ######################"
|
---|
77 |
|
---|
78 | for profile in $PROFILES; do
|
---|
79 | echo
|
---|
80 | ninja -C ${profile} || exit 1
|
---|
81 | done
|
---|
82 |
|
---|
83 | if [ "$NO_IMAGES" = 'true' ]; then
|
---|
84 | echo
|
---|
85 | echo "Bootable images not built due to argument --no-images."
|
---|
86 | exit 0
|
---|
87 | fi
|
---|
88 |
|
---|
89 | echo
|
---|
90 | echo "###################### Building all images ######################"
|
---|
91 |
|
---|
92 | for profile in $PROFILES; do
|
---|
93 | echo
|
---|
94 | ninja -C ${profile} image_path || exit 1
|
---|
95 | done
|
---|
96 |
|
---|
97 | echo
|
---|
98 | for profile in $PROFILES; do
|
---|
99 | path=`cat ${profile}/image_path`
|
---|
100 |
|
---|
101 | if [ ! -z "$path" ]; then
|
---|
102 | echo "built ${profile}/${path}"
|
---|
103 | fi
|
---|
104 | done
|
---|