From 4ce312d5b6755ba764b1303af577f0d9bcf5327b Mon Sep 17 00:00:00 2001 From: LoveSy Date: Sun, 17 Oct 2021 17:58:39 +0800 Subject: [PATCH] [CI] Fix ccache (#1301) --- .github/workflows/core.yml | 28 ++++++++++++++++------------ core/build.gradle.kts | 10 ++++++++++ core/src/main/cpp/main/Android.mk | 11 +++++------ 3 files changed, 31 insertions(+), 18 deletions(-) diff --git a/.github/workflows/core.yml b/.github/workflows/core.yml index 68046f02..5d3c4eac 100644 --- a/.github/workflows/core.yml +++ b/.github/workflows/core.yml @@ -20,11 +20,13 @@ jobs: - name: Write key if: github.event_name != 'pull_request' && github.ref == 'refs/heads/master' run: | - echo androidStorePassword='${{ secrets.KEY_STORE_PASSWORD }}' >> gradle.properties - echo androidKeyAlias='${{ secrets.ALIAS }}' >> gradle.properties - echo androidKeyPassword='${{ secrets.KEY_PASSWORD }}' >> gradle.properties - echo androidStoreFile='key.jks' >> gradle.properties - echo ${{ secrets.KEY_STORE }} | base64 --decode > key.jks + if [ ! -z "${{ secrets.KEY_STORE }}" ]; then + echo androidStorePassword='${{ secrets.KEY_STORE_PASSWORD }}' >> gradle.properties + echo androidKeyAlias='${{ secrets.ALIAS }}' >> gradle.properties + echo androidKeyPassword='${{ secrets.KEY_PASSWORD }}' >> gradle.properties + echo androidStoreFile='key.jks' >> gradle.properties + echo ${{ secrets.KEY_STORE }} | base64 --decode > key.jks + fi - name: set up JDK 11 uses: actions/setup-java@v1 with: @@ -120,10 +122,12 @@ jobs: COMMIT_MESSAGE: ${{ github.event.head_commit.message }} COMMIT_URL: ${{ github.event.head_commit.url }} run: | - OUTPUT="core/release/" - export riruRelease=$(find $OUTPUT -name "LSPosed-riru-v*-release.zip") - export riruDebug=$(find $OUTPUT -name "LSPosed-riru-v*-debug.zip") - export zygiskRelease=$(find $OUTPUT -name "LSPosed-zygisk-v*-release.zip") - export zygiskDebug=$(find $OUTPUT -name "LSPosed-zygisk-v*-debug.zip") - ESCAPED=`python3 -c 'import json,os,urllib.parse; msg = json.dumps(os.environ["COMMIT_MESSAGE"]); print(urllib.parse.quote(msg if len(msg) <= 1024 else json.dumps(os.environ["COMMIT_URL"])))'` - curl -v "https://api.telegram.org/bot${BOT_TOKEN}/sendMediaGroup?chat_id=${CHANNEL_ID}&media=%5B%7B%22type%22%3A%22document%22%2C%20%22media%22%3A%22attach%3A%2F%2FzygiskRelease%22%7D%2C%7B%22type%22%3A%22document%22%2C%20%22media%22%3A%22attach%3A%2F%2FriruRelease%22%7D%2C%7B%22type%22%3A%22document%22%2C%20%22media%22%3A%22attach%3A%2F%2FzygiskDebug%22%7D%2C%7B%22type%22%3A%22document%22%2C%20%22media%22%3A%22attach%3A%2F%2FriruDebug%22%2C%22caption%22:${ESCAPED}%7D%5D" -F riruRelease="@$riruRelease" -F riruDebug="@$riruDebug" -F zygiskRelease="@$zygiskRelease" -F zygiskDebug="@$zygiskDebug" + if [ ! -z "${{ secrets.BOT_TOKEN }}" ]; then + OUTPUT="core/release/" + export riruRelease=$(find $OUTPUT -name "LSPosed-riru-v*-release.zip") + export riruDebug=$(find $OUTPUT -name "LSPosed-riru-v*-debug.zip") + export zygiskRelease=$(find $OUTPUT -name "LSPosed-zygisk-v*-release.zip") + export zygiskDebug=$(find $OUTPUT -name "LSPosed-zygisk-v*-debug.zip") + ESCAPED=`python3 -c 'import json,os,urllib.parse; msg = json.dumps(os.environ["COMMIT_MESSAGE"]); print(urllib.parse.quote(msg if len(msg) <= 1024 else json.dumps(os.environ["COMMIT_URL"])))'` + curl -v "https://api.telegram.org/bot${BOT_TOKEN}/sendMediaGroup?chat_id=${CHANNEL_ID}&media=%5B%7B%22type%22%3A%22document%22%2C%20%22media%22%3A%22attach%3A%2F%2FzygiskRelease%22%7D%2C%7B%22type%22%3A%22document%22%2C%20%22media%22%3A%22attach%3A%2F%2FriruRelease%22%7D%2C%7B%22type%22%3A%22document%22%2C%20%22media%22%3A%22attach%3A%2F%2FzygiskDebug%22%7D%2C%7B%22type%22%3A%22document%22%2C%20%22media%22%3A%22attach%3A%2F%2FriruDebug%22%2C%22caption%22:${ESCAPED}%7D%5D" -F riruRelease="@$riruRelease" -F riruDebug="@$riruDebug" -F zygiskRelease="@$zygiskRelease" -F zygiskDebug="@$zygiskDebug" + fi diff --git a/core/build.gradle.kts b/core/build.gradle.kts index a980a2e5..07a037cc 100644 --- a/core/build.gradle.kts +++ b/core/build.gradle.kts @@ -122,6 +122,16 @@ android { sourceCompatibility(androidSourceCompatibility) } + buildTypes { + all { + externalNativeBuild { + ndkBuild { + arguments += "NDK_OUT=${File(buildDir, ".cxx/$name").absolutePath}" + } + } + } + } + productFlavors { all { externalNativeBuild { diff --git a/core/src/main/cpp/main/Android.mk b/core/src/main/cpp/main/Android.mk index 0fa91beb..bf47e448 100644 --- a/core/src/main/cpp/main/Android.mk +++ b/core/src/main/cpp/main/Android.mk @@ -19,11 +19,10 @@ LOCAL_LDLIBS := -llog include $(BUILD_SHARED_LIBRARY) $(LOCAL_PATH)/api/config.cpp : FORCE - $(file > $@,#include "config.h") - $(file >> $@,namespace lspd {) - $(file >> $@,const int versionCode = ${VERSION_CODE};) - $(file >> $@,const int apiVersion = ${API_VERSION};) - $(file >> $@,const char* const versionName = "${VERSION_NAME}";) - $(file >> $@,const char* const moduleName = "${MODULE_NAME}";) + $(file > $@,namespace lspd {) + $(file >> $@,extern const int versionCode = ${VERSION_CODE};) + $(file >> $@,extern const int apiVersion = ${API_VERSION};) + $(file >> $@,extern const char* const versionName = "${VERSION_NAME}";) + $(file >> $@,extern const char* const moduleName = "${MODULE_NAME}";) $(file >> $@,}) FORCE: ;