From 8990c36c920cba8b97cb5d7a26d42d04ee478591 Mon Sep 17 00:00:00 2001 From: albexk Date: Fri, 12 Apr 2024 22:15:16 +0300 Subject: [PATCH] Add build openssl .so libraries for android [android-openssl] --- .github/workflows/build_openssl3_android.yml | 99 ---------------- .github/workflows/build_openssl_android.yml | 117 ++++++++++--------- 2 files changed, 61 insertions(+), 155 deletions(-) delete mode 100644 .github/workflows/build_openssl3_android.yml diff --git a/.github/workflows/build_openssl3_android.yml b/.github/workflows/build_openssl3_android.yml deleted file mode 100644 index e266724..0000000 --- a/.github/workflows/build_openssl3_android.yml +++ /dev/null @@ -1,99 +0,0 @@ -name: android-openssl3 - -on: [push] - -jobs: - - Build-Libs-OpenSSL3-Android: - name: 'Build-Libs-OpenSSL3-Android' - runs-on: ubuntu-latest - if: | - contains(github.event.head_commit.message, '[all]') || - contains(github.event.head_commit.message, '[android]') || - contains(github.event.head_commit.message, '[android-openssl3]') || - contains(github.event.head_commit.message, '[openssl3]') - - env: - ANDROID_MIN_SDK: 24 - ANDROID_NDK_VERSION: 'r26b' - - strategy: - matrix: - include: - - arch: arm64-v8a - target: android-arm64 - - arch: armeabi-v7a - target: android-arm - - arch: x86_64 - target: android-x86_64 - - arch: x86 - target: android-x86 - - steps: - - - name: 'Setup Android NDK' - id: setup-ndk - uses: nttld/setup-ndk@v1 - with: - ndk-version: ${{ env.ANDROID_NDK_VERSION }} - - - name: 'Install patchelf' - run: sudo apt-get install -y patchelf - - - name: 'Get openssl' - uses: actions/checkout@v4 - with: - repository: openssl/openssl - ref: openssl-3.2.1 - path: openssl - - - name: 'Build OpenSSL3 Android' - run: | - cd openssl - PATH=$ANDROID_NDK_ROOT/toolchains/llvm/prebuilt/linux-x86_64/bin:$PATH - ./Configure ${{ matrix.target }} shared no-tests -D__ANDROID_API__=${{ env.ANDROID_MIN_SDK }} - make -j$(nproc) SHLIB_VERSION_NUMBER= build_libs - mkdir -p build/${{ matrix.arch }} - cp libcrypto.so ./build/${{ matrix.arch }}/libcrypto_3.so - cp libssl.so ./build/${{ matrix.arch }}/libssl_3.so - cd ./build/${{ matrix.arch }} - patchelf --debug --set-soname libcrypto_3.so libcrypto_3.so - patchelf --debug --set-soname libssl_3.so libssl_3.so - patchelf --debug --replace-needed libcrypto.so libcrypto_3.so libssl_3.so - - - name: 'Archive Android OpenSSL3 libs' - uses: actions/upload-artifact@v4 - with: - name: android-openssl3-${{ matrix.arch }} - path: openssl/build - - github-release: - name: GitHub Release - needs: Build-Libs-OpenSSL3-Android - runs-on: ubuntu-latest - if: startsWith(github.ref, 'refs/tags/') - - steps: - - name: Setup | Checkout - uses: actions/checkout@v4 - - - name: Setup | Artifacts - uses: actions/download-artifact@v4 - with: - path: android-openssl3 - merge-multiple: true - - - name: Setup | Checksums - run: for file in $(find ./ -name '*.so' ); do openssl dgst -sha256 -r "$file" | awk '{print $1}' > "${file}.sha256"; done - - - name: Zip ALL - run: for file in *; do zip -r ${file%.*}.zip $file; done - - - name: Upload binaries to release - uses: svenstaro/upload-release-action@v2 - with: - repo_token: ${{ secrets.GITHUB_TOKEN }} - file: android-openssl3.zip - tag: ${{ github.ref }} - overwrite: true - file_glob: true diff --git a/.github/workflows/build_openssl_android.yml b/.github/workflows/build_openssl_android.yml index 0e6f7ab..7a671eb 100644 --- a/.github/workflows/build_openssl_android.yml +++ b/.github/workflows/build_openssl_android.yml @@ -11,16 +11,36 @@ jobs: contains(github.event.head_commit.message, '[all]') || contains(github.event.head_commit.message, '[android]') || contains(github.event.head_commit.message, '[android-openssl]') || - contains(github.event.head_commit.message, '[openssl]') + contains(github.event.head_commit.message, '[openssl]') + + env: + ANDROID_MIN_SDK: 24 + ANDROID_NDK_VERSION: 'r26b' strategy: matrix: - arch: [x86, x86_64, armeabi-v7a, arm64-v8a] - fail-fast: false + include: + - arch: arm64-v8a + target: android-arm64 + - arch: armeabi-v7a + target: android-arm + - arch: x86_64 + target: android-x86_64 + - arch: x86 + target: android-x86 steps: + - name: 'Setup Android NDK' + id: setup-ndk + uses: nttld/setup-ndk@v1 + with: + ndk-version: ${{ env.ANDROID_NDK_VERSION }} + + - name: 'Install patchelf' + run: sudo apt-get install -y patchelf + - name: 'Get openssl' - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: repository: openssl/openssl ref: openssl-3.0.13 @@ -29,43 +49,27 @@ jobs: - name: 'Build OpenSSL Android' run: | cd openssl - mkdir build - case "${{ matrix.arch }}" in - arm64-v8a) - ANDROID_NDK_ROOT=$ANDROID_NDK_LATEST_HOME PATH=$ANDROID_NDK_LATEST_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin:$PATH ./Configure android-arm64 no-tests -U__ANDROID_API__ -D__ANDROID_API__=21 && PATH=$ANDROID_NDK_LATEST_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin:$PATH make - mkdir build/arm64-v8a - cp libcrypto.a ./build/arm64-v8a/libcrypto.a - cp libssl.a ./build/arm64-v8a/libssl.a - cp -a ./include/. ./build/include - ;; - armeabi-v7a) - ANDROID_NDK_ROOT=$ANDROID_NDK_LATEST_HOME PATH=$ANDROID_NDK_LATEST_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin:$PATH ./Configure android-arm no-tests -U__ANDROID_API__ -D__ANDROID_API__=21 && PATH=$ANDROID_NDK_LATEST_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin:$PATH make - mkdir build/armeabi-v7a - cp libcrypto.a ./build/armeabi-v7a/libcrypto.a - cp libssl.a ./build/armeabi-v7a/libssl.a - ;; - x86_64) - ANDROID_NDK_ROOT=$ANDROID_NDK_LATEST_HOME PATH=$ANDROID_NDK_LATEST_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin:$PATH ./Configure android-x86_64 no-tests -U__ANDROID_API__ -D__ANDROID_API__=21 && PATH=$ANDROID_NDK_LATEST_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin:$PATH make - mkdir build/x86_64 - cp libcrypto.a ./build/x86_64/libcrypto.a - cp libssl.a ./build/x86_64/libssl.a - ;; - x86) - ANDROID_NDK_ROOT=$ANDROID_NDK_LATEST_HOME PATH=$ANDROID_NDK_LATEST_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin:$PATH ./Configure android-x86 no-tests -U__ANDROID_API__ -D__ANDROID_API__=21 && PATH=$ANDROID_NDK_LATEST_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin:$PATH make - mkdir build/x86 - cp libcrypto.a ./build/x86/libcrypto.a - cp libssl.a ./build/x86/libssl.a - ;; - esac - - - name: Archive Android OpenSSL libs - uses: actions/upload-artifact@v3 + PATH=$ANDROID_NDK_ROOT/toolchains/llvm/prebuilt/linux-x86_64/bin:$PATH + ./Configure ${{ matrix.target }} shared no-tests -D__ANDROID_API__=${{ env.ANDROID_MIN_SDK }} + make -j$(nproc) SHLIB_VERSION_NUMBER= build_libs + mkdir -p build/${{ matrix.arch }} + cp libcrypto.so ./build/${{ matrix.arch }}/libcrypto_3.so + cp libssl.so ./build/${{ matrix.arch }}/libssl_3.so + cp libcrypto.a ./build/${{ matrix.arch }}/libcrypto.a + cp libssl.a ./build/${{ matrix.arch }}/libssl.a + [ ${{ matrix.arch }} == arm64-v8a ] && cp -a ./include/. ./build/include + cd ./build/${{ matrix.arch }} + patchelf --debug --set-soname libcrypto_3.so libcrypto_3.so + patchelf --debug --set-soname libssl_3.so libssl_3.so + patchelf --debug --replace-needed libcrypto.so libcrypto_3.so libssl_3.so + + - name: 'Archive Android OpenSSL libs' + uses: actions/upload-artifact@v4 with: retention-days: 1 - name: android-openssl - path: '~/work/3rd-build-ga/3rd-build-ga/openssl/build' + name: android-openssl-${{ matrix.arch }} + path: openssl/build - github-release: name: GitHub Release needs: Build-Libs-OpenSSL-Android @@ -73,25 +77,26 @@ jobs: if: startsWith(github.ref, 'refs/tags/') steps: - - name: Setup | Checkout - uses: actions/checkout@v2 - - - name: Setup | Artifacts - uses: actions/download-artifact@v2 + - name: Setup | Checkout + uses: actions/checkout@v4 - - name: Setup | Checksums - run: for file in $(find ./ -name '*.a' ); do openssl dgst -sha256 -r "$file" | awk '{print $1}' > "${file}.sha256"; done + - name: Setup | Artifacts + uses: actions/download-artifact@v4 + with: + path: android-openssl + merge-multiple: true - - name: Zip ALL - run: for file in *; do zip -r ${file%.*}.zip $file; done + - name: Setup | Checksums + run: for file in $(find ./ -regex '.*\.\(a\|so\)' ); do openssl dgst -sha256 -r "$file" | awk '{print $1}' > "${file}.sha256"; done - - name: Upload binaries to release - uses: svenstaro/upload-release-action@v2 - with: - repo_token: ${{ secrets.GITHUB_TOKEN }} - file: android-openssl.zip - tag: ${{ github.ref }} - overwrite: true - file_glob: true - + - name: Zip ALL + run: for file in *; do zip -r ${file%.*}.zip $file; done + - name: Upload binaries to release + uses: svenstaro/upload-release-action@v2 + with: + repo_token: ${{ secrets.GITHUB_TOKEN }} + file: android-openssl.zip + tag: ${{ github.ref }} + overwrite: true + file_glob: true