From 4e1b1751383207dc44c86e2fd3e6893dc50d0d48 Mon Sep 17 00:00:00 2001 From: LiuKang <44889940+liukangcc@users.noreply.github.com> Date: Sun, 20 Mar 2022 10:31:21 +0800 Subject: [PATCH] =?UTF-8?q?[update]=20=E9=80=9A=E8=BF=87=20SCons=E7=94=9F?= =?UTF-8?q?=E6=88=90=20CMakefile.txt=20=E4=BD=BF=E7=94=A8=E7=9B=B8?= =?UTF-8?q?=E5=AF=B9=E8=B7=AF=E5=BE=84=20(#5677)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * [update] 通过 SCons生成 CMakefile.txt 使用相对路径 * [update] 通过 SCons生成 VSC 使用相对路径 --- tools/cmake.py | 9 +++++++-- tools/vsc.py | 7 +++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/tools/cmake.py b/tools/cmake.py index 811b6693cb..02229556a1 100644 --- a/tools/cmake.py +++ b/tools/cmake.py @@ -8,6 +8,7 @@ import sys import re import utils import rtconfig +from utils import _make_path_relative def GenerateCFiles(env,project): @@ -106,7 +107,9 @@ def GenerateCFiles(env,project): cm_file.write("INCLUDE_DIRECTORIES(\n") 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("ADD_DEFINITIONS(\n") @@ -117,7 +120,9 @@ def GenerateCFiles(env,project): cm_file.write("SET(PROJECT_SOURCES\n") for group in project: 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") if rtconfig.PLATFORM == 'gcc': diff --git a/tools/vsc.py b/tools/vsc.py index 99a49789b7..5eed941bc8 100644 --- a/tools/vsc.py +++ b/tools/vsc.py @@ -29,6 +29,9 @@ import os import json import utils import rtconfig +import rtconfig +from utils import _make_path_relative + def GenerateCFiles(env): """ @@ -56,9 +59,9 @@ def GenerateCFiles(env): includePath = [] for i in info['CPPPATH']: 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: - includePath.append(i) + includePath.append(_make_path_relative(os.getcwd(), i)) config_obj['includePath'] = includePath json_obj = {} -- GitLab