使用多线程编译,优化praper_vscode.py

This commit is contained in:
2024-09-28 19:35:52 +08:00
parent a1a8f76b8c
commit f50a2a3751
12 changed files with 91 additions and 90 deletions

View File

@@ -20,16 +20,6 @@ Information is free from patent or copyright infringement.
#pragma pack(1)
typedef struct{
uint8_t a;
uint32_t b;
}test_def;
#pragma pack()
test_def g_test;
@@ -38,9 +28,6 @@ int main()
{ {
iot_build_info_t info; iot_build_info_t info;
g_test.a=1;
g_test.b=2;
printf("a=%d,b=%d\n",g_test.a,g_test.b);
#if IOT_SMART_GRID_ENABLE #if IOT_SMART_GRID_ENABLE

View File

@@ -87,7 +87,14 @@ extra_work = echo handle bb_cpu..;\
ifeq ($(bbcpu_enable), 1) ifeq ($(bbcpu_enable), 1)
.PHONY: TARGET .PHONY: TARGET
TARGET: .output/plc/lib/bb_cpu.out USR_CMD TARGET: .output/plc/lib/bb_cpu.out
@echo "const char plc_core1[] = {" > plc_core1.h
@chmod 777 $(TOPDIR)/tools/bin_tool/bin2hex_frame
@$(TOPDIR)/tools/bin_tool/bin2hex_frame $(OUTPUT_DIR)/$(OUTPUT_NAME).bin tmp.txt
@cat tmp.txt >> plc_core1.h
@echo "};" >> plc_core1.h
@mv plc_core1.h $(TOPDIR)/dtest/dtest3/mac_phy/double_cpu/kl3_core0
@rm -rf tmp.txt
endif endif
ifdef TOPDIR ifdef TOPDIR
@@ -98,15 +105,6 @@ TOPDIR = $(CURDIR)
export TOPDIR export TOPDIR
endif endif
# usr_cmd
USR_CMD::
@echo "const char plc_core1[] = {" > plc_core1.h
@chmod 777 $(TOPDIR)/tools/bin_tool/bin2hex_frame
@$(TOPDIR)/tools/bin_tool/bin2hex_frame $(OUTPUT_DIR)/$(OUTPUT_NAME).bin tmp.txt
@cat tmp.txt >> plc_core1.h
@echo "};" >> plc_core1.h
@mv plc_core1.h $(TOPDIR)/dtest/dtest3/mac_phy/double_cpu/kl3_core0
@rm -rf tmp.txt
dump: dump:
$(OBJDUMP) -D -S -l $(OUTPUT_FULL_NAME) > $(OUTPUT_FULL_NAME).dump $(OBJDUMP) -D -S -l $(OUTPUT_FULL_NAME) > $(OUTPUT_FULL_NAME).dump

View File

@@ -408,50 +408,50 @@ endif
.PHONY:dtest .PHONY:dtest
dtest: dtest:
@make -C $(TOPDIR)/dtest dtest_only=1 @$(MAKE) -C $(TOPDIR)/dtest dtest_only=1
dtest_clean: dtest_clean:
ifneq ($(product_line), BT) ifneq ($(product_line), BT)
@make -C $(TOPDIR)/plc/halphy clean @$(MAKE) -C $(TOPDIR)/plc/halphy clean
endif endif
@make -C $(TOPDIR)/dtest clean @$(MAKE) -C $(TOPDIR)/dtest clean
.PHONY:bootram .PHONY:bootram
bootram: bootram:
@make -C $(TOPDIR)/mfgtool/bootram @$(MAKE) -C $(TOPDIR)/mfgtool/bootram
bootram_clean: bootram_clean:
@make -C $(TOPDIR)/mfgtool/bootram clean @$(MAKE) -C $(TOPDIR)/mfgtool/bootram clean
.PHONY:ram .PHONY:ram
RAMDIR = $(TOPDIR)/mfgtool/ram RAMDIR = $(TOPDIR)/mfgtool/ram
ram: ram:
@make -C $(RAMDIR) @$(MAKE) -C $(RAMDIR)
ram_clean: ram_clean:
@make -C $(RAMDIR) clean @$(MAKE) -C $(RAMDIR) clean
.PHONY:sbl .PHONY:sbl
sbl: sbl:
@make -C $(TOPDIR)/sbl @$(MAKE) -C $(TOPDIR)/sbl
sbl_clean: sbl_clean:
@make -C $(TOPDIR)/sbl clean @$(MAKE) -C $(TOPDIR)/sbl clean
.PHONY:ah .PHONY:ah
ah: ah:
@make -C $(TOPDIR)/mfgtool/ah @$(MAKE) -C $(TOPDIR)/mfgtool/ah
ah_clean: ah_clean:
@make -C $(TOPDIR)/mfgtool/ah clean @$(MAKE) -C $(TOPDIR)/mfgtool/ah clean
.PHONY:lzma .PHONY:lzma
lzma: lzma:
@make -C $(TOPDIR)/mfgtool/lzma @$(MAKE) -C $(TOPDIR)/mfgtool/lzma
lzma_clean: lzma_clean:
@make -C $(TOPDIR)/mfgtool/lzma clean @$(MAKE) -C $(TOPDIR)/mfgtool/lzma clean
.PHONY:oem_tool .PHONY:oem_tool
oem_tool: oem_tool:
@make -C $(TOPDIR)/mfgtool/oem_tool @$(MAKE) -C $(TOPDIR)/mfgtool/oem_tool
oem_tool_clean: oem_tool_clean:
@make -C $(TOPDIR)/mfgtool/oem_tool clean @$(MAKE) -C $(TOPDIR)/mfgtool/oem_tool clean
# display the obj files and output name # display the obj files and output name
debug: debug:

View File

@@ -737,10 +737,10 @@ build_obj_func() {
export smart_cco_sta=1 export smart_cco_sta=1
. ${SRC_ENV_FILE} ${IMG_TYPE} ${APP_SELECTION} ${DEF_REL} ${DEF_FLASH} ${DEF_PSRAM} . ${SRC_ENV_FILE} ${IMG_TYPE} ${APP_SELECTION} ${DEF_REL} ${DEF_FLASH} ${DEF_PSRAM}
if [ "${DEF_CLEANUP}" == "true" ]; then if [ "${DEF_CLEANUP}" == "true" ]; then
make APP=${APP_SELECTION} -C .. clobber make -j APP=${APP_SELECTION} -C .. clobber
fi fi
if [ "${APP_SELECTION}" == "${DEF_CUS_APP}" ]; then if [ "${APP_SELECTION}" == "${DEF_CUS_APP}" ]; then
make PLATFORM=${DEF_PLATFORM_TYPE} cco=1 APP=${APP_SELECTION} FLASH_SIZE=${FLASH_SIZE_nM} PLC_SUPPORT_3_PHASE=0 -C .. make -j PLATFORM=${DEF_PLATFORM_TYPE} cco=1 APP=${APP_SELECTION} FLASH_SIZE=${FLASH_SIZE_nM} PLC_SUPPORT_3_PHASE=0 -C ..
#kl3 cus_core file. #kl3 cus_core file.
cp ../ap/.output/cus/lib/ht_cco.bin ../tools/gen_img/ht_cus.bin cp ../ap/.output/cus/lib/ht_cco.bin ../tools/gen_img/ht_cus.bin
cp ../ap/.output/cus/lib/ht_cco.out ../tools/gen_img/ht_cus.out cp ../ap/.output/cus/lib/ht_cco.out ../tools/gen_img/ht_cus.out
@@ -750,14 +750,14 @@ build_obj_func() {
else else
#kl3 plc_core file. #kl3 plc_core file.
if [ "${DEF_FLASH}" == "4m" ] && [ "${DEF_PSRAM}" == "8m" ]; then if [ "${DEF_FLASH}" == "4m" ] && [ "${DEF_PSRAM}" == "8m" ]; then
make PLATFORM=${DEF_PLATFORM_TYPE} cco=1 APP=${APP_SELECTION} FLASH_SIZE=${FLASH_SIZE_nM} -C .. make -j PLATFORM=${DEF_PLATFORM_TYPE} cco=1 APP=${APP_SELECTION} FLASH_SIZE=${FLASH_SIZE_nM} -C ..
cp ../ap/.output/plc/lib/ht_cco.bin ../tools/gen_img/iot_ht_3p.bin cp ../ap/.output/plc/lib/ht_cco.bin ../tools/gen_img/iot_ht_3p.bin
cp ../ap/.output/plc/lib/ht_cco.out ../tools/gen_img/ht_3p.out cp ../ap/.output/plc/lib/ht_cco.out ../tools/gen_img/ht_3p.out
cp ../ap/.output/plc/lib/ht_cco.map ../tools/gen_img/ht_3p.map cp ../ap/.output/plc/lib/ht_cco.map ../tools/gen_img/ht_3p.map
cp ../export/lib/libht_cco.a ${taget_cco_source_dir}/libht_plc_${plc_lib_kw}_3p.a cp ../export/lib/libht_cco.a ${taget_cco_source_dir}/libht_plc_${plc_lib_kw}_3p.a
make APP=${APP_SELECTION} -C .. clobber make -j APP=${APP_SELECTION} -C .. clobber
fi fi
make PLATFORM=${DEF_PLATFORM_TYPE} cco=1 APP=${APP_SELECTION} FLASH_SIZE=${FLASH_SIZE_nM} PLC_SUPPORT_3_PHASE=0 -C .. make -j PLATFORM=${DEF_PLATFORM_TYPE} cco=1 APP=${APP_SELECTION} FLASH_SIZE=${FLASH_SIZE_nM} PLC_SUPPORT_3_PHASE=0 -C ..
cp ../ap/.output/plc/lib/ht_cco.bin ../tools/gen_img/iot_ht_1p.bin cp ../ap/.output/plc/lib/ht_cco.bin ../tools/gen_img/iot_ht_1p.bin
cp ../ap/.output/plc/lib/ht_cco.out ../tools/gen_img/ht_1p.out cp ../ap/.output/plc/lib/ht_cco.out ../tools/gen_img/ht_1p.out
cp ../ap/.output/plc/lib/ht_cco.map ../tools/gen_img/ht_1p.map cp ../ap/.output/plc/lib/ht_cco.map ../tools/gen_img/ht_1p.map
@@ -784,9 +784,9 @@ build_obj_func() {
export cco=1 export cco=1
. ${SRC_ENV_FILE} . ${SRC_ENV_FILE}
if [ "${DEF_CLEANUP}" == "true" ]; then if [ "${DEF_CLEANUP}" == "true" ]; then
make APP=${APP_SELECTION} -C .. clobber make -j APP=${APP_SELECTION} -C .. clobber
fi fi
make PLATFORM=${DEF_PLATFORM_TYPE} cco=1 APP=${APP_SELECTION} FLASH_SIZE=${FLASH_SIZE_nM} -C .. make -j PLATFORM=${DEF_PLATFORM_TYPE} cco=1 APP=${APP_SELECTION} FLASH_SIZE=${FLASH_SIZE_nM} -C ..
if [ "${APP_SELECTION}" == "${DEF_CUS_APP}" ]; then if [ "${APP_SELECTION}" == "${DEF_CUS_APP}" ]; then
#kl3 customer demo, cus_core. #kl3 customer demo, cus_core.
cp ../ap/.output/cus/lib/ht_cco.bin ../tools/gen_img/ht_cus.bin cp ../ap/.output/cus/lib/ht_cco.bin ../tools/gen_img/ht_cus.bin
@@ -833,17 +833,17 @@ build_obj_func() {
export smart_cco_sta=2 export smart_cco_sta=2
. ${SRC_ENV_FILE} ${IMG_TYPE} ${APP_SELECTION} ${DEF_REL} ${DEF_FLASH} ${DEF_PSRAM} . ${SRC_ENV_FILE} ${IMG_TYPE} ${APP_SELECTION} ${DEF_REL} ${DEF_FLASH} ${DEF_PSRAM}
if [ "${DEF_CLEANUP}" == "true" ]; then if [ "${DEF_CLEANUP}" == "true" ]; then
make APP=${APP_SELECTION} -C .. clobber make -j APP=${APP_SELECTION} -C .. clobber
fi fi
make PLATFORM=${DEF_PLATFORM_TYPE} cco=0 APP=${APP_SELECTION} FLASH_SIZE=${FLASH_SIZE_nM} -C .. make -j PLATFORM=${DEF_PLATFORM_TYPE} cco=0 APP=${APP_SELECTION} FLASH_SIZE=${FLASH_SIZE_nM} -C ..
. clean_env_flash_smart.sh ${IMG_TYPE} ${APP_SELECTION} . clean_env_flash_smart.sh ${IMG_TYPE} ${APP_SELECTION}
else else
export cco=0 export cco=0
. ${SRC_ENV_FILE} . ${SRC_ENV_FILE}
if [ "${DEF_CLEANUP}" == "true" ]; then if [ "${DEF_CLEANUP}" == "true" ]; then
make APP=${APP_SELECTION} -C .. clobber make -j APP=${APP_SELECTION} -C .. clobber
fi fi
make PLATFORM=${DEF_PLATFORM_TYPE} cco=0 APP=${APP_SELECTION} FLASH_SIZE=${FLASH_SIZE_nM} -C .. make -j PLATFORM=${DEF_PLATFORM_TYPE} cco=0 APP=${APP_SELECTION} FLASH_SIZE=${FLASH_SIZE_nM} -C ..
fi fi
if [ "${APP_SELECTION}" == "${DEF_CUS_APP}" ]; then if [ "${APP_SELECTION}" == "${DEF_CUS_APP}" ]; then
@@ -883,10 +883,10 @@ build_obj_func() {
. ${SRC_ENV_FILE} . ${SRC_ENV_FILE}
if [ "${DEF_CLEANUP}" == "true" ]; then if [ "${DEF_CLEANUP}" == "true" ]; then
make APP=${APP_SELECTION} -C .. clobber make -j APP=${APP_SELECTION} -C .. clobber
fi fi
make PLATFORM=${DEF_PLATFORM_TYPE} cco=0 APP=${APP_SELECTION} FLASH_SIZE=${FLASH_SIZE_nM} -C .. make -j PLATFORM=${DEF_PLATFORM_TYPE} cco=0 APP=${APP_SELECTION} FLASH_SIZE=${FLASH_SIZE_nM} -C ..
cp ../ap/.output/plc/lib/ht_ftm.bin ../tools/gen_img/ht.bin cp ../ap/.output/plc/lib/ht_ftm.bin ../tools/gen_img/ht.bin
cp ../ap/.output/plc/lib/ht_ftm.out ../tools/gen_img/ht.out cp ../ap/.output/plc/lib/ht_ftm.out ../tools/gen_img/ht.out
@@ -899,10 +899,10 @@ build_obj_func() {
. ${SRC_ENV_FILE} . ${SRC_ENV_FILE}
if [ "${DEF_CLEANUP}" == "true" ]; then if [ "${DEF_CLEANUP}" == "true" ]; then
make APP=${APP_SELECTION} -C .. clobber make -j APP=${APP_SELECTION} -C .. clobber
fi fi
make PLATFORM=${DEF_PLATFORM_TYPE} cco=0 APP=${APP_SELECTION} FLASH_SIZE=${FLASH_SIZE_nM} -C .. make -j PLATFORM=${DEF_PLATFORM_TYPE} cco=0 APP=${APP_SELECTION} FLASH_SIZE=${FLASH_SIZE_nM} -C ..
cp ../ap/.output/plc/lib/ht_sta.bin ../tools/gen_img/ht.bin cp ../ap/.output/plc/lib/ht_sta.bin ../tools/gen_img/ht.bin
cp ../ap/.output/plc/lib/ht_sta.out ../tools/gen_img/ht.out cp ../ap/.output/plc/lib/ht_sta.out ../tools/gen_img/ht.out

View File

@@ -283,7 +283,7 @@ SIZE = riscv64-unknown-elf-size
OBJCOPY = riscv64-unknown-elf-objcopy OBJCOPY = riscv64-unknown-elf-objcopy
STRIP = riscv64-unknown-elf-strip STRIP = riscv64-unknown-elf-strip
MAKEDEP = -MM MAKEDEP = -MM
FLAGS = -march=$(ISA) -mabi=$(ABI) -ffunction-sections -fdata-sections -ffast-math -fno-common -fno-builtin-printf -Wall $(GDB_FLAG) $(OPT_FLAG)\ FLAGS = -march=$(ISA) -mabi=$(ABI) -ffunction-sections -fdata-sections -ffast-math -fno-common -Wno-array-bounds -fno-builtin-printf -Wall $(GDB_FLAG) $(OPT_FLAG)\
$(addprefix -D, $(PRE_MARCO))\ $(addprefix -D, $(PRE_MARCO))\
$(addprefix -D, $(GLOBAL_MACRO))\ $(addprefix -D, $(GLOBAL_MACRO))\
$(addprefix -I, $(ADD_INCLUDE)) $(addprefix -I, $(ADD_INCLUDE))
@@ -306,7 +306,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 @python3 $(TOPDIR)/praper_vscode.py $(TOPDIR)/make_flags.txt $@ >> $(TOPDIR)/python_script_log.log
@for d in $(SUB_DIRS); do\ @for d in $(SUB_DIRS); do\
if [ -e "$$d/Makefile" ]; then\ if [ -e "$$d/Makefile" ]; then\
make -C $$d || exit 1;\ $(MAKE) -C $$d || exit 1;\
if [ 2 -eq $(OUTPUT_TYPE) ];then\ if [ 2 -eq $(OUTPUT_TYPE) ];then\
if [ -e $(OUTPUT_FULL_NAME) ]; then \ if [ -e $(OUTPUT_FULL_NAME) ]; then \
echo "open $(OUTPUT_FULL_NAME)">tmp.mri;\ echo "open $(OUTPUT_FULL_NAME)">tmp.mri;\
@@ -373,7 +373,7 @@ $(BIN_DIR)/%.d: %.c
@set -e; rm -f $@; \ @set -e; rm -f $@; \
$(CC) $(FLAGS) $(MAKEDEP) $< > $@.$$$$; \ $(CC) $(FLAGS) $(MAKEDEP) $< > $@.$$$$; \
sed 's,\($(notdir $*)\.o\)[: ]*,$(BIN_DIR)\/$*\.o : ,' < $@.$$$$ > $@; \ sed 's,\($(notdir $*)\.o\)[: ]*,$(BIN_DIR)\/$*\.o : ,' < $@.$$$$ > $@; \
echo -e -n "\t@echo 'build \x24@'\x0a" >> $@; \ echo -e -n "\t@echo 'build \x24<'\x0a" >> $@; \
echo -e -n "\t@\x24(CC) \x24(FLAGS) -c \x24< -o \x24@" >> $@; \ echo -e -n "\t@\x24(CC) \x24(FLAGS) -c \x24< -o \x24@" >> $@; \
$(RM) $@.$$$$ $(RM) $@.$$$$
@@ -383,7 +383,7 @@ $(BIN_DIR)/%.d: %.S
@set -e; rm -f $@; \ @set -e; rm -f $@; \
$(CC) $(MAKEDEP) $(FLAGS) $< > $@.$$$$; \ $(CC) $(MAKEDEP) $(FLAGS) $< > $@.$$$$; \
sed 's,\($(notdir $*)\.o\)[ : ]*,$(BIN_DIR)\/$*\.o : ,' < $@.$$$$ > $@; \ sed 's,\($(notdir $*)\.o\)[ : ]*,$(BIN_DIR)\/$*\.o : ,' < $@.$$$$ > $@; \
echo -e -n "\t@echo 'build \x24@'\x0a" >> $@; \ echo -e -n "\t@echo 'build \x24<'\x0a" >> $@; \
echo -e -n "\t@\x24(CC) \x24(FLAGS) -c \x24< -o \x24@" >> $@; \ echo -e -n "\t@\x24(CC) \x24(FLAGS) -c \x24< -o \x24@" >> $@; \
$(RM) $@.$$$$ $(RM) $@.$$$$
@@ -396,7 +396,7 @@ clean:
-$(RM) $(OUTPUT_FULL_NAME) $(OBJECTS) $(DEPS) $(BIN_DIR)/.sub_dirs $(BIN_DIR)/.ext_src -$(RM) $(OUTPUT_FULL_NAME) $(OBJECTS) $(DEPS) $(BIN_DIR)/.sub_dirs $(BIN_DIR)/.ext_src
@for d in $(SUB_DIRS) ; do\ @for d in $(SUB_DIRS) ; do\
if [ -e "$$d/Makefile" ]; then\ if [ -e "$$d/Makefile" ]; then\
make -C $$d $@ ;\ $(MAKE) -C $$d $@ ;\
fi;\ fi;\
done done
-$(RM) $(OUTDIR) -$(RM) $(OUTDIR)
@@ -404,7 +404,7 @@ clean:
clobber: clobber:
@for d in $(SUB_DIRS); do\ @for d in $(SUB_DIRS); do\
if [ -e "$$d/Makefile" ]; then\ if [ -e "$$d/Makefile" ]; then\
make -C $$d $@ ;\ $(MAKE) -C $$d $@ ;\
fi;\ fi;\
done done
@-$(RM) $(TOPDIR)/make_flags.txt @-$(RM) $(TOPDIR)/make_flags.txt
@@ -417,7 +417,7 @@ clean_objs:
-$(RM) $(OBJECTS) -$(RM) $(OBJECTS)
@for d in $(SUB_DIRS); do\ @for d in $(SUB_DIRS); do\
if [ -e "$$d/Makefile" ]; then\ if [ -e "$$d/Makefile" ]; then\
make -C $$d $@ ;\ $(MAKE) -C $$d $@ ;\
fi;\ fi;\
done done

View File

@@ -51,10 +51,7 @@ include $(CURDIR)/build/makefile.cfg
TOPDIR = $(CURDIR) TOPDIR = $(CURDIR)
export TOPDIR export TOPDIR
endif endif
TARGET:: $(OUTPUT_FULL_NAME) USR_CMD TARGET:: $(OUTPUT_FULL_NAME)
# usr_cmd
USR_CMD::
@echo "const char mailbox_core1[] = {" > mailbox_core1.h @echo "const char mailbox_core1[] = {" > mailbox_core1.h
@./bin2hex_frame $(OUTPUT_FULL_NAME:.out=.bin) tmp.txt @./bin2hex_frame $(OUTPUT_FULL_NAME:.out=.bin) tmp.txt
@cat tmp.txt >> mailbox_core1.h @cat tmp.txt >> mailbox_core1.h

View File

@@ -52,10 +52,7 @@ TOPDIR = $(CURDIR)
export TOPDIR export TOPDIR
endif endif
TARGET:: $(OUTPUT_FULL_NAME) USR_CMD TARGET:: $(OUTPUT_FULL_NAME)
# usr_cmd
USR_CMD::
@echo "const char mailbox_core2[] = {" > mailbox_core2.h @echo "const char mailbox_core2[] = {" > mailbox_core2.h
@./bin2hex_frame $(OUTPUT_FULL_NAME:.out=.bin) tmp.txt @./bin2hex_frame $(OUTPUT_FULL_NAME:.out=.bin) tmp.txt
@cat tmp.txt >> mailbox_core2.h @cat tmp.txt >> mailbox_core2.h

View File

@@ -52,9 +52,7 @@ TOPDIR = $(CURDIR)
export TOPDIR export TOPDIR
endif endif
TARGET:: $(OUTPUT_FULL_NAME) USR_CMD TARGET:: $(OUTPUT_FULL_NAME)
# usr_cmd
USR_CMD::
@echo "const char plc_core1[] = {" > plc_core1.h @echo "const char plc_core1[] = {" > plc_core1.h
@./bin2hex_frame $(OUTPUT_FULL_NAME:.out=.bin) tmp.txt @./bin2hex_frame $(OUTPUT_FULL_NAME:.out=.bin) tmp.txt
@cat tmp.txt >> plc_core1.h @cat tmp.txt >> plc_core1.h

View File

@@ -51,10 +51,7 @@ include $(CURDIR)/build/makefile.cfg
TOPDIR = $(CURDIR) TOPDIR = $(CURDIR)
export TOPDIR export TOPDIR
endif endif
TARGET:: $(OUTPUT_FULL_NAME) USR_CMD TARGET:: $(OUTPUT_FULL_NAME)
# usr_cmd
USR_CMD::
@echo "const char wdg_core1[] = {" > wdg_core1.h @echo "const char wdg_core1[] = {" > wdg_core1.h
@./bin2hex_frame $(OUTPUT_FULL_NAME:.out=.bin) tmp.txt @./bin2hex_frame $(OUTPUT_FULL_NAME:.out=.bin) tmp.txt
@cat tmp.txt >> wdg_core1.h @cat tmp.txt >> wdg_core1.h

View File

@@ -52,10 +52,7 @@ TOPDIR = $(CURDIR)
export TOPDIR export TOPDIR
endif endif
TARGET:: $(OUTPUT_FULL_NAME) USR_CMD TARGET:: $(OUTPUT_FULL_NAME)
# usr_cmd
USR_CMD::
@echo "const char wdg_core2[] = {" > wdg_core2.h @echo "const char wdg_core2[] = {" > wdg_core2.h
@./bin2hex_frame $(OUTPUT_FULL_NAME:.out=.bin) tmp.txt @./bin2hex_frame $(OUTPUT_FULL_NAME:.out=.bin) tmp.txt
@cat tmp.txt >> wdg_core2.h @cat tmp.txt >> wdg_core2.h

View File

@@ -50,7 +50,13 @@ ADD_LIB += os driver common rf_mac
##################################################### #####################################################
.PHONY: TARGET .PHONY: TARGET
TARGET: .output/plc/lib/kl3_core1.out USR_CMD TARGET: .output/plc/lib/kl3_core1.out
@echo "const char plc_core1[] = {" > plc_core1.h
@./bin2hex_frame ../kl3_core1/.output/plc/lib/kl3_core1.bin tmp.txt
@cat tmp.txt >> plc_core1.h
@echo "};" >> plc_core1.h
@mv plc_core1.h ../kl3_core0
@rm -rf tmp.txt
ifdef TOPDIR ifdef TOPDIR
include $(TOPDIR)/build/makefile.cfg include $(TOPDIR)/build/makefile.cfg
@@ -60,14 +66,6 @@ TOPDIR = $(CURDIR)
export TOPDIR export TOPDIR
endif endif
# usr_cmd
USR_CMD::
@echo "const char plc_core1[] = {" > plc_core1.h
@./bin2hex_frame ../kl3_core1/.output/plc/lib/kl3_core1.bin tmp.txt
@cat tmp.txt >> plc_core1.h
@echo "};" >> plc_core1.h
@mv plc_core1.h ../kl3_core0
@rm -rf tmp.txt
dump: dump:
$(OBJDUMP) -D -S -l $(OUTPUT_FULL_NAME) > $(OUTPUT_FULL_NAME).dump $(OBJDUMP) -D -S -l $(OUTPUT_FULL_NAME) > $(OUTPUT_FULL_NAME).dump

View File

@@ -3,8 +3,38 @@ import os
import sys import sys
import time import time
'''
这个文件用于编译时输出编译符号在makefile.cfg中调用
自动更新vscode的c/c++配置
2024.9.28
根据脚本位置来确定位置文件路径
使用非冗余的路径
使用宏定义字符转义
'''
def unescape(line:str):
table=[("\\\"","\""),("\\<","<"),("\\>",">"),("\\$","$"),("\\(","("),("\\)",")")]
for item in table:
line=line.replace(item[0],item[1])
# 删除多余的 $ 符号
line=line.replace('$','')
return line
def main(flag_file:str,target:str): def main(flag_file:str,target:str):
make_flags=flag_file make_flags=flag_file
top_path=os.path.split(sys.argv[0])[0]
current_path=os.path.abspath('.') current_path=os.path.abspath('.')
if(make_flags!='clear'): if(make_flags!='clear'):
with open(make_flags,encoding='utf-8') as f: with open(make_flags,encoding='utf-8') as f:
@@ -14,7 +44,7 @@ def main(flag_file:str,target:str):
else: else:
flags="" flags=""
print(time.strftime("%Y-%m-%d %H:%M:%S"),"clear vscode setting.") print(time.strftime("%Y-%m-%d %H:%M:%S"),"clear vscode setting.")
cfgs_file_path='/mnt/disk/work/kunlun/.vscode/c_cpp_properties.json' cfgs_file_path=f'{top_path}/.vscode/c_cpp_properties.json'
with open(cfgs_file_path,encoding='utf-8') as f: with open(cfgs_file_path,encoding='utf-8') as f:
cfgs=f.read() cfgs=f.read()
@@ -24,11 +54,12 @@ def main(flag_file:str,target:str):
def_list=[] def_list=[]
for item in flags_list: for item in flags_list:
if(item[:2]=='-D'): if(item[:2]=='-D'):
def_list.append(item[2:]) def_list.append(unescape(item[2:]))
elif(item[:2]=='-I'): elif(item[:2]=='-I'):
p=item[2:] p=item[2:]
if(p[0]!='/'): if(p[0]!='/'):
p=os.path.join(current_path,p) p=os.path.join(current_path,p)
p=os.path.normpath(p)
if(os.path.exists(p)): if(os.path.exists(p)):
inc_list.append(p) inc_list.append(p)
else: else:
@@ -40,6 +71,7 @@ def main(flag_file:str,target:str):
if(make_flags!='clear'): if(make_flags!='clear'):
predef_info["name"]="myname" predef_info["name"]="myname"
for item in inc_list: for item in inc_list:
# 只有路径列表中不存在时才添加
if(item not in predef_info["includePath"]): if(item not in predef_info["includePath"]):
predef_info["includePath"].append(item) predef_info["includePath"].append(item)
for item in def_list: for item in def_list: