[03cfe2ec] | 1 | #!/bin/sh
|
---|
| 2 |
|
---|
| 3 | #
|
---|
| 4 | # Copyright (c) 2018 Vojtech Horky
|
---|
| 5 | # All rights reserved.
|
---|
| 6 | #
|
---|
| 7 | # Redistribution and use in source and binary forms, with or without
|
---|
| 8 | # modification, are permitted provided that the following conditions
|
---|
| 9 | # are met:
|
---|
| 10 | #
|
---|
| 11 | # - Redistributions of source code must retain the above copyright
|
---|
| 12 | # notice, this list of conditions and the following disclaimer.
|
---|
| 13 | # - Redistributions in binary form must reproduce the above copyright
|
---|
| 14 | # notice, this list of conditions and the following disclaimer in the
|
---|
| 15 | # documentation and/or other materials provided with the distribution.
|
---|
| 16 | # - The name of the author may not be used to endorse or promote products
|
---|
| 17 | # derived from this software without specific prior written permission.
|
---|
| 18 | #
|
---|
| 19 | # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
---|
| 20 | # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
---|
| 21 | # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
---|
| 22 | # IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
---|
| 23 | # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
---|
| 24 | # NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
---|
| 25 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
---|
| 26 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
---|
| 27 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
---|
| 28 | # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
---|
| 29 | #
|
---|
| 30 |
|
---|
| 31 | #
|
---|
| 32 | # This is wrapper script for testing build of HelenOS under Travis CI [1].
|
---|
| 33 | #
|
---|
| 34 | # You probably do not want to run this script directly. If you wish to test
|
---|
| 35 | # that HelenOS builds for all architectures, consider using either check.sh
|
---|
| 36 | # script or running our CI solution [2] (if you want to test ported software
|
---|
| 37 | # too).
|
---|
| 38 | #
|
---|
| 39 | # [1] https://travis-ci.org/
|
---|
| 40 | # [2] http://www.helenos.org/wiki/CI
|
---|
| 41 | #
|
---|
| 42 |
|
---|
| 43 | H_ARCH_CONFIG_CROSS_TARGET=2
|
---|
| 44 | H_ARCH_CONFIG_OUTPUT_FILENAME=3
|
---|
| 45 |
|
---|
| 46 | h_get_arch_config_space() {
|
---|
| 47 | cat <<'EOF_CONFIG_SPACE'
|
---|
[bbe5e34] | 48 | amd64:amd64-helenos:image.iso
|
---|
| 49 | arm32/beagleboardxm:arm-helenos:uImage.bin
|
---|
| 50 | arm32/beaglebone:arm-helenos:uImage.bin
|
---|
| 51 | arm32/gta02:arm-helenos:uImage.bin
|
---|
| 52 | arm32/integratorcp:arm-helenos:image.boot
|
---|
| 53 | arm32/raspberrypi:arm-helenos:uImage.bin
|
---|
[3498bd5] | 54 | arm64/virt:aarch64-helenos:image.iso
|
---|
[bbe5e34] | 55 | ia32:i686-helenos:image.iso
|
---|
| 56 | ia64/i460GX:ia64-helenos:image.boot
|
---|
| 57 | ia64/ski:ia64-helenos:image.boot
|
---|
| 58 | mips32/malta-be:mips-helenos:image.boot
|
---|
| 59 | mips32/malta-le:mipsel-helenos:image.boot
|
---|
| 60 | mips32/msim:mipsel-helenos:image.boot
|
---|
| 61 | ppc32:ppc-helenos:image.iso
|
---|
| 62 | sparc64/niagara:sparc64-helenos:image.iso
|
---|
| 63 | sparc64/ultra:sparc64-helenos:image.iso
|
---|
[03cfe2ec] | 64 | EOF_CONFIG_SPACE
|
---|
| 65 | }
|
---|
| 66 |
|
---|
| 67 | h_get_arch_config() {
|
---|
| 68 | h_get_arch_config_space | grep "^$H_ARCH:" | cut '-d:' -f "$1"
|
---|
| 69 | }
|
---|
| 70 |
|
---|
| 71 | H_DEFAULT_HARBOURS_LIST="binutils fdlibm jainja libgmp libiconv msim pcc zlib libisl libmpfr libpng python2 libmpc gcc"
|
---|
| 72 |
|
---|
| 73 |
|
---|
| 74 |
|
---|
| 75 | #
|
---|
| 76 | # main script starts here
|
---|
| 77 | #
|
---|
| 78 |
|
---|
| 79 | # Check we are actually running inside Travis
|
---|
| 80 | if [ -z "$TRAVIS" ]; then
|
---|
| 81 | echo "\$TRAVIS env not set. Are you running me inside Travis?" >&2
|
---|
| 82 | exit 5
|
---|
| 83 | fi
|
---|
| 84 |
|
---|
[483a3f4] | 85 | # C style check
|
---|
| 86 | if [ -n "$H_CCHECK" ]; then
|
---|
| 87 | echo "Will try to run C style check."
|
---|
| 88 | echo
|
---|
[6a6a15e] | 89 | cd tools
|
---|
| 90 | ./build-ccheck.sh || exit 1
|
---|
| 91 | cd ..
|
---|
| 92 | tools/ccheck.sh || exit 1
|
---|
[483a3f4] | 93 | echo "C style check passed."
|
---|
| 94 | exit 0
|
---|
| 95 | fi
|
---|
| 96 |
|
---|
[03cfe2ec] | 97 | # Check HelenOS configuration was set-up
|
---|
| 98 | if [ -z "$H_ARCH" ]; then
|
---|
| 99 | echo "\$H_ARCH env not set. Are you running me inside Travis?" >&2
|
---|
| 100 | exit 5
|
---|
| 101 | fi
|
---|
| 102 |
|
---|
| 103 | # Check cross-compiler target
|
---|
| 104 | H_CROSS_TARGET=`h_get_arch_config $H_ARCH_CONFIG_CROSS_TARGET`
|
---|
| 105 | if [ -z "$H_CROSS_TARGET" ]; then
|
---|
| 106 | echo "No suitable cross-target found for '$H_ARCH.'" >&2
|
---|
| 107 | exit 1
|
---|
| 108 | fi
|
---|
| 109 |
|
---|
| 110 | # Default Harbours repository
|
---|
| 111 | if [ -z "$H_HARBOURS_REPOSITORY" ]; then
|
---|
| 112 | H_HARBOURS_REPOSITORY="https://github.com/HelenOS/harbours.git"
|
---|
| 113 | fi
|
---|
| 114 |
|
---|
| 115 | if [ "$1" = "help" ]; then
|
---|
| 116 | echo
|
---|
| 117 | echo "Following variables needs to be set prior running this script."
|
---|
| 118 | echo "Example settings follows:"
|
---|
| 119 | echo
|
---|
| 120 | echo "export H_ARCH=$H_ARCH"
|
---|
| 121 | echo "export TRAVIS_BUILD_ID=`date +%s`"
|
---|
| 122 | echo
|
---|
| 123 | echo "export H_HARBOURS=true"
|
---|
| 124 | echo "export H_HARBOUR_LIST=\"$H_DEFAULT_HARBOURS_LIST\""
|
---|
| 125 | echo
|
---|
[483a3f4] | 126 | echo "or"
|
---|
| 127 | echo
|
---|
| 128 | echo "export H_CCHECK=true"
|
---|
| 129 | echo
|
---|
[03cfe2ec] | 130 | exit 0
|
---|
| 131 |
|
---|
| 132 | elif [ "$1" = "install" ]; then
|
---|
| 133 | set -x
|
---|
[a35b458] | 134 |
|
---|
[03cfe2ec] | 135 | # Fetch and install cross-compiler
|
---|
[79b39d0] | 136 | wget "https://helenos.s3.amazonaws.com/toolchain/$H_CROSS_TARGET.tar.xz" -O "/tmp/$H_CROSS_TARGET.tar.xz" || exit 1
|
---|
| 137 | sudo tar -xJ -C "/" -f "/tmp/$H_CROSS_TARGET.tar.xz" || exit 1
|
---|
[03cfe2ec] | 138 | exit 0
|
---|
| 139 |
|
---|
| 140 | elif [ "$1" = "run" ]; then
|
---|
| 141 | set -x
|
---|
[a35b458] | 142 |
|
---|
[03cfe2ec] | 143 | # Expected output filename (bootable image)
|
---|
| 144 | H_OUTPUT_FILENAME=`h_get_arch_config $H_ARCH_CONFIG_OUTPUT_FILENAME`
|
---|
| 145 | if [ -z "$H_OUTPUT_FILENAME" ]; then
|
---|
| 146 | echo "No suitable output image found for '$H_ARCH.'" >&2
|
---|
| 147 | exit 1
|
---|
| 148 | fi
|
---|
| 149 |
|
---|
| 150 | # Build HARBOURs too?
|
---|
| 151 | H_HARBOURS=`echo "$H_HARBOURS" | grep -e '^true$' -e '^false$'`
|
---|
| 152 | if [ -z "$H_HARBOURS" ]; then
|
---|
| 153 | H_HARBOURS=false
|
---|
| 154 | fi
|
---|
| 155 | if [ -z "$H_HARBOUR_LIST" ]; then
|
---|
| 156 | H_HARBOUR_LIST="$H_DEFAULT_HARBOURS_LIST"
|
---|
| 157 | fi
|
---|
| 158 |
|
---|
| 159 | # Build it
|
---|
[602b8c0] | 160 | SRCDIR="$PWD"
|
---|
| 161 |
|
---|
| 162 | mkdir -p build/$H_ARCH || exit 1
|
---|
| 163 | cd build/$H_ARCH
|
---|
[5c08011e] | 164 |
|
---|
[7c6ae0e] | 165 | export PATH="/usr/local/cross/bin:$PATH"
|
---|
| 166 |
|
---|
[602b8c0] | 167 | $SRCDIR/configure.sh $H_ARCH || exit 1
|
---|
[5c08011e] | 168 | ninja || exit 1
|
---|
| 169 | ninja image_path || exit 1
|
---|
[a35b458] | 170 |
|
---|
[602b8c0] | 171 | cd $SRCDIR
|
---|
| 172 |
|
---|
[03cfe2ec] | 173 | echo
|
---|
| 174 | echo "HelenOS for $H_ARCH built okay."
|
---|
| 175 | echo
|
---|
| 176 |
|
---|
| 177 | # Build harbours
|
---|
| 178 | if $H_HARBOURS; then
|
---|
| 179 | echo
|
---|
| 180 | echo "Will try to build ported software for $H_ARCH."
|
---|
| 181 | echo "Repository used is $H_HARBOURS_REPOSITORY."
|
---|
| 182 | echo
|
---|
[a35b458] | 183 |
|
---|
[03cfe2ec] | 184 | H_HELENOS_HOME=`pwd`
|
---|
| 185 | cd "$HOME" || exit 1
|
---|
| 186 | git clone --depth 10 "$H_HARBOURS_REPOSITORY" helenos-harbours || exit 1
|
---|
| 187 | mkdir "build-harbours-$TRAVIS_BUILD_ID" || exit 1
|
---|
| 188 | (
|
---|
| 189 | cd "build-harbours-$TRAVIS_BUILD_ID" || exit 1
|
---|
| 190 | mkdir build || exit 1
|
---|
| 191 | cd build
|
---|
| 192 |
|
---|
| 193 | (
|
---|
| 194 | #[ "$H_ARCH" = "mips32/malta-be" ] && H_ARCH="mips32eb/malta-be"
|
---|
| 195 | echo "root = $H_HELENOS_HOME"
|
---|
| 196 | echo "arch =" `echo "$H_ARCH" | cut -d/ -f 1`
|
---|
| 197 | echo "machine =" `echo "$H_ARCH" | cut -d/ -f 2`
|
---|
| 198 | ) >hsct.conf || exit 1
|
---|
[a35b458] | 199 |
|
---|
[3daa163] | 200 | "$HOME/helenos-harbours/hsct.sh" init "$H_HELENOS_HOME" $H_ARCH || exit 1
|
---|
[03cfe2ec] | 201 |
|
---|
[973be387] | 202 | # We cannot flood the output as Travis has limit of maximum output size
|
---|
| 203 | # (reason is to prevent endless stacktraces going forever). But also Travis
|
---|
| 204 | # kills a job that does not print anything for a while.
|
---|
| 205 | #
|
---|
[2f72560a] | 206 | # So we store the full output into a file and print single dot for each line.
|
---|
[973be387] | 207 | # As pipe tends to hide errors we check the success by checking that archive
|
---|
| 208 | # exists.
|
---|
| 209 | #
|
---|
[1b20da0] | 210 | FAILED_HARBOURS=""
|
---|
[03cfe2ec] | 211 | for HARBOUR in $H_HARBOUR_LIST; do
|
---|
[0cb53ea5] | 212 | "$HOME/helenos-harbours/hsct.sh" archive --no-deps "$HARBOUR" 2>&1 | tee "run-$HARBOUR.log" | awk '// {printf "."}'
|
---|
[b752a31] | 213 |
|
---|
[973be387] | 214 | test -s "archives/$HARBOUR.tar.xz"
|
---|
[03cfe2ec] | 215 | if [ $? -eq 0 ]; then
|
---|
| 216 | tail -n 10 "run-$HARBOUR.log"
|
---|
| 217 | else
|
---|
| 218 | FAILED_HARBOURS="$FAILED_HARBOURS $HARBOUR"
|
---|
| 219 | cat build/$HARBOUR/*/config.log
|
---|
| 220 | tail -n 100 "run-$HARBOUR.log"
|
---|
| 221 | fi
|
---|
[a35b458] | 222 |
|
---|
[03cfe2ec] | 223 | done
|
---|
[a35b458] | 224 |
|
---|
[03cfe2ec] | 225 | if [ -n "$FAILED_HARBOURS" ]; then
|
---|
| 226 | echo
|
---|
| 227 | echo "ERROR: following packages were not built:$FAILED_HARBOURS."
|
---|
| 228 | echo
|
---|
| 229 | exit 1
|
---|
| 230 | fi
|
---|
| 231 | ) || exit 1
|
---|
| 232 | fi
|
---|
| 233 | else
|
---|
| 234 | echo "Invalid action specified." >&2
|
---|
| 235 | exit 5
|
---|
| 236 | fi
|
---|
| 237 |
|
---|