99
1010jobs :
1111 build :
12- # For faster builds with OpenCV, consider using larger runners (requires GitHub subscription):
13- # Standard runner: 2-core CPU, 7GB RAM
14- # Larger runner: 4-core CPU, 14GB RAM (2x faster for parallel builds like OpenCV)
15- # To use larger runner, change to: runs-on: ubuntu-latest-4-cores
16- runs-on : ubuntu-latest
17- timeout-minutes : 150
12+ runs-on : ubuntu-22.04
13+ timeout-minutes : 90
1814
1915 steps :
20- - name : Check initial disk space
21- run : |
22- df -h
23- echo "Available disk space:"
24- df -h / | tail -1
25-
2616 - name : Checkout repository
2717 uses : actions/checkout@v4
2818 with :
2919 submodules : recursive
3020
21+ - name : Free up disk space
22+ run : |
23+ sudo rm -rf /usr/share/dotnet /usr/local/lib/android /opt/ghc
24+ sudo apt-get clean
25+ df -h
26+
3127 - name : Install system dependencies
3228 run : |
3329 sudo apt-get update
3430 sudo apt-get install -y \
35- bison \
36- flex \
3731 build-essential \
3832 cmake \
39- make \
33+ ninja-build \
34+ pkg-config \
4035 autoconf \
41- autoconf-archive \
4236 automake \
43- libtool \
44- libltdl-dev \
45- libx11-dev \
46- libxft-dev \
47- libxext-dev \
48- libxtst-dev \
49- libxrandr-dev \
50- ninja-build \
51- pkg-config
37+ libtool
5238 sudo apt-get clean
53- sudo rm -rf /var/lib/apt/lists/*
5439
55- - name : Cache vcpkg packages
40+ - name : Cache vcpkg
5641 uses : actions/cache@v4
57- id : vcpkg-cache
5842 with :
5943 path : |
44+ ${{ github.workspace }}/vcpkg
6045 ${{ github.workspace }}/build/vcpkg_installed
61- ${{ github.workspace }}/vcpkg/downloads
62- key : ${{ runner.os }}-vcpkg-${{ hashFiles('**/vcpkg.json') }}-${{ hashFiles('**/vcpkg.lock') }}
46+ key : ${{ runner.os }}-vcpkg-${{ hashFiles('vcpkg.json') }}
6347 restore-keys : |
64- ${{ runner.os }}-vcpkg-${{ hashFiles('**/vcpkg.json') }}-
6548 ${{ runner.os }}-vcpkg-
6649
6750 - name : Bootstrap vcpkg
68- working-directory : ${{ github.workspace }}
69- run : |
70- chmod +x ./vcpkg/bootstrap-vcpkg.sh
71- ./vcpkg/bootstrap-vcpkg.sh
72-
73- - name : Set vcpkg environment variables
74- run : |
75- echo "VCPKG_ROOT=${{ github.workspace }}/vcpkg" >> $GITHUB_ENV
76- echo "${{ github.workspace }}/vcpkg" >> $GITHUB_PATH
77- echo "VCPKG_DEFAULT_TRIPLET=x64-linux-release" >> $GITHUB_ENV
78- echo "VCPKG_FORCE_SYSTEM_BINARIES=0" >> $GITHUB_ENV
79-
80- - name : Verify and fix vcpkg packages
81- working-directory : ${{ github.workspace }}
82- run : |
83- # Simple solution: Try CMake configure and fix any missing library errors
84- python3 << 'EOF'
85- from pathlib import Path
86- import subprocess, re, shutil
87-
88- vcpkg = Path("build/vcpkg_installed/x64-linux-release")
89- if not vcpkg.exists():
90- exit(0)
91-
92- # Try a test CMake configure to catch errors
93- test_build = Path("build_test")
94- test_build.mkdir(exist_ok=True)
95-
96- try:
97- result = subprocess.run(
98- ["cmake", "-S", ".", "-B", str(test_build),
99- "-DCMAKE_TOOLCHAIN_FILE=./vcpkg/scripts/buildsystems/vcpkg.cmake",
100- "-DVCPKG_TARGET_TRIPLET=x64-linux-release"],
101- capture_output=True, text=True, timeout=60
102- )
103-
104- # Parse CMake errors for missing libraries
105- incomplete = set()
106- for line in result.stderr.split('\n'):
107- if 'references the file' in line and 'but this file does not exist' in line:
108- # Extract package name from error
109- # Error format: "CMake Error at .../share/PACKAGE/PACKAGETargets.cmake"
110- match = re.search(r'share/([^/]+)/.*Targets\.cmake', line)
111- if match:
112- pkg = match.group(1)
113- print(f"Found incomplete package: {pkg}")
114- incomplete.add(pkg)
115-
116- # Remove incomplete packages
117- for pkg in incomplete:
118- print(f"Removing: {pkg}")
119- shutil.rmtree(vcpkg / "share" / pkg, ignore_errors=True)
120- for lib in (vcpkg / "lib").glob(f"*{pkg}*"):
121- if lib.is_file():
122- lib.unlink()
123-
124- if incomplete:
125- print(f"Removed {len(incomplete)} incomplete package(s)")
126- except subprocess.TimeoutExpired:
127- print("CMake test timed out, skipping verification")
128- except Exception as e:
129- print(f"Verification error: {e}")
130- finally:
131- shutil.rmtree(test_build, ignore_errors=True)
132- EOF
133-
134- - name : Check disk space before CMake
13551 run : |
136- df -h
137- du -sh ${{ github.workspace }}/* 2>/dev/null | sort -h | tail -10
138- echo "=== /tmp usage ==="
139- df -h /tmp || true
140-
141- - name : Clean /tmp before build
142- run : |
143- sudo rm -rf /tmp/* /tmp/.* 2>/dev/null || true
144- df -h /tmp || true
52+ if [ ! -f vcpkg/vcpkg ]; then
53+ chmod +x ./vcpkg/bootstrap-vcpkg.sh
54+ ./vcpkg/bootstrap-vcpkg.sh
55+ fi
14556
14657 - name : Configure CMake
147- working-directory : ${{ github.workspace }}
14858 run : |
149- # Verify triplet is set correctly
150- echo "VCPKG_DEFAULT_TRIPLET=${VCPKG_DEFAULT_TRIPLET}"
151- # Verify build tools are available
152- which cmake
153- which make
154- which ninja
155- cmake --version
156- make --version || true
157- ninja --version || true
15859 cmake -S . -B build \
159- -DCMAKE_TOOLCHAIN_FILE=./vcpkg/scripts/buildsystems/vcpkg.cmake \
60+ -G Ninja \
16061 -DCMAKE_BUILD_TYPE=Release \
161- -DVCPKG_TARGET_TRIPLET=x64-linux-release \
162- -DCMAKE_POLICY_DEFAULT_CMP0167=NEW
62+ -DCMAKE_TOOLCHAIN_FILE=${{ github.workspace }}/vcpkg/scripts/buildsystems/vcpkg.cmake \
63+ -DVCPKG_TARGET_TRIPLET=x64-linux-release
16364
164- - name : Clean up vcpkg build artifacts (keep cached packages)
165- run : |
166- # Clean up vcpkg buildtrees to save disk space
167- # Keep downloads/ and build/vcpkg_installed/ for caching
168- if [ -d "${{ github.workspace }}/vcpkg/buildtrees" ]; then
169- rm -rf ${{ github.workspace }}/vcpkg/buildtrees
170- fi
171- if [ -d "${{ github.workspace }}/build/vcpkg_installed" ]; then
172- find ${{ github.workspace }}/build/vcpkg_installed -name "buildtrees" -type d -exec rm -rf {} + 2>/dev/null || true
173- fi
174- df -h
65+ - name : Build
66+ run : cmake --build build --parallel 2
17567
176- - name : Build C++ project
177- working-directory : ${{ github.workspace }}
68+ - name : List executables
17869 run : |
179- # Clean /tmp before starting build
180- sudo find /tmp -type f -mmin +5 -delete 2>/dev/null || true
181- df -h /tmp || true
182- cmake --build build --parallel $(nproc)
183- # Clean /tmp after build
184- sudo find /tmp -type f -mmin +1 -delete 2>/dev/null || true
185-
186- - name : Clean up build artifacts (keep only binaries)
187- run : |
188- if [ -d "${{ github.workspace }}/build" ]; then
189- find ${{ github.workspace }}/build -name "*.o" -delete
190- find ${{ github.workspace }}/build -name "*.a" -delete
191- find ${{ github.workspace }}/build -name "CMakeFiles" -type d -exec rm -rf {} + 2>/dev/null || true
192- fi
193- df -h
194-
195- - name : Verify build
196- working-directory : ${{ github.workspace }}
197- run : |
198- echo "=== C++ Build Verification ==="
199- ls -la build/
200- echo ""
201- echo "=== Built executables ==="
202- find build -type f -executable -name "*" ! -name "*.so" ! -name "*.a" | head -20
70+ echo "Built executables:"
71+ find build -type f -executable | grep -E '(ceres|manif|sophus|rerun)' || true
20372
73+ - name : Upload artifacts
74+ uses : actions/upload-artifact@v4
75+ if : success()
76+ with :
77+ name : build-artifacts
78+ path : |
79+ build/ceres_*
80+ build/manif_*
81+ build/sophus_*
82+ build/rerun
83+ build/*SfM
84+ build/bundle_adjuster
85+ retention-days : 7
0 commit comments