Skip to content

Commit

Permalink
WIP: Android please
Browse files Browse the repository at this point in the history
  • Loading branch information
askmeaboutlo0m committed Sep 3, 2023
1 parent 24bcafb commit e5226f7
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,11 @@ jobs:
key: gradle-${{ runner.os }}+${{ matrix.cross_os }}-${{ matrix.qt }}
if: matrix.cross_os == 'Android'

- name: Install Android Rust target
run: >
rustup target add aarch64-linux-android
if: matrix.cross_os == 'Android'

- name: Generate project
run: >
cmake -S . -B build --log-level=VERBOSE
Expand Down
12 changes: 10 additions & 2 deletions cmake/Cargo.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ function(_corrosion_determine_libs_new target_triple out_libs)
list(APPEND args --target=${target_triple})
endif()
list(APPEND args -- --print=native-static-libs)
message(STATUS "Checking native libraries with command: ${CARGO_COMMAND} ${args}")
execute_process(
COMMAND ${CARGO_COMMAND} ${args}
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/corrosion/required_libs"
Expand Down Expand Up @@ -59,7 +60,7 @@ endfunction()
# SPDX-SnippetEnd

function(_cargo_set_libs target triple)
if(NOT "${triple}")
if("${triple}")
set(cache_var "CARGO_LIBS_${triple}")
else()
set(cache_var "CARGO_LIBS_HOST")
Expand Down Expand Up @@ -99,6 +100,8 @@ function(add_cargo_library target package)
else()
set(arch i686)
endif()
else()
message(WARNING "Unknown Cargo arch for processor '${CMAKE_SYSTEM_PROCESSOR}'")
endif()

if(WIN32)
Expand All @@ -108,16 +111,21 @@ function(add_cargo_library target package)
elseif(MINGW)
set(abi gnu)
endif()
elseif(ANDROID)
set(sys linux)
set(abi android)
elseif(CMAKE_SYSTEM_NAME STREQUAL Darwin)
set(sys apple)
set(abi darwin)
elseif(CMAKE_SYSTEM_NAME STREQUAL Linux)
set(sys unknown-linux)
set(abi gnu)
else()
message(WARNING "Unknown Cargo sys and abi for system '${CMAKE_SYSTEM_NAME}'")
endif()

if(NOT arch OR NOT sys OR NOT abi)
message(WARNING "Unable to determine target ABI for Cargo; using host ABI")
message(SEND_ERROR "Unable to determine target ABI for Cargo")
else()
set(triple ${arch}-${sys}-${abi})
message(STATUS "Cargo target ABI: ${triple}")
Expand Down

0 comments on commit e5226f7

Please sign in to comment.