]> git.proxmox.com Git - mirror_edk2.git/commitdiff
BaseTools: Fixed issue in MultiThread Genfds function
authorFeng, Bob C <bob.c.feng@intel.com>
Wed, 3 Apr 2019 02:17:02 +0000 (10:17 +0800)
committerFeng, Bob C <bob.c.feng@intel.com>
Wed, 10 Apr 2019 05:32:10 +0000 (13:32 +0800)
https://bugzilla.tianocore.org/show_bug.cgi?id=1450
In the Multiple thread Genfds feature, build tool generates
GenSec, GenFFS command in Makefile.

The Non-Hii Driver does not generate .offset file for uni string offset,
but the build tool has not knowledge about this in autogen phase. So
in this patch, I add a check in Makefile for GenSec command. If the GenSec
input file does not exist, the GenSec will not be called. And if GenSec
command is not called, its output file, which is also the input file of
GenFfs command, will also not exist.So for GenFfs command,
I add a new command parameter -oi which means
the input file is an optional input file which would not exist. so
that I can generate GenFfs command with "-oi" parameter in Makefile.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Bob Feng <bob.c.feng@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
BaseTools/Conf/build_rule.template
BaseTools/Source/C/GenFfs/GenFfs.c
BaseTools/Source/Python/AutoGen/GenMake.py
BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py
BaseTools/Source/Python/Workspace/DscBuildData.py
BaseTools/Source/Python/build/build.py

index 166935d61c68e6449b409f96bfa2c9d7f3a73895..030e74c35a65a0f99a1b3fad2c3b18f781bb954b 100755 (executable)
         ?.dll\r
 \r
     <OutputFile>\r
-        $(DEBUG_DIR)(+)$(MODULE_NAME).efi\r
+        $(OUTPUT_DIR)(+)$(MODULE_NAME).efi\r
 \r
     <Command.MSFT, Command.INTEL, Command.RVCT>\r
         "$(GENFW)" -e $(MODULE_TYPE) -o ${dst} ${src} $(GENFW_FLAGS)\r
-        $(CP) ${dst} $(OUTPUT_DIR)\r
+        $(CP) ${dst} $(DEBUG_DIR)\r
         $(CP) ${dst} $(BIN_DIR)(+)$(MODULE_NAME_GUID).efi\r
         -$(CP) $(DEBUG_DIR)(+)*.map $(OUTPUT_DIR)\r
         -$(CP) $(DEBUG_DIR)(+)*.pdb $(OUTPUT_DIR) \r
         -$(CP) $(DEBUG_DIR)(+)$(MODULE_NAME).debug $(BIN_DIR)(+)$(MODULE_NAME_GUID).debug\r
 \r
         "$(GENFW)" -e $(MODULE_TYPE) -o ${dst} ${src} $(GENFW_FLAGS)\r
-        $(CP) ${dst} $(OUTPUT_DIR)\r
+        $(CP) ${dst} $(DEBUG_DIR)\r
         $(CP) ${dst} $(BIN_DIR)(+)$(MODULE_NAME_GUID).efi\r
         -$(CP) $(DEBUG_DIR)(+)*.map $(OUTPUT_DIR)\r
         \r
         # create symbol file for GDB debug\r
         -$(DSYMUTIL) ${src}\r
         "$(GENFW)" -e $(MODULE_TYPE) -o ${dst} $(DEBUG_DIR)(+)$(MODULE_NAME).pecoff $(GENFW_FLAGS)\r
-        $(CP) ${dst} $(OUTPUT_DIR)\r
+        $(CP) ${dst} $(DEBUG_DIR)\r
         $(CP) ${dst} $(BIN_DIR)(+)$(MODULE_NAME_GUID).efi\r
         -$(CP) $(DEBUG_DIR)(+)*.map $(OUTPUT_DIR)\r
 \r
index 7a2a04c0ac9fd440624df78b463b36b713080975..fcb911f4fc34e560fd06001f91ddc1afde71273c 100644 (file)
@@ -13,6 +13,10 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
 #include <sys/stat.h>\r
 #endif\r
 \r
+#ifdef __GNUC__\r
+#include <unistd.h>\r
+#endif\r
+\r
 #include <stdio.h>\r
 #include <stdlib.h>\r
 #include <string.h>\r
@@ -154,6 +158,8 @@ Returns:
                         128K,256K,512K,1M,2M,4M,8M,16M\n");\r
   fprintf (stdout, "  -i SectionFile, --sectionfile SectionFile\n\\r
                         Section file will be contained in this FFS file.\n");\r
+  fprintf (stdout, "  -oi SectionFile, --optionalsectionfile SectionFile\n\\r
+                        If the Section file exists, it will be contained in this FFS file, otherwise, it will be ignored.\n");\r
   fprintf (stdout, "  -n SectionAlign, --sectionalign SectionAlign\n\\r
                         SectionAlign points to section alignment, which support\n\\r
                         the alignment scope 0~16M. If SectionAlign is specified\n\\r
@@ -730,7 +736,7 @@ Returns:
       continue;\r
     }\r
 \r
-    if ((stricmp (argv[0], "-i") == 0) || (stricmp (argv[0], "--sectionfile") == 0)) {\r
+    if ((stricmp (argv[0], "-oi") == 0) || (stricmp (argv[0], "--optionalsectionfile") == 0) || (stricmp (argv[0], "-i") == 0) || (stricmp (argv[0], "--sectionfile") == 0)) {\r
       //\r
       // Get Input file name and its alignment\r
       //\r
@@ -738,7 +744,14 @@ Returns:
         Error (NULL, 0, 1003, "Invalid option value", "input section file is missing for -i option");\r
         goto Finish;\r
       }\r
-\r
+      if ((stricmp (argv[0], "-oi") == 0) || (stricmp (argv[0], "--optionalsectionfile") == 0) ){\r
+        if (-1 == access(argv[1] , 0)){\r
+          Warning(NULL, 0, 0001, "File is not found.", argv[1]);\r
+          argc -= 2;\r
+          argv += 2;\r
+          continue;\r
+        }\r
+      }\r
       //\r
       // Allocate Input file name buffer and its alignment buffer.\r
       //\r
index 724e64e0bade538f5896c42296d6b7fbb6257311..ed2368f6a37586e5e3f2d2d4550aaadc40827c07 100644 (file)
@@ -710,7 +710,7 @@ cleanlib:
             for index, Str in enumerate(FfsCmdList):\r
                 if '-o' == Str:\r
                     OutputFile = FfsCmdList[index + 1]\r
-                if '-i' == Str:\r
+                if '-i' == Str or "-oi" == Str:\r
                     if DepsFileList == []:\r
                         DepsFileList = [FfsCmdList[index + 1]]\r
                     else:\r
index eb7a56d252025d6bca46da4f24505992b42029ed..c9c476cf615486f80cbbd0d2ccabe34999db00d4 100644 (file)
@@ -29,6 +29,7 @@ import Common.DataType as DataType
 from Common.Misc import PathClass\r
 from Common.LongFilePathSupport import OpenLongFilePath as open\r
 from Common.MultipleWorkspace import MultipleWorkspace as mws\r
+import Common.GlobalData as GlobalData\r
 \r
 ## Global variables\r
 #\r
@@ -495,6 +496,10 @@ class GenFdsGlobalVariable:
 \r
             SaveFileOnChange(CommandFile, ' '.join(Cmd), False)\r
             if IsMakefile:\r
+                if GlobalData.gGlobalDefines.get("FAMILY") == "MSFT":\r
+                    Cmd = ['if', 'exist', Input[0]] + Cmd\r
+                else:\r
+                    Cmd = ['test', '-e', Input[0], "&&"] + Cmd\r
                 if ' '.join(Cmd).strip() not in GenFdsGlobalVariable.SecCmdList:\r
                     GenFdsGlobalVariable.SecCmdList.append(' '.join(Cmd).strip())\r
             elif GenFdsGlobalVariable.NeedsUpdate(Output, list(Input) + [CommandFile]):\r
@@ -536,7 +541,10 @@ class GenFdsGlobalVariable:
 \r
         Cmd += ("-o", Output)\r
         for I in range(0, len(Input)):\r
-            Cmd += ("-i", Input[I])\r
+            if MakefilePath:\r
+                Cmd += ("-oi", Input[I])\r
+            else:\r
+                Cmd += ("-i", Input[I])\r
             if SectionAlign and SectionAlign[I]:\r
                 Cmd += ("-n", SectionAlign[I])\r
 \r
index f34cf180567f4dddfab26e80b55e4bdd02cc1579..5431296b5a4b48f0830b4f8318fee3bdefb891dc 100644 (file)
@@ -314,6 +314,9 @@ class DscBuildData(PlatformBuildClassObject):
     @property\r
     def Arch(self):\r
         return self._Arch\r
+    @property\r
+    def Dir(self):\r
+        return self.MetaFile.Dir\r
 \r
     ## Retrieve all information in [Defines] section\r
     #\r
index 587370caaf0286fb8c8fce718979ca292e3affbc..9e6e5c15b2a744b5747fa591add652533b8da848 100644 (file)
@@ -1663,7 +1663,7 @@ class Build():
                 # Add ffs build to makefile\r
                 CmdListDict = {}\r
                 if GlobalData.gEnableGenfdsMultiThread and self.Fdf:\r
-                    CmdListDict = self._GenFfsCmd()\r
+                    CmdListDict = self._GenFfsCmd(Wa.ArchList)\r
 \r
                 for Arch in Wa.ArchList:\r
                     GlobalData.gGlobalDefines['ARCH'] = Arch\r
@@ -1756,7 +1756,7 @@ class Build():
                 # Add ffs build to makefile\r
                 CmdListDict = None\r
                 if GlobalData.gEnableGenfdsMultiThread and self.Fdf:\r
-                    CmdListDict = self._GenFfsCmd()\r
+                    CmdListDict = self._GenFfsCmd(Wa.ArchList)\r
                 self.Progress.Stop("done!")\r
                 MaList = []\r
                 ExitFlag = threading.Event()\r
@@ -1875,11 +1875,11 @@ class Build():
                     #\r
                     self._SaveMapFile (MapBuffer, Wa)\r
 \r
-    def _GenFfsCmd(self):\r
+    def _GenFfsCmd(self,ArchList):\r
         # convert dictionary of Cmd:(Inf,Arch)\r
         # to a new dictionary of (Inf,Arch):Cmd,Cmd,Cmd...\r
         CmdSetDict = defaultdict(set)\r
-        GenFfsDict = GenFds.GenFfsMakefile('', GlobalData.gFdfParser, self, self.ArchList, GlobalData)\r
+        GenFfsDict = GenFds.GenFfsMakefile('', GlobalData.gFdfParser, self, ArchList, GlobalData)\r
         for Cmd in GenFfsDict:\r
             tmpInf, tmpArch = GenFfsDict[Cmd]\r
             CmdSetDict[tmpInf, tmpArch].add(Cmd)\r
@@ -1923,7 +1923,7 @@ class Build():
                 # Add ffs build to makefile\r
                 CmdListDict = None\r
                 if GlobalData.gEnableGenfdsMultiThread and self.Fdf:\r
-                    CmdListDict = self._GenFfsCmd()\r
+                    CmdListDict = self._GenFfsCmd(Wa.ArchList)\r
 \r
                 # multi-thread exit flag\r
                 ExitFlag = threading.Event()\r