diff --git a/make.py b/make.py index 1b5a398..73d79ed 100644 --- a/make.py +++ b/make.py @@ -1,5 +1,4 @@ - -# -*- coding: gbk -*- +# -*- coding: utf-8 -*- @@ -11,7 +10,7 @@ import time ''' -修改编译脚本之后需要全编译一次 +淇敼缂栬瘧鑴氭湰涔嬪悗闇瑕佸叏缂栬瘧涓娆 ''' @@ -38,11 +37,11 @@ TARGET = 'hello.exe' # CFLAG = ["-Wall -pedantic -specs=nano.specs -mcpu=cortex-m3 -mthumb -lc -lm -lnosys -Og -Tstm32_boot.ld", # f"-Wl,-Map={BUILD_DIR}/{TARGET}.map,--cref -Wl,--gc-sections"] -# -pedantic 这一项是ISO语法检验 +# -pedantic 杩欎竴椤规槸ISO璇硶妫楠 CFLAG = ["-Wall -g"] -# 找到指定后缀的文件 +# 鎵惧埌鎸囧畾鍚庣紑鐨勬枃浠 def find_type(path:str,fix:list[str]): dlist=os.listdir(path) file_list=[] @@ -59,11 +58,11 @@ def find_type(path:str,fix:list[str]): ''' -将.c编译为.o文件, -编译脚本需要实现 如果.c文件有修改 则重新编译对应文件的.o文件 +灏.c缂栬瘧涓.o鏂囦欢锛 +缂栬瘧鑴氭湰闇瑕佸疄鐜 濡傛灉.c鏂囦欢鏈変慨鏀 鍒欓噸鏂扮紪璇戝搴旀枃浠剁殑.o鏂囦欢 gcc -c test.c -o test.o -输出依赖关系到.d文件 +杈撳嚭渚濊禆鍏崇郴鍒.d鏂囦欢 gcc -MM main.c -o build/main.d @@ -82,7 +81,7 @@ def tran_path(path:str): return p -# 判断是否需要重新生成 +# 鍒ゆ柇鏄惁闇瑕侀噸鏂扮敓鎴 def check_rebuild(dst:str,src:list[str]): # print(f"src:{src}") if(not os.path.exists(dst)): @@ -101,7 +100,7 @@ def check_rebuild(dst:str,src:list[str]): -# 读取.d文件,返回依赖文件列表 +# 璇诲彇.d鏂囦欢锛岃繑鍥炰緷璧栨枃浠跺垪琛 def read_depend_files(name:str): with open(name) as f: lines=f.readlines() @@ -114,11 +113,11 @@ def read_depend_files(name:str): t+=line t=t.split(':')[-1].strip() t=t.split(' ') - # print(f"依赖列表{t}") + # print(f"渚濊禆鍒楄〃{t}") return t -# 生成依赖关系 +# 鐢熸垚渚濊禆鍏崇郴 def build_depend(src:list[str]): flags=f"{' '.join(CINC)} {' '.join(CDEF)} {' '.join(CFLAG)}" for i in src: @@ -132,9 +131,9 @@ def build_depend(src:list[str]): if(ret): exit() else: - print(f"{i} 没有更新源文件") + print(f"{i} 娌℃湁鏇存柊婧愭枃浠") -# 生成中间文件 +# 鐢熸垚涓棿鏂囦欢 def build_object(src:list[str]): flags=f"{' '.join(CINC)} {' '.join(CDEF)} {' '.join(CFLAG)}" for i in src: @@ -150,12 +149,12 @@ def build_object(src:list[str]): if(check_rebuild(dst,read_depend_files(cd))): cmd=f"{CC} -c {i} -o {dst} {flags}" else: - print(f"{i} 没有更新依赖关系") + print(f"{i} 娌℃湁鏇存柊渚濊禆鍏崇郴") elif(file_type in ['s','S','asm','ASM']): if(check_rebuild(dst,[i])): cmd=f"{AS} -c {i} -o {dst} {flags}" else: - print(f"{i} 没有更新依赖关系") + print(f"{i} 娌℃湁鏇存柊渚濊禆鍏崇郴") if(len(cmd)>0): print(cmd) ret=os.system(cmd) @@ -163,7 +162,7 @@ def build_object(src:list[str]): exit() -# 生成可执行文件 +# 鐢熸垚鍙墽琛屾枃浠 def build_target(src:list[str]): flags=f"{' '.join(CINC)} {' '.join(CDEF)} {' '.join(CFLAG)}" obj_list=[] @@ -178,7 +177,7 @@ def build_target(src:list[str]): if(ret): exit() else: - print(f"{dst} 没有更新的链接文件") + print(f"{dst} 娌℃湁鏇存柊鐨勯摼鎺ユ枃浠") def main(): @@ -190,12 +189,12 @@ def main(): if(not os.path.exists(BUILD_DIR)): os.makedirs(BUILD_DIR) - print("生成依赖关系") + print("鐢熸垚渚濊禆鍏崇郴") build_depend(CSRC) - print("生成对象文件") + print("鐢熸垚瀵硅薄鏂囦欢") build_object(CSRC) # build_object(ASRC) - print("生成目标文件") + print("鐢熸垚鐩爣鏂囦欢") build_target(CSRC+ASRC) # os.system(f"{HEX} {BUILD_DIR}/{TARGET} {BUILD_DIR}/{TARGET}.hex") # os.system(f"{BIN} {BUILD_DIR}/{TARGET} {BUILD_DIR}/{TARGET}.bin")