SConscript (5799:0af61da2b66a) | SConscript (5824:b88edb9f3333) |
---|---|
1# -*- mode:python -*- 2 3# Copyright (c) 2004-2005 The Regents of The University of Michigan 4# All rights reserved. 5# 6# Redistribution and use in source and binary forms, with or without 7# modification, are permitted provided that the following conditions are 8# met: redistributions of source code must retain the above copyright --- 341 unchanged lines hidden (view full) --- 350 351######################################################################## 352# 353# Commands for the basic automatically generated python files 354# 355 356scons_dir = str(SCons.Node.FS.default_fs.SConstruct_dir) 357 | 1# -*- mode:python -*- 2 3# Copyright (c) 2004-2005 The Regents of The University of Michigan 4# All rights reserved. 5# 6# Redistribution and use in source and binary forms, with or without 7# modification, are permitted provided that the following conditions are 8# met: redistributions of source code must retain the above copyright --- 341 unchanged lines hidden (view full) --- 350 351######################################################################## 352# 353# Commands for the basic automatically generated python files 354# 355 356scons_dir = str(SCons.Node.FS.default_fs.SConstruct_dir) 357 |
358hg_info = ("Unknown", "Unknown", "Unknown") | 358hg_info = "Unknown" |
359hg_demandimport = False 360try: 361 if not exists(scons_dir) or not isdir(scons_dir) or \ 362 not exists(joinpath(scons_dir, ".hg")): 363 raise ValueError(".hg directory not found") | 359hg_demandimport = False 360try: 361 if not exists(scons_dir) or not isdir(scons_dir) or \ 362 not exists(joinpath(scons_dir, ".hg")): 363 raise ValueError(".hg directory not found") |
364 365 import mercurial.demandimport, mercurial.hg, mercurial.ui 366 import mercurial.util, mercurial.node 367 hg_demandimport = True 368 369 repo = mercurial.hg.repository(mercurial.ui.ui(), scons_dir) 370 rev = mercurial.node.nullrev + repo.changelog.count() 371 changenode = repo.changelog.node(rev) 372 changes = repo.changelog.read(changenode) 373 id = mercurial.node.hex(changenode) 374 date = mercurial.util.datestr(changes[2]) 375 376 hg_info = (rev, id, date) | 364 import subprocess 365 output = subprocess.Popen("hg id -n -i -t -b".split(), 366 stdout=subprocess.PIPE).communicate()[0] 367 hg_info = output.strip() |
377except ImportError, e: 378 print "Mercurial not found" 379except ValueError, e: 380 print e 381except Exception, e: 382 print "Other mercurial exception: %s" % e 383 | 368except ImportError, e: 369 print "Mercurial not found" 370except ValueError, e: 371 print e 372except Exception, e: 373 print "Other mercurial exception: %s" % e 374 |
384if hg_demandimport: 385 mercurial.demandimport.disable() 386 | |
387# Generate Python file containing a dict specifying the current 388# build_env flags. 389def makeDefinesPyFile(target, source, env): 390 f = file(str(target[0]), 'w') 391 build_env, hg_info = [ x.get_contents() for x in source ] 392 print >>f, "buildEnv = %s" % build_env | 375# Generate Python file containing a dict specifying the current 376# build_env flags. 377def makeDefinesPyFile(target, source, env): 378 f = file(str(target[0]), 'w') 379 build_env, hg_info = [ x.get_contents() for x in source ] 380 print >>f, "buildEnv = %s" % build_env |
393 print >>f, "hgRev, hgId, hgDate = %s" % hg_info | 381 print >>f, "hgRev = '%s'" % hg_info |
394 f.close() 395 396defines_info = [ Value(build_env), Value(hg_info) ] 397# Generate a file with all of the compile options in it 398env.Command('python/m5/defines.py', defines_info, makeDefinesPyFile) 399PySource('m5', 'python/m5/defines.py') 400 401# Generate python file containing info about the M5 source code --- 668 unchanged lines hidden --- | 382 f.close() 383 384defines_info = [ Value(build_env), Value(hg_info) ] 385# Generate a file with all of the compile options in it 386env.Command('python/m5/defines.py', defines_info, makeDefinesPyFile) 387PySource('m5', 'python/m5/defines.py') 388 389# Generate python file containing info about the M5 source code --- 668 unchanged lines hidden --- |