Skip to content

Commit a9445c9

Browse files
committed
Replace small C lib with std C lib if not supported for a given target
1 parent 03dab7f commit a9445c9

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

tools/build.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
from tools.build_api import print_build_results
4040
from tools.build_api import target_supports_toolchain
4141
from tools.build_api import find_valid_toolchain
42+
from tools.build_api import check_small_c_lib_support
4243
from tools.notifier.term import TerminalNotifier
4344
from tools.utils import argparse_filestring_type, args_error, argparse_many
4445
from tools.utils import argparse_dir_not_parent
@@ -177,6 +178,10 @@ def main():
177178
except NoValidToolchainException as e:
178179
print_end_warnings(e.end_warnings)
179180
args_error(parser, str(e))
181+
182+
warning = check_small_c_lib_support(target, toolchain_name)
183+
end_warnings += [warning] if warning is not None else []
184+
180185
tt_id = "%s::%s" % (internal_tc_name, target_name)
181186
if not target_supports_toolchain(target, toolchain_name):
182187
# Log this later

tools/build_api.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,11 @@
5252

5353
RELEASE_VERSIONS = ['2', '5']
5454

55+
SMALL_C_LIB_CHANGE_WARNING = (
56+
"Warning: We noticed that you are using target.c_lib set to small. "
57+
"As the {} target does not support a small C library for the {} toolchain, we are using the standard C library instead. "
58+
)
59+
5560
def prep_report(report, target_name, toolchain_name, id_name):
5661
"""Setup report keys
5762
@@ -205,6 +210,27 @@ def get_toolchain_name(target, toolchain_name):
205210

206211
return toolchain_name
207212

213+
214+
def check_small_c_lib_support(target, toolchain_name):
215+
"""
216+
Check if the small C lib is supported, if not use the standard C library.
217+
Return a warning if target.c_lib is changed.
218+
"""
219+
if (
220+
hasattr(target, "c_lib")
221+
and target.c_lib.lower() == "small"
222+
and hasattr(target, "supported_c_libs")
223+
and toolchain_name not in target.supported_c_libs
224+
):
225+
if (
226+
"small" not in target.supported_c_libs[toolchain_name]
227+
and "std" in target.supported_c_libs[toolchain_name]
228+
):
229+
target.c_lib = "std"
230+
return SMALL_C_LIB_CHANGE_WARNING.format(target.name, toolchain_name)
231+
232+
233+
208234
def find_valid_toolchain(target, toolchain):
209235
"""Given a target and toolchain, get the names for the appropriate
210236
toolchain to use. The environment is also checked to see if the corresponding
@@ -250,6 +276,7 @@ def find_valid_toolchain(target, toolchain):
250276
and "uARM" in {toolchain_name, target.default_toolchain}
251277
):
252278
end_warnings.append(UARM_TOOLCHAIN_WARNING)
279+
253280
return toolchain_name, internal_tc_name, end_warnings
254281
else:
255282
if last_error:

0 commit comments

Comments
 (0)