|
| 1 | +#!/usr/bin/env bash |
| 2 | +# Licensed to the Apache Software Foundation (ASF) under one or more |
| 3 | +# contributor license agreements. See the NOTICE file distributed with this |
| 4 | +# work for additional information regarding copyright ownership. The ASF |
| 5 | +# licenses this file to you under the Apache License, Version 2.0 (the |
| 6 | +# "License"); you may not use this file except in compliance with the |
| 7 | +# License. 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 | +# Link-test example/client-cpp-example against a freshly built Windows SDK install |
| 18 | +# tree, using the same Visual Studio generator as the package job (CMAKE_GENERATOR). |
| 19 | +set -euxo pipefail |
| 20 | + |
| 21 | +cd "${GITHUB_WORKSPACE:?GITHUB_WORKSPACE is not set}" |
| 22 | + |
| 23 | +SDK="${GITHUB_WORKSPACE}/iotdb-client/client-cpp/target/install" |
| 24 | +EXAMPLE_SRC="${GITHUB_WORKSPACE}/example/client-cpp-example/src" |
| 25 | +BUILD_DIR="${GITHUB_WORKSPACE}/build/client-cpp-example-verify" |
| 26 | +rm -rf "${BUILD_DIR}" |
| 27 | + |
| 28 | +test -f "${SDK}/lib/iotdb_session.dll" |
| 29 | +test -f "${SDK}/lib/iotdb_session.lib" |
| 30 | + |
| 31 | +GEN_ARGS=() |
| 32 | +if [[ -n "${CMAKE_GENERATOR:-}" ]]; then |
| 33 | + GEN_ARGS=(-G "${CMAKE_GENERATOR}") |
| 34 | +fi |
| 35 | + |
| 36 | +echo "=== Link-test client-cpp-example (Windows / same VS generator) ===" |
| 37 | +if [[ ${#GEN_ARGS[@]} -gt 0 ]]; then |
| 38 | + echo "CMAKE_GENERATOR=${CMAKE_GENERATOR}" |
| 39 | +else |
| 40 | + echo "CMAKE_GENERATOR=(default for runner)" |
| 41 | +fi |
| 42 | +cmake --version | head -1 |
| 43 | + |
| 44 | +cmake -S "${EXAMPLE_SRC}" -B "${BUILD_DIR}" \ |
| 45 | + "${GEN_ARGS[@]}" \ |
| 46 | + -A x64 \ |
| 47 | + -DIOTDB_SDK_ROOT="${SDK}" \ |
| 48 | + -DWITH_SSL=OFF |
| 49 | + |
| 50 | +cmake --build "${BUILD_DIR}" --config Release --target SessionExample --parallel |
| 51 | + |
| 52 | +EXE="${BUILD_DIR}/Release/SessionExample.exe" |
| 53 | +DLL="${BUILD_DIR}/Release/iotdb_session.dll" |
| 54 | +test -f "${EXE}" |
| 55 | +test -f "${DLL}" |
| 56 | + |
| 57 | +# Guard against accidental Win32 builds. |
| 58 | +python3 - <<'PY' "${EXE}" |
| 59 | +import struct, sys |
| 60 | +path = sys.argv[1] |
| 61 | +with open(path, "rb") as f: |
| 62 | + data = f.read() |
| 63 | +pe_off = struct.unpack_from("<I", data, 0x3C)[0] |
| 64 | +machine = struct.unpack_from("<H", data, pe_off + 4)[0] |
| 65 | +if machine != 0x8664: |
| 66 | + raise SystemExit(f"Expected PE32+ x64 (0x8664), got 0x{machine:04X}") |
| 67 | +print(f"Verified x64 executable: {path}") |
| 68 | +PY |
| 69 | + |
| 70 | +echo "client-cpp-example SessionExample link test passed (Windows)" |
0 commit comments