[update] 通过 SCons生成 CMakefile.txt 使用相对路径 (#5677)

* [update] 通过 SCons生成 CMakefile.txt 使用相对路径
* [update] 通过 SCons生成 VSC 使用相对路径
This commit is contained in:
LiuKang 2022-03-20 10:31:21 +08:00 committed by GitHub
parent 0c82e033dc
commit 4e1b175138
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 4 deletions

View File

@ -8,6 +8,7 @@ import sys
import re import re
import utils import utils
import rtconfig import rtconfig
from utils import _make_path_relative
def GenerateCFiles(env,project): def GenerateCFiles(env,project):
@ -106,7 +107,9 @@ def GenerateCFiles(env,project):
cm_file.write("INCLUDE_DIRECTORIES(\n") cm_file.write("INCLUDE_DIRECTORIES(\n")
for i in info['CPPPATH']: for i in info['CPPPATH']:
cm_file.write( "\t" + i.replace("\\", "/") + "\n") # use relative path
path = _make_path_relative(os.getcwd(), i)
cm_file.write( "\t" + path.replace("\\", "/") + "\n")
cm_file.write(")\n\n") cm_file.write(")\n\n")
cm_file.write("ADD_DEFINITIONS(\n") cm_file.write("ADD_DEFINITIONS(\n")
@ -117,7 +120,9 @@ def GenerateCFiles(env,project):
cm_file.write("SET(PROJECT_SOURCES\n") cm_file.write("SET(PROJECT_SOURCES\n")
for group in project: for group in project:
for f in group['src']: for f in group['src']:
cm_file.write( "\t" + os.path.normpath(f.rfile().abspath).replace("\\", "/") + "\n" ) # use relative path
path = _make_path_relative(os.getcwd(), os.path.normpath(f.rfile().abspath))
cm_file.write( "\t" + path.replace("\\", "/") + "\n" )
cm_file.write(")\n\n") cm_file.write(")\n\n")
if rtconfig.PLATFORM == 'gcc': if rtconfig.PLATFORM == 'gcc':

View File

@ -29,6 +29,9 @@ import os
import json import json
import utils import utils
import rtconfig import rtconfig
import rtconfig
from utils import _make_path_relative
def GenerateCFiles(env): def GenerateCFiles(env):
""" """
@ -56,9 +59,9 @@ def GenerateCFiles(env):
includePath = [] includePath = []
for i in info['CPPPATH']: for i in info['CPPPATH']:
if i[0] == '\"' and i[len(i) - 2:len(i)] == '\",': if i[0] == '\"' and i[len(i) - 2:len(i)] == '\",':
includePath.append(i[1:len(i) - 2]) includePath.append(_make_path_relative(os.getcwd(), i[1:len(i) - 2]))
else: else:
includePath.append(i) includePath.append(_make_path_relative(os.getcwd(), i))
config_obj['includePath'] = includePath config_obj['includePath'] = includePath
json_obj = {} json_obj = {}