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
2 changed files with 51 additions and 17 deletions

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()