Skip to content

Commit 4e1b175

Browse files
authored
[update] 通过 SCons生成 CMakefile.txt 使用相对路径 (#5677)
* [update] 通过 SCons生成 CMakefile.txt 使用相对路径 * [update] 通过 SCons生成 VSC 使用相对路径
1 parent 0c82e03 commit 4e1b175

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

tools/cmake.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import re
99
import utils
1010
import rtconfig
11+
from utils import _make_path_relative
1112

1213

1314
def GenerateCFiles(env,project):
@@ -106,7 +107,9 @@ def GenerateCFiles(env,project):
106107

107108
cm_file.write("INCLUDE_DIRECTORIES(\n")
108109
for i in info['CPPPATH']:
109-
cm_file.write( "\t" + i.replace("\\", "/") + "\n")
110+
# use relative path
111+
path = _make_path_relative(os.getcwd(), i)
112+
cm_file.write( "\t" + path.replace("\\", "/") + "\n")
110113
cm_file.write(")\n\n")
111114

112115
cm_file.write("ADD_DEFINITIONS(\n")
@@ -117,7 +120,9 @@ def GenerateCFiles(env,project):
117120
cm_file.write("SET(PROJECT_SOURCES\n")
118121
for group in project:
119122
for f in group['src']:
120-
cm_file.write( "\t" + os.path.normpath(f.rfile().abspath).replace("\\", "/") + "\n" )
123+
# use relative path
124+
path = _make_path_relative(os.getcwd(), os.path.normpath(f.rfile().abspath))
125+
cm_file.write( "\t" + path.replace("\\", "/") + "\n" )
121126
cm_file.write(")\n\n")
122127

123128
if rtconfig.PLATFORM == 'gcc':

tools/vsc.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@
2929
import json
3030
import utils
3131
import rtconfig
32+
import rtconfig
33+
from utils import _make_path_relative
34+
3235

3336
def GenerateCFiles(env):
3437
"""
@@ -56,9 +59,9 @@ def GenerateCFiles(env):
5659
includePath = []
5760
for i in info['CPPPATH']:
5861
if i[0] == '\"' and i[len(i) - 2:len(i)] == '\",':
59-
includePath.append(i[1:len(i) - 2])
62+
includePath.append(_make_path_relative(os.getcwd(), i[1:len(i) - 2]))
6063
else:
61-
includePath.append(i)
64+
includePath.append(_make_path_relative(os.getcwd(), i))
6265
config_obj['includePath'] = includePath
6366

6467
json_obj = {}

0 commit comments

Comments
 (0)