Skip to content

Commit 59f837d

Browse files
kaidegit1078249029
authored andcommitted
[tools][cmake] fix processing groups with similar name (RT-Thread#9667)
1 parent bd363be commit 59f837d

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

tools/cmake.py

+15-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import utils
1010
import rtconfig
1111
from utils import _make_path_relative
12-
from collections import defaultdict
12+
from collections import defaultdict, Counter
1313

1414

1515
def GenerateCFiles(env, project, project_name):
@@ -184,6 +184,20 @@ def GenerateCFiles(env, project, project_name):
184184
else:
185185
libgroups.append(group)
186186

187+
# Process groups whose names differ only in capitalization.
188+
# (Groups have same name should be merged into one before)
189+
for group in libgroups:
190+
group['alias'] = group['name'].lower()
191+
names = [group['alias'] for group in libgroups]
192+
counter = Counter(names)
193+
names = [name for name in names if counter[name] > 1]
194+
for group in libgroups:
195+
if group['alias'] in names:
196+
counter[group['alias']] -= 1
197+
group['alias'] = f"{group['name']}_{counter[group['alias']]}"
198+
print(f"Renamed {group['name']} to {group['alias']}")
199+
group['name'] = group['alias']
200+
187201
cm_file.write("# Library source files\n")
188202
for group in project:
189203
cm_file.write("SET(RT_{:s}_SOURCES\n".format(group['name'].upper()))

0 commit comments

Comments
 (0)