From 31f083f14b738ddaf7e192f0ed9f99e262f1b990 Mon Sep 17 00:00:00 2001 From: Neal Xu Date: Tue, 14 Mar 2023 10:50:40 +0800 Subject: [PATCH] chore: optimize CI scripts (run-on macos, version, slack notification --- .github/workflows/build-release-android.yml | 96 +++++++++--- .github/workflows/build-release-ios.yml | 63 ++++++-- .github/workflows/integrate-fe.yml | 146 ++++++++++++++++++ .github/workflows/release-notes.yml | 15 ++ README.md | 41 +++-- README.zh.md | 19 +++ VERSION | 1 + imkey-core/ikc-docs/BUILD.zh.md | 2 +- imkey-core/ikc-tools/build-android-example.sh | 4 +- imkey-core/ikc-tools/build-android.sh | 2 +- ...uild-android-linux.sh => build-android.sh} | 36 ++--- 11 files changed, 354 insertions(+), 71 deletions(-) create mode 100644 .github/workflows/integrate-fe.yml create mode 100644 .github/workflows/release-notes.yml create mode 100644 README.zh.md create mode 100644 VERSION rename script/{build-android-linux.sh => build-android.sh} (63%) diff --git a/.github/workflows/build-release-android.yml b/.github/workflows/build-release-android.yml index 57543c31..e19a2089 100644 --- a/.github/workflows/build-release-android.yml +++ b/.github/workflows/build-release-android.yml @@ -1,18 +1,28 @@ -name: Build Release Android +name: Build Android Release on: push: - tags: - - 'v*' + branches: + - main + issue_comment: + types: [created, edited] env: CARGO_TERM_COLOR: always jobs: + build: + name: Build Android Release + if: ( + github.ref == 'refs/heads/main' || + (github.event.issue.pull_request && + contains( + fromJson('["build", "build android"]'), + github.event.comment.body + )) + ) - cross-compile: - name: cross compile - runs-on: ubuntu-20.04 + runs-on: macos-latest steps: - name: Checkout repository @@ -33,50 +43,64 @@ jobs: - name: Install Rust run: | rustup toolchain install nightly-2022-10-31 - rustup default nightly-2022-10-31-x86_64-unknown-linux-gnu + rustup default nightly-2022-10-31-x86_64-apple-darwin rustup target add aarch64-linux-android armv7-linux-androideabi i686-linux-android x86_64-linux-android rustup show - - name: Install dependent - run: | - sudo apt-get install -y libusb-dev libusb-1.0-0-dev libftdi1-dev libudev-dev - sudo apt-get install -y protobuf-compiler libprotobuf-dev - + # - name: Install dependent + # run: | + # sudo apt-get install -y libusb-dev libusb-1.0-0-dev libftdi1-dev libudev-dev + # sudo apt-get install -y protobuf-compiler libprotobuf-dev + + - name: Install dependency + run: | + brew install protobuf + - name: Setup Android SDK uses: android-actions/setup-android@v2 + + - name: Install Android Tools + run: sdkmanager "build-tools;29.0.3" "platforms;android-31" "ndk;25.2.9519653" - name: Configure Rust Config File run: | echo '[target.armv7-linux-androideabi]' >> ~/.cargo/config - echo 'ar = "/usr/local/lib/android/sdk/ndk/25.1.8937393/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-ar"' >> ~/.cargo/config - echo 'linker = "/usr/local/lib/android/sdk/ndk/25.1.8937393/toolchains/llvm/prebuilt/linux-x86_64/bin/armv7a-linux-androideabi29-clang"' >> ~/.cargo/config + echo 'ar = "/Users/runner/Library/Android/sdk/ndk/25.2.9519653/toolchains/llvm/prebuilt/darwin-x86_64/bin/llvm-ar"' >> ~/.cargo/config + echo 'linker = "/Users/runner/Library/Android/sdk/ndk/25.2.9519653/toolchains/llvm/prebuilt/darwin-x86_64/bin/armv7a-linux-androideabi22-clang"' >> ~/.cargo/config echo '[target.aarch64-linux-android]' >> ~/.cargo/config - echo 'ar = "/usr/local/lib/android/sdk/ndk/25.1.8937393/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-ar"' >> ~/.cargo/config - echo 'linker = "/usr/local/lib/android/sdk/ndk/25.1.8937393/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android29-clang"' >> ~/.cargo/config + echo 'ar = "/Users/runner/Library/Android/sdk/ndk/25.2.9519653/toolchains/llvm/prebuilt/darwin-x86_64/bin/llvm-ar"' >> ~/.cargo/config + echo 'linker = "/Users/runner/Library/Android/sdk/ndk/25.2.9519653/toolchains/llvm/prebuilt/darwin-x86_64/bin/aarch64-linux-android29-clang"' >> ~/.cargo/config echo '[target.i686-linux-android]' >> ~/.cargo/config - echo 'ar = "/usr/local/lib/android/sdk/ndk/25.1.8937393/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-ar"' >> ~/.cargo/config - echo 'linker = "/usr/local/lib/android/sdk/ndk/25.1.8937393/toolchains/llvm/prebuilt/linux-x86_64/bin/i686-linux-android29-clang"' >> ~/.cargo/config + echo 'ar = "/Users/runner/Library/Android/sdk/ndk/25.2.9519653/toolchains/llvm/prebuilt/darwin-x86_64/bin/llvm-ar"' >> ~/.cargo/config + echo 'linker = "/Users/runner/Library/Android/sdk/ndk/25.2.9519653/toolchains/llvm/prebuilt/darwin-x86_64/bin/i686-linux-android29-clang"' >> ~/.cargo/config echo '[target.x86_64-linux-android]' >> ~/.cargo/config - echo 'ar = "/usr/local/lib/android/sdk/ndk/25.1.8937393/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-ar"' >> ~/.cargo/config - echo 'linker = "/usr/local/lib/android/sdk/ndk/25.1.8937393/toolchains/llvm/prebuilt/linux-x86_64/bin/x86_64-linux-android29-clang"' >> ~/.cargo/config + echo 'ar = "/Users/runner/Library/Android/sdk/ndk/25.2.9519653/toolchains/llvm/prebuilt/darwin-x86_64/bin/llvm-ar"' >> ~/.cargo/config + echo 'linker = "/Users/runner/Library/Android/sdk/ndk/25.2.9519653/toolchains/llvm/prebuilt/darwin-x86_64/bin/x86_64-linux-android29-clang"' >> ~/.cargo/config cat ~/.cargo/config - name: Build TCX And IKC run: | pushd ${{github.workspace}}/script - ./build-android-linux.sh + ./build-android.sh popd - name: Setup Gradle uses: gradle/gradle-build-action@v2 with: gradle-version: 7.0.1 - - - name: publish + + - name: Read VERSION file + id: getversion + run: echo "version=$(cat VERSION)+$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT + + - name: Get commits + id: getcommits + run: echo "commits=$(git log -5 --pretty=%B)" >> $GITHUB_OUTPUT + + - name: Publish run: | pushd ${{github.workspace}}/publish/android - TAG_NAME=${{ github.ref }} - VERSION_NAME="VERSION=${TAG_NAME: 11}" + VERSION_NAME="VERSION=${{ steps.getversion.outputs.version }}" echo 'NEXUS_USER=${{secrets.NEXUS_USER}}' >> ./local.properties echo 'NEXUS_PASSWORD=${{secrets.NEXUS_PASSWORD}}' >> ./local.properties echo ${VERSION_NAME} >> ./local.properties @@ -84,3 +108,25 @@ jobs: ./gradlew pPPTNR popd + + - name: Send custom JSON data to Slack workflow + id: slack + uses: slackapi/slack-github-action@v1.23.0 + with: + # For posting a rich message using Block Kit + payload: | + { + "text": "New build of android-token-core: ${{ job.status }}\nVERSION: ${{ steps.getversion.outputs.version }}\nCheck more: ${{ github.event.pull_request.html_url || github.event.head_commit.url }}\nCommits:\n${{ steps.getcommits.outputs.commits }}", + "blocks": [ + { + "type": "section", + "text": { + "type": "mrkdwn", + "text": "New build of android-token-core: ${{ job.status }}\nVERSION: ${{ steps.getversion.outputs.version }}\nCheck more: ${{ github.event.pull_request.html_url || github.event.head_commit.url }}\nCommits:\n${{ steps.getcommits.outputs.commits }}" + } + } + ] + } + env: + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }} + SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK \ No newline at end of file diff --git a/.github/workflows/build-release-ios.yml b/.github/workflows/build-release-ios.yml index 6dbce25d..53be4f76 100644 --- a/.github/workflows/build-release-ios.yml +++ b/.github/workflows/build-release-ios.yml @@ -1,17 +1,27 @@ -name: Build Release IOS +name: Build iOS Release on: push: - tags: - - 'v*' + branches: + - main + issue_comment: + types: [created, edited] env: CARGO_TERM_COLOR: always jobs: - build: - name: build release + name: Build iOS Release + if: ( + github.ref == 'refs/heads/main' || + (github.event.issue.pull_request && + contains( + fromJson('["build", "build ios"]'), + github.event.comment.body + )) + ) + runs-on: macos-latest steps: @@ -39,6 +49,15 @@ jobs: cargo install cargo-lipo brew install protobuf + - name: Read VERSION file + id: getversion + run: echo "version=$(cat VERSION)+$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT + + - name: Get commits + id: getcommits + run: echo "commits=$(git log -5 --pretty=%B)" >> $GITHUB_OUTPUT + + - name: Build And Publish run: | pushd ./imkey-core/ikc @@ -84,11 +103,9 @@ jobs: popd pushd ./imkey-core/ios-release - TAG_NAME=${{ github.ref }} - VERSION_NAME=${TAG_NAME: 11} - PACKAGE_NAME=ios-release-v$VERSION_NAME.zip + PACKAGE_NAME=ios-release-${{ steps.getversion.outputs.version }}.zip zip -q -r $PACKAGE_NAME . - curl -v -u ${{secrets.NEXUS_USER}}:${{secrets.NEXUS_PASSWORD}} --upload-file $PACKAGE_NAME https://nexus.token.im/repository/im-releases/im/imkey/ios/$VERSION_NAME/$PACKAGE_NAME + curl -v -u ${{secrets.NEXUS_USER}}:${{secrets.NEXUS_PASSWORD}} --upload-file $PACKAGE_NAME https://nexus.token.im/repository/im-releases/im/imkey/ios/${{ steps.getversion.outputs.version }}/$PACKAGE_NAME popd pushd ./token-core/tcx-examples/TokenCoreX @@ -106,10 +123,30 @@ jobs: popd pushd ./token-core/ios-release - TAG_NAME=${{ github.ref }} - VERSION_NAME=${TAG_NAME: 11} - PACKAGE_NAME=ios-release-v$VERSION_NAME.zip + PACKAGE_NAME=ios-release-${{ steps.getversion.outputs.version }}.zip zip -q -r $PACKAGE_NAME . - curl -v -u ${{secrets.NEXUS_USER}}:${{secrets.NEXUS_PASSWORD}} --upload-file $PACKAGE_NAME https://nexus.token.im/repository/im-releases/com/consenlabs/ios/$VERSION_NAME/$PACKAGE_NAME + curl -v -u ${{secrets.NEXUS_USER}}:${{secrets.NEXUS_PASSWORD}} --upload-file $PACKAGE_NAME https://nexus.token.im/repository/im-releases/com/consenlabs/ios/${{ steps.getversion.outputs.version }}/$PACKAGE_NAME popd + + - name: Send custom JSON data to Slack workflow + id: slack + uses: slackapi/slack-github-action@v1.23.0 + with: + # For posting a rich message using Block Kit + payload: | + { + "text": "New build of ios-token-core: ${{ job.status }}\nVERSION: ${{ steps.getversion.outputs.version }}\nCheck more: ${{ github.event.pull_request.html_url || github.event.head_commit.url }}\nCommits:\n${{ steps.getcommits.outputs.commits }}", + "blocks": [ + { + "type": "section", + "text": { + "type": "mrkdwn", + "text": "New build of ios-token-core: ${{ job.status }}\nVERSION: ${{ steps.getversion.outputs.version }}\nCheck more: ${{ github.event.pull_request.html_url || github.event.head_commit.url }}\nCommits:\n${{ steps.getcommits.outputs.commits }}" + } + } + ] + } + env: + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }} + SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK \ No newline at end of file diff --git a/.github/workflows/integrate-fe.yml b/.github/workflows/integrate-fe.yml new file mode 100644 index 00000000..f60f3cf3 --- /dev/null +++ b/.github/workflows/integrate-fe.yml @@ -0,0 +1,146 @@ +name: Build iOS Debug + +on: + issue_comment: + types: [created, edited] + +env: + CARGO_TERM_COLOR: always + +jobs: + build: + name: Build iOS Debug + if: (github.event.issue.pull_request && + contains( + fromJson('["build debug"]'), + github.event.comment.body + )) + + runs-on: macos-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v2 + with: + fetch-depth: 1 + + - name: Cache + uses: actions/cache@v2 + with: + path: | + ~/.cargo/registry + ~/.cargo/git + ~/.rustup + target + key: macos-latest-nightly + + - name: Install Rust + run: | + rustup toolchain install nightly-2022-10-31 + rustup default nightly-2022-10-31-x86_64-apple-darwin + rustup target add x86_64-apple-ios + rustup show + cargo install cargo-lipo + brew install protobuf + + - name: Read VERSION file + id: getversion + run: echo "version=$(cat VERSION)-alpha+$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT + + - name: Get commits + id: getcommits + run: echo "commits=$(git log -5 --pretty=%B)" >> $GITHUB_OUTPUT + + + - name: Build And Publish + run: | + pushd ./imkey-core/ikc + cargo lipo --release --targets x86_64-apple-ios + cbindgen ./src/lib.rs -l c > ${{github.workspace}}/target/connector.h + popd + + pushd ./token-core/tcx + cargo lipo --release --targets x86_64-apple-ios + cbindgen ./src/lib.rs -l c > ${{github.workspace}}/target/tcx.h + popd + + LIBS_IKC=./imkey-core/mobile-sdk/imKeyCoreX/imKeyCoreX + LIBS_TCX=./token-core/tcx-examples/TokenCoreX/TokenCoreX + cp ./target/universal/release/libconnector.a $LIBS_IKC/libconnector.a + cp ./target/universal/release/libtcx.a $LIBS_TCX/libtcx.a + cp ./target/connector.h $LIBS_IKC/connector.h + cp ./target/tcx.h $LIBS_TCX/tcx.h + if [ -d "./ios-release" ]; then + rm -rf ./ios-release + fi + + BUILD_DIR=./Products + BUILD_ROOT=./Products + SYMROOT=./Products + BUILD_PRODUCTS=./Products + CONFIGURATION=Release + PROJECT_NAME_IKC=imKeyCoreX + PROJECT_NAME_TCX=TokenCoreX + + pushd ./imkey-core/mobile-sdk/imKeyCoreX + mkdir -p $BUILD_DIR + UNIVERSAL_OUTPUTFOLDER=$BUILD_DIR/$CONFIGURATION-Universal + mkdir -p $UNIVERSAL_OUTPUTFOLDER + + xcodebuild -target $PROJECT_NAME_IKC ONLY_ACTIVE_ARCH=NO -configuration $CONFIGURATION -sdk iphoneos BUILD_DIR=$BUILD_DIR BUILD_ROOT=$BUILD_ROOT build + xcodebuild -target $PROJECT_NAME_IKC -configuration Debug -sdk iphonesimulator ONLY_ACTIVE_ARCH=NO BUILD_DIR=$BUILD_DIR BUILD_ROOT=$BUILD_ROOT EXCLUDED_ARCHS=arm64 build + cp -R $BUILD_DIR/$CONFIGURATION-iphoneos/$PROJECT_NAME_IKC.framework $UNIVERSAL_OUTPUTFOLDER/ + lipo -create -output $UNIVERSAL_OUTPUTFOLDER/$PROJECT_NAME_IKC.framework/$PROJECT_NAME_IKC $BUILD_PRODUCTS/Debug-iphonesimulator/$PROJECT_NAME_IKC.framework/$PROJECT_NAME_IKC $BUILD_DIR/$CONFIGURATION-iphoneos/$PROJECT_NAME_IKC.framework/$PROJECT_NAME_IKC + + cp -R $UNIVERSAL_OUTPUTFOLDER/ ../../ios-release + rm -rf $UNIVERSAL_OUTPUTFOLDER + popd + + pushd ./imkey-core/ios-release + PACKAGE_NAME=ios-release-${{ steps.getversion.outputs.version }}.zip + zip -q -r $PACKAGE_NAME . + curl -v -u ${{secrets.NEXUS_USER}}:${{secrets.NEXUS_PASSWORD}} --upload-file $PACKAGE_NAME https://nexus.token.im/repository/im-releases/im/imkey/ios/${{ steps.getversion.outputs.version }}/$PACKAGE_NAME + popd + + pushd ./token-core/tcx-examples/TokenCoreX + mkdir -p $BUILD_DIR + UNIVERSAL_OUTPUTFOLDER=$BUILD_DIR/$CONFIGURATION-Universal + mkdir -p $UNIVERSAL_OUTPUTFOLDER + + xcodebuild -target $PROJECT_NAME_TCX ONLY_ACTIVE_ARCH=NO -configuration $CONFIGURATION -sdk iphoneos BUILD_DIR=$BUILD_DIR BUILD_ROOT=$BUILD_ROOT build + xcodebuild -target $PROJECT_NAME_TCX -configuration Debug -sdk iphonesimulator ONLY_ACTIVE_ARCH=NO BUILD_DIR=$BUILD_DIR BUILD_ROOT=$BUILD_ROOT EXCLUDED_ARCHS=arm64 build + cp -R $BUILD_DIR/$CONFIGURATION-iphoneos/$PROJECT_NAME_TCX.framework $UNIVERSAL_OUTPUTFOLDER/ + lipo -create -output $UNIVERSAL_OUTPUTFOLDER/$PROJECT_NAME_TCX.framework/$PROJECT_NAME_TCX $BUILD_PRODUCTS/Debug-iphonesimulator/$PROJECT_NAME_TCX.framework/$PROJECT_NAME_TCX $BUILD_DIR/$CONFIGURATION-iphoneos/$PROJECT_NAME_TCX.framework/$PROJECT_NAME_TCX + + cp -R $UNIVERSAL_OUTPUTFOLDER/ ../../ios-release + rm -rf $UNIVERSAL_OUTPUTFOLDER + popd + + pushd ./token-core/ios-release + PACKAGE_NAME=ios-release-${{ steps.getversion.outputs.version }}.zip + zip -q -r $PACKAGE_NAME . + curl -v -u ${{secrets.NEXUS_USER}}:${{secrets.NEXUS_PASSWORD}} --upload-file $PACKAGE_NAME https://nexus.token.im/repository/im-releases/com/consenlabs/ios/${{ steps.getversion.outputs.version }}/$PACKAGE_NAME + popd + + + - name: Send custom JSON data to Slack workflow + id: slack + uses: slackapi/slack-github-action@v1.23.0 + with: + # For posting a rich message using Block Kit + payload: | + { + "text": "New build of ios-token-core: ${{ job.status }}\nVERSION: ${{ steps.getversion.outputs.version }}\nCheck more: ${{ github.event.pull_request.html_url || github.event.head_commit.url }}\nCommits:\n${{ steps.getcommits.outputs.commits }}", + "blocks": [ + { + "type": "section", + "text": { + "type": "mrkdwn", + "text": "New build of ios-token-core: ${{ job.status }}\nVERSION: ${{ steps.getversion.outputs.version }}\nCheck more: ${{ github.event.pull_request.html_url || github.event.head_commit.url }}\nCommits:\n${{ steps.getcommits.outputs.commits }}" + } + } + ] + } + env: + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }} + SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK \ No newline at end of file diff --git a/.github/workflows/release-notes.yml b/.github/workflows/release-notes.yml new file mode 100644 index 00000000..873fda2f --- /dev/null +++ b/.github/workflows/release-notes.yml @@ -0,0 +1,15 @@ +name: 'Create Release Notes' + +on: + push: + tags: + - 'v*.*.*' + +jobs: + release: + runs-on: ubuntu-latest + steps: + - name: 'Create Release Notes' + uses: softprops/action-gh-release@de2c0eb89ae2a093876385947365aca7b0e5f844 + with: + generate_release_notes: true \ No newline at end of file diff --git a/README.md b/README.md index 9219b05f..a4bb2caa 100644 --- a/README.md +++ b/README.md @@ -1,20 +1,39 @@ -# token-core-monorepo +# TokenCore Monorepo -合并token-core和imkey-core两个项目到一个workspace,使用统一的rust版本和依赖库版本进行编译,解决不同rust版本编译出来的库文件集成到 -client端冲突问题,并提供Android包的publish到nexus功能 +This repo holds some core code which support imToken. It contains +- token-core, which manages the wallet keystore and sign signature by mobile phone +- imkey-core, which hold the private key in an imKey Hardwallet and sign signature security whitout leaks the pk to mobile. -警告:还未应用到生产环境 +## Getting Started +```bash +$ git clone git@github.com:consenlabs/token-core-monorepo.git +$ cargo build +$ cargo test +``` +See more documents in the package readme -## package + + +## Packages * `token-core` [token-core README](./token-core/README.md) * `imkey-core` [imkey-core README](./imkey-core/README.md) -* `publish` [publish README](./publish/README.md) -* `script` Linux交叉编译脚本,主要用于CI发布Android库时调用 -## Code Build -cargo build +## Copyright and License + +``` + Copyright 2023 imToken PTE. LTD. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 -## License -Apache Licence v2.0 + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +``` \ No newline at end of file diff --git a/README.zh.md b/README.zh.md new file mode 100644 index 00000000..bb68fc11 --- /dev/null +++ b/README.zh.md @@ -0,0 +1,19 @@ +# token-core-monorepo + +合并token-core和imkey-core两个项目到一个workspace,使用统一的rust版本和依赖库版本进行编译,解决不同rust版本编译出来的库文件集成到 +client端冲突问题,并提供Android包的publish到nexus功能 + + +## package +* `token-core` [token-core README](./token-core/README.md) +* `imkey-core` [imkey-core README](./imkey-core/README.md) +* `publish` [publish README](./publish/README.md) +* `script` Linux交叉编译脚本,主要用于CI发布Android库时调用 + + +## Code Build +cargo build + + +## License +Apache Licence v2.0 diff --git a/VERSION b/VERSION new file mode 100644 index 00000000..437459cd --- /dev/null +++ b/VERSION @@ -0,0 +1 @@ +2.5.0 diff --git a/imkey-core/ikc-docs/BUILD.zh.md b/imkey-core/ikc-docs/BUILD.zh.md index c95fc736..8f5726f5 100644 --- a/imkey-core/ikc-docs/BUILD.zh.md +++ b/imkey-core/ikc-docs/BUILD.zh.md @@ -24,5 +24,5 @@ cargo install cbindgen ## 配置 Android 编译工具 1. 安装 Android SDK, Android Studio 会默认附带 Android SDK。也可以单独安装。Android Studio 附带的 SDK 目录在`/Users/xxx/Library/Android/sdk` 2. 配置`~/.cargo/config` -3. 运行 `imkey-core` 项目中的`tools/build-android-linux.sh`。注意目前android编译仅支持在linux系统上实现。 +3. 运行 `imkey-core` 项目中的`tools/build-android.sh`。注意目前android编译仅支持在linux系统上实现。 diff --git a/imkey-core/ikc-tools/build-android-example.sh b/imkey-core/ikc-tools/build-android-example.sh index 7dd904cc..147aa42a 100755 --- a/imkey-core/ikc-tools/build-android-example.sh +++ b/imkey-core/ikc-tools/build-android-example.sh @@ -22,7 +22,7 @@ export OPENSSL_DIR=/Users/xiaoguang/work/project/token-core-monorepo/ikc-depend/ #export OPENSSL_INCLUDE_DIR=`brew --prefix openssl`/include #export OPENSSL_LIB_DIR=`brew --prefix openssl`/lib OPENSSL_LIB_DIR=$OPENSSL_LIB_ROOT_DIR/android-arm64/lib OPENSSL_INCLUDE_DIR=$OPENSSL_INCLUDE_ROOT_DIR/android-arm64/include AR=$ANDROID_NDK_TOOLCHAINS/aarch64-linux-android-ar CC=$ANDROID_NDK_TOOLCHAINS/aarch64-linux-android29-clang LD=$ANDROID_NDK_TOOLCHAINS/aarch64-linux-android-ld env OPENSSL_STATIC=1 cargo build --target aarch64-linux-android --release -OPENSSL_LIB_DIR=$OPENSSL_LIB_ROOT_DIR/android-arm/lib OPENSSL_INCLUDE_DIR=$OPENSSL_INCLUDE_ROOT_DIR/android-arm/include AR=$ANDROID_NDK_TOOLCHAINS/arm-linux-androideabi-ar CC=$ANDROID_NDK_TOOLCHAINS/armv7a-linux-androideabi29-clang LD=$ANDROID_NDK_TOOLCHAINS/arm-linux-androideabi-ld env OPENSSL_STATIC=1 cargo build --target armv7-linux-androideabi --release +OPENSSL_LIB_DIR=$OPENSSL_LIB_ROOT_DIR/android-arm/lib OPENSSL_INCLUDE_DIR=$OPENSSL_INCLUDE_ROOT_DIR/android-arm/include AR=$ANDROID_NDK_TOOLCHAINS/arm-linux-androideabi-ar CC=$ANDROID_NDK_TOOLCHAINS/armv7a-linux-androideabi22-clang LD=$ANDROID_NDK_TOOLCHAINS/arm-linux-androideabi-ld env OPENSSL_STATIC=1 cargo build --target armv7-linux-androideabi --release OPENSSL_LIB_DIR=$OPENSSL_LIB_ROOT_DIR/android-x86/lib OPENSSL_INCLUDE_DIR=$OPENSSL_INCLUDE_ROOT_DIR/android-x86/include AR=$ANDROID_NDK_TOOLCHAINS/i686-linux-android-ar CC=$ANDROID_NDK_TOOLCHAINS/i686-linux-android29-clang LD=$ANDROID_NDK_TOOLCHAINS/i686-linux-android-ld env OPENSSL_STATIC=1 cargo build --target i686-linux-android --release OPENSSL_LIB_DIR=$OPENSSL_LIB_ROOT_DIR/android-x86_64/lib OPENSSL_INCLUDE_DIR=$OPENSSL_INCLUDE_ROOT_DIR/android-x86_64/include AR=$ANDROID_NDK_TOOLCHAINS/x86_64-linux-android-ar CC=$ANDROID_NDK_TOOLCHAINS/x86_64-linux-android29-clang LD=$ANDROID_NDK_TOOLCHAINS/x86_64-linux-android-ld env OPENSSL_STATIC=1 cargo build --target x86_64-linux-android --release @@ -30,7 +30,7 @@ OPENSSL_LIB_DIR=$OPENSSL_LIB_ROOT_DIR/android-x86_64/lib OPENSSL_INCLUDE_DIR=$OP ## linking with `cc` failed #export RUSTFLAGS="-Clink-arg=-fuse-ld=gold" #AR=$ANDROID_NDK_TOOLCHAINS/aarch64-linux-android-ar CC=$ANDROID_NDK_TOOLCHAINS/aarch64-linux-android29-clang LD=$ANDROID_NDK_TOOLCHAINS/aarch64-linux-android-ld env OPENSSL_STATIC=1 cargo build --target aarch64-linux-android --release -#AR=$ANDROID_NDK_TOOLCHAINS/arm-linux-androideabi-ar CC=$ANDROID_NDK_TOOLCHAINS/armv7a-linux-androideabi29-clang LD=$ANDROID_NDK_TOOLCHAINS/arm-linux-androideabi-ld env OPENSSL_STATIC=1 cargo build --target armv7-linux-androideabi --release +#AR=$ANDROID_NDK_TOOLCHAINS/arm-linux-androideabi-ar CC=$ANDROID_NDK_TOOLCHAINS/armv7a-linux-androideabi22-clang LD=$ANDROID_NDK_TOOLCHAINS/arm-linux-androideabi-ld env OPENSSL_STATIC=1 cargo build --target armv7-linux-androideabi --release #AR=$ANDROID_NDK_TOOLCHAINS/i686-linux-android-ar CC=$ANDROID_NDK_TOOLCHAINS/i686-linux-android29-clang LD=$ANDROID_NDK_TOOLCHAINS/i686-linux-android-ld env OPENSSL_STATIC=1 cargo build --target i686-linux-android --release #AR=$ANDROID_NDK_TOOLCHAINS/x86_64-linux-android-ar CC=$ANDROID_NDK_TOOLCHAINS/x86_64-linux-android29-clang LD=$ANDROID_NDK_TOOLCHAINS/x86_64-linux-android-ld env OPENSSL_STATIC=1 cargo build --target x86_64-linux-android --release diff --git a/imkey-core/ikc-tools/build-android.sh b/imkey-core/ikc-tools/build-android.sh index d505513f..c19a0486 100755 --- a/imkey-core/ikc-tools/build-android.sh +++ b/imkey-core/ikc-tools/build-android.sh @@ -19,7 +19,7 @@ export OPENSSL_LIB_DIR=`brew --prefix openssl`/lib ## linking with `cc` failed #export RUSTFLAGS="-Clink-arg=-fuse-ld=gold" AR=$ANDROID_NDK_TOOLCHAINS/aarch64-linux-android-ar CC=$ANDROID_NDK_TOOLCHAINS/aarch64-linux-android29-clang LD=$ANDROID_NDK_TOOLCHAINS/aarch64-linux-android-ld env OPENSSL_STATIC=1 cargo build --target aarch64-linux-android --release -AR=$ANDROID_NDK_TOOLCHAINS/arm-linux-androideabi-ar CC=$ANDROID_NDK_TOOLCHAINS/armv7a-linux-androideabi29-clang LD=$ANDROID_NDK_TOOLCHAINS/arm-linux-androideabi-ld env OPENSSL_STATIC=1 cargo build --target armv7-linux-androideabi --release +AR=$ANDROID_NDK_TOOLCHAINS/arm-linux-androideabi-ar CC=$ANDROID_NDK_TOOLCHAINS/armv7a-linux-androideabi22-clang LD=$ANDROID_NDK_TOOLCHAINS/arm-linux-androideabi-ld env OPENSSL_STATIC=1 cargo build --target armv7-linux-androideabi --release AR=$ANDROID_NDK_TOOLCHAINS/i686-linux-android-ar CC=$ANDROID_NDK_TOOLCHAINS/i686-linux-android29-clang LD=$ANDROID_NDK_TOOLCHAINS/i686-linux-android-ld env OPENSSL_STATIC=1 cargo build --target i686-linux-android --release AR=$ANDROID_NDK_TOOLCHAINS/x86_64-linux-android-ar CC=$ANDROID_NDK_TOOLCHAINS/x86_64-linux-android29-clang LD=$ANDROID_NDK_TOOLCHAINS/x86_64-linux-android-ld env OPENSSL_STATIC=1 cargo build --target x86_64-linux-android --release diff --git a/script/build-android-linux.sh b/script/build-android.sh similarity index 63% rename from script/build-android-linux.sh rename to script/build-android.sh index ce4bc7fe..b4042976 100755 --- a/script/build-android-linux.sh +++ b/script/build-android.sh @@ -1,30 +1,30 @@ #!/bin/bash -export ANDROID_NDK_TOOLCHAINS=/usr/local/lib/android/sdk/ndk/25.1.8937393/toolchains/llvm/prebuilt/linux-x86_64/bin - -export OPENSSL_DIR=/home/runner/work/token-core-monorepo/token-core-monorepo/imkey-core/ikc-depend/openssl -export OPENSSL_LIB_ROOT_DIR=/home/runner/work/token-core-monorepo/token-core-monorepo/imkey-core/ikc-depend/openssl -export OPENSSL_INCLUDE_ROOT_DIR=/home/runner/work/token-core-monorepo/token-core-monorepo/imkey-core/ikc-depend/openssl -export OPENSSL_LIB_DIR=/home/runner/work/token-core-monorepo/token-core-monorepo/imkey-core/ikc-depend/openssl -export X86_64_LINUX_ANDROID_OPENSSL_LIB_DIR=/home/runner/work/token-core-monorepo/token-core-monorepo/imkey-core/ikc-depend/openssl/android-x86_64/lib/ -export I686_LINUX_ANDROID_OPENSSL_LIB_DIR=/home/runner/work/token-core-monorepo/token-core-monorepo/imkey-core/ikc-depend/openssl/android-x86/lib/ -export ARMV7_LINUX_ANDROIDEABI_OPENSSL_LIB_DIR=/home/runner/work/token-core-monorepo/token-core-monorepo/imkey-core/ikc-depend/openssl/android-arm/lib/ -export AARCH64_LINUX_ANDROID_OPENSSL_LIB_DIR=/home/runner/work/token-core-monorepo/token-core-monorepo/imkey-core/ikc-depend/openssl/android-arm64/lib/ -export OPENSSL_INCLUDE_DIR=/home/runner/work/token-core-monorepo/token-core-monorepo/imkey-core/ikc-depend/openssl -export X86_64_LINUX_ANDROID_OPENSSL_INCLUDE_DIR=/home/runner/work/token-core-monorepo/token-core-monorepo/imkey-core/ikc-depend/openssl/android-x86_64/include/ -export I686_LINUX_ANDROID_OPENSSL_INCLUDE_DIR=/home/runner/work/token-core-monorepo/token-core-monorepo/imkey-core/ikc-depend/openssl/android-x86/include/ -export ARMV7_LINUX_ANDROIDEABI_OPENSSL_INCLUDE_DIR=/home/runner/work/token-core-monorepo/token-core-monorepo/imkey-core/ikc-depend/openssl/android-arm/include/ -export AARCH64_LINUX_ANDROID_OPENSSL_INCLUDE_DIR=/home/runner/work/token-core-monorepo/token-core-monorepo/imkey-core/ikc-depend/openssl/android-arm64/include/ -export OPENSSL_DIR=/home/runner/work/token-core-monorepo/token-core-monorepo/imkey-core/ikc-depend/openssl +export ANDROID_NDK_TOOLCHAINS=$ANDROID_SDK_ROOT/ndk/25.2.9519653/toolchains/llvm/prebuilt/darwin-x86_64/bin + +export OPENSSL_DIR=$GITHUB_WORKSPACE/imkey-core/ikc-depend/openssl +export OPENSSL_LIB_ROOT_DIR=$GITHUB_WORKSPACE/imkey-core/ikc-depend/openssl +export OPENSSL_INCLUDE_ROOT_DIR=$GITHUB_WORKSPACE/imkey-core/ikc-depend/openssl +export OPENSSL_LIB_DIR=$GITHUB_WORKSPACE/imkey-core/ikc-depend/openssl +export X86_64_LINUX_ANDROID_OPENSSL_LIB_DIR=$GITHUB_WORKSPACE/imkey-core/ikc-depend/openssl/android-x86_64/lib/ +export I686_LINUX_ANDROID_OPENSSL_LIB_DIR=$GITHUB_WORKSPACE/imkey-core/ikc-depend/openssl/android-x86/lib/ +export ARMV7_LINUX_ANDROIDEABI_OPENSSL_LIB_DIR=$GITHUB_WORKSPACE/imkey-core/ikc-depend/openssl/android-arm/lib/ +export AARCH64_LINUX_ANDROID_OPENSSL_LIB_DIR=$GITHUB_WORKSPACE/imkey-core/ikc-depend/openssl/android-arm64/lib/ +export OPENSSL_INCLUDE_DIR=$GITHUB_WORKSPACE/imkey-core/ikc-depend/openssl +export X86_64_LINUX_ANDROID_OPENSSL_INCLUDE_DIR=$GITHUB_WORKSPACE/imkey-core/ikc-depend/openssl/android-x86_64/include/ +export I686_LINUX_ANDROID_OPENSSL_INCLUDE_DIR=$GITHUB_WORKSPACE/imkey-core/ikc-depend/openssl/android-x86/include/ +export ARMV7_LINUX_ANDROIDEABI_OPENSSL_INCLUDE_DIR=$GITHUB_WORKSPACE/imkey-core/ikc-depend/openssl/android-arm/include/ +export AARCH64_LINUX_ANDROID_OPENSSL_INCLUDE_DIR=$GITHUB_WORKSPACE/imkey-core/ikc-depend/openssl/android-arm64/include/ +export OPENSSL_DIR=$GITHUB_WORKSPACE/imkey-core/ikc-depend/openssl OPENSSL_LIB_DIR=$OPENSSL_LIB_ROOT_DIR/android-arm64/lib OPENSSL_INCLUDE_DIR=$OPENSSL_INCLUDE_ROOT_DIR/android-arm64/include AR=$ANDROID_NDK_TOOLCHAINS/llvm-ar CC=$ANDROID_NDK_TOOLCHAINS/aarch64-linux-android29-clang LD=$ANDROID_NDK_TOOLCHAINS/ld env OPENSSL_STATIC=1 cargo build --target aarch64-linux-android --release -OPENSSL_LIB_DIR=$OPENSSL_LIB_ROOT_DIR/android-arm/lib OPENSSL_INCLUDE_DIR=$OPENSSL_INCLUDE_ROOT_DIR/android-arm/include AR=$ANDROID_NDK_TOOLCHAINS/llvm-ar CC=$ANDROID_NDK_TOOLCHAINS/armv7a-linux-androideabi29-clang LD=$ANDROID_NDK_TOOLCHAINS/ld env OPENSSL_STATIC=1 cargo build --target armv7-linux-androideabi --release +OPENSSL_LIB_DIR=$OPENSSL_LIB_ROOT_DIR/android-arm/lib OPENSSL_INCLUDE_DIR=$OPENSSL_INCLUDE_ROOT_DIR/android-arm/include AR=$ANDROID_NDK_TOOLCHAINS/llvm-ar CC=$ANDROID_NDK_TOOLCHAINS/armv7a-linux-androideabi22-clang LD=$ANDROID_NDK_TOOLCHAINS/ld env OPENSSL_STATIC=1 cargo build --target armv7-linux-androideabi --release OPENSSL_LIB_DIR=$OPENSSL_LIB_ROOT_DIR/android-x86/lib OPENSSL_INCLUDE_DIR=$OPENSSL_INCLUDE_ROOT_DIR/android-x86/include AR=$ANDROID_NDK_TOOLCHAINS/llvm-ar CC=$ANDROID_NDK_TOOLCHAINS/i686-linux-android29-clang LD=$ANDROID_NDK_TOOLCHAINS/ld env OPENSSL_STATIC=1 cargo build --target i686-linux-android --release OPENSSL_LIB_DIR=$OPENSSL_LIB_ROOT_DIR/android-x86_64/lib OPENSSL_INCLUDE_DIR=$OPENSSL_INCLUDE_ROOT_DIR/android-x86_64/include AR=$ANDROID_NDK_TOOLCHAINS/llvm-ar CC=$ANDROID_NDK_TOOLCHAINS/x86_64-linux-android29-clang LD=$ANDROID_NDK_TOOLCHAINS/ld env OPENSSL_STATIC=1 cargo build --target x86_64-linux-android --release pushd ../token-core/tcx-libs/secp256k1/ AR=$ANDROID_NDK_TOOLCHAINS/llvm-ar CC=$ANDROID_NDK_TOOLCHAINS/aarch64-linux-android29-clang LD=$ANDROID_NDK_TOOLCHAINS/ld env OPENSSL_STATIC=1 cargo build --target aarch64-linux-android --release -AR=$ANDROID_NDK_TOOLCHAINS/llvm-ar CC=$ANDROID_NDK_TOOLCHAINS/armv7a-linux-androideabi29-clang LD=$ANDROID_NDK_TOOLCHAINS/ld env OPENSSL_STATIC=1 cargo build --target armv7-linux-androideabi --release +AR=$ANDROID_NDK_TOOLCHAINS/llvm-ar CC=$ANDROID_NDK_TOOLCHAINS/armv7a-linux-androideabi22-clang LD=$ANDROID_NDK_TOOLCHAINS/ld env OPENSSL_STATIC=1 cargo build --target armv7-linux-androideabi --release AR=$ANDROID_NDK_TOOLCHAINS/llvm-ar CC=$ANDROID_NDK_TOOLCHAINS/i686-linux-android29-clang LD=$ANDROID_NDK_TOOLCHAINS/ld env OPENSSL_STATIC=1 cargo build --target i686-linux-android --release AR=$ANDROID_NDK_TOOLCHAINS/llvm-ar CC=$ANDROID_NDK_TOOLCHAINS/x86_64-linux-android29-clang LD=$ANDROID_NDK_TOOLCHAINS/ld env OPENSSL_STATIC=1 cargo build --target x86_64-linux-android --release popd