From 8b9ac2d4aa632c27018957f73c13462a6e704c70 Mon Sep 17 00:00:00 2001
From: Luca Erbetta <luca.erbetta@skywarder.eu>
Date: Tue, 11 May 2021 14:14:59 +0200
Subject: [PATCH] [SBS] Added ability to add library-specific defines

---
 Makefile.template |  4 ++--
 sbs               |  4 +++-
 sbs.conf          | 27 +++++++++++++++++++++++++++
 3 files changed, 32 insertions(+), 3 deletions(-)

diff --git a/Makefile.template b/Makefile.template
index 3b3ea18e0..b9b7c91c6 100644
--- a/Makefile.template
+++ b/Makefile.template
@@ -111,11 +111,11 @@ $(OBJDIR)/%.o: %.s
 
 $(OBJDIR)/%.o : %.c
 	$(ECHO) "[CC]  " $<
-	$(Q) $(CC)  $(DFLAGS) $(CFLAGS) {SBS_CUSTOM_DEFINES} $< -o $@
+	$(Q) $(CC)  $(DFLAGS) $(CFLAGS) {SBS_CUSTOM_DEFINES} {SBS_LIB_DEFINES} $< -o $@
 
 $(OBJDIR)/%.o : %.cpp
 	$(ECHO) "[CXX] " $<
-	$(Q) $(CXX) $(DFLAGS) $(CXXFLAGS) {SBS_CUSTOM_DEFINES} $< -o $@
+	$(Q) $(CXX) $(DFLAGS) $(CXXFLAGS) {SBS_CUSTOM_DEFINES} {SBS_LIB_DEFINES} $< -o $@
 
 folders:
 	$(Q) mkdir -pv $(dir $(OBJ)) $(BINDIR)
diff --git a/sbs b/sbs
index 6c5201fe2..c7cdf9a97 100755
--- a/sbs
+++ b/sbs
@@ -156,6 +156,7 @@ def parseConf(path):
         elif stype == 'library':
             extlibs[i] = {'subdir': conf.get(i, 'Subdir'),
                           'libs': [x.strip() for x in conf.get(i, 'Libs').split()],
+                          'defines':  conf.get(i, 'Defines').strip(),
                           'includes': [x.strip() for x in conf.get(i, 'Includes').split()]}
         elif stype == 'board' or stype == 'test':
             if stype == 'test':
@@ -221,7 +222,8 @@ def build_makefile(template, board, bname):
              "BIN_NAME": board['bin'],
              "LIB_SUBDIR": " ".join([x['subdir'] for _,x in board['libs'].items()]),
              "LIB_LIBS": " ".join([" ".join(x['libs']) for _,x in board['libs'].items()]),
-             "LIB_INCLUDES": " ".join([" ".join([ "-I" + s for s in x['includes']]) for _,x in board['libs'].items()])
+             "LIB_INCLUDES": " ".join([" ".join([ "-I" + s for s in x['includes']]) for _,x in board['libs'].items()]),
+             "LIB_DEFINES": " ".join(x['defines'] for _,x in board['libs'].items())
     }
 
     rmap["PROJECT_INCLUDES"] = "-I" + projconf["SRC_PATH"].strip() + " "
diff --git a/sbs.conf b/sbs.conf
index ebcbf53dc..c5b570ef2 100644
--- a/sbs.conf
+++ b/sbs.conf
@@ -93,14 +93,30 @@ PROJECT_LIBS:
 Type:       library
 Subdir:     libs/mxgui
 Libs:       libs/mxgui/libmxgui.a
+Defines:    
 Includes:   libs/mxgui
 
 [eigen]
 Type:       library
 Subdir:     
 Libs:       
+Defines:    
 Includes:   libs/eigen
 
+[fmt]
+Type:       library
+Subdir:     libs/fmt/
+Libs:       libs/fmt/libfmt.a
+Defines:    -DFMT_STATIC_THOUSANDS_SEPARATOR=0 -D_GLIBCXX_USE_WCHAR_T
+Includes:   libs/fmt/include
+
+[fmt-header-only]
+Type:       library
+Subdir:     
+Libs:       
+Defines:    
+Includes:   libs/fmt/include
+
 #-----------------------------------#
 #          List of Sources          #
 #-----------------------------------#
@@ -322,8 +338,18 @@ BoardId:    stm32f429zi_stm32f4discovery
 BinName:    test-serial
 Include:    
 Defines:    
+Libs:       fmt
 Main:       test-serial
 
+[test-trace-logger]
+Type:       test
+BoardId:    stm32f429zi_stm32f4discovery
+BinName:    test-trace-logger
+Include:    src/shared/diagnostic/PrintLogger.cpp
+Defines:    -DDEBUG
+Libs:       fmt
+Main:       test-trace-logger
+
 [test-hsm]
 Type:       test
 BoardId:    stm32f429zi_stm32f4discovery
@@ -612,6 +638,7 @@ Main:       drivers/xbee/test-xbee-rcv
 
 [test-xbee-bidir]
 Type:       test
+# BoardId:    stm32f429zi_skyward_death_stack_x
 BoardId:    stm32f429zi_stm32f4discovery
 BinName:    test-xbee-bidir
 Include:    %shared %spi %xbee %logger
-- 
GitLab