From 48120d1f637e72f264c292dbe44c2943cdc57e6f Mon Sep 17 00:00:00 2001
From: Rahix <rahix@rahix.de>
Date: Mon, 5 Aug 2019 23:28:15 +0200
Subject: [PATCH] build(ble): Only link cordio-phy where necessary

Signed-off-by: Rahix <rahix@rahix.de>
---
 card10-cross.ini                   | 2 +-
 lib/sdk/Libraries/BTLE/meson.build | 9 +++++++--
 2 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/card10-cross.ini b/card10-cross.ini
index 7208481c..5199d505 100644
--- a/card10-cross.ini
+++ b/card10-cross.ini
@@ -6,7 +6,7 @@ strip = 'arm-none-eabi-strip'
 [properties]
 c_args      = ['-mthumb', '-mcpu=cortex-m4', '-mfloat-abi=softfp', '-mfpu=fpv4-sp-d16', '-Wa,-mimplicit-it=thumb', '-ffunction-sections', '-fdata-sections', '-fsingle-precision-constant', '-fno-isolate-erroneous-paths-dereference']
 
-c_link_args = ['-mthumb', '-mcpu=cortex-m4', '-mfloat-abi=softfp', '-mfpu=fpv4-sp-d16', '-Wl,--start-group', '-lc', '-lnosys', '-Wl,--end-group', '--specs=nano.specs', '../lib/sdk/Libraries/BTLE/cordio-phy.a']
+c_link_args = ['-mthumb', '-mcpu=cortex-m4', '-mfloat-abi=softfp', '-mfpu=fpv4-sp-d16', '-Wl,--start-group', '-lc', '-lnosys', '-Wl,--end-group', '--specs=nano.specs']
 
 target_defs = ['-DTARGET=32665', '-DTARGET_REV=0x4131', '-DBOARD_CARD10=1', '-DWSF_TRACE_ENABLED=TRUE', '-DWSF_ASSERT_ENABLED=TRUE', '-DWSF_MS_PER_TICK=1', '-DINIT_BROADCASTER', '-DINIT_PERIPHERAL', '-DINIT_ENCRYPTED']
 
diff --git a/lib/sdk/Libraries/BTLE/meson.build b/lib/sdk/Libraries/BTLE/meson.build
index b80f44af..167fd740 100644
--- a/lib/sdk/Libraries/BTLE/meson.build
+++ b/lib/sdk/Libraries/BTLE/meson.build
@@ -1,3 +1,8 @@
+# cordio-phy.a
+cc = meson.get_compiler('c')
+libcordiophy = cc.find_library('cordio-phy', dirs: meson.current_source_dir())
+
+
 includes = include_directories(
   'wsf/include',
   'stack/ble-host/include',
@@ -413,7 +418,7 @@ lib = static_library(
   'ble',
   sources,
   include_directories: includes,
-  dependencies: periphdriver,
+  dependencies: [periphdriver, libcordiophy],
   c_args: ['-w',
             '-DLHCI_ENABLE_VS=TRUE',
             '-DBB_CLK_RATE_HZ=1600000',
@@ -426,5 +431,5 @@ lib = static_library(
 ble = declare_dependency(
   include_directories: includes,
   link_with: lib,
-  dependencies: periphdriver,
+  dependencies: [periphdriver, libcordiophy],
 )
-- 
GitLab