|
1 | | -#!/bin/bash |
| 1 | +#!/usr/bin/env bash |
2 | 2 | # |
3 | 3 | # Copyright 2025 Google LLC |
4 | 4 | # |
5 | 5 | # Licensed under the Apache License, Version 2.0 (the "License"); |
6 | | -# you may not use this file except in compliance with the License. |
| 6 | +# You may not use this file except in compliance with the License. |
7 | 7 | # You may obtain a copy of the License at |
8 | 8 | # |
9 | 9 | # https://www.apache.org/licenses/LICENSE-2.0 |
10 | 10 | # |
11 | 11 | # Unless required by applicable law or agreed to in writing, software |
12 | 12 | # distributed under the License is distributed on an "AS IS" BASIS, |
13 | 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. |
| 14 | +# |
16 | 15 |
|
17 | 16 | set -euo pipefail |
18 | 17 |
|
| 18 | +# --------------------------- |
| 19 | +# Local Tools Directory Setup |
| 20 | +# --------------------------- |
| 21 | +TOOLS_DIR="${TOOLS_DIR:-$PWD/tools}" |
| 22 | +mkdir -p "$TOOLS_DIR/bin" |
| 23 | +export PATH="$TOOLS_DIR/bin:$PATH" |
| 24 | + |
| 25 | +# --------------------------- |
| 26 | +# Bazel (via Bazelisk) |
| 27 | +# --------------------------- |
| 28 | +BAZEL_VERSION="7.0.0" |
| 29 | +BAZELISK_URL="https://github.com/bazelbuild/bazelisk/releases/download/v1.24.1/bazelisk-linux-amd64" |
| 30 | + |
| 31 | +if [ ! -x "$TOOLS_DIR/bin/bazelisk" ]; then |
| 32 | + echo "Downloading Bazelisk..." |
| 33 | + curl -fsSL "$BAZELISK_URL" -o "$TOOLS_DIR/bin/bazelisk" |
| 34 | + chmod +x "$TOOLS_DIR/bin/bazelisk" |
| 35 | + ln -sf "$TOOLS_DIR/bin/bazelisk" "$TOOLS_DIR/bin/bazel" |
| 36 | +fi |
| 37 | + |
| 38 | +export USE_BAZEL_VERSION="$BAZEL_VERSION" |
| 39 | +echo "Bazel version check:" |
| 40 | +bazel --version |
| 41 | + |
| 42 | +# --------------------------- |
| 43 | +# CMake (local install) |
| 44 | +# --------------------------- |
| 45 | +CMAKE_VERSION="3.29.0" |
| 46 | +if ! command -v cmake >/dev/null 2>&1 || [[ "$(cmake --version | head -n1 | awk '{print $3}')" != "$CMAKE_VERSION" ]]; then |
| 47 | + echo "Installing CMake locally..." |
| 48 | + mkdir -p "$TOOLS_DIR/cmake" |
| 49 | + curl -fsSL "https://github.com/Kitware/CMake/releases/download/v${CMAKE_VERSION}/cmake-${CMAKE_VERSION}-linux-x86_64.sh" -o "$TOOLS_DIR/cmake/cmake-installer.sh" |
| 50 | + chmod +x "$TOOLS_DIR/cmake/cmake-installer.sh" |
| 51 | + "$TOOLS_DIR/cmake/cmake-installer.sh" --skip-license --prefix="$TOOLS_DIR" |
| 52 | +fi |
| 53 | +cmake --version |
| 54 | + |
| 55 | +# --------------------------- |
| 56 | +# iODBC (local) |
| 57 | +# --------------------------- |
| 58 | +if ! command -v iodbc-config >/dev/null 2>&1; then |
| 59 | + echo "Installing iODBC locally..." |
| 60 | + sudo apt-get update |
| 61 | + sudo apt-get install -y libiodbc2-dev |
| 62 | +fi |
| 63 | + |
| 64 | +# --------------------------- |
| 65 | +# Source dependencies |
| 66 | +# --------------------------- |
19 | 67 | source "$(dirname "$0")/../../lib/init.sh" |
20 | 68 | source module ci/install-dependencies.sh |
21 | | - |
22 | 69 | source module ci/cloudbuild/builds/lib/cmake.sh |
23 | | -source module ci/cloudbuild/builds/lib/bazel-local.sh |
24 | 70 | source module ci/cloudbuild/builds/lib/secrets.sh |
25 | 71 | source module ci/lib/io.sh |
26 | 72 |
|
27 | | -# Common build args |
| 73 | +# --------------------------- |
| 74 | +# Build Driver |
| 75 | +# --------------------------- |
28 | 76 | mapfile -t cmake_args < <(cmake::common_args) |
29 | | - |
30 | 77 | BUILD_DIR="/opt/odbc-driver" |
31 | 78 |
|
32 | | -# Build driver |
| 79 | +echo "Building driver in $BUILD_DIR..." |
33 | 80 | io::run cmake -B "$BUILD_DIR" \ |
34 | | - "${cmake_args[@]}" \ |
35 | | - -DCMAKE_CXX_STANDARD=17 \ |
36 | | - -DODBC_UNIT_TESTING=OFF \ |
37 | | - -DBQ_DRIVER_INTEGRATION_TESTS=OFF \ |
38 | | - -DODBC_DEMO_TESTING=OFF \ |
39 | | - -DODBC_EXAMPLES=ON \ |
40 | | - -DCLIENT_LIBRARY_INTEGRATION_TESTING=OFF |
| 81 | + "${cmake_args[@]}" \ |
| 82 | + -DCMAKE_CXX_STANDARD=17 \ |
| 83 | + -DODBC_UNIT_TESTING=OFF \ |
| 84 | + -DBQ_DRIVER_INTEGRATION_TESTS=OFF \ |
| 85 | + -DODBC_DEMO_TESTING=OFF \ |
| 86 | + -DODBC_EXAMPLES=ON \ |
| 87 | + -DCLIENT_LIBRARY_INTEGRATION_TESTING=OFF |
41 | 88 |
|
42 | 89 | io::run cmake --build "$BUILD_DIR" --target all |
43 | 90 |
|
44 | | -# Create tarball for release |
| 91 | +# --------------------------- |
| 92 | +# Package Release |
| 93 | +# --------------------------- |
45 | 94 | VERSION_TAG="${TAG_NAME:-unknown}" |
46 | 95 | OUTPUT_TAR="cpp-bigquery-odbc-${VERSION_TAG}-linux-x86_64.tar.gz" |
47 | 96 |
|
48 | 97 | echo "Packaging build artifacts into ${OUTPUT_TAR}..." |
49 | 98 | tar -czf "${OUTPUT_TAR}" -C "$BUILD_DIR" . |
50 | 99 |
|
51 | | -echo "Build packaged successfully: ${OUTPUT_TAR}" |
| 100 | +echo "✅ Build packaged successfully: ${OUTPUT_TAR}" |
0 commit comments