Skip to content

Commit 0f57549

Browse files
authored
conan 2 (#345)
1 parent 08186c4 commit 0f57549

13 files changed

Lines changed: 112 additions & 1031 deletions

.github/workflows/android_main.yml

Lines changed: 21 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,19 @@ concurrency:
1919
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
2020
cancel-in-progress: true
2121

22+
env:
23+
ndk_version: 26.1.10909125
24+
2225
jobs:
2326
build:
2427
runs-on: ubuntu-20.04
25-
2628
steps:
2729
- name: checkout
2830
uses: actions/checkout@v3
2931

3032
- name: install ninja
3133
run: sudo apt-get install -y ninja-build
34+
3235
- name: setup java
3336
uses: actions/setup-java@v3
3437
with:
@@ -41,31 +44,24 @@ jobs:
4144
python-version: 3.8
4245

4346
- name: install pip and conan
44-
run: python -m pip install --upgrade pip conan==1.*
47+
run: python -m pip install --upgrade pip conan
48+
49+
- name: install ndk
50+
run: echo "y" | sudo ${ANDROID_HOME}/cmdline-tools/latest/bin/sdkmanager --install "ndk;${{ env.ndk_version }}"
4551

46-
- name: conan config
47-
run: conan config set general.revisions_enabled=1
4852
- name: conan remote
49-
run: |
50-
conan remote clean
51-
conan remote add odr https://artifactory.opendocument.app/artifactory/api/conan/conan
52-
conan remote add conancenter https://center.conan.io
53+
run: conan remote add --index 0 odr https://artifactory.opendocument.app/artifactory/api/conan/conan
5354
- name: conan login
54-
run: conan user --remote odr --password ${{ secrets.ARTIFACTORY }} admin
55+
run: conan remote login odr admin --password ${{ secrets.ARTIFACTORY }}
5556

56-
- name: tweak conan profile for build machine
57-
run: |
58-
echo "" >> conanprofile_build.txt
59-
echo "[settings]" >> conanprofile_build.txt
60-
echo "compiler=clang" >> conanprofile_build.txt
61-
echo "compiler.libcxx=libstdc++11" >> conanprofile_build.txt
62-
echo "" >> conanprofile_build.txt
57+
- name: conan profile
58+
run: conan profile detect
6359

6460
- name: gradle
6561
run: ./gradlew assembleDebug lintProDebug lintLiteDebug --stacktrace
6662

6763
- name: upload binaries to conan repo
68-
run: conan upload "*" --remote odr --confirm --all --no-overwrite all
64+
run: conan upload "*" --check --confirm --remote odr
6965

7066
- name: upload apks
7167
uses: actions/upload-artifact@v3
@@ -112,7 +108,7 @@ jobs:
112108
- name: install brew
113109
run: ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" < /dev/null 2> /dev/null
114110
- name: fix ninja install
115-
run: rm '/usr/local/bin/2to3'
111+
run: rm /usr/local/bin/2to3
116112
- name: install ninja
117113
run: brew install ninja
118114
# https://stackoverflow.com/a/57758679/198996
@@ -124,25 +120,15 @@ jobs:
124120
- name: install pip
125121
run: python3 -m ensurepip
126122
- name: install conan
127-
run: pip3 install --upgrade conan==1.*
123+
run: pip3 install --upgrade conan
128124

129-
- name: conan config
130-
run: conan config set general.revisions_enabled=1
131125
- name: conan remote
132-
run: |
133-
conan remote clean
134-
conan remote add odr https://artifactory.opendocument.app/artifactory/api/conan/conan
135-
conan remote add conancenter https://center.conan.io
126+
run: conan remote add --index 0 odr https://artifactory.opendocument.app/artifactory/api/conan/conan
136127
- name: conan login
137-
run: conan user --remote odr --password ${{ secrets.ARTIFACTORY }} admin
128+
run: conan remote login odr admin --password ${{ secrets.ARTIFACTORY }}
138129

139-
- name: tweak conan profile for build machine
140-
run: |
141-
echo "" >> conanprofile_build.txt
142-
echo "[settings]" >> conanprofile_build.txt
143-
echo "compiler=clang" >> conanprofile_build.txt
144-
echo "compiler.libcxx=libc++" >> conanprofile_build.txt
145-
echo "" >> conanprofile_build.txt
130+
- name: conan profile
131+
run: conan profile detect
146132

147133
- name: Android Virtual Device (AVD) cache
148134
uses: actions/cache@v3
@@ -151,7 +137,7 @@ jobs:
151137
path: |
152138
~/.android/avd/*
153139
~/.android/adb*
154-
key: avd-${{ matrix.arch }}-${{ matrix.api-level }}
140+
key: avd-${{ matrix.arch }}-${{ matrix.api-level }}-r3
155141

156142
- name: Create AVD and generate snapshot for caching
157143
if: steps.avd-cache.outputs.cache-hit != 'true'
@@ -160,8 +146,6 @@ jobs:
160146
api-level: ${{ matrix.api-level }}
161147
arch: ${{ matrix.arch }}
162148
target: google_apis
163-
sdcard-path-or-size: 1G
164-
disk-size: 8G
165149
script: echo "Generated AVD snapshot for caching."
166150

167151
- name: Run tests
@@ -172,8 +156,6 @@ jobs:
172156
api-level: ${{ matrix.api-level }}
173157
arch: ${{ matrix.arch }}
174158
target: google_apis
175-
sdcard-path-or-size: 1G
176-
disk-size: 8G
177159
script: |
178160
mkdir -p testResults/screenshots
179161
adb logcat > testResults/logcat.txt &
@@ -193,7 +175,7 @@ jobs:
193175
test ! -f sorry_but_tests_are_failing
194176
195177
- name: upload binaries to conan repo
196-
run: conan upload "*" --remote odr --confirm --all --no-overwrite all
178+
run: conan upload "*" --check --confirm --remote odr
197179

198180
- name: upload test results
199181
uses: actions/upload-artifact@v3

CMakeLists.txt

Lines changed: 0 additions & 49 deletions
This file was deleted.

app/CMakeLists.txt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
cmake_minimum_required(VERSION 3.18.1)
2+
project(odr-droid CXX)
3+
4+
set(CMAKE_CXX_STANDARD 17)
5+
set(CMAKE_CXX_STANDARD_REQUIRED ON)
6+
set(CMAKE_CXX_EXTENSIONS OFF)
7+
8+
find_package(odrcore REQUIRED)
9+
10+
add_library(odr-core SHARED
11+
src/main/cpp/CoreWrapper.cpp)
12+
target_include_directories(odr-core
13+
PRIVATE src/main/cpp)
14+
target_link_libraries(odr-core
15+
PRIVATE odrcore::odrcore log)

app/build.gradle

Lines changed: 42 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,37 @@ plugins {
44
id 'com.google.firebase.crashlytics'
55
}
66

7+
task conanProfile {
8+
file("build").mkdirs()
9+
10+
copy {
11+
from "conanprofile.txt"
12+
into "build"
13+
}
14+
15+
def file = file("build/conanprofile.txt")
16+
def content = file.text
17+
content = content.replace("<NDK_PATH>", android.ndkDirectory.toString())
18+
file.write(content)
19+
}
20+
21+
task conanInstall {
22+
["armv7", "armv8", "x86", "x86_64"].each { String arch ->
23+
exec {
24+
commandLine(
25+
"conan", "install", ".",
26+
"--output-folder=build/conan/" + arch,
27+
"--build=missing",
28+
"--profile:host=build/conanprofile.txt",
29+
"-s", "arch=" + arch,
30+
"-s", "build_type=Release",
31+
"-s", "&:build_type=RelWithDebInfo",
32+
"-s", "odrcore/*:build_type=RelWithDebInfo",
33+
)
34+
}
35+
}
36+
}
37+
738
android {
839
compileSdkVersion 34
940
ndkVersion "26.1.10909125"
@@ -20,8 +51,15 @@ android {
2051

2152
vectorDrawables.useSupportLibrary true
2253

23-
externalNativeBuild.cmake.targets "odr-core"
24-
externalNativeBuild.cmake.arguments "-DANDROID_STL=c++_shared"
54+
externalNativeBuild {
55+
cmake {
56+
targets "odr-core"
57+
arguments(
58+
"-DCMAKE_TOOLCHAIN_FILE=conan_android_toolchain.cmake",
59+
"-DCMAKE_BUILD_TYPE=RelWithDebInfo",
60+
)
61+
}
62+
}
2563
}
2664

2765
flavorDimensions "default"
@@ -80,7 +118,7 @@ android {
80118
externalNativeBuild {
81119
cmake {
82120
version "3.22.0+"
83-
path file('../CMakeLists.txt')
121+
path "CMakeLists.txt"
84122
}
85123
}
86124
lint {
@@ -127,4 +165,4 @@ dependencies {
127165
// espresso-idling-resource is used in main sourceSet as well. cannot be just androidTestImplementation
128166
implementation 'androidx.test.espresso:espresso-idling-resource:3.5.1'
129167
implementation 'androidx.annotation:annotation:1.8.0'
130-
}
168+
}

0 commit comments

Comments
 (0)