-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathtest-cpp-build.sh
More file actions
executable file
·68 lines (57 loc) · 2.11 KB
/
Copy pathtest-cpp-build.sh
File metadata and controls
executable file
·68 lines (57 loc) · 2.11 KB
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
#!/bin/bash
# Test script to verify C++ build works locally
# This mimics what happens in GitHub Actions
set -e
echo "🔧 Testing C++ build locally..."
# Check if we're on macOS or Linux
if [[ "$OSTYPE" == "darwin"* ]]; then
echo "🍎 Detected macOS"
# Install dependencies using Homebrew
if ! command -v brew &> /dev/null; then
echo "❌ Homebrew not found. Please install Homebrew first:"
echo " /bin/bash -c \"\$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)\""
exit 1
fi
echo "📦 Installing dependencies with Homebrew..."
brew install protobuf abseil cmake
elif [[ "$OSTYPE" == "linux-gnu"* ]]; then
echo "🐧 Detected Linux"
# Install dependencies using apt
echo "📦 Installing dependencies with apt..."
sudo apt-get update
sudo apt-get install -y libprotobuf-dev protobuf-compiler libabsl-dev cmake build-essential
# Install newer protobuf version
echo "📦 Installing protobuf v24.4..."
wget https://github.com/protocolbuffers/protobuf/releases/download/v24.4/protobuf-24.4.tar.gz
tar -xzf protobuf-24.4.tar.gz
cd protobuf-24.4
mkdir build && cd build
# Build protobuf with system Abseil to ensure compatibility
cmake -DCMAKE_BUILD_TYPE=Release -Dprotobuf_BUILD_TESTS=OFF -Dprotobuf_ABSL_PROVIDER=package -DCMAKE_INSTALL_PREFIX=/usr/local ..
make -j$(nproc)
sudo make install
sudo ldconfig
cd ../..
else
echo "❌ Unsupported OS: $OSTYPE"
exit 1
fi
# Generate protobuf code
echo "🔄 Generating protobuf code..."
buf generate proto
# Build C++ library
echo "🔨 Building C++ library..."
cmake -S gen/cpp -B build/cpp
cmake --build build/cpp -j
echo "✅ C++ build successful!"
echo "📁 Static library created at: build/cpp/libampy_proto.a"
# Test the library
echo "🧪 Testing the library..."
if [[ -f "build/cpp/libampy_proto.a" ]]; then
echo "✅ Static library exists and is ready to use"
ls -la build/cpp/libampy_proto.a
else
echo "❌ Static library not found"
exit 1
fi
echo "🎉 All tests passed! The C++ build should work in CI."