添加一些可能有用的python脚本
This commit is contained in:
129
creat_mm.py
Executable file
129
creat_mm.py
Executable file
@@ -0,0 +1,129 @@
|
|||||||
|
import os
|
||||||
|
import sys
|
||||||
|
|
||||||
|
|
||||||
|
# 这个文件放在out文件夹中运行
|
||||||
|
|
||||||
|
_file_list='''
|
||||||
|
|
||||||
|
device/soc/wtz/wtz31x/source/Mainline/ap/src/dprintf.c
|
||||||
|
device/soc/wtz/wtz31x/source/Mainline/ap/src/main.c
|
||||||
|
device/soc/wtz/wtz31x/source/Mainline/ap/src/read_flash.c
|
||||||
|
device/soc/wtz/wtz31x/source/Mainline/common/dbglog/iot_dbglog.c
|
||||||
|
device/soc/wtz/wtz31x/source/Mainline/common/io_lib/src/iot_mem.c
|
||||||
|
device/soc/wtz/wtz31x/source/Mainline/common/io_lib/src/iot_printf.c
|
||||||
|
device/soc/wtz/wtz31x/source/Mainline/common/io_lib/src/iot_snprintf.c
|
||||||
|
device/soc/wtz/wtz31x/source/Mainline/common/io_lib/src/iot_sprintf.c
|
||||||
|
device/soc/wtz/wtz31x/source/Mainline/common/io_lib/src/iot_strformat.c
|
||||||
|
device/soc/wtz/wtz31x/source/Mainline/common/io_lib/src/iot_string.c
|
||||||
|
device/soc/wtz/wtz31x/source/Mainline/common/os_shim/liteos/src/os_event.c
|
||||||
|
device/soc/wtz/wtz31x/source/Mainline/common/os_shim/liteos/src/os_lock.c
|
||||||
|
device/soc/wtz/wtz31x/source/Mainline/common/os_shim/liteos/src/os_malloc.c
|
||||||
|
device/soc/wtz/wtz31x/source/Mainline/common/os_shim/liteos/src/os_mem.c
|
||||||
|
device/soc/wtz/wtz31x/source/Mainline/common/os_shim/liteos/src/os_task.c
|
||||||
|
device/soc/wtz/wtz31x/source/Mainline/common/os_shim/liteos/src/os_timer.c
|
||||||
|
device/soc/wtz/wtz31x/source/Mainline/common/os_shim/liteos/src/os_utils.c
|
||||||
|
|
||||||
|
device/soc/wtz/wtz31x/source/Mainline/driver/src/hal/board_info.c
|
||||||
|
device/soc/wtz/wtz31x/source/Mainline/driver/src/hal/clock.c
|
||||||
|
device/soc/wtz/wtz31x/source/Mainline/driver/src/hal/debug_uart.c
|
||||||
|
device/soc/wtz/wtz31x/source/Mainline/driver/src/hal/flash.c
|
||||||
|
device/soc/wtz/wtz31x/source/Mainline/driver/src/hal/iot_gp_timer.c
|
||||||
|
device/soc/wtz/wtz31x/source/Mainline/driver/src/hal/iot_gpio.c
|
||||||
|
device/soc/wtz/wtz31x/source/Mainline/driver/src/hal/iot_spinlock.c
|
||||||
|
device/soc/wtz/wtz31x/source/Mainline/driver/src/hal/iot_uart_h.c
|
||||||
|
device/soc/wtz/wtz31x/source/Mainline/driver/src/hal/irq.c
|
||||||
|
device/soc/wtz/wtz31x/source/Mainline/driver/src/hal/led.c
|
||||||
|
device/soc/wtz/wtz31x/source/Mainline/driver/src/hal/mtd.c
|
||||||
|
device/soc/wtz/wtz31x/source/Mainline/driver/src/hal/vfs_uart.c
|
||||||
|
|
||||||
|
device/soc/wtz/wtz31x/source/Mainline/driver/src/hw3/ahb.c
|
||||||
|
device/soc/wtz/wtz31x/source/Mainline/driver/src/hw3/ana.c
|
||||||
|
device/soc/wtz/wtz31x/source/Mainline/driver/src/hw3/apb.c
|
||||||
|
device/soc/wtz/wtz31x/source/Mainline/driver/src/hw3/board_info_hw.c
|
||||||
|
device/soc/wtz/wtz31x/source/Mainline/driver/src/hw3/clk.c
|
||||||
|
device/soc/wtz/wtz31x/source/Mainline/driver/src/hw3/cpu.c
|
||||||
|
device/soc/wtz/wtz31x/source/Mainline/driver/src/hw3/dev_spinlock.c
|
||||||
|
device/soc/wtz/wtz31x/source/Mainline/driver/src/hw3/gp_timer.c
|
||||||
|
device/soc/wtz/wtz31x/source/Mainline/driver/src/hw3/gpio_hw.c
|
||||||
|
device/soc/wtz/wtz31x/source/Mainline/driver/src/hw3/gpio_mtx.c
|
||||||
|
device/soc/wtz/wtz31x/source/Mainline/driver/src/hw3/intc.c
|
||||||
|
device/soc/wtz/wtz31x/source/Mainline/driver/src/hw3/pll_cal.c
|
||||||
|
device/soc/wtz/wtz31x/source/Mainline/driver/src/hw3/sfc.c
|
||||||
|
device/soc/wtz/wtz31x/source/Mainline/driver/src/hw3/smc.c
|
||||||
|
device/soc/wtz/wtz31x/source/Mainline/driver/src/hw3/system_hw.c
|
||||||
|
device/soc/wtz/wtz31x/source/Mainline/driver/src/hw3/uart_e.c
|
||||||
|
device/soc/wtz/wtz31x/source/Mainline/driver/src/hw3/wdg.c
|
||||||
|
|
||||||
|
device/soc/wtz/wtz31x/source/Mainline/hals/update/hal_hota_board.c
|
||||||
|
device/soc/wtz/wtz31x/source/Mainline/hals/utils/file/src/hal_file.c
|
||||||
|
device/soc/wtz/wtz31x/source/Mainline/os/liteos/src/version.c
|
||||||
|
device/soc/wtz/wtz31x/source/Mainline/startup/riscv3/src/entry_def.S
|
||||||
|
device/soc/wtz/wtz31x/source/Mainline/startup/riscv3/src/exception.c
|
||||||
|
device/soc/wtz/wtz31x/source/Mainline/startup/riscv3/src/platform.c
|
||||||
|
device/soc/wtz/wtz31x/source/Mainline/startup/riscv3/src/start.S
|
||||||
|
device/soc/wtz/wtz31x/source/Mainline/startup/riscv3/src/startup_init.c
|
||||||
|
|
||||||
|
'''.split()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# 生成依赖文件
|
||||||
|
def creat_mm():
|
||||||
|
_tmp_file="../../../ninja_commands.txt"
|
||||||
|
c_file_list=[]
|
||||||
|
with open(_tmp_file) as f:
|
||||||
|
for item in f.readlines():
|
||||||
|
item_sp=item.split()
|
||||||
|
for item_x in item_sp:
|
||||||
|
item_x_fix=item_x.split('.')[-1]
|
||||||
|
if(item_x_fix in ['c','cpp','C','CPP','S','s']):
|
||||||
|
f_path=item_x[9:]
|
||||||
|
if f_path not in c_file_list:
|
||||||
|
c_file_list.append(f_path)
|
||||||
|
if(f_path in _file_list):
|
||||||
|
# 在文件列表之中的文件,需要生成依赖关系
|
||||||
|
out_file_name=f'out/{os.path.split(f_path)[-1]}.d'
|
||||||
|
cmd_str_list=[item_sp[1],'-MM']+item_sp[2:-1]+[out_file_name]
|
||||||
|
cmd_str=' '.join(cmd_str_list)
|
||||||
|
# print(cmd_str)
|
||||||
|
if(os.path.exists(out_file_name)):
|
||||||
|
print(f"文件 {out_file_name} 已经存在")
|
||||||
|
os.system(cmd_str)
|
||||||
|
# os.remove(_tmp_file)
|
||||||
|
c_file_list.sort()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# 列出依赖的文件
|
||||||
|
def list_depend_files():
|
||||||
|
dir='out'
|
||||||
|
# save_file=open(dir+'/depend_list.txt',mode='w+')
|
||||||
|
depend_list=[]
|
||||||
|
file_list=os.listdir(dir)
|
||||||
|
for item in file_list:
|
||||||
|
ps=os.path.join(dir,item)
|
||||||
|
with open(ps) as f:
|
||||||
|
lines=f.readlines()
|
||||||
|
for line in lines:
|
||||||
|
line=line.replace('\\','').strip()
|
||||||
|
if(line[-1]!=':'):
|
||||||
|
path=os.path.abspath(line)
|
||||||
|
if(path not in depend_list):
|
||||||
|
print(path)
|
||||||
|
depend_list.append(path)
|
||||||
|
depend_list.sort()
|
||||||
|
with open(dir+'/depend_list.txt',mode='w+') as f:
|
||||||
|
for item in depend_list:
|
||||||
|
f.write(item+'\n')
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
# main()
|
||||||
|
# creat_mm()
|
||||||
|
list_depend_files()
|
||||||
|
|
||||||
|
|
@@ -1,162 +0,0 @@
|
|||||||
[
|
|
||||||
{
|
|
||||||
"file:": "/home/andy/harmony/PowerHarmony_PHM_SDK_V1.0.1.0/out/htzd3201_board/htzd3201_product_demo/obj/kernel/liteos_m/liteos.ninja",
|
|
||||||
"values": [
|
|
||||||
"-static",
|
|
||||||
"-Wl,--gc-sections",
|
|
||||||
"-Wl,-Map=OHOS_Image.map",
|
|
||||||
"--specs=nano.specs",
|
|
||||||
"-Wl,--gc-sections",
|
|
||||||
"-Wl,--wrap=_calloc_r",
|
|
||||||
"-Wl,--wrap=_malloc_r",
|
|
||||||
"-Wl,--wrap=_realloc_r",
|
|
||||||
"-Wl,--wrap=_reallocf_r",
|
|
||||||
"-Wl,--wrap=_free_r",
|
|
||||||
"-Wl,--wrap=_memalign_r",
|
|
||||||
"-Wl,--wrap=_malloc_usable_size_r",
|
|
||||||
"-mabi=ilp32",
|
|
||||||
"-falign-functions=2",
|
|
||||||
"-msave-restore",
|
|
||||||
"-fno-optimize-strlen",
|
|
||||||
"-freorder-blocks-algorithm=simple",
|
|
||||||
"-fno-schedule-insns",
|
|
||||||
"-fno-inline-small-functions",
|
|
||||||
"-fno-inline-functions-called-once",
|
|
||||||
"-mtune=size",
|
|
||||||
"-mno-small-data-limit=0",
|
|
||||||
"-fno-aggressive-loop-optimizations",
|
|
||||||
"-Wpointer-arith",
|
|
||||||
"-ffunction-sections",
|
|
||||||
"-fdata-sections",
|
|
||||||
"-fno-exceptions",
|
|
||||||
"-fno-short-enums",
|
|
||||||
"-D__LITEOS__M",
|
|
||||||
"-nostartfiles",
|
|
||||||
"-mstrict-align",
|
|
||||||
"-march=rv32i",
|
|
||||||
"-L.",
|
|
||||||
"-Wl,-rpath-link=.",
|
|
||||||
"-Wl,-T/home/andy/harmony/PowerHarmony_PHM_SDK_V1.0.1.0/device/soc/htzd/htzd32xx/kunlun/Mainline/startup/ldscripts/riscv3/link_psram_8m_cco_plc_only.ld",
|
|
||||||
"-Wl,-u_printf_float"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"file:": "/home/andy/harmony/PowerHarmony_PHM_SDK_V1.0.1.0/out/htzd3201_board/htzd3201_product_demo/obj/device/board/csg/htzd3201_board/htzd3201_htzd3201_board.ninja",
|
|
||||||
"values": [
|
|
||||||
"-Wl,--gc-sections",
|
|
||||||
"-Wl,-Map=bin/htzd3201_htzd3201_board.map",
|
|
||||||
"-L/home/andy/harmony/PowerHarmony_PHM_SDK_V1.0.1.0/out/htzd3201_board/htzd3201_product_demo/libs",
|
|
||||||
"--specs=nano.specs",
|
|
||||||
"-Wl,--gc-sections",
|
|
||||||
"-Wl,--wrap=_calloc_r",
|
|
||||||
"-Wl,--wrap=_malloc_r",
|
|
||||||
"-Wl,--wrap=_realloc_r",
|
|
||||||
"-Wl,--wrap=_reallocf_r",
|
|
||||||
"-Wl,--wrap=_free_r",
|
|
||||||
"-Wl,--wrap=_memalign_r",
|
|
||||||
"-Wl,--wrap=_malloc_usable_size_r",
|
|
||||||
"-mabi=ilp32",
|
|
||||||
"-falign-functions=2",
|
|
||||||
"-msave-restore",
|
|
||||||
"-fno-optimize-strlen",
|
|
||||||
"-freorder-blocks-algorithm=simple",
|
|
||||||
"-fno-schedule-insns",
|
|
||||||
"-fno-inline-small-functions",
|
|
||||||
"-fno-inline-functions-called-once",
|
|
||||||
"-mtune=size",
|
|
||||||
"-mno-small-data-limit=0",
|
|
||||||
"-fno-aggressive-loop-optimizations",
|
|
||||||
"-Wpointer-arith",
|
|
||||||
"-ffunction-sections",
|
|
||||||
"-fdata-sections",
|
|
||||||
"-fno-exceptions",
|
|
||||||
"-fno-short-enums",
|
|
||||||
"-D__LITEOS__M",
|
|
||||||
"-nostartfiles",
|
|
||||||
"-mstrict-align",
|
|
||||||
"-march=rv32i",
|
|
||||||
"-L.",
|
|
||||||
"-Wl,-rpath-link=.",
|
|
||||||
"-Wl,-T/home/andy/harmony/PowerHarmony_PHM_SDK_V1.0.1.0/device/soc/htzd/htzd32xx/kunlun/Mainline/startup/ldscripts/riscv3/link_psram_8m_cco_plc_only.ld",
|
|
||||||
"-Wl,-u_printf_float"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"file:": "/home/andy/harmony/PowerHarmony_PHM_SDK_V1.0.1.0/out/htzd3201_board/htzd3201_product_demo/obj/base/startup/init/watchdog/watchdog_service.ninja",
|
|
||||||
"values": [
|
|
||||||
"--specs=nano.specs",
|
|
||||||
"-Wl,--gc-sections",
|
|
||||||
"-Wl,--wrap=_calloc_r",
|
|
||||||
"-Wl,--wrap=_malloc_r",
|
|
||||||
"-Wl,--wrap=_realloc_r",
|
|
||||||
"-Wl,--wrap=_reallocf_r",
|
|
||||||
"-Wl,--wrap=_free_r",
|
|
||||||
"-Wl,--wrap=_memalign_r",
|
|
||||||
"-Wl,--wrap=_malloc_usable_size_r",
|
|
||||||
"-mabi=ilp32",
|
|
||||||
"-falign-functions=2",
|
|
||||||
"-msave-restore",
|
|
||||||
"-fno-optimize-strlen",
|
|
||||||
"-freorder-blocks-algorithm=simple",
|
|
||||||
"-fno-schedule-insns",
|
|
||||||
"-fno-inline-small-functions",
|
|
||||||
"-fno-inline-functions-called-once",
|
|
||||||
"-mtune=size",
|
|
||||||
"-mno-small-data-limit=0",
|
|
||||||
"-fno-aggressive-loop-optimizations",
|
|
||||||
"-Wpointer-arith",
|
|
||||||
"-ffunction-sections",
|
|
||||||
"-fdata-sections",
|
|
||||||
"-fno-exceptions",
|
|
||||||
"-fno-short-enums",
|
|
||||||
"-D__LITEOS__M",
|
|
||||||
"-nostartfiles",
|
|
||||||
"-mstrict-align",
|
|
||||||
"-march=rv32i",
|
|
||||||
"-L.",
|
|
||||||
"-Wl,-rpath-link=.",
|
|
||||||
"-Wl,-T/home/andy/harmony/PowerHarmony_PHM_SDK_V1.0.1.0/device/soc/htzd/htzd32xx/kunlun/Mainline/startup/ldscripts/riscv3/link_psram_8m_cco_plc_only.ld",
|
|
||||||
"-Wl,-u_printf_float"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"file:": "/home/andy/harmony/PowerHarmony_PHM_SDK_V1.0.1.0/out/htzd3201_board/htzd3201_product_demo/obj/base/startup/init/services/begetctl/begetctl.ninja",
|
|
||||||
"values": [
|
|
||||||
"-lbegetutil_ph",
|
|
||||||
"--specs=nano.specs",
|
|
||||||
"-Wl,--gc-sections",
|
|
||||||
"-Wl,--wrap=_calloc_r",
|
|
||||||
"-Wl,--wrap=_malloc_r",
|
|
||||||
"-Wl,--wrap=_realloc_r",
|
|
||||||
"-Wl,--wrap=_reallocf_r",
|
|
||||||
"-Wl,--wrap=_free_r",
|
|
||||||
"-Wl,--wrap=_memalign_r",
|
|
||||||
"-Wl,--wrap=_malloc_usable_size_r",
|
|
||||||
"-mabi=ilp32",
|
|
||||||
"-falign-functions=2",
|
|
||||||
"-msave-restore",
|
|
||||||
"-fno-optimize-strlen",
|
|
||||||
"-freorder-blocks-algorithm=simple",
|
|
||||||
"-fno-schedule-insns",
|
|
||||||
"-fno-inline-small-functions",
|
|
||||||
"-fno-inline-functions-called-once",
|
|
||||||
"-mtune=size",
|
|
||||||
"-mno-small-data-limit=0",
|
|
||||||
"-fno-aggressive-loop-optimizations",
|
|
||||||
"-Wpointer-arith",
|
|
||||||
"-ffunction-sections",
|
|
||||||
"-fdata-sections",
|
|
||||||
"-fno-exceptions",
|
|
||||||
"-fno-short-enums",
|
|
||||||
"-D__LITEOS__M",
|
|
||||||
"-nostartfiles",
|
|
||||||
"-mstrict-align",
|
|
||||||
"-march=rv32i",
|
|
||||||
"-L.",
|
|
||||||
"-Wl,-rpath-link=.",
|
|
||||||
"-Wl,-T/home/andy/harmony/PowerHarmony_PHM_SDK_V1.0.1.0/device/soc/htzd/htzd32xx/kunlun/Mainline/startup/ldscripts/riscv3/link_psram_8m_cco_plc_only.ld",
|
|
||||||
"-Wl,-u_printf_float",
|
|
||||||
"-lm"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
29
list_files.py
Executable file
29
list_files.py
Executable file
@@ -0,0 +1,29 @@
|
|||||||
|
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# 找到指定后缀的文件
|
||||||
|
def find_type(path:str,fix:str):
|
||||||
|
dlist=os.listdir(path)
|
||||||
|
file_list=[]
|
||||||
|
for i in dlist:
|
||||||
|
ps=os.path.join(path, i)
|
||||||
|
if os.path.isdir(ps):
|
||||||
|
# file_list+=find_type(ps,fix)
|
||||||
|
pass
|
||||||
|
else:
|
||||||
|
if(ps[-len(fix):]==fix):
|
||||||
|
file_list.append(ps)
|
||||||
|
return file_list
|
||||||
|
|
||||||
|
|
||||||
|
# 第一个参数是扫描路径,第二个参数是文件类型
|
||||||
|
if __name__ == "__main__":
|
||||||
|
|
||||||
|
f_list=find_type(sys.argv[1],sys.argv[2])
|
||||||
|
for item in f_list:
|
||||||
|
print(item)
|
||||||
|
|
87
replace_file.py
Executable file
87
replace_file.py
Executable file
@@ -0,0 +1,87 @@
|
|||||||
|
import os
|
||||||
|
import sys
|
||||||
|
|
||||||
|
# 导入要修改的文件列表
|
||||||
|
from remove_file import src_files
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# 找到文件列表中的所有源文件
|
||||||
|
def list_type_files(file_list:list,tail:str):
|
||||||
|
src_list=[]
|
||||||
|
for item in file_list:
|
||||||
|
if(str(item).endswith(tail)):
|
||||||
|
src_list.append(item)
|
||||||
|
return src_list
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# 生成要修改的文件名称列表
|
||||||
|
def create_modify_name(file_list:list):
|
||||||
|
modify_name=[]
|
||||||
|
for item in file_list:
|
||||||
|
sp=os.path.split(item)
|
||||||
|
if(sp[-1].startswith('iot_')):
|
||||||
|
path=os.path.join(sp[0],sp[-1].replace('iot_','sw_'))
|
||||||
|
modify_name.append((item,path))
|
||||||
|
return modify_name
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# 修改名称
|
||||||
|
def file_list_rename(rename_list:list):
|
||||||
|
for src,dst in rename_list:
|
||||||
|
os.rename(src,dst)
|
||||||
|
|
||||||
|
|
||||||
|
# 生成要修改的头文件字符串
|
||||||
|
def create_modify_strings(modify_files:list):
|
||||||
|
modify_list=[]
|
||||||
|
for src,dst in modify_files:
|
||||||
|
ps_src=os.path.split(src)[-1]
|
||||||
|
ps_dst=os.path.split(dst)[-1]
|
||||||
|
if(ps_src.endswith('.h')):
|
||||||
|
modify_list.append((ps_src,ps_dst))
|
||||||
|
return modify_list
|
||||||
|
|
||||||
|
# 修改源文件中的include
|
||||||
|
def modify_include(file_list:list,replace_list:list):
|
||||||
|
for item in file_list:
|
||||||
|
try:
|
||||||
|
with open(item,mode='r') as f:
|
||||||
|
lines=f.readlines()
|
||||||
|
except Exception as e:
|
||||||
|
print(e)
|
||||||
|
print(f"file {item} open failed.")
|
||||||
|
continue
|
||||||
|
for replace in replace_list:
|
||||||
|
for i in range(len(lines)):
|
||||||
|
if(lines[i].startswith("#include")):
|
||||||
|
lines[i]=lines[i].replace(replace[0],replace[1])
|
||||||
|
with open(item,mode='w+') as f:
|
||||||
|
for item in lines:
|
||||||
|
f.write(item)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
# 第一步,生成需要修改的文件列表
|
||||||
|
md_files=create_modify_name(src_files)
|
||||||
|
# for item in md_files:
|
||||||
|
# print('---')
|
||||||
|
# print(item[0])
|
||||||
|
# print(item[1])
|
||||||
|
# 第二步,生成需要修改的include替换列表
|
||||||
|
md_string_list=create_modify_strings(md_files)
|
||||||
|
# for item in md_string_list:
|
||||||
|
# print('---')
|
||||||
|
# print(f"{item[0]},{item[1]}")
|
||||||
|
# 第三步,修改源文件中的inlude
|
||||||
|
modify_include(src_files,md_string_list)
|
||||||
|
# 第四步,修改文件名
|
||||||
|
file_list_rename(md_files)
|
||||||
|
|
Reference in New Issue
Block a user