From 4ce09f1d4330f9da482c8111ce6451d14f2b081a Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Thu, 14 May 2015 17:47:39 +0200 Subject: [PATCH] Implement "whole-archive" hook for mbed-lib and LINCOM command --- platformio/builder/scripts/frameworks/mbed.py | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/platformio/builder/scripts/frameworks/mbed.py b/platformio/builder/scripts/frameworks/mbed.py index 191e04d1ed..90a27ac623 100644 --- a/platformio/builder/scripts/frameworks/mbed.py +++ b/platformio/builder/scripts/frameworks/mbed.py @@ -177,6 +177,25 @@ def get_build_flags(data): return flags +def _mbed_whole_archive_hook(flags): + if not isinstance(flags, list): + return flags + + for pos, flag in enumerate(flags[:]): + if isinstance(flag, basestring): + continue + flags.insert(pos, "-Wl,-whole-archive") + flags.insert(pos + 2, "-Wl,-no-whole-archive") + + return flags + + +env.Replace( + _mbed_whole_archive_hook=_mbed_whole_archive_hook, + _LIBFLAGS="${_mbed_whole_archive_hook(%s)}" % env.get("_LIBFLAGS")[2:-1] +) + + board_type = env.subst("$BOARD") variant = MBED_VARIANTS[ board_type] if board_type in MBED_VARIANTS else board_type.upper() @@ -187,6 +206,8 @@ def get_build_flags(data): variant_dir = join("$PLATFORMFW_DIR", "variant", variant) env.Replace( + _mbed_whole_archive_hook=_mbed_whole_archive_hook, + _LIBFLAGS="${_mbed_whole_archive_hook(%s)}" % env.get("_LIBFLAGS")[2:-1], CPPFLAGS=build_flags.get("CPPFLAGS", []), CFLAGS=build_flags.get("CFLAGS", []), CXXFLAGS=build_flags.get("CXXFLAGS", []),