BaseTools/BuildEnv.py:

Removing BaseTools/ConfTemplates/* and using common BaseTools/Conf,
  even though they cannot be made common for all systems.  (For example,
  target.template)  I will look a different method to accomplish the
  same goal.


git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@4229 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
jljusten
2007-10-29 07:42:00 +00:00
parent a0d76ec7db
commit 8625864ea9

View File

@ -34,14 +34,15 @@ class SetupBuildEnvironmentApp:
(self.Opt, self.Args) = self.ProcessCommandLine() (self.Opt, self.Args) = self.ProcessCommandLine()
self.SetupDefaults() self.SetupDefaults()
self.DetermineEnvironment() self.DetermineEnvironment()
self.DeleteEnvironmentConfigurationScript()
self.CopyTemplates() self.CopyTemplates()
self.WriteEnvironmentConfigurationScript() self.WriteEnvironmentConfigurationScript()
def SetupDefaults(self): def SetupDefaults(self):
self.itemsToConfigure = ( self.itemsToConfigure = (
'compiler', 'compiler',
'compiler-prefix', #'compiler-prefix',
'templates and Conf directory', 'templates',
) )
self.defaults = { self.defaults = {
@ -53,7 +54,8 @@ class SetupBuildEnvironmentApp:
'options': ('/usr/bin', '/usr/bin/x86_64-pc-mingw32-'), 'options': ('/usr/bin', '/usr/bin/x86_64-pc-mingw32-'),
'freeform': True, 'freeform': True,
}, },
'templates and Conf directory': { 'templates': {
'description': 'templates and Conf directory',
'options': ( 'options': (
'copy once (no-overwrite)', 'copy once (no-overwrite)',
'copy with overwrite', 'copy with overwrite',
@ -116,28 +118,28 @@ class SetupBuildEnvironmentApp:
pickle.dump(conf, confFile) pickle.dump(conf, confFile)
confFile.close() confFile.close()
def AskCompiler(self):
self.AskForValueOfOption('compiler')
def AskCompilerPrefix(self):
self.AskForValueOfOption('compiler-prefix')
def AskForValueOfOption(self, option): def AskForValueOfOption(self, option):
options = self.defaults[option]['options'] options = self.defaults[option]['options']
if self.defaults[option].has_key('default'): if self.defaults[option].has_key('default'):
default = self.defaults[option]['default'] default = self.defaults[option]['default']
else: else:
default = None default = None
if self.defaults[option].has_key('freeform'): if self.defaults[option].has_key('freeform'):
freeform = self.defaults[option]['freeform'] freeform = self.defaults[option]['freeform']
else: else:
freeform = False freeform = False
self.AskForValue(option, options, default, freeform)
def AskForValue(self, index, options, default=None, freeform=False): if self.defaults[option].has_key('description'):
description = self.defaults[option]['description']
else:
description = option
conf = self.conf conf = self.conf
if conf.has_key(index): if conf.has_key(option):
default = conf[index] default = conf[option]
options = list(options) # in case options came in as a tuple options = list(options) # in case options came in as a tuple
assert((default == '') or (default is None) or ('' not in options)) assert((default == '') or (default is None) or ('' not in options))
if (default is not None) and (default not in options): if (default is not None) and (default not in options):
@ -148,7 +150,7 @@ class SetupBuildEnvironmentApp:
while True: while True:
print print
if len(options) > 0: if len(options) > 0:
print 'Options for', index print 'Options for', description
for i in range(len(options)): for i in range(len(options)):
print ' %d.' % (i + 1), print ' %d.' % (i + 1),
if options[i] != '': if options[i] != '':
@ -163,7 +165,7 @@ class SetupBuildEnvironmentApp:
if len(options) > 0: if len(options) > 0:
prompt = 'Select number or type value: ' prompt = 'Select number or type value: '
else: else:
prompt = 'Type value for %s: ' % index prompt = 'Type value: '
response = raw_input(prompt) response = raw_input(prompt)
response = response.strip() response = response.strip()
@ -182,8 +184,8 @@ class SetupBuildEnvironmentApp:
break break
conf[index] = response conf[option] = response
print 'Using', conf[index], 'for', index print 'Using', conf[option], 'for', description
def SummarizeCurrentState(self): def SummarizeCurrentState(self):
print print
@ -195,20 +197,20 @@ class SetupBuildEnvironmentApp:
print ' ', item, '->', value print ' ', item, '->', value
def CopyTemplates(self): def CopyTemplates(self):
todo = self.conf['templates and Conf directory'] todo = self.conf['templates']
workspace = os.path.realpath(self.Opt.workspace) workspace = os.path.realpath(self.Opt.workspace)
templatesDir = \ templatesDir = \
os.path.join(workspace, 'BaseTools', 'ConfTemplates', sys.platform.title()) os.path.join(workspace, 'BaseTools', 'Conf')
confDir = \ confDir = \
os.path.join(workspace, 'Conf') os.path.join(workspace, 'Conf')
print print
print 'Templates & Conf directory' print 'Templates & Conf directory'
print ' Templates dir:', self.RelativeToWorkspace(templatesDir) print ' Templates dir:', self.RelativeToWorkspace(templatesDir)
for filename in os.listdir(templatesDir): for filename in os.listdir(templatesDir):
if filename.startswith('.'): continue if not filename.endswith('.template'): continue
srcFilename = os.path.join(templatesDir, filename) srcFilename = os.path.join(templatesDir, filename)
destFilename = os.path.join(confDir, filename) destFilename = os.path.join(confDir, filename[:-len('template')] + 'txt')
print ' ', self.RelativeToWorkspace(destFilename), print ' ', self.RelativeToWorkspace(destFilename),
if todo == 'copy once (no-overwrite)': if todo == 'copy once (no-overwrite)':
@ -225,18 +227,24 @@ class SetupBuildEnvironmentApp:
shutil.copy(srcFilename, destFilename) shutil.copy(srcFilename, destFilename)
print '[copied' + overwrite + ']' print '[copied' + overwrite + ']'
elif todo == 'symlink to templates': elif todo == 'symlink to templates':
if os.path.exists(destFilename): if os.path.islink(destFilename) or os.path.exists(destFilename):
if not os.path.islink(destFilename): if not os.path.islink(destFilename):
raise Exception, '%s is not a symlink! (remove file if you want to start using symlinks)' % \ raise Exception, '%s is not a symlink! (remove file if you want to start using symlinks)' % \
(self.RelativeToWorkspace(destFilename)) (self.RelativeToWorkspace(destFilename))
os.remove(destFilename) os.remove(destFilename)
os.symlink(srcFilename, destFilename) os.symlink(os.path.join('..', self.RelativeToWorkspace(srcFilename)), destFilename)
print '[symlinked]' print '[symlinked]'
elif todo == 'do nothing': elif todo == 'do nothing':
print '[skipped by user request]' print '[skipped by user request]'
else: else:
raise Exception, 'Unknown action for templates&conf: %s' % todo raise Exception, 'Unknown action for templates&conf: %s' % todo
def DeleteEnvironmentConfigurationScript(self):
workspace = os.path.realpath(self.Opt.workspace)
scriptFilename = os.path.join(workspace, 'Conf', 'BuildEnv.sh')
if os.path.exists(scriptFilename):
os.remove(scriptFilename)
def WriteEnvironmentConfigurationScript(self): def WriteEnvironmentConfigurationScript(self):
workspace = os.path.realpath(self.Opt.workspace) workspace = os.path.realpath(self.Opt.workspace)
scriptFilename = os.path.join(workspace, 'Conf', 'BuildEnv.sh') scriptFilename = os.path.join(workspace, 'Conf', 'BuildEnv.sh')
@ -247,7 +255,7 @@ class SetupBuildEnvironmentApp:
print >> script, 'export WORKSPACE="%s"' % workspace print >> script, 'export WORKSPACE="%s"' % workspace
print >> script, 'export TOOLCHAIN="%s"' % self.conf['compiler'] print >> script, 'export TOOLCHAIN="%s"' % self.conf['compiler']
print >> script, 'export EDK_CC_PATH_PREFIX="%s"' % self.conf['compiler-prefix'] #print >> script, 'export COMPILER_SUITE_PATH_PREFIX="%s"' % self.conf['compiler-prefix']
EDK_TOOLS_PATH = os.path.join(workspace, 'BaseTools') EDK_TOOLS_PATH = os.path.join(workspace, 'BaseTools')
print >> script, 'if [ $EDK_TOOLS_PATH=="" ]' print >> script, 'if [ $EDK_TOOLS_PATH=="" ]'
@ -273,7 +281,6 @@ class SetupBuildEnvironmentApp:
for prefix in (workspace + os.path.sep, workspace): for prefix in (workspace + os.path.sep, workspace):
if path.startswith(prefix): if path.startswith(prefix):
return path[len(prefix):] return path[len(prefix):]
if __name__ == '__main__': if __name__ == '__main__':
SetupBuildEnvironmentApp() SetupBuildEnvironmentApp()