Skip to content

Commit 7d3ddfb

Browse files
committed
ci(workflow): 修复CMake路径设置问题并更新build.sh
将CMake路径通过环境变量传递,并在build.sh中添加对CMAKE_PATH的支持
1 parent f55d47d commit 7d3ddfb

2 files changed

Lines changed: 21 additions & 5 deletions

File tree

.github/workflows/ci.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,14 +77,16 @@ jobs:
7777
sudo /Applications/CMake.app/Contents/bin/cmake-gui --install
7878
hdiutil detach /Volumes/cmake-3.26.4-macos-universal
7979
rm cmake.dmg
80-
export PATH="/Applications/CMake.app/Contents/bin:$PATH"
80+
echo "CMAKE_PATH=/Applications/CMake.app/Contents/bin" >> $GITHUB_ENV
8181
8282
- name: Configure and build
8383
env:
8484
OPENSSL_ROOT_DIR: /opt/homebrew/opt/openssl@3
8585
OPENSSL_LIBRARIES: /opt/homebrew/opt/openssl@3/lib
8686
OPENSSL_INCLUDE_DIR: /opt/homebrew/opt/openssl@3/include
87+
CMAKE_PATH: /Applications/CMake.app/Contents/bin
8788
run: |
89+
export PATH="/Applications/CMake.app/Contents/bin:$PATH"
8890
./build.sh -DCMAKE_BUILD_TYPE=debug -DONESDK_WITH_TEST=ON
8991
9092
- name: Run tests

build.sh

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,19 @@ set -e # Exit on any error
33

44
# Function to check CMake version
55
check_cmake_version() {
6-
if ! command -v cmake &> /dev/null; then
7-
echo "Error: CMake is not installed!"
6+
# Use CMAKE_PATH if provided, otherwise use default cmake command
7+
if [ -n "$CMAKE_PATH" ]; then
8+
CMAKE_CMD="$CMAKE_PATH/cmake"
9+
else
10+
CMAKE_CMD="cmake"
11+
fi
12+
13+
if ! command -v $CMAKE_CMD &> /dev/null; then
14+
echo "Error: CMake is not installed at $CMAKE_CMD!"
815
exit 1
916
fi
1017

11-
cmake_version=$(cmake --version | head -n1 | cut -d' ' -f3)
18+
cmake_version=$($CMAKE_CMD --version | head -n1 | cut -d' ' -f3)
1219
cmake_major=$(echo $cmake_version | cut -d'.' -f1)
1320
cmake_minor=$(echo $cmake_version | cut -d'.' -f2)
1421

@@ -48,8 +55,15 @@ fi
4855
mkdir -p build
4956
cd build
5057

58+
# Use CMAKE_PATH if provided, otherwise use default cmake command
59+
if [ -n "$CMAKE_PATH" ]; then
60+
CMAKE_CMD="$CMAKE_PATH/cmake"
61+
else
62+
CMAKE_CMD="cmake"
63+
fi
64+
5165
echo "Running cmake with arguments: $@"
52-
cmake $@ ..
66+
$CMAKE_CMD $@ ..
5367
if [ $? -ne 0 ]; then
5468
echo "CMake configuration failed!"
5569
exit 1

0 commit comments

Comments
 (0)