Debian Codegraph @

third_party/spirv-tools/kokoro/scripts/linux/build.sh

raw
1 #!/bin/bash
2 # Copyright (c) 2018 Google LLC.
3 #
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
7 #
8 # http://www.apache.org/licenses/LICENSE-2.0
9 #
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
15 #
16 # Linux Build Script.
17
18 # Fail on any error.
19 set -e
20 # Display commands being run.
21 set -x
22
23 BUILD_ROOT=$PWD
24 SRC=$PWD/github/SPIRV-Tools
25 CONFIG=$1
26 COMPILER=$2
27
28 SKIP_TESTS="False"
29 BUILD_TYPE="Debug"
30
31 CMAKE_C_CXX_COMPILER=""
32 if [ $COMPILER = "clang" ]
33 then
34 PATH=/usr/lib/llvm-3.8/bin:$PATH
35 CMAKE_C_CXX_COMPILER="-DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++"
36 fi
37
38 # Possible configurations are:
39 # ASAN, COVERAGE, RELEASE, DEBUG, DEBUG_EXCEPTION, RELEASE_MINGW
40
41 if [ $CONFIG = "RELEASE" ] || [ $CONFIG = "RELEASE_MINGW" ]
42 then
43 BUILD_TYPE="RelWithDebInfo"
44 fi
45
46 ADDITIONAL_CMAKE_FLAGS=""
47 if [ $CONFIG = "ASAN" ]
48 then
49 ADDITIONAL_CMAKE_FLAGS="-DSPIRV_USE_SANITIZER=address,bounds,null"
50 [ $COMPILER = "clang" ] || { echo "$CONFIG requires clang"; exit 1; }
51 elif [ $CONFIG = "COVERAGE" ]
52 then
53 ADDITIONAL_CMAKE_FLAGS="-DENABLE_CODE_COVERAGE=ON"
54 SKIP_TESTS="True"
55 elif [ $CONFIG = "DEBUG_EXCEPTION" ]
56 then
57 ADDITIONAL_CMAKE_FLAGS="-DDISABLE_EXCEPTIONS=ON -DDISABLE_RTTI=ON"
58 elif [ $CONFIG = "RELEASE_MINGW" ]
59 then
60 ADDITIONAL_CMAKE_FLAGS="-Dgtest_disable_pthreads=ON -DCMAKE_TOOLCHAIN_FILE=$SRC/cmake/linux-mingw-toolchain.cmake"
61 SKIP_TESTS="True"
62 fi
63
64 # Get NINJA.
65 wget -q https://github.com/ninja-build/ninja/releases/download/v1.8.2/ninja-linux.zip
66 unzip -q ninja-linux.zip
67 export PATH="$PWD:$PATH"
68
69 cd $SRC
70 git clone --depth=1 https://github.com/KhronosGroup/SPIRV-Headers external/spirv-headers
71 git clone https://github.com/google/googletest external/googletest
72 cd external && cd googletest && git reset --hard 1fb1bb23bb8418dc73a5a9a82bbed31dc610fec7 && cd .. && cd ..
73 git clone --depth=1 https://github.com/google/effcee external/effcee
74 git clone --depth=1 https://github.com/google/re2 external/re2
75 git clone --depth=1 --branch v3.13.0 https://github.com/protocolbuffers/protobuf external/protobuf
76
77 mkdir build && cd $SRC/build
78
79 # Invoke the build.
80 BUILD_SHA=${KOKORO_GITHUB_COMMIT:-$KOKORO_GITHUB_PULL_REQUEST_COMMIT}
81 echo $(date): Starting build...
82 cmake -DPYTHON_EXECUTABLE:FILEPATH=/usr/bin/python3 -GNinja -DCMAKE_INSTALL_PREFIX=$KOKORO_ARTIFACTS_DIR/install -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DRE2_BUILD_TESTING=OFF -DSPIRV_BUILD_FUZZER=ON $ADDITIONAL_CMAKE_FLAGS $CMAKE_C_CXX_COMPILER ..
83
84 echo $(date): Build everything...
85 ninja
86 echo $(date): Build completed.
87
88 if [ $CONFIG = "COVERAGE" ]
89 then
90 echo $(date): Check coverage...
91 ninja report-coverage
92 echo $(date): Check coverage completed.
93 fi
94
95 echo $(date): Starting ctest...
96 if [ $SKIP_TESTS = "False" ]
97 then
98 ctest -j4 --output-on-failure --timeout 300
99 fi
100 echo $(date): ctest completed.
101
102 # Package the build.
103 ninja install
104 cd $KOKORO_ARTIFACTS_DIR
105 tar czf install.tgz install