genPanel.py
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 | #!/usr/bin/python # -*- coding: UTF-8 -*- import os import sys import re import shutil import glob ''' 脚本使用说明 1. 执行命令./genPanel.py -a 分辨率 :代表生成这种分辨率的软件包 2. 如果想要编译特定的几个分辨率的软件,可在make radissonconfig中选择多个分辨率,然后执行命令./genPanel.py -b 即可 ''' cfgFileName = "radisson.config" buildNowfile = "../BUILD_RECORD/BUILD_NOW.h" g_ratioAMode = 0 g_ratioBMode = 0 def CreatebinDir(): global binDir try : fd = open (cfgFileName, "r" ) data = fd.readlines() for linedata in data: if re.search( "^CONFIG_CUSDEF_MI.*" ,linedata):<br> #获取字串linedata以“_”分开的第四个字串,linedata.split('_')返回一个列表 Customer = (linedata.split( '_' ))[ 3 ] elif re.search( "^CONFIG_CUSDEF_BD.*" ,linedata): ChipType = (linedata.split( '_' ))[ 4 ] BoardType = (linedata.split( '_' ))[ 5 ].split( '=' )[ 0 ] BDCfg = ChipType + "_" + BoardType binDir = Customer + "_" + BDCfg fd.close() except IOError as err: binDir = "binFile" print ( 'File Error: ' + str (err)) if os.path.exists(binDir): shutil.rmtree(binDir) os.mkdir(binDir) #编译某一分辨率的所有软件。 def RatioA(Resolution): PANEL_floder_path = ( "../CUS_FILE/PN" ).replace( '"' ,'') for dirPath, dirNames, fileNames in os.walk(PANEL_floder_path): break for panelName in dirNames: #筛选符合需求的分辨率 if Resolution not in panelName: continue print "===Start Panel %s Please Wait ===" % panelName listSave = [] try : cfgFile = open (buildFile, "r" ) list = cfgFile.readlines() for each in list : if re.search( "^#define PN_CUSDEF.*" ,each): continue else : listSave.append(each) each = "#define PN_CUSDEF %s" % (panelName) listSave.append(each) listSave.append( "\n" ) cfgFile = open (buildFile, "w" ) cfgFile.writelines(listSave) cfgFile.close() except IOError as err: print ( 'File Error: ' + str (err)) os.system( 'make clean;./build_history.sh' ) #将生成的bin文件移进软件包目录<br> #glob模块返回一个完整的路径列表,而不是查找到的文件名 binPath = glob.glob(r "./mergedir/RR*.bin" ) if len (binPath) ! = 0 : os.mkdir(panelName) shutil.copy(binPath[ 0 ],panelName) shutil.move(panelName,binDir) else : print "compile error!" sys.exit() #编译make radissonconfig中选中的多个分辨率 def RatioB(): try : panelSet = [] setStr = set () cfgFile = open (buildFile, "r" ) list = cfgFile.readlines() for each in list : if re.search( "^#define PN_CUSDEF\d?(.*)" ,each): setStr.add(re.search( "^#define PN_CUSDEF\d?(.*)" ,each).group( 1 )) for line in setStr: line1 = line.strip() panelSet.append(line1) except IOError as err: print ( 'File Error: ' + str (err)) for panelName in panelSet: print "===Start Panel %s Please Wait ===" % panelName listSave = [] try : cfgFile = open (buildFile, "r" ) list = cfgFile.readlines() for each in list : if re.search( "^#define PN_CUSDEF .*" ,each): continue else : listSave.append(each) each = "#define PN_CUSDEF %s" % (panelName) listSave.append(each) listSave.append( "\n" ) cfgFile = open (buildFile, "w" ) cfgFile.writelines(listSave) cfgFile.close() except IOError as err: print ( 'File Error: ' + str (err)) os.system( 'make clean;./build_history.sh' ) #将生成的bin文件移进软件包目录 binPath = glob.glob(r "./mergedir/RR*.bin" ) if len (binPath) ! = 0 : os.mkdir(panelName) shutil.copy(binPath[ 0 ],panelName) shutil.move(panelName,binDir) else : print "compile error!" sys.exit() def fun_parse_InputParam(): global g_ratioAMode global g_ratioBMode #获取脚本带入参数的长度 if len (sys.argv) < 2 : print "The number of parameters is wrong!" sys.exit() else :<br> #sys.argv[1]表示脚本带入的第一个的参数 opt1 = sys.argv[ 1 ] opt2 = [ "1366x768" , "1440x900" , "1024x768" , "1400x1050" , "1920x1080" , "1024x600" , "1280x1024" , "1280x800" , "1400x1050" , "1600x900" , "1680x1050" , "1920x1200" , "1600x1200" ] if opt1 = = "-a" and len (sys.argv) = = 3 : g_ratioAMode = 1 if sys.argv[ 2 ] not in opt2: print ( "parameter2: unhandled option!" ) sys.exit() elif opt1 = = "-b" and len (sys.argv) = = 2 : g_ratioBMode = 1 else : print ( "parameter error!" ) sys.exit() if __name__ = = "__main__" : #处理脚本带入的参数 fun_parse_InputParam() #从BUILD_NOW.h中获取build_setting.h所在的目录名 try : buildNow = open (buildNowfile, "r" ) list = buildNow.readlines() for line in list : if re.search( "^#define BUILD_NAME .*" ,line): buildDir = re.search( "^#define BUILD_NAME (.*)" ,line).group( 1 ) buildNow.close() except IOError as err: print ( 'File Error: ' + str (err)) buildFile = "../BUILD_RECORD/" + buildDir + "/BUILD_SETTING.h" #创建软件包目录 CreatebinDir() if g_ratioAMode: #编译某一分辨率的所有软件。 RatioA(sys.argv[ 2 ]) if g_ratioBMode: #编译make radissonconfig中选中的多个分辨率 RatioB() |
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· 别再用vector<bool>了!Google高级工程师:这可能是STL最大的设计失误
· 单元测试从入门到精通
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
· 上周热点回顾(3.3-3.9)