Skip to content

Commit 5543849

Browse files
committed
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.
1 parent 69d8c0b commit 5543849

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

tools/toolchains/__init__.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -724,10 +724,10 @@ def _add_file(self, file_path, resources, base_path, exclude_paths=None):
724724
elif ext == '.c':
725725
resources.c_sources.append(file_path)
726726

727-
elif ext == '.cpp':
727+
elif ext == '.cpp' or ext == '.cc':
728728
resources.cpp_sources.append(file_path)
729729

730-
elif ext == '.h' or ext == '.hpp':
730+
elif ext == '.h' or ext == '.hpp' or ext == '.hh':
731731
resources.headers.append(file_path)
732732

733733
elif ext == '.o':
@@ -996,7 +996,7 @@ def compile_command(self, source, object, includes):
996996

997997
source = abspath(source) if PRINT_COMPILER_OUTPUT_AS_LINK else source
998998

999-
if ext == '.c' or ext == '.cpp':
999+
if ext == '.c' or ext == '.cpp' or ext == '.cc':
10001000
base, _ = splitext(object)
10011001
dep_path = base + '.d'
10021002
try:
@@ -1006,12 +1006,12 @@ def compile_command(self, source, object, includes):
10061006
config_file = ([self.config.app_config_location]
10071007
if self.config.app_config_location else [])
10081008
deps.extend(config_file)
1009-
if ext == '.cpp' or self.COMPILE_C_AS_CPP:
1009+
if ext != '.c' or self.COMPILE_C_AS_CPP:
10101010
deps.append(join(self.build_dir, self.PROFILE_FILE_NAME + "-cxx"))
10111011
else:
10121012
deps.append(join(self.build_dir, self.PROFILE_FILE_NAME + "-c"))
10131013
if len(deps) == 0 or self.need_update(object, deps):
1014-
if ext == '.cpp' or self.COMPILE_C_AS_CPP:
1014+
if ext != '.c' or self.COMPILE_C_AS_CPP:
10151015
return self.compile_cpp(source, object, includes)
10161016
else:
10171017
return self.compile_c(source, object, includes)

0 commit comments

Comments
 (0)