Skip to content

Commit f02be6a

Browse files
committed
修复windows下编译错误
1 parent fc602e6 commit f02be6a

File tree

3 files changed

+23
-5
lines changed

3 files changed

+23
-5
lines changed

project.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,10 @@ def select_config(config_path, type):
5858
exit(-1)
5959

6060
shutil.copyfile(config_path, cfg_dir + "/.config")
61+
print("Copy " + config_path + " to config/.config")
62+
# The above code is calling a function `generate_cmake` and passing `tools.project_path` as an
63+
# argument.
64+
generate_cmake(cfg_dir)
6165
tools.clean_cache()
6266
tools.config_cmake(type)
6367

@@ -70,6 +74,8 @@ def select_config_idf(config_path, type):
7074
exit(-1)
7175

7276
shutil.copyfile(config_path, cfg_dir + "/.config")
77+
print("Copy " + config_path + " to config/.config")
78+
generate_cmake(cfg_dir)
7379
tools.clean_cache()
7480
tools.config_cmake_idf(type)
7581

@@ -80,7 +86,7 @@ def build(board, robot, type="Debug", code_check=False):
8086
target = []
8187
time_count = 0.0
8288

83-
os.system("rm -rf " + fm_dir)
89+
shutil.rmtree(fm_dir)
8490
os.makedirs(fm_dir, exist_ok=True)
8591

8692
if board == "all":

utils/CMake/toolchain.cmake

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
execute_process(COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/project.py generate
2-
${CMAKE_CURRENT_SOURCE_DIR})
3-
41
include(${CMAKE_CURRENT_LIST_DIR}/../../config/config.cmake)
52

63
set(BSP_DIR ${CMAKE_CURRENT_SOURCE_DIR}/hw/bsp)

utils/python/tool.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import sys
22
import os
3+
import shutil
34

45

56
class ProjectTools:
@@ -9,6 +10,7 @@ class ProjectTools:
910

1011
def __init__(self):
1112
self.project_path = os.path.split(os.path.realpath(__file__))[0][:-13]
13+
self.project_path = self.project_path.replace("\\", "/")
1214
self.kconfig_path = self.project_path + "/lib/Kconfiglib"
1315
if " " in self.project_path:
1416
print("工程路径请不要带有空格")
@@ -30,7 +32,20 @@ def menuconfig(self, path):
3032
print("Menu config done.")
3133

3234
def clean_cache(self):
33-
os.system("rm -rf " + self.project_path + "/build/*")
35+
filepath = self.project_path + "/build"
36+
37+
if not os.path.exists(filepath):
38+
os.mkdir(filepath)
39+
return
40+
41+
del_list = os.listdir(filepath)
42+
43+
for f in del_list:
44+
file_path = os.path.join(filepath, f)
45+
if os.path.isfile(file_path):
46+
os.remove(file_path)
47+
elif os.path.isdir(file_path):
48+
shutil.rmtree(file_path)
3449

3550
def config_cmake(self, type="Debug"):
3651
os.system(

0 commit comments

Comments
 (0)