-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathunix-x64.bash
71 lines (58 loc) · 1.78 KB
/
unix-x64.bash
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/bin/bash
# Check if the script is running on a Unix-like system (Linux or macOS)
if [[ "$OSTYPE" == "darwin"* ]] || [[ "$OSTYPE" == "linux-gnu"* ]]; then
echo "Running on a Unix-like system (Linux or macOS)."
else
echo "This script is only meant to run on Linux or macOS."
exit 1
fi
# Function to test if a command exists
function test_command {
command -v "$1" &> /dev/null
return $?
}
# Check if git is installed
if ! test_command "git"; then
echo "Git is not installed. Please install Git and try again."
exit 1
fi
# Check if cmake is installed
if ! test_command "cmake"; then
echo "CMake is not installed. Please install CMake and try again."
exit 1
fi
# Check if vcpkg is already cloned, else clone it
VCPKG_DIR="$HOME/vcpkg"
if [ ! -d "$VCPKG_DIR" ]; then
echo "Cloning vcpkg repository..."
git clone https://github.com/microsoft/vcpkg.git "$VCPKG_DIR"
else
echo "vcpkg directory already exists."
fi
# Run the bootstrap script for vcpkg
echo "Running bootstrap-vcpkg.sh..."
cd "$VCPKG_DIR" || exit
./bootstrap-vcpkg.sh
# Integrate vcpkg with the system
echo "Integrating vcpkg..."
./vcpkg integrate install
# Install dependencies using vcpkg
echo "Installing dependencies with vcpkg..."
./vcpkg install
# Set up build directory
BUILD_DIR="$GITHUB_WORKSPACE/build"
if [ ! -d "$BUILD_DIR" ]; then
mkdir -p "$BUILD_DIR"
fi
# Configure CMake with vcpkg toolchain
echo "Configuring CMake..."
cmake -B"$BUILD_DIR" \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_TOOLCHAIN_FILE="$VCPKG_DIR/scripts/buildsystems/vcpkg.cmake" \
-S"$GITHUB_WORKSPACE"
# Build the project
echo "Building the project..."
cmake --build "$BUILD_DIR" --config Release
# Run tests with ctest
echo "Running tests with ctest..."
ctest --build-config Release --output-on-failure