Update Logger.c #62
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build latest (Android2) | |
on: [push] | |
concurrency: | |
group: ${{ github.ref }}-android | |
cancel-in-progress: true | |
jobs: | |
build: | |
if: github.ref_name == github.event.repository.default_branch | |
runs-on: ubuntu-22.04 | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Compile android builds | |
shell: bash | |
id: compile | |
env: | |
COMMON_FLAGS: "-O1 -s -fno-stack-protector -fno-math-errno -Qn" | |
DROID_FLAGS: "-fPIC -shared -s -O1 -fvisibility=hidden -rdynamic -funwind-tables" | |
DROID_LIBS: "-lGLESv2 -lEGL -lm -landroid -llog" | |
run: | | |
LATEST_FLAG=-DCC_COMMIT_SHA=\"${GITHUB_SHA::9}\" | |
DROID_FLAGS="-fPIC -shared -s -O1 -fvisibility=hidden -rdynamic -funwind-tables" | |
DROID_LIBS="-lGLESv2 -lEGL -lm -landroid -llog" | |
ROOT_DIR=$PWD | |
NDK_ROOT="$ANDROID_NDK_ROOT/toolchains/llvm/prebuilt/linux-x86_64/bin" | |
TOOLS_ROOT="$ANDROID_SDK_ROOT/build-tools/31.0.0" | |
SDK_ROOT="$ANDROID_SDK_ROOT/platforms/android-34" | |
cd $ROOT_DIR/src | |
$NDK_ROOT/armv7a-linux-androideabi21-clang *.c $DROID_FLAGS -march=armv5 $DROID_LIBS $LATEST_FLAG -o cc-droid-arm_16 | |
$NDK_ROOT/armv7a-linux-androideabi21-clang *.c $DROID_FLAGS $DROID_LIBS $LATEST_FLAG -o cc-droid-arm_32 | |
$NDK_ROOT/aarch64-linux-android21-clang *.c $DROID_FLAGS $DROID_LIBS $LATEST_FLAG -o cc-droid-arm_64 | |
$NDK_ROOT/i686-linux-android21-clang *.c $DROID_FLAGS $DROID_LIBS $LATEST_FLAG -o cc-droid-x86_32 | |
$NDK_ROOT/x86_64-linux-android21-clang *.c $DROID_FLAGS $DROID_LIBS $LATEST_FLAG -o cc-droid-x86_64 | |
cd $ROOT_DIR/android/app/src/main | |
# copy required native libraries | |
mkdir lib lib/armeabi lib/armeabi-v7a lib/arm64-v8a lib/x86 lib/x86_64 | |
cp $ROOT_DIR/src/cc-droid-arm_16 lib/armeabi/libclassicube.so | |
cp $ROOT_DIR/src/cc-droid-arm_32 lib/armeabi-v7a/libclassicube.so | |
cp $ROOT_DIR/src/cc-droid-arm_64 lib/arm64-v8a/libclassicube.so | |
cp $ROOT_DIR/src/cc-droid-x86_32 lib/x86/libclassicube.so | |
cp $ROOT_DIR/src/cc-droid-x86_64 lib/x86_64/libclassicube.so | |
# The following commands are for manually building an .apk, see | |
# https://spin.atomicobject.com/2011/08/22/building-android-application-bundles-apks-by-hand/ | |
# https://github.com/cnlohr/rawdrawandroid/blob/master/Makefile | |
# https://stackoverflow.com/questions/41132753/how-can-i-build-an-android-apk-without-gradle-on-the-command-line | |
# https://github.com/skanti/Android-Manual-Build-Command-Line/blob/master/hello-jni/Makefile | |
# https://github.com/skanti/Android-Manual-Build-Command-Line/blob/master/hello-jni/CMakeLists.txt | |
# compile java files into multiple .class files | |
cd $ROOT_DIR/android/app/src/main/java/com/classicube | |
javac *.java -d $ROOT_DIR/android/app/src/main -classpath $SDK_ROOT/android.jar --release 8 | |
cd $ROOT_DIR/android/app/src/main | |
# get debug signing key | |
echo -n "${{ secrets.ANDROID_SIGNING_KEY_BASE64 }}" | base64 --decode > debug.keystore | |
CLASSES_LIST="$(find $ROOT_DIR -name "*.class" -printf '%p ')" | |
# compile the multiple .class files into one .dex file | |
$TOOLS_ROOT/d8 $CLASSES_LIST --lib $SDK_ROOT/android.jar | |
# create initial .apk with packaged version of resources | |
$TOOLS_ROOT/aapt package -f -M AndroidManifest.xml -S res -F cc-unsigned.apk -I $SDK_ROOT/android.jar | |
$TOOLS_ROOT/aapt add -f cc-unsigned.apk classes.dex lib/armeabi/libclassicube.so lib/armeabi-v7a/libclassicube.so lib/arm64-v8a/libclassicube.so lib/x86/libclassicube.so lib/x86_64/libclassicube.so | |
# sign the apk with debug key (https://stackoverflow.com/questions/16711233/) | |
# Note per https://developer.android.com/tools/zipalign | |
# - if using apksigner, zipalign must be called before apksigner | |
# - if using jarsigner, zipalign must be called after jarsigner | |
$TOOLS_ROOT/zipalign -f 4 cc-unsigned.apk cc-signed.apk | |
$TOOLS_ROOT/apksigner sign --ks debug.keystore --ks-pass pass:android cc-signed.apk | |
cp cc-signed.apk $ROOT_DIR/src/cc.apk | |
#cp cc-unsigned.apk cc-signed.apk | |
#jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore debug.keystore -storepass android -keypass android cc-signed.apk androiddebugkey | |
# jarsigner -verbose | |
# create aligned .apk file | |
#$TOOLS_ROOT/zipalign -f 4 cc-signed.apk $ROOT_DIR/src/cc.apk | |
- uses: ./.github/actions/notify_failure | |
if: ${{ always() && steps.compile.outcome == 'failure' }} | |
with: | |
NOTIFY_MESSAGE: 'Failed to compile android build' | |
WEBHOOK_URL: '${{ secrets.WEBHOOK_URL }}' | |
- uses: ./.github/actions/upload_build | |
if: ${{ always() && steps.compile.outcome == 'success' }} | |
with: | |
SOURCE_FILE: 'src/cc.apk' | |
DEST_NAME: 'cc.apk' | |
- uses: ./.github/actions/notify_success | |
if: ${{ always() && steps.compile.outcome == 'success' }} | |
with: | |
DESTINATION_URL: '${{ secrets.NOTIFY_URL }}' | |
WORKFLOW_NAME: 'android' |