From f2b3edec15e839c04528e073f0e19f6ed6ac15d6 Mon Sep 17 00:00:00 2001
From: Rahix <rahix@rahix.de>
Date: Tue, 6 Aug 2019 15:04:17 +0200
Subject: [PATCH] build(ble): Disable tracing by default

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

diff --git a/card10-cross.ini b/card10-cross.ini
index 5199d505..8ccc9963 100644
--- a/card10-cross.ini
+++ b/card10-cross.ini
@@ -8,7 +8,7 @@ c_args      = ['-mthumb', '-mcpu=cortex-m4', '-mfloat-abi=softfp', '-mfpu=fpv4-s
 
 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']
+target_defs = ['-DTARGET=32665', '-DTARGET_REV=0x4131', '-DBOARD_CARD10=1']
 
 [host_machine]
 system = 'none'
diff --git a/lib/sdk/Libraries/BTLE/meson.build b/lib/sdk/Libraries/BTLE/meson.build
index 36d6cda7..ab0db720 100644
--- a/lib/sdk/Libraries/BTLE/meson.build
+++ b/lib/sdk/Libraries/BTLE/meson.build
@@ -414,22 +414,40 @@ sources = files(
 'link_layer/controller/sources/common/sch/sch_list.c',
 )
 
+
+ble_compileargs = [
+  '-DWSF_ASSERT_ENABLED=TRUE',
+  '-DWSF_MS_PER_TICK=1',
+  '-DINIT_BROADCASTER',
+  '-DINIT_PERIPHERAL',
+  '-DINIT_ENCRYPTED',
+]
+
+if get_option('ble_trace')
+  ble_compileargs += [
+    '-DWSF_TRACE_ENABLED=TRUE',
+  ]
+endif
+
 lib = static_library(
   'ble',
   sources,
   include_directories: includes,
   dependencies: [periphdriver, libcordiophy],
-  c_args: ['-w',
-            '-DLHCI_ENABLE_VS=TRUE',
-            '-DBB_CLK_RATE_HZ=1600000',
-            '-DLCTR_CONN_NO_TIFS_REASSEMBLY=1',
-            '-DBB_ENABLE_INLINE_ENC_TX=1',
-            '-DBB_ENABLE_INLINE_DEC_RX=1',
-            '-DFORCE_PMU_WAKEUP=1']
+  c_args: [
+    '-w',
+    '-DLHCI_ENABLE_VS=TRUE',
+    '-DBB_CLK_RATE_HZ=1600000',
+    '-DLCTR_CONN_NO_TIFS_REASSEMBLY=1',
+    '-DBB_ENABLE_INLINE_ENC_TX=1',
+    '-DBB_ENABLE_INLINE_DEC_RX=1',
+    '-DFORCE_PMU_WAKEUP=1',
+  ] + ble_compileargs,
 )
 
 ble = declare_dependency(
   include_directories: includes,
   link_with: lib,
+  compile_args: ble_compileargs,
   dependencies: [periphdriver, libcordiophy],
 )
diff --git a/meson_options.txt b/meson_options.txt
index e0a79c54..bb96608f 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -5,3 +5,11 @@ option(
 
   description: 'Whether to print debug messages on the serial console'
 )
+
+option(
+  'ble_trace',
+  type: 'boolean',
+  value: false,
+
+  description: 'Whether to enable WSF TRACE prints',
+)
-- 
GitLab