edk2-build.py (aa9e7fa4689d1becb2faf67f65aafcbcf664f1ce) | edk2-build.py (c28a2891f34f95a94da9d6ac9f60b1446881ea1a) |
---|---|
1#!/usr/bin/python3 2""" 3build helper script for edk2, see 4https://gitlab.com/kraxel/edk2-build-config 5 6""" 7import os 8import sys | 1#!/usr/bin/python3 2""" 3build helper script for edk2, see 4https://gitlab.com/kraxel/edk2-build-config 5 6""" 7import os 8import sys |
9import time |
|
9import shutil 10import argparse 11import subprocess 12import configparser 13 14rebase_prefix = "" 15version_override = None 16release_date = None --- 23 unchanged lines hidden (view full) --- 40 # fixed version speeds up builds 41 version_override = "test-build-patch-series" 42 43def get_coredir(cfg): 44 if cfg.has_option('global', 'core'): 45 return os.path.abspath(cfg['global']['core']) 46 return os.getcwd() 47 | 10import shutil 11import argparse 12import subprocess 13import configparser 14 15rebase_prefix = "" 16version_override = None 17release_date = None --- 23 unchanged lines hidden (view full) --- 41 # fixed version speeds up builds 42 version_override = "test-build-patch-series" 43 44def get_coredir(cfg): 45 if cfg.has_option('global', 'core'): 46 return os.path.abspath(cfg['global']['core']) 47 return os.getcwd() 48 |
48def get_version(cfg): | 49def get_toolchain(cfg, build): 50 if cfg.has_option(build, 'tool'): 51 return cfg[build]['tool'] 52 if cfg.has_option('global', 'tool'): 53 return cfg['global']['tool'] 54 return 'GCC5' 55 56def get_version(cfg, silent = False): |
49 coredir = get_coredir(cfg) 50 if version_override: 51 version = version_override | 57 coredir = get_coredir(cfg) 58 if version_override: 59 version = version_override |
52 print('') 53 print(f'### version [override]: {version}') | 60 if not silent: 61 print('') 62 print(f'### version [override]: {version}') |
54 return version 55 if os.environ.get('RPM_PACKAGE_NAME'): 56 version = os.environ.get('RPM_PACKAGE_NAME') 57 version += '-' + os.environ.get('RPM_PACKAGE_VERSION') 58 version += '-' + os.environ.get('RPM_PACKAGE_RELEASE') | 63 return version 64 if os.environ.get('RPM_PACKAGE_NAME'): 65 version = os.environ.get('RPM_PACKAGE_NAME') 66 version += '-' + os.environ.get('RPM_PACKAGE_VERSION') 67 version += '-' + os.environ.get('RPM_PACKAGE_RELEASE') |
59 print('') 60 print(f'### version [rpmbuild]: {version}') | 68 if not silent: 69 print('') 70 print(f'### version [rpmbuild]: {version}') |
61 return version 62 if os.path.exists(coredir + '/.git'): 63 cmdline = [ 'git', 'describe', '--tags', '--abbrev=8', 64 '--match=edk2-stable*' ] 65 result = subprocess.run(cmdline, cwd = coredir, 66 stdout = subprocess.PIPE, 67 check = True) 68 version = result.stdout.decode().strip() | 71 return version 72 if os.path.exists(coredir + '/.git'): 73 cmdline = [ 'git', 'describe', '--tags', '--abbrev=8', 74 '--match=edk2-stable*' ] 75 result = subprocess.run(cmdline, cwd = coredir, 76 stdout = subprocess.PIPE, 77 check = True) 78 version = result.stdout.decode().strip() |
69 print('') 70 print(f'### version [git]: {version}') | 79 if not silent: 80 print('') 81 print(f'### version [git]: {version}') |
71 return version 72 return None 73 74def pcd_string(name, value): 75 return f'{name}=L{value}\\0' 76 | 82 return version 83 return None 84 85def pcd_string(name, value): 86 return f'{name}=L{value}\\0' 87 |
77def pcd_version(cfg): 78 version = get_version(cfg) | 88def pcd_version(cfg, silent = False): 89 version = get_version(cfg, silent) |
79 if version is None: 80 return [] 81 return [ '--pcd', pcd_string('PcdFirmwareVersionString', version) ] 82 83def pcd_release_date(): 84 if release_date is None: 85 return [] 86 return [ '--pcd', pcd_string('PcdFirmwareReleaseDateString', release_date) ] 87 | 90 if version is None: 91 return [] 92 return [ '--pcd', pcd_string('PcdFirmwareVersionString', version) ] 93 94def pcd_release_date(): 95 if release_date is None: 96 return [] 97 return [ '--pcd', pcd_string('PcdFirmwareReleaseDateString', release_date) ] 98 |
88def build_message(line, line2 = None): | 99def build_message(line, line2 = None, silent = False): |
89 if os.environ.get('TERM') in [ 'xterm', 'xterm-256color' ]: 90 # setxterm title 91 start = '\x1b]2;' 92 end = '\x07' 93 print(f'{start}{rebase_prefix}{line}{end}', end = '') 94 | 100 if os.environ.get('TERM') in [ 'xterm', 'xterm-256color' ]: 101 # setxterm title 102 start = '\x1b]2;' 103 end = '\x07' 104 print(f'{start}{rebase_prefix}{line}{end}', end = '') 105 |
95 print('') 96 print('###') 97 print(f'### {rebase_prefix}{line}') 98 if line2: 99 print(f'### {line2}') 100 print('###', flush = True) | 106 if silent: 107 print(f'### {rebase_prefix}{line}', flush = True) 108 else: 109 print('') 110 print('###') 111 print(f'### {rebase_prefix}{line}') 112 if line2: 113 print(f'### {line2}') 114 print('###', flush = True) |
101 | 115 |
102def build_run(cmdline, name, section, silent = False): 103 print(cmdline, flush = True) | 116def build_run(cmdline, name, section, silent = False, nologs = False): |
104 if silent: | 117 if silent: |
105 print('### building in silent mode ...', flush = True) | 118 logfile = f'{section}.log' 119 if nologs: 120 print(f'### building in silent mode [no log] ...', flush = True) 121 else: 122 print(f'### building in silent mode [{logfile}] ...', flush = True) 123 start = time.time() |
106 result = subprocess.run(cmdline, check = False, 107 stdout = subprocess.PIPE, 108 stderr = subprocess.STDOUT) | 124 result = subprocess.run(cmdline, check = False, 125 stdout = subprocess.PIPE, 126 stderr = subprocess.STDOUT) |
127 if not nologs: 128 with open(logfile, 'wb') as f: 129 f.write(result.stdout) |
|
109 | 130 |
110 logfile = f'{section}.log' 111 print(f'### writing log to {logfile} ...') 112 with open(logfile, 'wb') as f: 113 f.write(result.stdout) 114 | |
115 if result.returncode: 116 print('### BUILD FAILURE') | 131 if result.returncode: 132 print('### BUILD FAILURE') |
133 print('### cmdline') 134 print(cmdline) |
|
117 print('### output') 118 print(result.stdout.decode()) 119 print(f'### exit code: {result.returncode}') 120 else: | 135 print('### output') 136 print(result.stdout.decode()) 137 print(f'### exit code: {result.returncode}') 138 else: |
121 print('### OK') | 139 secs = int(time.time() - start) 140 print(f'### OK ({int(secs/60)}:{secs%60:02d})') |
122 else: | 141 else: |
142 print(cmdline, flush = True) |
|
123 result = subprocess.run(cmdline, check = False) 124 if result.returncode: 125 print(f'ERROR: {cmdline[0]} exited with {result.returncode}' 126 f' while building {name}') 127 sys.exit(result.returncode) 128 | 143 result = subprocess.run(cmdline, check = False) 144 if result.returncode: 145 print(f'ERROR: {cmdline[0]} exited with {result.returncode}' 146 f' while building {name}') 147 sys.exit(result.returncode) 148 |
129def build_copy(plat, tgt, dstdir, copy): 130 srcdir = f'Build/{plat}/{tgt}_GCC5' | 149def build_copy(plat, tgt, toolchain, dstdir, copy): 150 srcdir = f'Build/{plat}/{tgt}_{toolchain}' |
131 names = copy.split() 132 srcfile = names[0] 133 if len(names) > 1: 134 dstfile = names[1] 135 else: 136 dstfile = os.path.basename(srcfile) 137 print(f'# copy: {srcdir} / {srcfile} => {dstdir} / {dstfile}') 138 --- 12 unchanged lines hidden (view full) --- 151 'truncate', 152 '--size', size, 153 dstdir + '/' + name, 154 ] 155 print(f'# padding: {dstdir} / {name} => {size}') 156 subprocess.run(cmdline, check = True) 157 158# pylint: disable=too-many-branches | 151 names = copy.split() 152 srcfile = names[0] 153 if len(names) > 1: 154 dstfile = names[1] 155 else: 156 dstfile = os.path.basename(srcfile) 157 print(f'# copy: {srcdir} / {srcfile} => {dstdir} / {dstfile}') 158 --- 12 unchanged lines hidden (view full) --- 171 'truncate', 172 '--size', size, 173 dstdir + '/' + name, 174 ] 175 print(f'# padding: {dstdir} / {name} => {size}') 176 subprocess.run(cmdline, check = True) 177 178# pylint: disable=too-many-branches |
159def build_one(cfg, build, jobs = None, silent = False): | 179def build_one(cfg, build, jobs = None, silent = False, nologs = False): 180 b = cfg[build] 181 |
160 cmdline = [ 'build' ] | 182 cmdline = [ 'build' ] |
161 cmdline += [ '-t', 'GCC5' ] 162 cmdline += [ '-p', cfg[build]['conf'] ] | 183 cmdline += [ '-t', get_toolchain(cfg, build) ] 184 cmdline += [ '-p', b['conf'] ] |
163 | 185 |
164 if (cfg[build]['conf'].startswith('OvmfPkg/') or 165 cfg[build]['conf'].startswith('ArmVirtPkg/')): 166 cmdline += pcd_version(cfg) | 186 if (b['conf'].startswith('OvmfPkg/') or 187 b['conf'].startswith('ArmVirtPkg/')): 188 cmdline += pcd_version(cfg, silent) |
167 cmdline += pcd_release_date() 168 169 if jobs: 170 cmdline += [ '-n', jobs ] | 189 cmdline += pcd_release_date() 190 191 if jobs: 192 cmdline += [ '-n', jobs ] |
171 for arch in cfg[build]['arch'].split(): | 193 for arch in b['arch'].split(): |
172 cmdline += [ '-a', arch ] | 194 cmdline += [ '-a', arch ] |
173 if 'opts' in cfg[build]: 174 for name in cfg[build]['opts'].split(): | 195 if 'opts' in b: 196 for name in b['opts'].split(): |
175 section = 'opts.' + name 176 for opt in cfg[section]: 177 cmdline += [ '-D', opt + '=' + cfg[section][opt] ] | 197 section = 'opts.' + name 198 for opt in cfg[section]: 199 cmdline += [ '-D', opt + '=' + cfg[section][opt] ] |
178 if 'pcds' in cfg[build]: 179 for name in cfg[build]['pcds'].split(): | 200 if 'pcds' in b: 201 for name in b['pcds'].split(): |
180 section = 'pcds.' + name 181 for pcd in cfg[section]: 182 cmdline += [ '--pcd', pcd + '=' + cfg[section][pcd] ] | 202 section = 'pcds.' + name 203 for pcd in cfg[section]: 204 cmdline += [ '--pcd', pcd + '=' + cfg[section][pcd] ] |
183 if 'tgts' in cfg[build]: 184 tgts = cfg[build]['tgts'].split() | 205 if 'tgts' in b: 206 tgts = b['tgts'].split() |
185 else: 186 tgts = [ 'DEBUG' ] 187 for tgt in tgts: 188 desc = None | 207 else: 208 tgts = [ 'DEBUG' ] 209 for tgt in tgts: 210 desc = None |
189 if 'desc' in cfg[build]: 190 desc = cfg[build]['desc'] 191 build_message(f'building: {cfg[build]["conf"]} ({cfg[build]["arch"]}, {tgt})', 192 f'description: {desc}') | 211 if 'desc' in b: 212 desc = b['desc'] 213 build_message(f'building: {b["conf"]} ({b["arch"]}, {tgt})', 214 f'description: {desc}', 215 silent = silent) |
193 build_run(cmdline + [ '-b', tgt ], | 216 build_run(cmdline + [ '-b', tgt ], |
194 cfg[build]['conf'], | 217 b['conf'], |
195 build + '.' + tgt, | 218 build + '.' + tgt, |
196 silent) | 219 silent, 220 nologs) |
197 | 221 |
198 if 'plat' in cfg[build]: | 222 if 'plat' in b: |
199 # copy files | 223 # copy files |
200 for cpy in cfg[build]: | 224 for cpy in b: |
201 if not cpy.startswith('cpy'): 202 continue | 225 if not cpy.startswith('cpy'): 226 continue |
203 build_copy(cfg[build]['plat'], 204 tgt, 205 cfg[build]['dest'], 206 cfg[build][cpy]) | 227 build_copy(b['plat'], tgt, 228 get_toolchain(cfg, build), 229 b['dest'], b[cpy]) |
207 # pad builds | 230 # pad builds |
208 for pad in cfg[build]: | 231 for pad in b: |
209 if not pad.startswith('pad'): 210 continue | 232 if not pad.startswith('pad'): 233 continue |
211 pad_file(cfg[build]['dest'], 212 cfg[build][pad]) | 234 pad_file(b['dest'], b[pad]) |
213 | 235 |
214def build_basetools(silent = False): 215 build_message('building: BaseTools') | 236def build_basetools(silent = False, nologs = False): 237 build_message('building: BaseTools', silent = silent) |
216 basedir = os.environ['EDK_TOOLS_PATH'] 217 cmdline = [ 'make', '-C', basedir ] | 238 basedir = os.environ['EDK_TOOLS_PATH'] 239 cmdline = [ 'make', '-C', basedir ] |
218 build_run(cmdline, 'BaseTools', 'build.basetools', silent) | 240 build_run(cmdline, 'BaseTools', 'build.basetools', silent, nologs) |
219 220def binary_exists(name): 221 for pdir in os.environ['PATH'].split(':'): 222 if os.path.exists(pdir + '/' + name): 223 return True 224 return False 225 | 241 242def binary_exists(name): 243 for pdir in os.environ['PATH'].split(':'): 244 if os.path.exists(pdir + '/' + name): 245 return True 246 return False 247 |
226def prepare_env(cfg): | 248def prepare_env(cfg, silent = False): |
227 """ mimic Conf/BuildEnv.sh """ 228 workspace = os.getcwd() 229 packages = [ workspace, ] 230 path = os.environ['PATH'].split(':') 231 dirs = [ 232 'BaseTools/Bin/Linux-x86_64', 233 'BaseTools/BinWrappers/PosixLike' 234 ] --- 13 unchanged lines hidden (view full) --- 248 if p in path: 249 continue 250 path.insert(0, p) 251 252 # run edksetup if needed 253 toolsdef = coredir + '/Conf/tools_def.txt' 254 if not os.path.exists(toolsdef): 255 os.makedirs(os.path.dirname(toolsdef), exist_ok = True) | 249 """ mimic Conf/BuildEnv.sh """ 250 workspace = os.getcwd() 251 packages = [ workspace, ] 252 path = os.environ['PATH'].split(':') 253 dirs = [ 254 'BaseTools/Bin/Linux-x86_64', 255 'BaseTools/BinWrappers/PosixLike' 256 ] --- 13 unchanged lines hidden (view full) --- 270 if p in path: 271 continue 272 path.insert(0, p) 273 274 # run edksetup if needed 275 toolsdef = coredir + '/Conf/tools_def.txt' 276 if not os.path.exists(toolsdef): 277 os.makedirs(os.path.dirname(toolsdef), exist_ok = True) |
256 build_message('running BaseTools/BuildEnv') | 278 build_message('running BaseTools/BuildEnv', silent = silent) |
257 cmdline = [ 'bash', 'BaseTools/BuildEnv' ] 258 subprocess.run(cmdline, cwd = coredir, check = True) 259 260 # set variables 261 os.environ['PATH'] = ':'.join(path) 262 os.environ['PACKAGES_PATH'] = ':'.join(packages) 263 os.environ['WORKSPACE'] = workspace 264 os.environ['EDK_TOOLS_PATH'] = coredir + '/BaseTools' 265 os.environ['CONF_PATH'] = coredir + '/Conf' 266 os.environ['PYTHON_COMMAND'] = '/usr/bin/python3' 267 os.environ['PYTHONHASHSEED'] = '1' 268 269 # for cross builds | 279 cmdline = [ 'bash', 'BaseTools/BuildEnv' ] 280 subprocess.run(cmdline, cwd = coredir, check = True) 281 282 # set variables 283 os.environ['PATH'] = ':'.join(path) 284 os.environ['PACKAGES_PATH'] = ':'.join(packages) 285 os.environ['WORKSPACE'] = workspace 286 os.environ['EDK_TOOLS_PATH'] = coredir + '/BaseTools' 287 os.environ['CONF_PATH'] = coredir + '/Conf' 288 os.environ['PYTHON_COMMAND'] = '/usr/bin/python3' 289 os.environ['PYTHONHASHSEED'] = '1' 290 291 # for cross builds |
270 if binary_exists('arm-linux-gnu-gcc'): | 292 if binary_exists('arm-linux-gnueabi-gcc'): 293 # ubuntu 294 os.environ['GCC5_ARM_PREFIX'] = 'arm-linux-gnueabi-' 295 os.environ['GCC_ARM_PREFIX'] = 'arm-linux-gnueabi-' 296 elif binary_exists('arm-linux-gnu-gcc'): 297 # fedora |
271 os.environ['GCC5_ARM_PREFIX'] = 'arm-linux-gnu-' | 298 os.environ['GCC5_ARM_PREFIX'] = 'arm-linux-gnu-' |
299 os.environ['GCC_ARM_PREFIX'] = 'arm-linux-gnu-' |
|
272 if binary_exists('loongarch64-linux-gnu-gcc'): 273 os.environ['GCC5_LOONGARCH64_PREFIX'] = 'loongarch64-linux-gnu-' | 300 if binary_exists('loongarch64-linux-gnu-gcc'): 301 os.environ['GCC5_LOONGARCH64_PREFIX'] = 'loongarch64-linux-gnu-' |
302 os.environ['GCC_LOONGARCH64_PREFIX'] = 'loongarch64-linux-gnu-' |
|
274 275 hostarch = os.uname().machine 276 if binary_exists('aarch64-linux-gnu-gcc') and hostarch != 'aarch64': 277 os.environ['GCC5_AARCH64_PREFIX'] = 'aarch64-linux-gnu-' | 303 304 hostarch = os.uname().machine 305 if binary_exists('aarch64-linux-gnu-gcc') and hostarch != 'aarch64': 306 os.environ['GCC5_AARCH64_PREFIX'] = 'aarch64-linux-gnu-' |
307 os.environ['GCC_AARCH64_PREFIX'] = 'aarch64-linux-gnu-' |
|
278 if binary_exists('riscv64-linux-gnu-gcc') and hostarch != 'riscv64': 279 os.environ['GCC5_RISCV64_PREFIX'] = 'riscv64-linux-gnu-' | 308 if binary_exists('riscv64-linux-gnu-gcc') and hostarch != 'riscv64': 309 os.environ['GCC5_RISCV64_PREFIX'] = 'riscv64-linux-gnu-' |
310 os.environ['GCC_RISCV64_PREFIX'] = 'riscv64-linux-gnu-' |
|
280 if binary_exists('x86_64-linux-gnu-gcc') and hostarch != 'x86_64': 281 os.environ['GCC5_IA32_PREFIX'] = 'x86_64-linux-gnu-' 282 os.environ['GCC5_X64_PREFIX'] = 'x86_64-linux-gnu-' 283 os.environ['GCC5_BIN'] = 'x86_64-linux-gnu-' | 311 if binary_exists('x86_64-linux-gnu-gcc') and hostarch != 'x86_64': 312 os.environ['GCC5_IA32_PREFIX'] = 'x86_64-linux-gnu-' 313 os.environ['GCC5_X64_PREFIX'] = 'x86_64-linux-gnu-' 314 os.environ['GCC5_BIN'] = 'x86_64-linux-gnu-' |
315 os.environ['GCC_IA32_PREFIX'] = 'x86_64-linux-gnu-' 316 os.environ['GCC_X64_PREFIX'] = 'x86_64-linux-gnu-' 317 os.environ['GCC_BIN'] = 'x86_64-linux-gnu-' |
|
284 285def build_list(cfg): 286 for build in cfg.sections(): 287 if not build.startswith('build.'): 288 continue 289 name = build.lstrip('build.') 290 desc = 'no description' 291 if 'desc' in cfg[build]: --- 6 unchanged lines hidden (view full) --- 298 parser.add_argument('-c', '--config', dest = 'configfile', 299 type = str, default = '.edk2.builds', metavar = 'FILE', 300 help = 'read configuration from FILE (default: .edk2.builds)') 301 parser.add_argument('-C', '--directory', dest = 'directory', type = str, 302 help = 'change to DIR before building', metavar = 'DIR') 303 parser.add_argument('-j', '--jobs', dest = 'jobs', type = str, 304 help = 'allow up to JOBS parallel build jobs', 305 metavar = 'JOBS') | 318 319def build_list(cfg): 320 for build in cfg.sections(): 321 if not build.startswith('build.'): 322 continue 323 name = build.lstrip('build.') 324 desc = 'no description' 325 if 'desc' in cfg[build]: --- 6 unchanged lines hidden (view full) --- 332 parser.add_argument('-c', '--config', dest = 'configfile', 333 type = str, default = '.edk2.builds', metavar = 'FILE', 334 help = 'read configuration from FILE (default: .edk2.builds)') 335 parser.add_argument('-C', '--directory', dest = 'directory', type = str, 336 help = 'change to DIR before building', metavar = 'DIR') 337 parser.add_argument('-j', '--jobs', dest = 'jobs', type = str, 338 help = 'allow up to JOBS parallel build jobs', 339 metavar = 'JOBS') |
306 parser.add_argument('-m', '--match', dest = 'match', type = str, | 340 parser.add_argument('-m', '--match', dest = 'match', 341 type = str, action = 'append', |
307 help = 'only run builds matching INCLUDE (substring)', 308 metavar = 'INCLUDE') | 342 help = 'only run builds matching INCLUDE (substring)', 343 metavar = 'INCLUDE') |
309 parser.add_argument('-x', '--exclude', dest = 'exclude', type = str, | 344 parser.add_argument('-x', '--exclude', dest = 'exclude', 345 type = str, action = 'append', |
310 help = 'skip builds matching EXCLUDE (substring)', 311 metavar = 'EXCLUDE') 312 parser.add_argument('-l', '--list', dest = 'list', 313 action = 'store_true', default = False, 314 help = 'list build configs available') 315 parser.add_argument('--silent', dest = 'silent', 316 action = 'store_true', default = False, 317 help = 'write build output to logfiles, ' 318 'write to console only on errors') | 346 help = 'skip builds matching EXCLUDE (substring)', 347 metavar = 'EXCLUDE') 348 parser.add_argument('-l', '--list', dest = 'list', 349 action = 'store_true', default = False, 350 help = 'list build configs available') 351 parser.add_argument('--silent', dest = 'silent', 352 action = 'store_true', default = False, 353 help = 'write build output to logfiles, ' 354 'write to console only on errors') |
355 parser.add_argument('--no-logs', dest = 'nologs', 356 action = 'store_true', default = False, 357 help = 'do not write build log files (with --silent)') |
|
319 parser.add_argument('--core', dest = 'core', type = str, metavar = 'DIR', 320 help = 'location of the core edk2 repository ' 321 '(i.e. where BuildTools are located)') 322 parser.add_argument('--pkg', '--package', dest = 'pkgs', 323 type = str, action = 'append', metavar = 'DIR', 324 help = 'location(s) of additional packages ' 325 '(can be specified multiple times)') | 358 parser.add_argument('--core', dest = 'core', type = str, metavar = 'DIR', 359 help = 'location of the core edk2 repository ' 360 '(i.e. where BuildTools are located)') 361 parser.add_argument('--pkg', '--package', dest = 'pkgs', 362 type = str, action = 'append', metavar = 'DIR', 363 help = 'location(s) of additional packages ' 364 '(can be specified multiple times)') |
365 parser.add_argument('-t', '--toolchain', dest = 'toolchain', 366 type = str, metavar = 'NAME', 367 help = 'tool chain to be used to build edk2') |
|
326 parser.add_argument('--version-override', dest = 'version_override', 327 type = str, metavar = 'VERSION', 328 help = 'set firmware build version') 329 parser.add_argument('--release-date', dest = 'release_date', 330 type = str, metavar = 'DATE', 331 help = 'set firmware build release date (in MM/DD/YYYY format)') 332 options = parser.parse_args() 333 334 if options.directory: 335 os.chdir(options.directory) 336 337 if not os.path.exists(options.configfile): | 368 parser.add_argument('--version-override', dest = 'version_override', 369 type = str, metavar = 'VERSION', 370 help = 'set firmware build version') 371 parser.add_argument('--release-date', dest = 'release_date', 372 type = str, metavar = 'DATE', 373 help = 'set firmware build release date (in MM/DD/YYYY format)') 374 options = parser.parse_args() 375 376 if options.directory: 377 os.chdir(options.directory) 378 379 if not os.path.exists(options.configfile): |
338 print('config file "{options.configfile}" not found') | 380 print(f'config file "{options.configfile}" not found') |
339 return 1 340 341 cfg = configparser.ConfigParser() 342 cfg.optionxform = str 343 cfg.read(options.configfile) 344 345 if options.list: 346 build_list(cfg) | 381 return 1 382 383 cfg = configparser.ConfigParser() 384 cfg.optionxform = str 385 cfg.read(options.configfile) 386 387 if options.list: 388 build_list(cfg) |
347 return | 389 return 0 |
348 349 if not cfg.has_section('global'): 350 cfg.add_section('global') 351 if options.core: 352 cfg.set('global', 'core', options.core) 353 if options.pkgs: 354 cfg.set('global', 'pkgs', ' '.join(options.pkgs)) | 390 391 if not cfg.has_section('global'): 392 cfg.add_section('global') 393 if options.core: 394 cfg.set('global', 'core', options.core) 395 if options.pkgs: 396 cfg.set('global', 'pkgs', ' '.join(options.pkgs)) |
397 if options.toolchain: 398 cfg.set('global', 'tool', options.toolchain) |
|
355 356 global version_override 357 global release_date 358 check_rebase() 359 if options.version_override: 360 version_override = options.version_override 361 if options.release_date: 362 release_date = options.release_date 363 | 399 400 global version_override 401 global release_date 402 check_rebase() 403 if options.version_override: 404 version_override = options.version_override 405 if options.release_date: 406 release_date = options.release_date 407 |
364 prepare_env(cfg) 365 build_basetools(options.silent) | 408 prepare_env(cfg, options.silent) 409 build_basetools(options.silent, options.nologs) |
366 for build in cfg.sections(): 367 if not build.startswith('build.'): 368 continue | 410 for build in cfg.sections(): 411 if not build.startswith('build.'): 412 continue |
369 if options.match and options.match not in build: 370 print(f'# skipping "{build}" (not matching "{options.match}")') 371 continue 372 if options.exclude and options.exclude in build: 373 print(f'# skipping "{build}" (matching "{options.exclude}")') 374 continue 375 build_one(cfg, build, options.jobs, options.silent) | 413 if options.match: 414 matching = False 415 for item in options.match: 416 if item in build: 417 matching = True 418 if not matching: 419 print(f'# skipping "{build}" (not matching "{"|".join(options.match)}")') 420 continue 421 if options.exclude: 422 exclude = False 423 for item in options.exclude: 424 if item in build: 425 print(f'# skipping "{build}" (matching "{item}")') 426 exclude = True 427 if exclude: 428 continue 429 build_one(cfg, build, options.jobs, options.silent, options.nologs) |
376 377 return 0 378 379if __name__ == '__main__': 380 sys.exit(main()) | 430 431 return 0 432 433if __name__ == '__main__': 434 sys.exit(main()) |