opendocument-app / OpenDocument.droid

It's Android's first OpenOffice Document Reader!
https://opendocument.app/
Other
266 stars 36 forks source link

F-Droid - update recipe #346

Closed licaon-kter closed 4 months ago

licaon-kter commented 5 months ago

...and create an actual flavor that's FOSS, so there's no need for this huge recipe

  - versionName: '3.24'
    versionCode: 177
    commit: f33ded86b3bb0bd4e62c9aead37063a087180043
    subdir: app
    sudo:
      - apt-get update
      - apt-get install -y cmake ninja-build pipx
    output: apk.apk
    prebuild:
      - pipx install conan==1.*
      - export PATH="${HOME}/.local/bin:$PATH"
      - sed -i -e '/com.google/d' ../build.gradle
      - sed -i -e '/com.google.firebase/d' -e '/firebaseCrashlytics/d' -e '/com.google.android.play/d'
        -e '/com.android.billingclient/d' -e '/com.google.gms/d' -e '/pro"/d' -e '/com.google.android.gms/d'
        build.gradle
      - sed -i -e '/INTERNET/d' -e '/BILLING/d' -e '/^        <meta-data/,+5d' src/main/AndroidManifest.xml
      - cd src/main/java/at/tomtasche/reader
      - sed -i -e '/com.google.firebase/d' background/FileLoader.java
      - sed -i -e '/gms/d' -e '/play.core/d' -e '/firebase/d' ui/activity/*.java
      - sed -i -e '/private Uri doFirebaseConvert/,/^    }/d' -e 's/viewerUri = doFirebaseConvert(options)/return/'
        -e '/com.google/d' -e '/Firebase/d' -e '/Storage/d' -e '/auth /d' -e '/storage
        /d' background/OnlineLoader.java
      - sed -i -e '/void initializeProprietaryLibraries/,/^    }/d' -e '/initializeProprietaryLibraries/d'
        -e '/void buyAdRemoval/,/^    }/d' -e '/buyAdRemoval/d' -e 's/billingManager.hasPurchased()/true/'
        -e 's/billingManager.isEnabled()/false/' -e '/addOnPreDrawListener/,/});/d'
        ui/activity/MainActivity.java
      - sed -i -e '/getBooleanConfig("show_in_app_rating/,/^                });/d'
        -e '/void offerUpload/,/^    }/d' -e '/offerUpload/d' -e '/void requestInAppRating/,/^    }/d'
        -e '/requestInAppRating/d' ui/activity/DocumentFragment.java
      - sed -i -e 's/configManager.getBooleanConfig(".*")/null/' background/OdfLoader.java
      - for class in AdManager AnalyticsManager BillingManager ConfigManager CrashManager
        HelpManager; do echo "package at.tomtasche.reader.nonfree; public class ${class}
        {}" > nonfree/${class}.java; sed -i -e "/${class}\./Id" background/*.java
        ui/*/*.java ui/*.java; done
      - echo "[settings]" >> conanprofile_build.txt
      - echo "compiler=clang" >> conanprofile_build.txt
      - echo "compiler.libcxx=libstdc++11" >> conanprofile_build.txt
      - conan config set general.revisions_enabled=1
      - conan remote add odr https://artifactory.opendocument.app/artifactory/api/conan/conan,
      - cd ..
      - gradle clean
    build:
      - export PATH="${HOME}/.local/bin:$PATH"
      - cd ..
      - gradle assembleProRelease
    ndk: 25.2.9519653

this recipe falls with

> Task :app:configureCMakeRelWithDebInfo[arm64-v8a]
C/C++: WARN: *** Conan 1 is legacy and on a deprecation path ***
C/C++: WARN: *** Please upgrade to Conan 2 ***
C/C++: cmake/3.29.3: ERROR: Package 'ada521499582ffec91aef450980290fff1f6c275' build failed
C/C++: cmake/3.29.3: WARN: Build folder /home/vagrant/.conan/data/cmake/3.29.3/_/_/build/ada521499582ffec91aef450980290fff1f6c275
C/C++: ERROR: cmake/3.29.3: Error in build() method, line 30
C/C++:  get(self, **self.conan_data["sources"][self.version][str(self.settings.os)][arch],
C/C++:  KeyError: 'Android'
C/C++: CMake Error at app/conan.cmake:633 (message):
C/C++:   Conan install failed='1'
C/C++: Call Stack (most recent call first):
C/C++:   CMakeLists.txt:29 (conan_cmake_install)

> Task :app:configureCMakeRelWithDebInfo[arm64-v8a] FAILED

FAILURE: Build failed with an exception.

* What went wrong:
> IDLE
> [CXX1429] error when building with cmake using /home/vagrant/build/at.tomtasche.reader/CMakeLists.txt: -- The CXX compiler identification is Clang 14.0.7
  -- Detecting CXX compiler ABI info
  -- Detecting CXX compiler ABI info - done
  -- Check for working CXX compiler: /opt/android-sdk/ndk/25.2.9519653/toolchains/llvm/prebuilt/linux-x86_64/bin/clang++ - skipped
  -- Detecting CXX compile features
  -- Detecting CXX compile features - done
  -- Downloading conan.cmake from https://github.com/conan-io/cmake-conan
  -- Conan: checking conan executable
  -- Conan: Found program /home/vagrant/.local/bin/conan
  -- Conan: Version found Conan version 1.64.1
  -- Conan executing: /home/vagrant/.local/bin/conan install /home/vagrant/build/at.tomtasche.reader --build missing --env CONAN_CMAKE_TOOLCHAIN_FILE=/home/vagrant/build/at.tomtasche.reader/app/.cxx/RelWithDebInfo/1n412d41/arm64-v8a/toolchain.cmake --profile /home/vagrant/build/at.tomtasche.reader/conanprofile.txt --settings arch=armv8 --settings build_type=RelWithDebInfo --settings compiler=clang --settings compiler.version=14 --settings compiler.libcxx=libc++
  Auto detecting your dev setup to initialize the default profile (/home/vagrant/.conan/profiles/default)
  CC and CXX: None, /opt/android-sdk/ndk/25.2.9519653/toolchains/llvm/prebuilt/linux-x86_64/bin/clang++ 
  Found clang 14.0
  clang>=8, using the major as version
  Default settings
        os=Linux
        os_build=Linux
        arch=x86_64
        arch_build=x86_64
        compiler=clang
        compiler.version=14
        compiler.libcxx=libstdc++
        build_type=Release
  *** You can change them in /home/vagrant/.conan/profiles/default ***
  *** Or override with -s compiler='other' -s ...s***

  Configuration:
  [settings]
  arch=armv8
  arch_build=x86_64
  build_type=RelWithDebInfo
  compiler=clang
  compiler.l
  miniz/3.0.2: Not found in local cache, looking in remotes...
  miniz/3.0.2: Trying with 'conancenter'...
  Downloading conanmanifest.txt
  Downloading conanfile.py
  Downloading conan_export.tgz
  miniz/3.0.2: Downloaded recipe revision 6e39a83b94a8951a57a0e29969960170
  nlohmann_json/3.11.3: Not found in local cache, looking in remotes...
  nlohmann_json/3.11.3: Trying with 'conancenter'...
  Downloading conanmanifest.txt
  Downloading conanfile.py
  Downloading conan_export.tgz
  nlohmann_json/3.11.3: Downloaded recipe revision 45828be26eb619a2e04ca517bb7b828d
  vincentlaucsb-csv-parser/2.1.3: Not found in local cache, looking in remotes...
  vincentlaucsb-csv-parser/2.1.3: Trying with 'conancenter'...
  Downloading conanmanifest.txt
  Downloading conanfile.py
  Downloading conan_export.tgz
  vincentlaucsb-csv-parser/2.1.3: Downloaded recipe revision 7d96da1144496d8aefbc76dda620e9e7
  uchardet/0.0.7: Not found in local cache, looking in remotes...
  uchardet/0.0.7: Trying with 'conancenter'...
  Downloading conanmanifest.txt
  Downloading conanfile.py
  Downloading conan_export.tgz
  uchardet/0.0.7: Downloaded recipe revision 540e0bb16506f0b42bfbffbebddfd63a
  cmake/3.29.3: Not found in local cache, looking in remotes...
  cmake/3.29.3: Trying with 'conancenter'...
  Downloading conanmanifest.txt
  Downloading conanfile.py
  Downloading conan_export.tgz
  cmake/3.29.3: Downloaded recipe revision 292a699b66d006bf4c6648608fa7c9e4
  gtest/1.14.0: Not found in local cache, looking in remotes...
  gtest/1.14.0: Trying with 'conancenter'...
  Downloading conanmanifest.txt
  Downloading conanfile.py
  Downloading conan_export.tgz
  Cross-build from 'Linux:x86_64' to 'Android:armv8'
  Installing (downloading, building) binaries...
  nlohmann_json/3.11.3: Retrieving package 5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9 from remote 'conancenter' 
  Downloading conanmanifest.txt
  Downloading conaninfo.txt
  Downloading conan_package.tgz
  nlohmann_json/3.11.3: Package installed 5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9
  nlohmann_json/3.11.3: Downloaded package revision 570207c0cf4a2d9790a6f36ab5e3f077
  vincentlaucsb-csv-parser/2.1.3: Retrieving package 5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9 from remote 'conancenter' 
  Downloading conanmanifest.txt
  Downloading conaninfo.txt
  Downloading conan_package.tgz
  vincentlaucsb-csv-parser/2.1.3: Package installed 5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9
  vincentlaucsb-csv-parser/2.1.3: Downloaded package revision 741758e6bbb087d16ad3a0685a31f4f0
  cmake/3.29.3: Configuring sources in /home/vagrant/.conan/data/cmake/3.29.3/_/_/source
  cmake/3.29.3: Copying sources to build folder
  cmake/3.29.3: Building your package in /home/vagrant/.conan/data/cmake/3.29.3/_/_/build/ada521499582ffec91aef450980290fff1f6c275
  cmake/3.29.3: Generator txt created conanbuildinfo.txt
  cmake/3.29.3: Aggregating env generators
  cmake/3.29.3: Calling build()
  cmake/3.29.3: 
  -- Configuring incomplete, errors occurred!
  See also "/home/vagrant/build/at.tomtasche.reader/app/.cxx/RelWithDebInfo/1n412d41/arm64-v8a/CMakeFiles/CMakeOutput.log".

  C++ build system [configure] failed while executing:
      /usr/bin/cmake \
        -H/home/vagrant/build/at.tomtasche.reader \
        -DCMAKE_SYSTEM_NAME=Android \
        -DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
        -DCMAKE_SYSTEM_VERSION=21 \
        -DANDROID_PLATFORM=android-21 \
        -DANDROID_ABI=arm64-v8a \
        -DCMAKE_ANDROID_ARCH_ABI=arm64-v8a \
        -DANDROID_NDK=/opt/android-sdk/ndk/25.2.9519653 \
        -DCMAKE_ANDROID_NDK=/opt/android-sdk/ndk/25.2.9519653 \
        -DCMAKE_TOOLCHAIN_FILE=/opt/android-sdk/ndk/25.2.9519653/build/cmake/android.toolchain.cmake \
        -DCMAKE_MAKE_PROGRAM=/usr/bin/ninja \
        -DCMAKE_LIBRARY_OUTPUT_DIRECTORY=/home/vagrant/build/at.tomtasche.reader/app/build/intermediates/cxx/RelWithDebInfo/1n412d41/obj/arm64-v8a \
        -DCMAKE_RUNTIME_OUTPUT_DIRECTORY=/home/vagrant/build/at.tomtasche.reader/app/build/intermediates/cxx/RelWithDebInfo/1n412d41/obj/arm64-v8a \
        -DCMAKE_BUILD_TYPE=RelWithDebInfo \
        -B/home/vagrant/build/at.tomtasche.reader/app/.cxx/RelWithDebInfo/1n412d41/arm64-v8a \
        -GNinja \
        -DANDROID_STL=c++_shared
    from /home/vagrant/build/at.tomtasche.reader/app
  WARN: *** Conan 1 is legacy and on a deprecation path ***
  WARN: *** Please upgrade to Conan 2 ***
  cmake/3.29.3: ERROR: Package 'ada521499582ffec91aef450980290fff1f6c275' build failed
  cmake/3.29.3: WARN: Build folder /home/vagrant/.conan/data/cmake/3.29.3/_/_/build/ada521499582ffec91aef450980290fff1f6c275
  ERROR: cmake/3.29.3: Error in build() method, line 30
        get(self, **self.conan_data["sources"][self.version][str(self.settings.os)][arch],
        KeyError: 'Android'
  CMake Error at app/conan.cmake:633 (message):
    Conan install failed='1'
  Call Stack (most recent call first):
    CMakeLists.txt:29 (conan_cmake_install)

then again, surely I'm missing some steps :smile:

licaon-kter commented 5 months ago

https://gitlab.com/fdroid/fdroiddata/-/merge_requests/15059 might solve it now, thanks to @linsui but in the long run this needs to be tackled here too

andiwand commented 5 months ago

Hey @licaon-kter ! Thanks for moving things forward with F-Droid! Our conan setup on Android is a bit brittle at the moment. I am trying to move things towards conan v2 right now with https://github.com/opendocument-app/OpenDocument.droid/pull/345. This requires to move https://github.com/opendocument-app/OpenDocument.core to conan v2 as well with I am working on right now https://github.com/opendocument-app/OpenDocument.core/pull/354.

This is the recipe I am following https://docs.conan.io/2/examples/cross_build/android/android_studio.html#examples-cross-build-android-studio which seems much more stable than what was suggested for conan v1 so I hope this will also solve the problems you are facing right now.

TomTasche commented 4 months ago

Should be good now?

TomTasche commented 4 months ago

Thanks for your FOSS work by the way @licaon-kter!

licaon-kter commented 4 months ago

@TomTasche will you open a MR to update?

TomTasche commented 4 months ago

You mean on F-Droid? How do I do that / what needs to be done exactly? I thought this is automated in some way.

licaon-kter commented 4 months ago

just like https://gitlab.com/fdroid/fdroiddata/-/merge_requests/15059/diffs

I thought this is automated in some way.

sometimes it can be, but there you see AutoUpdateMode: None so currently it isn't

looking at https://github.com/opendocument-app/OpenDocument.droid/blob/v3.28/app/src/main/AndroidManifest.xml#L5-L6 I guess it might be feasible, will try asap

licaon-kter commented 4 months ago

updated recipe, but:

...
arch=armv7
arch_build=x86_64
build_type=Release
compiler=clang
compiler.cppstd=17
compiler.libcxx=c++_shared
compiler.version=12
os=Android
os.api_level=23
os_build=Linux
&:build_type=RelWithDebInfo
odrcore/*:build_type=RelWithDebInfo
[options]
[build_requires]
[env]
[conf]
tools.android:ndk_path=/opt/android-sdk/ndk/26.3.11579264
tools.build:skip_test=True

odrcore/4.1.0: Not found in local cache, looking in remotes...
odrcore/4.1.0: Trying with 'conancenter'...
ERROR: Unable to find 'odrcore/4.1.0' in remotes
andiwand commented 4 months ago

you need to add our conan remote like we do it in our CI https://github.com/opendocument-app/OpenDocument.droid/blob/5796674f30d14f2d3b5ebf1ade8977662a58310a/.github/workflows/android_main.yml#L51-L52

licaon-kter commented 4 months ago

what does that contain?

why was that not needed in the previous version?

andiwand commented 4 months ago

What do you mean? Looking at your original post you have

      - conan remote add odr https://artifactory.opendocument.app/artifactory/api/conan/conan,

which is the same thing but with conan 1 instead of conan 2 which is what we use now

licaon-kter commented 4 months ago

ignore my post here, or that version for now

previous version build recipe is: https://gitlab.com/fdroid/fdroiddata/-/blob/master/metadata/at.tomtasche.reader.yml#L258-L294

and I don't see the remote thing

what does that contain?

?

how can I see the url contents? are those binaries? source code?

linsui commented 4 months ago

Does conan export . odrcore/VERSION@ still work? We use that to build the core locally.

andiwand commented 4 months ago

It is the same as it was with this here https://gitlab.com/fdroid/fdroiddata/-/blob/master/metadata/at.tomtasche.reader.yml#L255

It adds our conan remote which contains the recipe for https://github.com/opendocument-app/OpenDocument.core and potential other dependencies in the future.

It is up to you if you want to use the remote or not. If you don't use it you have to export the odrcore package with the correct version yourself like you did here https://gitlab.com/fdroid/fdroiddata/-/blob/master/metadata/at.tomtasche.reader.yml#L291-293

licaon-kter commented 4 months ago

let me retry, the log is https://gitlab.com/fdroid/fdroiddata/-/merge_requests/15059#note_1992311087 and this fails in gradle clean after prebuild: where the export part is LATER in build:

I'll try to export in prebuild: and see if that does it

licaon-kter commented 4 months ago

@andiwand what's the new export command for conan2?

andiwand commented 4 months ago

I have an example here https://github.com/opendocument-app/OpenDocument.core/blob/de96f913cedd19fe968e6b2c99e4e3c3593302b4/.github/workflows/build_test.yml#L254-L255

conan export . --name odrcore --version 4.1.0
linsui commented 4 months ago

Can you update it in https://github.com/opendocument-app/OpenDocument.core?tab=readme-ov-file#local-build?

licaon-kter commented 4 months ago

Some issues that I see:

remember when I asked

what does that contain?

well.. this is why I asked because it appears it contains binary deps... which are a blocker

/LE: reopen this issue

andiwand commented 4 months ago

Well it contains what a conan remote contains. Your question is way too generic to give you a definite answer.

  1. Maybe @TomTasche can give insights about gradle clean.
  2. That is a conan issue. You can overrule that if you need to or use a system cmake.
  3. Again this is up to you. What you call random binaries I call stuff we don't have to compile thousands of times in our CI. You can instruct conan to build all packages from source. See https://docs.conan.io/2/reference/commands/install.html with the --build option.

Again you were already using a conan remote. I have a hard time understanding the confusion here. You can look up everything you asked here on the conan docs.

licaon-kter commented 4 months ago

That is a conan issue. You can overrule that if you need to or use a system cmake.

how?

What you call random binaries I call stuff we don't have to compile thousands of times in our CI.

same here, I can install several versions of cmake, including 3.30.0, but your build system ignores the local installed one and pull 3.30.0 from conancenter anyway

Again you were already using a conan remote.

if we missed them then and notice random binaries being downloaded now, against the F-Droid policy, we need to remove those actions, and remove faulty past versions as needed

You can look up everything you asked here on the conan docs.

right, but that takes time for those that don't use it daily

anyway, this recipe:

  - versionName: '3.28'
    versionCode: 181
    commit: 5796674f30d14f2d3b5ebf1ade8977662a58310a
    subdir: app
    sudo:
      - apt-get update
      - apt-get install -y cmake make ninja-build pipx
      - PIPX_HOME=/opt/pipx PIPX_BIN_DIR=/usr/local/bin pipx install conan
    gradle:
      - pro
    srclibs:
      - OpenDocument.core@v4.1.0
    prebuild:
      - export coreVersion=$(sed -n -E 's/odrcore\/([0-9.]+)@/\1/p' conanfile.txt)
      - git -C $$OpenDocument.core$$ checkout -f v$coreVersion
      - conan export $$OpenDocument.core$$ --name odrcore --version $coreVersion
      - conan profile detect
      - sed -i -e '/gms/d' -e '/firebase/d' -e 's/build=missing/build=*/' {.,..}/build.gradle
      - sed -i -e '/com.google.android.play/d' -e '/ump/d' -e '/pro"/d' build.gradle
      - sed -i -e '/INTERNET/d' -e '/^        <meta-data/,+5d' -e '/property/,+4d'
        src/main/AndroidManifest.xml
      - cd src/main/java/at/tomtasche/reader
      - sed -i -e '/gms/d' -e '/play.core/d' -e '/firebase/d' -e '/void initializeProprietaryLibraries/,/^    }/d'
        -e '/initializeProprietaryLibraries/d' -e 's/billingManager.hasPurchased()/true/'
        ui/activity/*.java background/FileLoader.java background/LoaderService.java
      - sed -i -e '/private Uri doFirebaseConvert/,/^    }/d' -e 's/viewerUri = doFirebaseConvert(options)/return/'
        -e '/gms/d' -e '/firebase/Id' -e '/Storage/d' -e '/auth /d' -e '/storage /d'
        background/OnlineLoader.java
      - sed -i -e '/getBooleanConfig("show_in_app_rating/,/});/d' -e '/void offerUpload/,/^    }/d'
        -e '/offerUpload/d' -e '/void requestInAppRating/,/^    }/d' -e '/requestInAppRating/d'
        ui/activity/DocumentFragment.java
      - sed -i -e 's/configManager.getBooleanConfig(".*")/null/' background/OdfLoader.java
      - for class in AdManager AnalyticsManager BillingManager ConfigManager CrashManager
        HelpManager; do echo "package at.tomtasche.reader.nonfree; public class ${class}
        {}" > nonfree/${class}.java; sed -i -e "/${class}\./Id" background/*.java
        ui/*/*.java ui/*.java; done
    ndk: 26.3.11579264

will build

cmake/3.30.0 (1 of 10)
gtest/1.14.0 (2 of 10)
miniz/3.0.2 (3 of 10)
nlohmann_json/3.11.3 (4 of 10)
pugixml/1.14 (5 of 10)
uchardet/0.0.7 (6 of 10)
utfcpp/4.0.4 (7 of 10)
vincentlaucsb-csv-parser/2.1.3 (8 of 10)
cryptopp/8.8.0 (9 of 10)
odrcore/4.1.0 (10 of 10)

as expected, which is nice :tada:

it will build them 8 (!!) times each... but yeah...

here's the full log: at.tomtasche.reader_181.log.gz

while I understand it will be built once in prebuild, maybe you can find a way for us to not build it 7 more times later? :smile:

ViliusSutkus89 commented 3 months ago

gradle clean invokes task conanInstall. It's not that gradle's clean task specifically invokes it, it's just that the conanInstall task is involved on each gradle invocation. I'll find the correct Android Gradle Plugin task, on which should we attach the conanInstall task dependency.

@licaon-kter , I do believe you could ask conan to build everything from source if you change --build=missing into --build="*" in conan install invocation. Additional line of sed in prebuild is reasonable, right?

ViliusSutkus89 commented 3 months ago

@licaon-kter , also, it's not our build system that ignores your preinstalled system cmake, it's conan. We didn't ask it to do it this way, it's the default way.

licaon-kter commented 3 months ago

Please read under "anyway, this recipe:" too :)

ViliusSutkus89 commented 3 months ago

sorry, misread that somehow