Skip to content

Commit

Permalink
conan 2 (#345)
Browse files Browse the repository at this point in the history
  • Loading branch information
andiwand authored May 27, 2024
1 parent 08186c4 commit 0f57549
Show file tree
Hide file tree
Showing 13 changed files with 112 additions and 1,031 deletions.
60 changes: 21 additions & 39 deletions .github/workflows/android_main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,19 @@ concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true

env:
ndk_version: 26.1.10909125

jobs:
build:
runs-on: ubuntu-20.04

steps:
- name: checkout
uses: actions/checkout@v3

- name: install ninja
run: sudo apt-get install -y ninja-build

- name: setup java
uses: actions/setup-java@v3
with:
Expand All @@ -41,31 +44,24 @@ jobs:
python-version: 3.8

- name: install pip and conan
run: python -m pip install --upgrade pip conan==1.*
run: python -m pip install --upgrade pip conan

- name: install ndk
run: echo "y" | sudo ${ANDROID_HOME}/cmdline-tools/latest/bin/sdkmanager --install "ndk;${{ env.ndk_version }}"

- name: conan config
run: conan config set general.revisions_enabled=1
- name: conan remote
run: |
conan remote clean
conan remote add odr https://artifactory.opendocument.app/artifactory/api/conan/conan
conan remote add conancenter https://center.conan.io
run: conan remote add --index 0 odr https://artifactory.opendocument.app/artifactory/api/conan/conan
- name: conan login
run: conan user --remote odr --password ${{ secrets.ARTIFACTORY }} admin
run: conan remote login odr admin --password ${{ secrets.ARTIFACTORY }}

- name: tweak conan profile for build machine
run: |
echo "" >> conanprofile_build.txt
echo "[settings]" >> conanprofile_build.txt
echo "compiler=clang" >> conanprofile_build.txt
echo "compiler.libcxx=libstdc++11" >> conanprofile_build.txt
echo "" >> conanprofile_build.txt
- name: conan profile
run: conan profile detect

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

- name: upload binaries to conan repo
run: conan upload "*" --remote odr --confirm --all --no-overwrite all
run: conan upload "*" --check --confirm --remote odr

- name: upload apks
uses: actions/upload-artifact@v3
Expand Down Expand Up @@ -112,7 +108,7 @@ jobs:
- name: install brew
run: ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" < /dev/null 2> /dev/null
- name: fix ninja install
run: rm '/usr/local/bin/2to3'
run: rm /usr/local/bin/2to3
- name: install ninja
run: brew install ninja
# https://stackoverflow.com/a/57758679/198996
Expand All @@ -124,25 +120,15 @@ jobs:
- name: install pip
run: python3 -m ensurepip
- name: install conan
run: pip3 install --upgrade conan==1.*
run: pip3 install --upgrade conan

- name: conan config
run: conan config set general.revisions_enabled=1
- name: conan remote
run: |
conan remote clean
conan remote add odr https://artifactory.opendocument.app/artifactory/api/conan/conan
conan remote add conancenter https://center.conan.io
run: conan remote add --index 0 odr https://artifactory.opendocument.app/artifactory/api/conan/conan
- name: conan login
run: conan user --remote odr --password ${{ secrets.ARTIFACTORY }} admin
run: conan remote login odr admin --password ${{ secrets.ARTIFACTORY }}

- name: tweak conan profile for build machine
run: |
echo "" >> conanprofile_build.txt
echo "[settings]" >> conanprofile_build.txt
echo "compiler=clang" >> conanprofile_build.txt
echo "compiler.libcxx=libc++" >> conanprofile_build.txt
echo "" >> conanprofile_build.txt
- name: conan profile
run: conan profile detect

- name: Android Virtual Device (AVD) cache
uses: actions/cache@v3
Expand All @@ -151,7 +137,7 @@ jobs:
path: |
~/.android/avd/*
~/.android/adb*
key: avd-${{ matrix.arch }}-${{ matrix.api-level }}
key: avd-${{ matrix.arch }}-${{ matrix.api-level }}-r3

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

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

- name: upload test results
uses: actions/upload-artifact@v3
Expand Down
49 changes: 0 additions & 49 deletions CMakeLists.txt

This file was deleted.

15 changes: 15 additions & 0 deletions app/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
cmake_minimum_required(VERSION 3.18.1)
project(odr-droid CXX)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)

find_package(odrcore REQUIRED)

add_library(odr-core SHARED
src/main/cpp/CoreWrapper.cpp)
target_include_directories(odr-core
PRIVATE src/main/cpp)
target_link_libraries(odr-core
PRIVATE odrcore::odrcore log)
46 changes: 42 additions & 4 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,37 @@ plugins {
id 'com.google.firebase.crashlytics'
}

task conanProfile {
file("build").mkdirs()

copy {
from "conanprofile.txt"
into "build"
}

def file = file("build/conanprofile.txt")
def content = file.text
content = content.replace("<NDK_PATH>", android.ndkDirectory.toString())
file.write(content)
}

task conanInstall {
["armv7", "armv8", "x86", "x86_64"].each { String arch ->
exec {
commandLine(
"conan", "install", ".",
"--output-folder=build/conan/" + arch,
"--build=missing",
"--profile:host=build/conanprofile.txt",
"-s", "arch=" + arch,
"-s", "build_type=Release",
"-s", "&:build_type=RelWithDebInfo",
"-s", "odrcore/*:build_type=RelWithDebInfo",
)
}
}
}

android {
compileSdkVersion 34
ndkVersion "26.1.10909125"
Expand All @@ -20,8 +51,15 @@ android {

vectorDrawables.useSupportLibrary true

externalNativeBuild.cmake.targets "odr-core"
externalNativeBuild.cmake.arguments "-DANDROID_STL=c++_shared"
externalNativeBuild {
cmake {
targets "odr-core"
arguments(
"-DCMAKE_TOOLCHAIN_FILE=conan_android_toolchain.cmake",
"-DCMAKE_BUILD_TYPE=RelWithDebInfo",
)
}
}
}

flavorDimensions "default"
Expand Down Expand Up @@ -80,7 +118,7 @@ android {
externalNativeBuild {
cmake {
version "3.22.0+"
path file('../CMakeLists.txt')
path "CMakeLists.txt"
}
}
lint {
Expand Down Expand Up @@ -127,4 +165,4 @@ dependencies {
// espresso-idling-resource is used in main sourceSet as well. cannot be just androidTestImplementation
implementation 'androidx.test.espresso:espresso-idling-resource:3.5.1'
implementation 'androidx.annotation:annotation:1.8.0'
}
}
Loading

0 comments on commit 0f57549

Please sign in to comment.