- Remove the TOOL without NAME defined and its definition in ARCH_build.opt
authorjwang36 <jwang36@de2fecce-e211-0410-80a6-f3fac2684e05>
Fri, 26 Jan 2007 06:28:27 +0000 (06:28 +0000)
committerjwang36 <jwang36@de2fecce-e211-0410-80a6-f3fac2684e05>
Fri, 26 Jan 2007 06:28:27 +0000 (06:28 +0000)
- Prefix the tool path to its name in ARCH_build.opt
- Support the same library class in different package

git-svn-id: https://edk2.tianocore.org/svn/edk2/trunk@2325 de2fecce-e211-0410-80a6-f3fac2684e05

edk2/Tools/Python/buildgen/BuildFile.py
edk2/Tools/Python/buildgen/FrameworkElement.py
edk2/Tools/Python/buildgen/SurfaceAreaElement.py

index 8514e4c..9a2aae3 100644 (file)
@@ -230,18 +230,19 @@ class AntPlatformBuildFile(BuildFile):
         """Generate ${ARCH}_build.opt which contains the default build&tool definitions"""\r
         tools = self.Workspace.ToolConfig.ToolCodes\r
         for arch in self.Workspace.ActiveArchs:\r
+            validTools = []\r
+            for tool in tools:\r
+                key = (self.Toolchain, self.Target, arch, tool, "NAME")\r
+                if self.Workspace.ToolConfig[key] == "": continue\r
+                validTools.append(tool)\r
+                \r
             optFileDir = os.path.join(self.Workspace.Path, self.Platform.OutputPath,\r
                                       self.Target + "_" + self.Toolchain)\r
             optFileName = arch + "_build.opt"\r
             if not os.path.exists(optFileDir): os.makedirs(optFileDir)\r
             f = open(os.path.join(optFileDir, optFileName), "w")\r
-            for tool in tools:\r
-                key = (self.Toolchain, self.Target, arch, tool, "FLAGS")\r
-                flag = self.Workspace.ToolConfig[key]\r
-                f.write("DEFAULT_%s_FLAGS=%s\n" % (tool, flag))\r
-\r
-            f.write("\n")\r
-            for tool in tools:\r
+            \r
+            for tool in validTools:\r
                 key = (self.Toolchain, self.Target, arch, tool, "FLAGS")\r
                 if key in self.Platform.BuildOptions:\r
                     flag = self.Platform.BuildOptions[key]\r
@@ -254,15 +255,22 @@ class AntPlatformBuildFile(BuildFile):
                     else:\r
                         flag = ""\r
                 f.write("PLATFORM_%s_FLAGS=%s\n" % (tool, flag))\r
+            f.write("\n")\r
+\r
+            for tool in validTools:\r
+                key = (self.Toolchain, self.Target, arch, tool, "FLAGS")\r
+                flag = self.Workspace.ToolConfig[key]\r
+                f.write("DEFAULT_%s_FLAGS=%s\n" % (tool, flag))\r
 \r
             f.write("\n")\r
-            for tool in tools:\r
+            for tool in validTools:\r
                 for attr in self.Workspace.ToolConfig.Attributes:\r
                     if attr == "FLAGS": continue\r
                     key = (self.Toolchain, self.Target, arch, tool, attr)\r
                     value = self.Workspace.ToolConfig[key]\r
                     if attr == "NAME":\r
-                        f.write("%s=%s\n" % (tool, value))\r
+                        path = self.Workspace.ToolConfig[(self.Toolchain, self.Target, arch, tool, "PATH")]\r
+                        f.write("%s=%s\n" % (tool, os.path.join(path, value)))\r
                     else:\r
                         f.write("%s_%s=%s\n" % (tool, attr, value))\r
                 f.write("%s_FLAGS=${DEFAULT_%s_FLAGS} ${DEFAULT_MODULE_%s_FLAGS} ${PLATFORM_%s_FLAGS} ${MODULE_%s_FLAGS}\n" %\r
index 6fd8740..3be8eaa 100644 (file)
@@ -487,7 +487,7 @@ class Workspace(Element):
                                         "PATH"  : {},\r
                                         "NAME"  : {},\r
                                       }\r
-        ## "NAME" : {name : library interface}\r
+        ## "NAME" : {name : [library interface]}\r
         ## "PATH" : {path : library interface}\r
         self.LibraryInterfaceXref   = {\r
                                         "PATH"  : {},\r
index 2f022c7..ae1938f 100644 (file)
@@ -284,9 +284,6 @@ class LibraryClass(FrameworkElement.LibraryClass, SurfaceAreaElement):
                 self.FavoriteIntance = FrameworkElement.Module()\r
             self.FavoriteIntance.Version = attribute\r
 \r
-    def Postprocess(self):\r
-        self.Interface = self._Workspace.GetLibraryInterface(self.Name)\r
-\r
 class SourceFile(FrameworkElement.SourceFile, SurfaceAreaElement):\r
     def __init__(self, workspace, module, dom):\r
         FrameworkElement.SourceFile.__init__(self)\r
@@ -758,7 +755,7 @@ class ModuleSurfaceArea(FrameworkElement.Module, SurfaceAreaElement):
         # resolve library class\r
         if self._Elements.has_key("LibraryClassDefinitions"):\r
             for lc in self._Elements["LibraryClassDefinitions"]:\r
-                lc.Interface = self._Workspace.GetLibraryInterface(lc.Name)\r
+                lc.Interface = self.GetLibraryInterface(lc.Name)\r
                 if "ALWAYS_PRODUCED" in lc.Usage:\r
                     self.IsLibrary = True\r
                     lc.Interface.Instances.append(self)\r
@@ -811,6 +808,14 @@ class ModuleSurfaceArea(FrameworkElement.Module, SurfaceAreaElement):
                     if arch not in self.Externs:\r
                         self.Externs[arch] = []\r
                     self.Externs[arch].append(extern)\r
+                    \r
+    def GetLibraryInterface(self, name):\r
+        if name in self.Package.LibraryInterfaces:\r
+            return self.Package.LibraryInterfaces[name]\r
+        for pd in self._Elements["PackageDependencies"]:\r
+            if name in pd.Package.LibraryInterfaces:\r
+                return pd.Package.LibraryInterfaces[name]\r
+        return ""\r
 ##    def SetupEnvironment(self):\r
 ##        self.Environment["MODULE"] = self.Name\r
 ##        self.Environment["MODULE_GUID"] = self.GuidValue\r
@@ -1027,10 +1032,14 @@ class Workspace(FrameworkElement.Workspace, SurfaceAreaElement):
                 return platform\r
         return ""\r
 \r
-    def GetLibraryInterface(self, name):\r
+    def GetLibraryInterface(self, name, package):\r
         if name not in self.LibraryInterfaceXref["NAME"]:\r
             return ""\r
-        return self.LibraryInterfaceXref["NAME"][name]\r
+        liList = self.LibraryInterfaceXref["NAME"][name]\r
+        for li in liList:\r
+            if li.Package == package:\r
+                return li\r
+        return ""\r
     \r
     def SubPath(self, *relativePathList):\r
         return os.path.normpath(os.path.join(self.Path, *relativePathList))\r
@@ -1084,14 +1093,17 @@ class Workspace(FrameworkElement.Workspace, SurfaceAreaElement):
             ##      library class name -> library class object\r
             ##\r
             for lcname in p.LibraryInterfaces:\r
-                if lcname in self.LibraryInterfaceXref["NAME"]:\r
-                    raise Exception("Duplicate library class: %s in package %s" % (lcname, name))\r
+                if lcname not in self.LibraryInterfaceXref["NAME"]:\r
+                    # raise Exception("Duplicate library class: %s in package %s" % (lcname, name))\r
+                    self.LibraryInterfaceXref["NAME"][lcname] = []\r
                 lcInterface = p.LibraryInterfaces[lcname]\r
-                self.LibraryInterfaceXref["NAME"][lcname] = lcInterface\r
+                self.LibraryInterfaceXref["NAME"][lcname].append(lcInterface)\r
                 \r
-                if lcInterface not in self.LibraryInterfaceXref["PATH"]:\r
-                    self.LibraryInterfaceXref["PATH"][lcInterface] = []\r
-                self.LibraryInterfaceXref["PATH"][lcInterface].append(lcname)\r
+                lcHeader = p.SubPath(lcInterface.Path)\r
+                if lcHeader not in self.LibraryInterfaceXref["PATH"]:\r
+                    # raise Exception("Duplicate library class interface: %s in package %s" % (lcInterface, name))\r
+                    self.LibraryInterfaceXref["PATH"][lcHeader] = []\r
+                self.LibraryInterfaceXref["PATH"][lcHeader].append(lcInterface)\r
 \r
         ##\r
         ## setup package cross reference as nest-dict\r
@@ -1111,7 +1123,10 @@ class Workspace(FrameworkElement.Workspace, SurfaceAreaElement):
                 if guid not in moduleGuidIndex:\r
                     moduleGuidIndex[guid] = {}\r
                 else:\r
-                    print "! Duplicate module GUID found:", guid, path\r
+                    print "! Duplicate module GUID found:", guid, p.SubPath(path)\r
+                    dm = moduleGuidIndex[guid].values()[0][0]\r
+                    print "                              ", dm.GuidValue,\\r
+                                                    dm.Package.SubPath(dm.Path)\r
 \r
                 if version not in moduleGuidIndex[guid]:\r
                     moduleGuidIndex[guid][version] = []\r
@@ -1483,17 +1498,18 @@ def PrintWorkspace(ws):
                 print "\n"\r
     print "\nLibrary Classes:"\r
     for name in ws.LibraryInterfaceXref["NAME"]:\r
-        lc = ws.LibraryInterfaceXref["NAME"][name]\r
-        pkgPath = os.path.dirname(lc.Package.Path)\r
-        print "\n  [%s] <%s>" % (lc.Name, pkgPath + os.path.sep + lc.Path)\r
-\r
-        print "    Produced By:"\r
-        for li in lc.Instances:\r
-            print "      %-40s <%s>" % (li.Name+"-"+li.Version, li.Package.SubPath(li.Path))\r
-\r
-        print "    Consumed By:"\r
-        for li in lc.Consumers:\r
-            print "      %-40s <%s>" % (li.Name+"-"+li.Version, li.Package.SubPath(li.Path))\r
+        lcList = ws.LibraryInterfaceXref["NAME"][name]\r
+        for lc in lcList:\r
+            pkgPath = os.path.dirname(lc.Package.Path)\r
+            print "\n  [%s] <%s>" % (lc.Name, pkgPath + os.path.sep + lc.Path)\r
+\r
+            print "    Produced By:"\r
+            for li in lc.Instances:\r
+                print "      %-40s <%s>" % (li.Name+"-"+li.Version, li.Package.SubPath(li.Path))\r
+\r
+            print "    Consumed By:"\r
+            for li in lc.Consumers:\r
+                print "      %-40s <%s>" % (li.Name+"-"+li.Version, li.Package.SubPath(li.Path))\r
 \r
     print "\nActive Platform:"\r
     for arch in ws.ActivePlatform.Libraries:\r