|
| 1 | +#!/bin/bash -ex |
| 2 | +# |
| 3 | +# Copyright (C) 2020 HERE Europe B.V. |
| 4 | +# |
| 5 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | +# you may not use this file except in compliance with the License. |
| 7 | +# You may obtain a copy of the License at |
| 8 | +# |
| 9 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | +# |
| 11 | +# Unless required by applicable law or agreed to in writing, software |
| 12 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | +# See the License for the specific language governing permissions and |
| 15 | +# limitations under the License. |
| 16 | +# |
| 17 | +# SPDX-License-Identifier: Apache-2.0 |
| 18 | +# License-Filename: LICENSE |
| 19 | + |
| 20 | +# |
| 21 | +# Special build in debug, to be build in special docker images: Centos gcc 7.3 |
| 22 | +# |
| 23 | + |
| 24 | +# Set workspace location |
| 25 | +if [[ ${WORKSPACE} == "" ]]; then |
| 26 | + export WORKSPACE=`pwd` |
| 27 | +fi |
| 28 | +# Add all needed variables |
| 29 | +export BUILD_DIR_NAME="build" |
| 30 | +export BUILD_DIR="$WORKSPACE/$BUILD_DIR_NAME" |
| 31 | +export ARCHIVE_FILE_NAME="binaries.tar.gz" # artifact name is defined by CI so please do not rename it |
| 32 | +export BUILD_ZIP=1 # always build artifacts |
| 33 | + |
| 34 | +export CMAKE_CXX_FLAGS="-march=x86-64 -gdwarf-2 -g3 -O0 -fno-builtin" |
| 35 | +export CMAKE_C_FLAGS="-march=x86-64 -gdwarf-2 -g3 -O0 -fno-builtin" |
| 36 | + |
| 37 | +# Add more parameters into CMAKE_PARAM below when needed |
| 38 | +export FLAVOR="Debug" |
| 39 | +export CMAKE_PARAM="-DCMAKE_CXX_FLAGS=\"${CMAKE_CXX_FLAGS}\" -DCMAKE_C_FLAGS=\"${CMAKE_C_FLAGS}\" -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DBUILD_SHARED_LIBS=ON -DCMAKE_BUILD_TYPE=$FLAVOR -DOLP_SDK_BUILD_EXAMPLES=ON" |
| 40 | +export CMAKE_COMMAND="cmake ${CMAKE_PARAM} .." |
| 41 | +export CMAKE_BUILD_ALL_TARGETS="cmake --build . -- -j8" |
| 42 | + |
| 43 | +# Function : |
| 44 | +build_for_centos() { |
| 45 | + echo "" |
| 46 | + echo "" |
| 47 | + echo "*************** $VARIANT Build EDGE SDK CPP ********** Start ***************" |
| 48 | + # Show initial ccache data |
| 49 | + ccache -s |
| 50 | + echo "" |
| 51 | + echo " ---- Calling ${CMAKE_COMMAND}" |
| 52 | + eval "${CMAKE_COMMAND}" |
| 53 | + |
| 54 | + # Run CMake. Warnings and errors are saved to build/CMakeFiles/CMakeOutput.log and |
| 55 | + # build/CMakeFiles/CMakeError.log. |
| 56 | + # -- We link Edge SDK as shared libraries in order to use shadowing for unit tests. |
| 57 | + # -- We build the examples. |
| 58 | + echo "" |
| 59 | + echo " ---- Calling ${CMAKE_BUILD_ALL_TARGETS}" |
| 60 | + ${CMAKE_BUILD_ALL_TARGETS} |
| 61 | + |
| 62 | + cd ${WORKSPACE} |
| 63 | + |
| 64 | + if [[ ${BUILD_ZIP} -eq 1 ]]; then |
| 65 | + echo "Zipping up artifacts needed for testing ..." |
| 66 | + |
| 67 | + # Prepare artifacts archive for test job |
| 68 | + # Zip up all the binaries needed to run the tests but need to leave the tar.gz file in build |
| 69 | + # folder as this ensure the CI system archives it automatically |
| 70 | + tar -czf "${BUILD_DIR_NAME}/$ARCHIVE_FILE_NAME" --exclude='*.git' \ |
| 71 | + "${BUILD_DIR_NAME}/olp-*/*.so" |
| 72 | + # List files in build archive |
| 73 | + tar -tvf "${BUILD_DIR_NAME}/$ARCHIVE_FILE_NAME" |
| 74 | + fi |
| 75 | + echo "" |
| 76 | + echo "" |
| 77 | + echo "*************** $VARIANT Build EDGE SDK CPP ********** Done ***************" |
| 78 | +} |
| 79 | + |
| 80 | +while [[ $# -gt 0 ]]; do |
| 81 | + key="$1" |
| 82 | + case "$key" in |
| 83 | + -c|--centos) |
| 84 | + BUILD_VARIANT=1 |
| 85 | + VARIANT="Centos" |
| 86 | + ;; |
| 87 | + esac |
| 88 | + # Shift after checking all the cases to get the next option |
| 89 | + shift |
| 90 | +done |
| 91 | + |
| 92 | + if [[ -d ${BUILD_DIR} ]]; then |
| 93 | + rm -rf ${BUILD_DIR} |
| 94 | + fi |
| 95 | + mkdir -p ${BUILD_DIR} |
| 96 | + |
| 97 | + echo "" |
| 98 | + echo "*************** Build Started ***************" |
| 99 | + echo "WORKSPACE: $WORKSPACE" |
| 100 | + echo "BUILD DIR: $BUILD_DIR" |
| 101 | + echo "FLAVOR: $FLAVOR" |
| 102 | + echo "VARIANT: $VARIANT" |
| 103 | + echo "" |
| 104 | + echo "" |
| 105 | + |
| 106 | + # Goto build folder |
| 107 | + cd "$BUILD_DIR" |
| 108 | + |
| 109 | + case "$BUILD_VARIANT" in |
| 110 | + 1) |
| 111 | + build_for_centos |
| 112 | + ;; |
| 113 | + esac |
| 114 | + echo "" |
| 115 | + echo "" |
| 116 | + echo "*************** Build Done ***************" |
| 117 | + |
0 commit comments