Changeset 84266669 in mainline
- Timestamp:
- 2009-02-12T20:10:22Z (16 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- fcd7053
- Parents:
- 6da1013f
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
tools/config.py
r6da1013f r84266669 38 38 39 39 INPUT = sys.argv[1] 40 OUTPUT = 'Makefile.config' 40 MAKEFILE = 'Makefile.config' 41 MACROS = 'config.h' 42 DEFS = 'config.defs' 41 43 42 44 def read_defaults(fname, defaults): 43 45 "Read saved values from last configuration run" 44 46 45 inf = file(fname, 'r')47 inf = file(fname, 'r') 46 48 47 49 for line in inf: … … 217 219 return True 218 220 219 def create_output( fname, defaults, ask_names):221 def create_output(mkname, mcname, dfname, defaults, ask_names): 220 222 "Create output configuration" 221 223 222 outf = file(fname, 'w') 223 224 outf.write('#########################################\n') 225 outf.write('## AUTO-GENERATED FILE, DO NOT EDIT!!! ##\n') 226 outf.write('#########################################\n\n') 224 revision = commands.getoutput('svnversion . 2> /dev/null') 225 timestamp = commands.getoutput('date "+%Y-%m-%d %H:%M:%S"') 226 227 outmk = file(mkname, 'w') 228 outmc = file(mcname, 'w') 229 outdf = file(dfname, 'w') 230 231 outmk.write('#########################################\n') 232 outmk.write('## AUTO-GENERATED FILE, DO NOT EDIT!!! ##\n') 233 outmk.write('#########################################\n\n') 234 235 outmc.write('/***************************************\n') 236 outmc.write(' * AUTO-GENERATED FILE, DO NOT EDIT!!! *\n') 237 outmc.write(' ***************************************/\n\n') 238 239 outdf.write('#########################################\n') 240 outdf.write('## AUTO-GENERATED FILE, DO NOT EDIT!!! ##\n') 241 outdf.write('#########################################\n\n') 242 outdf.write('CONFIG_DEFS =') 227 243 228 244 for varname, vartype, name, choices, cond in ask_names: … … 235 251 default = defaults[varname] 236 252 237 outf.write('# %s\n%s = %s\n\n' % (name, varname, default)) 238 239 outf.write('REVISION = %s\n' % commands.getoutput('svnversion . 2> /dev/null')) 240 outf.write('TIMESTAMP = %s\n' % commands.getoutput('date "+%Y-%m-%d %H:%M:%S"')) 241 outf.close() 253 outmk.write('# %s\n%s = %s\n\n' % (name, varname, default)) 254 255 if ((vartype == "y") or (vartype == "y/n") or (vartype == "n/y")): 256 if (default == "y"): 257 outmc.write('/* %s */\n#define %s\n\n' % (name, varname)) 258 outdf.write(' -D%s' % varname) 259 else: 260 outmc.write('/* %s */\n#define %s %s\n\n' % (name, varname, default)) 261 outdf.write(' -D%s=%s' % (varname, default)) 262 263 outmk.write('REVISION = %s\n' % revision) 264 outmk.write('TIMESTAMP = %s\n' % timestamp) 265 266 outmc.write('#define REVISION %s\n' % revision) 267 outmc.write('#define TIMESTAMP %s\n' % timestamp) 268 269 outdf.write(' "-DREVISION=%s" "-DTIMESTAMP=%s"\n' % (revision, timestamp)) 270 271 outmk.close() 272 outmc.close() 273 outdf.close() 242 274 243 275 def main(): … … 249 281 250 282 # Read defaults from previous run 251 if os.path.exists( OUTPUT):252 read_defaults( OUTPUT, defaults)283 if os.path.exists(MAKEFILE): 284 read_defaults(MAKEFILE, defaults) 253 285 254 286 # Default mode: only check defaults and regenerate configuration 255 287 if ((len(sys.argv) >= 3) and (sys.argv[2] == 'default')): 256 288 if (check_choices(defaults, ask_names)): 257 create_output( OUTPUT, defaults, ask_names)289 create_output(MAKEFILE, MACROS, DEFS, defaults, ask_names) 258 290 return 0 259 291 … … 294 326 # If there is just one option, use it 295 327 if (len(choices) == 1): 296 default = choices[0][0]297 defaults[varname] = default328 defaults[varname] = choices[0][0] 329 continue 298 330 299 331 options.append(" %s [%s] --> " % (name, default)) 332 elif (vartype == 'y'): 333 defaults[varname] = 'y' 334 continue 300 335 elif (vartype == 'y/n'): 301 336 if (default == None): … … 347 382 xtui.screen_done(screen) 348 383 349 create_output( OUTPUT, defaults, ask_names)384 create_output(MAKEFILE, MACROS, DEFS, defaults, ask_names) 350 385 return 0 351 386
Note:
See TracChangeset
for help on using the changeset viewer.