使用python脚本删除上次生成 加快编译速度

This commit is contained in:
2025-01-13 11:19:08 +08:00
parent 6c31c3d96f
commit b29b776229
4 changed files with 19 additions and 13 deletions

View File

@@ -50,10 +50,10 @@ export product_line=PLC
export PATH=/opt/kunlun2/bin/:$PATH
set -o errexit
make -C .. clobber
# make -j -C .. clobber
# clean phy lib etc.
make -C .. sbl_clean
# make -j -C .. sbl_clean
# build klx ram
make -C .. sbl opt_build=1
make -j -C .. sbl opt_build=1

View File

@@ -13,6 +13,9 @@ if __name__ == "__main__":
cmd=f"{' '.join(sys.argv[1:])} > build_log.log"
if not ('not_clean' in sys.argv[1:]):
os.system("python3 ../clear_output.py > /dev/null")
os.remove("../make_flags.txt")
os.remove("../python_script_log.log")
os.system("python3 ../praper_vscode.py clear >> ../python_script_log.log")
path="../tools/gen_img/customer"
if os.path.exists(path):
shutil.rmtree(path)

View File

@@ -71,7 +71,14 @@ GET_SRCS = $(wildcard $(1)/*.c) $(wildcard $(1)/*.cpp) $(wildcard $(1)/*.S)
# local .c
SRCS += $(call GET_SRCS, .)
# every sub dir's .c
SRCS += $(foreach dirname, $(SUB_DIRS), $(call GET_SRCS, $(dirname)))
# 如果子文件夹包含makefile文件 则不包含这个目录的源文件
SRC_DIRS = $(shell for dir in $(SUB_DIRS); do \
if [ ! -f "$$dir/Makefile" ]; then \
echo "$$dir"; \
fi \
done)
SRCS += $(foreach dirname, $(SRC_DIRS), $(call GET_SRCS, $(dirname)))
# ext src
SRCS += $(EXT_SRC)
# all the obj names
@@ -312,6 +319,7 @@ $(OUTPUT_FULL_NAME): $(OUTPUT_DIR) $(BIN_DIR)/.sub_dirs $(BIN_DIR)/.ext_src $(OB
@python3 $(TOPDIR)/praper_vscode.py $(TOPDIR)/make_flags.txt $@ >> $(TOPDIR)/python_script_log.log
@for d in $(SUB_DIRS); do\
if [ -e "$$d/Makefile" ]; then\
echo "enter $$d";\
$(MAKE) -C $$d || exit 1;\
if [ 2 -eq $(OUTPUT_TYPE) ];then\
if [ -e $(OUTPUT_FULL_NAME) ]; then \
@@ -402,27 +410,21 @@ clean:
-$(RM) $(OUTPUT_FULL_NAME) $(OBJECTS) $(DEPS) $(BIN_DIR)/.sub_dirs $(BIN_DIR)/.ext_src
@for d in $(SUB_DIRS) ; do\
if [ -e "$$d/Makefile" ]; then\
echo "clean $$d";\
$(MAKE) -C $$d $@ ;\
fi;\
done
-$(RM) $(OUTDIR)
clobber:
@for d in $(SUB_DIRS); do\
if [ -e "$$d/Makefile" ]; then\
$(MAKE) -C $$d $@ ;\
fi;\
done
@-$(RM) $(TOPDIR)/make_flags.txt
@-$(RM) $(TOPDIR)/python_script_log.log
@-python3 $(TOPDIR)/praper_vscode.py clear >> $(TOPDIR)/python_script_log.log
@-$(RM) $(OUTDIR)
@echo clobber
# clean obj files only
clean_objs:
-$(RM) $(OBJECTS)
@for d in $(SUB_DIRS); do\
if [ -e "$$d/Makefile" ]; then\
echo "clean_objs $$d";\
$(MAKE) -C $$d $@ ;\
fi;\
done