]> git.proxmox.com Git - mirror_edk2.git/commitdiff
BaseTools/BuildEnv.py:
authorjljusten <jljusten@6f19259b-4bc3-4df7-8a09-765794883524>
Mon, 29 Oct 2007 07:42:00 +0000 (07:42 +0000)
committerjljusten <jljusten@6f19259b-4bc3-4df7-8a09-765794883524>
Mon, 29 Oct 2007 07:42:00 +0000 (07:42 +0000)
  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

BaseTools/BuildEnv.py

index 98b5ca1f457d34995c8c35a3b70668d52929ca25..b065861d2bad47de2b7aff8ce76796ff88718ebd 100755 (executable)
@@ -34,14 +34,15 @@ class SetupBuildEnvironmentApp:
     (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
@@ -53,7 +54,8 @@ class SetupBuildEnvironmentApp:
         '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
@@ -116,28 +118,28 @@ class SetupBuildEnvironmentApp:
     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
@@ -148,7 +150,7 @@ class SetupBuildEnvironmentApp:
     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
@@ -163,7 +165,7 @@ class SetupBuildEnvironmentApp:
       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
@@ -182,8 +184,8 @@ class SetupBuildEnvironmentApp:
 \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
@@ -195,20 +197,20 @@ class SetupBuildEnvironmentApp:
       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
@@ -225,18 +227,24 @@ class SetupBuildEnvironmentApp:
         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
@@ -247,7 +255,7 @@ class SetupBuildEnvironmentApp:
 \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
@@ -273,7 +281,6 @@ class SetupBuildEnvironmentApp:
     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