Skip to content

Commit 0f65821

Browse files
authored
Merge pull request #4806 from thread-liu/master
[update] support windows cmake tool.
2 parents 4b9913f + 7a52944 commit 0f65821

File tree

1 file changed

+24
-14
lines changed

1 file changed

+24
-14
lines changed

tools/cmake.py

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"""
55

66
import os
7+
import sys
78
import re
89
import utils
910
import rtconfig
@@ -13,17 +14,26 @@ def GenerateCFiles(env,project):
1314
"""
1415
Generate CMakeLists.txt files
1516
"""
16-
1717
info = utils.ProjectInfo(env)
18-
19-
CC = os.path.join(rtconfig.EXEC_PATH, rtconfig.CC)
20-
CXX = os.path.join(rtconfig.EXEC_PATH, rtconfig.CXX)
21-
AS = os.path.join(rtconfig.EXEC_PATH, rtconfig.AS)
22-
AR = os.path.join(rtconfig.EXEC_PATH, rtconfig.AR)
23-
LINK = os.path.join(rtconfig.EXEC_PATH, rtconfig.LINK)
24-
SIZE = os.path.join(rtconfig.EXEC_PATH, rtconfig.SIZE)
25-
OBJDUMP = os.path.join(rtconfig.EXEC_PATH, rtconfig.OBJDUMP)
26-
OBJCOPY = os.path.join(rtconfig.EXEC_PATH, rtconfig.OBJCPY)
18+
19+
CC = os.path.join(rtconfig.EXEC_PATH, rtconfig.CC).replace('\\', "/")
20+
CXX = os.path.join(rtconfig.EXEC_PATH, rtconfig.CXX).replace('\\', "/")
21+
AS = os.path.join(rtconfig.EXEC_PATH, rtconfig.AS).replace('\\', "/")
22+
AR = os.path.join(rtconfig.EXEC_PATH, rtconfig.AR).replace('\\', "/")
23+
LINK = os.path.join(rtconfig.EXEC_PATH, rtconfig.LINK).replace('\\', "/")
24+
SIZE = os.path.join(rtconfig.EXEC_PATH, rtconfig.SIZE).replace('\\', "/")
25+
OBJDUMP = os.path.join(rtconfig.EXEC_PATH, rtconfig.OBJDUMP).replace('\\', "/")
26+
OBJCOPY = os.path.join(rtconfig.EXEC_PATH, rtconfig.OBJCPY).replace('\\', "/")
27+
28+
if "win32" in sys.platform:
29+
CC += ".exe"
30+
CXX += ".exe"
31+
AS += ".exe"
32+
AR += ".exe"
33+
LINK += ".exe"
34+
SIZE += ".exe"
35+
OBJDUMP += ".exe"
36+
OBJCOPY += ".exe"
2737

2838
cm_file = open('CMakeLists.txt', 'w')
2939
if cm_file:
@@ -49,7 +59,7 @@ def GenerateCFiles(env,project):
4959

5060
cm_file.write("INCLUDE_DIRECTORIES(\n")
5161
for i in info['CPPPATH']:
52-
cm_file.write( "\t" +i + "\n")
62+
cm_file.write( "\t" + i.replace("\\", "/") + "\n")
5363
cm_file.write(")\n\n")
5464

5565

@@ -61,21 +71,21 @@ def GenerateCFiles(env,project):
6171
cm_file.write("SET(PROJECT_SOURCES\n")
6272
for group in project:
6373
for f in group['src']:
64-
cm_file.write( "\t"+os.path.normpath(f.rfile().abspath)+"\n" )
74+
cm_file.write( "\t" + os.path.normpath(f.rfile().abspath).replace("\\", "/") + "\n" )
6575
cm_file.write(")\n\n")
6676

6777
cm_file.write("LINK_DIRECTORIES(\n")
6878
for group in project:
6979
if 'LIBPATH' in group.keys():
7080
for f in group['LIBPATH']:
71-
cm_file.write( "\t"+ f + "\n" )
81+
cm_file.write( "\t"+ f.replace("\\", "/") + "\n" )
7282
cm_file.write(")\n\n")
7383

7484
cm_file.write("LINK_LIBRARIES(\n")
7585
for group in project:
7686
if 'LIBS' in group.keys():
7787
for f in group['LIBS']:
78-
cm_file.write( "\t"+ "{}\n".format(f))
88+
cm_file.write( "\t"+ "{}\n".format(f.replace("\\", "/")))
7989
cm_file.write(")\n\n")
8090

8191
cm_file.write("ADD_EXECUTABLE(${CMAKE_PROJECT_NAME}.elf ${PROJECT_SOURCES})\n")

0 commit comments

Comments
 (0)