Skip to content

Commit

Permalink
[nrf-ble-driver] update and fix arm64-osx (#27116)
Browse files Browse the repository at this point in the history
  • Loading branch information
autoantwort authored Oct 9, 2022
1 parent 7497b02 commit d04bb15
Show file tree
Hide file tree
Showing 5 changed files with 95 additions and 6 deletions.
11 changes: 9 additions & 2 deletions ports/nrf-ble-driver/portfile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@ endif()
vcpkg_from_github(
OUT_SOURCE_PATH SOURCE_PATH
REPO NordicSemiconductor/pc-ble-driver
REF v4.1.2
SHA512 625a52151f2c78421e48e90ff60292c6106e8504b55a26c7df716df75e051a40d2ee4a26c57b5daaa370e53a79002fe965aee8a0d8749f7dce380e8e4a617c95
REF v4.1.4
SHA512 8f35e757dddc27c9b11cdb3b9920562bbe09ceac715d65957e56ec8479e8ffedf12df2f976e484ed0d24b9325d9ef2b8ad6576cccefd2de8d7fa6fa8d58b03e5
HEAD_REF master
PATCHES
001-arm64-support.patch
support-arm64-osx.diff # from https://github.com/NordicSemiconductor/pc-ble-driver/pull/271
)

# Ensure that git is found within CMakeLists.txt by appending vcpkg's git executable dirpath to $PATH.
Expand All @@ -23,13 +24,19 @@ vcpkg_find_acquire_program(GIT)
get_filename_component(GIT_EXE_PATH "${GIT}" DIRECTORY)
vcpkg_add_to_path("${GIT_EXE_PATH}")

set(OPTIONS)
if (VCPKG_TARGET_IS_OSX AND VCPKG_TARGET_ARCHITECTURE STREQUAL "arm64")
set(OPTIONS "-DARCH=${VCPKG_TARGET_ARCHITECTURE}")
endif()

vcpkg_cmake_configure(
SOURCE_PATH "${SOURCE_PATH}"
OPTIONS
-DDISABLE_EXAMPLES=ON
-DDISABLE_TESTS=ON
-DNRF_BLE_DRIVER_VERSION=4.1.2
-DCONNECTIVITY_VERSION=4.1.2
${OPTIONS}
MAYBE_UNUSED_VARIABLES
DISABLE_EXAMPLES
DISABLE_TESTS
Expand Down
78 changes: 78 additions & 0 deletions ports/nrf-ble-driver/support-arm64-osx.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index ec7b4d2d7..16c136958 100755
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -298,7 +298,17 @@ include (cmake/clang-dev-tools.cmake)
set(ARCH_SUFFIX "unknown")

if("${CMAKE_SIZEOF_VOID_P}" EQUAL "8")
- set(ARCH_SUFFIX "x86_64")
+ if(APPLE)
+ if(${ARCH} STREQUAL not_set OR ${ARCH} STREQUAL x86_64)
+ set(ARCH_SUFFIX "x86_64")
+ elseif(${ARCH} STREQUAL arm64)
+ set(ARCH_SUFFIX "arm64")
+ else()
+ message(FATAL_ERROR "Invalid ARCH_SUFFIX: ARCH=${ARCH}.")
+ endif()
+ else()
+ set(ARCH_SUFFIX "x86_64")
+ endif()
else()
set(ARCH_SUFFIX "x86_32")
endif()
diff --git a/cmake/apple.cmake b/cmake/apple.cmake
index c413cfa7e..cef762cf1 100644
--- a/cmake/apple.cmake
+++ b/cmake/apple.cmake
@@ -1,4 +1,13 @@
-set(CMAKE_OSX_ARCHITECTURES "x86_64")
+if(${ARCH} STREQUAL not_set)
+ message(STATUS "macOS Architecture not set, using x86_64 as default.")
+ SET(CMAKE_OSX_ARCHITECTURES "x86_64")
+else()
+ if(${ARCH} STREQUAL x86_64 OR ${ARCH} STREQUAL arm64)
+ set(CMAKE_OSX_ARCHITECTURES "${ARCH}")
+ else()
+ message(FATAL_ERROR "Invalid CMAKE_OSX_ARCHITECTURES: ARCH=${ARCH}.")
+ endif()
+endif()

set(CMAKE_SKIP_BUILD_RPATH TRUE)
set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
diff --git a/cmake/nrf-ble-driver.cmake b/cmake/nrf-ble-driver.cmake
index d81608c72..467afd0e9 100644
--- a/cmake/nrf-ble-driver.cmake
+++ b/cmake/nrf-ble-driver.cmake
@@ -8,7 +8,7 @@ math(EXPR COMPILER_ARCH_BITS "8*${CMAKE_SIZEOF_VOID_P}")
# Default to compiler architecture
set(ARCH_BITS ${COMPILER_ARCH_BITS})

-SET(ARCH not_set CACHE STRING "Architecture (x86_32 or x86_64)")
+SET(ARCH not_set CACHE STRING "Architecture (x86_32, x86_64, arm or arm64)")
string(TOLOWER "${ARCH}" ARCH)

if(${ARCH} STREQUAL not_set)
@@ -16,17 +16,19 @@ if(${ARCH} STREQUAL not_set)
else()
if(MSVC)
message(FATAL_ERROR "ARCH not available with MSVC. Use -G \"Visual Studio XX <Win64>\" instead.")
- elseif(APPLE)
- message(FATAL_ERROR "ARCH not available on macOS / OS X. Universal 32 and 64-bit binaries will be built.")
endif()
if(${ARCH} STREQUAL x86_32)
set(ARCH_BITS 32)
elseif(${ARCH} STREQUAL x86_64)
set(ARCH_BITS 64)
+ elseif(${ARCH} STREQUAL arm)
+ set(ARCH_BITS 32)
+ elseif(${ARCH} STREQUAL arm64)
+ set(ARCH_BITS 64)
else()
message(FATAL_ERROR "Invalid architecture: ARCH=${ARCH}.")
endif()
- message(STATUS "Building ${ARCH_BITS}-bit targets with ${COMPILER_ARCH_BITS}-bit toolchain.")
+ message(STATUS "Building ${ARCH} ${ARCH_BITS}-bit targets with ${COMPILER_ARCH_BITS}-bit toolchain.")
endif()

if(NOT MSVC)
3 changes: 1 addition & 2 deletions ports/nrf-ble-driver/vcpkg.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"name": "nrf-ble-driver",
"version": "4.1.2",
"port-version": 2,
"version": "4.1.4",
"description": "BLE driver is a library for Bluetooth Low Energy communication using Nordic Semiconductor development kits.",
"homepage": "https://github.com/NordicSemiconductor/pc-ble-driver",
"license": "BSD-3-Clause",
Expand Down
4 changes: 2 additions & 2 deletions versions/baseline.json
Original file line number Diff line number Diff line change
Expand Up @@ -5141,8 +5141,8 @@
"port-version": 0
},
"nrf-ble-driver": {
"baseline": "4.1.2",
"port-version": 2
"baseline": "4.1.4",
"port-version": 0
},
"nspr": {
"baseline": "4.33",
Expand Down
5 changes: 5 additions & 0 deletions versions/n-/nrf-ble-driver.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
{
"versions": [
{
"git-tree": "f7eb0b4a2be63dfe15611d96725869023f7b438c",
"version": "4.1.4",
"port-version": 0
},
{
"git-tree": "82619c9f6f7860cb053b79c1091a39e0483b7d85",
"version": "4.1.2",
Expand Down

0 comments on commit d04bb15

Please sign in to comment.