From b0f31e38b536e2b59e7a99db55b35322f422bb34 Mon Sep 17 00:00:00 2001 From: Jens Alfke Date: Fri, 6 Jul 2018 10:10:22 -0700 Subject: [PATCH] Recognize ".cc" and ".hh" source file extensions ".cc" --> C++ source code ".hh" --> header This change allows existing source code with this naming convention (e.g. my company's) to be used in mbed.os projects. --- tools/toolchains/__init__.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/tools/toolchains/__init__.py b/tools/toolchains/__init__.py index a6016166b1..e0172ef46a 100644 --- a/tools/toolchains/__init__.py +++ b/tools/toolchains/__init__.py @@ -722,10 +722,10 @@ class mbedToolchain: elif ext == '.c': resources.c_sources.append(file_path) - elif ext == '.cpp': + elif ext == '.cpp' or ext == '.cc': resources.cpp_sources.append(file_path) - elif ext == '.h' or ext == '.hpp': + elif ext == '.h' or ext == '.hpp' or ext == '.hh': resources.headers.append(file_path) elif ext == '.o': @@ -992,7 +992,9 @@ class mbedToolchain: _, ext = splitext(source) ext = ext.lower() - if ext == '.c' or ext == '.cpp': + source = abspath(source) if PRINT_COMPILER_OUTPUT_AS_LINK else source + + if ext == '.c' or ext == '.cpp' or ext == '.cc': base, _ = splitext(object) dep_path = base + '.d' try: @@ -1002,12 +1004,12 @@ class mbedToolchain: config_file = ([self.config.app_config_location] if self.config.app_config_location else []) deps.extend(config_file) - if ext == '.cpp' or self.COMPILE_C_AS_CPP: + if ext != '.c' or self.COMPILE_C_AS_CPP: deps.append(join(self.build_dir, self.PROFILE_FILE_NAME + "-cxx")) else: deps.append(join(self.build_dir, self.PROFILE_FILE_NAME + "-c")) if len(deps) == 0 or self.need_update(object, deps): - if ext == '.cpp' or self.COMPILE_C_AS_CPP: + if ext != '.c' or self.COMPILE_C_AS_CPP: return self.compile_cpp(source, object, includes) else: return self.compile_c(source, object, includes)