Fix Android x86_64 build

Note: At this time, both arm32 and arm64 emulation doesn't work on either macOS and Ubuntu so we could only have x86_64
This commit is contained in:
mio 2021-10-16 20:35:23 +02:00
parent 9954763c02
commit bc5efc9ee5
No known key found for this signature in database
GPG Key ID: DFF27E34A47CB873
2 changed files with 51 additions and 17 deletions

View File

@ -223,7 +223,7 @@ jobs:
cmake --build . --config ${{ matrix.config.build_type }}
cmake --install . --strip
ctest -C ${{ matrix.config.build_type }}
- name: '🚧 Android x86_64 build'
if: contains(matrix.config.name, 'android')
shell: bash
@ -245,16 +245,41 @@ jobs:
cmake --build . --config ${{ matrix.config.build_type }}
cmake --install . --strip
- name: '🚧 AVD Cache'
if: contains(matrix.config.name, 'android')
uses: actions/cache@v2
id: avd-cache
with:
path: |
~/.android/avd/*
~/.android/adb*
key: avd-28
- name: '🚧 Create x86_64 tests environment'
if: contains(matrix.config.name, 'android') && steps.avd-cache.outputs.cache-hit != 'true'
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: 28
arch: ${{ matrix.config.arch }}
force-avd-creation: false
disable-animations: false
target: default
profile: Nexus 6
emulator-options: -no-window -gpu swiftshader_indirect -no-snapshot -noaudio -no-boot-anim -verbose -show-kernel
script: echo "Generated AVD snapshot for caching."
- name: '🚧 Android x86_64 tests'
if: contains(matrix.config.name, 'android')
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: 28
force-avd-creation: false
disable-animations: true
arch: ${{ matrix.config.arch }}
target: default
profile: Nexus 6
emulator-options: -no-window -gpu swiftshader_indirect -no-snapshot -noaudio -no-boot-anim -verbose -show-kernel
script: ctest -C ${{ matrix.config.build_type }}
script: bash ./adb.sh
- name: '📦 Pack artifact'
shell: bash

View File

@ -90,6 +90,7 @@ else()
endif()
elseif(ANDROID_ABI)
string(FIND "${ANDROID_ABI}" "arm64" UC_RET)
file(WRITE ${CMAKE_BINARY_DIR}/adb.sh "#!/bin/bash\n\nadb shell mkdir -p /data/local/tmp/build\n")
if (${UC_RET} GREATER_EQUAL "0")
set(UNICORN_TARGET_ARCH "aarch64")
@ -1023,6 +1024,9 @@ if (UNICORN_BUILD_SHARED)
add_library(unicorn SHARED
${UNICORN_SRCS}
)
if (ANDROID_ABI)
file(APPEND ${CMAKE_BINARY_DIR}/adb.sh "adb push ./libunicorn.so /data/local/tmp/build/\n")
endif()
else()
add_library(unicorn STATIC
${UNICORN_SRCS}
@ -1159,22 +1163,27 @@ if(UNICORN_FUZZ)
endforeach()
else()
foreach(SAMPLE_FILE ${UNICORN_SAMPLE_FILE})
add_executable(${SAMPLE_FILE}
${CMAKE_CURRENT_SOURCE_DIR}/samples/${SAMPLE_FILE}.c
)
target_link_libraries(${SAMPLE_FILE}
${SAMPLES_LIB}
)
endforeach(SAMPLE_FILE)
add_executable(${SAMPLE_FILE}
${CMAKE_CURRENT_SOURCE_DIR}/samples/${SAMPLE_FILE}.c
)
target_link_libraries(${SAMPLE_FILE}
${SAMPLES_LIB}
)
endforeach(SAMPLE_FILE)
foreach(TEST_FILE ${UNICORN_TEST_FILE})
add_executable(${TEST_FILE}
${CMAKE_CURRENT_SOURCE_DIR}/tests/unit/${TEST_FILE}.c
)
target_link_libraries(${TEST_FILE}
${SAMPLES_LIB}
)
add_test(${TEST_FILE} ${TEST_FILE})
foreach(TEST_FILE ${UNICORN_TEST_FILE})
add_executable(${TEST_FILE}
${CMAKE_CURRENT_SOURCE_DIR}/tests/unit/${TEST_FILE}.c
)
target_link_libraries(${TEST_FILE}
${SAMPLES_LIB}
)
add_test(${TEST_FILE} ${TEST_FILE})
if (ANDROID_ABI)
file(APPEND ${CMAKE_BINARY_DIR}/adb.sh "adb push ${TEST_FILE} /data/local/tmp/build/\n")
file(APPEND ${CMAKE_BINARY_DIR}/adb.sh "adb shell \"chmod +x /data/local/tmp/build/${TEST_FILE}\"\n")
file(APPEND ${CMAKE_BINARY_DIR}/adb.sh "adb shell \'LD_LIBRARY_PATH=/data/local/tmp/build:$LD_LIBRARY_PATH /data/local/tmp/build/${TEST_FILE}\' || exit -1\n")
endif()
endforeach(TEST_FILE)
endif()