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