forked from hunter-packages/ceres-solver
-
Notifications
You must be signed in to change notification settings - Fork 0
171 lines (153 loc) · 6 KB
/
android.yml
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
name: Android
on: [push, pull_request]
jobs:
build-android:
name: NDK-${{matrix.abi}}-${{matrix.build_type}}-${{matrix.lib}}
runs-on: ${{matrix.os}}
defaults:
run:
shell: bash -e -o pipefail {0}
env:
CCACHE_DIR: ${{github.workspace}}/ccache
CMAKE_GENERATOR: Ninja
DEBIAN_FRONTEND: noninteractive
strategy:
fail-fast: true
matrix:
os:
- ubuntu-20.04
abi:
- arm64-v8a
- armeabi-v7a
- x86
- x86_64
build_type:
- Release
lib:
- shared
- static
android_api_level:
- '28'
steps:
- uses: actions/checkout@v3
- name: Setup Dependencies
run: |
sudo apt-get update
sudo apt-get install -y \
ccache \
ninja-build
# Ensure the declared NDK version is always installed even if it's removed
# from the virtual environment.
- name: Setup NDK
env:
ANDROID_NDK_VERSION: 23.2.8568313
ANDROID_SDK_ROOT: /usr/local/lib/android/sdk
run: |
echo 'y' | ${{env.ANDROID_SDK_ROOT}}/cmdline-tools/latest/bin/sdkmanager --install 'ndk;${{env.ANDROID_NDK_VERSION}}'
echo "ANDROID_NDK_ROOT=${{env.ANDROID_SDK_ROOT}}/ndk/${{env.ANDROID_NDK_VERSION}}" >> $GITHUB_ENV
- name: Cache Eigen
id: cache-eigen
uses: actions/cache@v3
with:
path: eigen/
key: NDK-${{matrix.os}}-eigen-3.4.0-${{matrix.abi}}
- name: Download Eigen
if: steps.cache-eigen.outputs.cache-hit != 'true'
run: |
wget https://gitlab.com/libeigen/eigen/-/archive/3.4.0/eigen-3.4.0.zip
unzip eigen-3.4.0.zip
- name: Setup Eigen
if: steps.cache-eigen.outputs.cache-hit != 'true'
run: |
cmake -S eigen-3.4.0 -B build-eigen \
-DBUILD_TESTING=OFF \
-DCMAKE_ANDROID_API=${{matrix.android_api_level}} \
-DCMAKE_ANDROID_ARCH_ABI=${{matrix.abi}} \
-DCMAKE_ANDROID_STL_TYPE=c++_shared \
-DCMAKE_Fortran_COMPILER= \
-DCMAKE_INSTALL_PREFIX=${{github.workspace}}/eigen \
-DCMAKE_SYSTEM_NAME=Android \
-DEIGEN_BUILD_DOC=OFF
cmake --build build-eigen \
--config ${{matrix.build_type}} \
--target install
- name: Cache gflags
id: cache-gflags
uses: actions/cache@v3
with:
path: gflags/
key: NDK-${{matrix.os}}-gflags-2.2.2-${{matrix.abi}}-${{matrix.build_type}}-${{matrix.lib}}
- name: Download gflags
if: steps.cache-gflags.outputs.cache-hit != 'true'
run: |
wget https://github.com/gflags/gflags/archive/refs/tags/v2.2.2.zip
unzip v2.2.2.zip
- name: Setup gflags
if: steps.cache-gflags.outputs.cache-hit != 'true'
run: |
cmake -S gflags-2.2.2 -B build-gflags \
-DBUILD_SHARED_LIBS=${{matrix.lib == 'shared'}} \
-DBUILD_TESTING=OFF \
-DCMAKE_ANDROID_API=${{matrix.android_api_level}} \
-DCMAKE_ANDROID_ARCH_ABI=${{matrix.abi}} \
-DCMAKE_ANDROID_STL_TYPE=c++_shared \
-DCMAKE_BUILD_TYPE=${{matrix.build_type}} \
-DCMAKE_INSTALL_PREFIX=${{github.workspace}}/gflags \
-DCMAKE_SYSTEM_NAME=Android
cmake --build build-gflags \
--config ${{matrix.build_type}} \
--target install
- name: Cache glog
id: cache-glog
uses: actions/cache@v3
with:
path: glog/
key: NDK-${{matrix.os}}-glog-0.5-${{matrix.abi}}-${{matrix.build_type}}-${{matrix.lib}}
- name: Download glog
if: steps.cache-glog.outputs.cache-hit != 'true'
run: |
wget https://github.com/google/glog/archive/refs/tags/v0.5.0.zip
unzip v0.5.0.zip
- name: Setup glog
if: steps.cache-glog.outputs.cache-hit != 'true'
run: |
cmake -S glog-0.5.0 -B build-glog \
-DBUILD_SHARED_LIBS=${{matrix.lib == 'shared'}} \
-DBUILD_TESTING=OFF \
-DCMAKE_ANDROID_API=${{matrix.android_api_level}} \
-DCMAKE_ANDROID_ARCH_ABI=${{matrix.abi}} \
-DCMAKE_ANDROID_STL_TYPE=c++_shared \
-DCMAKE_BUILD_TYPE=${{matrix.build_type}} \
-DCMAKE_FIND_ROOT_PATH=${{github.workspace}}/gflags \
-DCMAKE_INSTALL_PREFIX=${{github.workspace}}/glog \
-DCMAKE_SYSTEM_NAME=Android
cmake --build build-glog \
--config ${{matrix.build_type}} \
--target install
- name: Cache Build
id: cache-build
uses: actions/cache@v3
with:
path: ${{env.CCACHE_DIR}}
key: NDK-${{matrix.os}}-ccache-${{matrix.abi}}-${{matrix.build_type}}-${{matrix.lib}}-${{github.run_id}}
restore-keys: NDK-${{matrix.os}}-ccache-${{matrix.abi}}-${{matrix.build_type}}-${{matrix.lib}}-
- name: Setup Environment
if: matrix.build_type == 'Release'
run: |
echo 'CXXFLAGS=-flto' >> $GITHUB_ENV
- name: Configure
run: |
cmake -S . -B build_${{matrix.abi}} \
-DBUILD_SHARED_LIBS=${{matrix.lib == 'shared'}} \
-DCMAKE_ANDROID_API=${{matrix.android_api_level}} \
-DCMAKE_ANDROID_ARCH_ABI=${{matrix.abi}} \
-DCMAKE_ANDROID_STL_TYPE=c++_shared \
-DCMAKE_BUILD_TYPE=${{matrix.build_type}} \
-DCMAKE_C_COMPILER_LAUNCHER=$(which ccache) \
-DCMAKE_CXX_COMPILER_LAUNCHER=$(which ccache) \
-DCMAKE_FIND_ROOT_PATH="${{github.workspace}}/eigen;${{github.workspace}}/gflags;${{github.workspace}}/glog" \
-DCMAKE_SYSTEM_NAME=Android
- name: Build
run: |
cmake --build build_${{matrix.abi}} \
--config ${{matrix.build_type}}