BaseTools: Fixed issue in MultiThread Genfds function

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>
This commit is contained in:
Feng, Bob C 2019-04-03 10:17:02 +08:00
parent ae2fb9ead4
commit b1e27d175a
6 changed files with 37 additions and 13 deletions

View File

@ -353,11 +353,11 @@
?.dll
<OutputFile>
$(DEBUG_DIR)(+)$(MODULE_NAME).efi
$(OUTPUT_DIR)(+)$(MODULE_NAME).efi
<Command.MSFT, Command.INTEL, Command.RVCT>
"$(GENFW)" -e $(MODULE_TYPE) -o ${dst} ${src} $(GENFW_FLAGS)
$(CP) ${dst} $(OUTPUT_DIR)
$(CP) ${dst} $(DEBUG_DIR)
$(CP) ${dst} $(BIN_DIR)(+)$(MODULE_NAME_GUID).efi
-$(CP) $(DEBUG_DIR)(+)*.map $(OUTPUT_DIR)
-$(CP) $(DEBUG_DIR)(+)*.pdb $(OUTPUT_DIR)
@ -372,7 +372,7 @@
-$(CP) $(DEBUG_DIR)(+)$(MODULE_NAME).debug $(BIN_DIR)(+)$(MODULE_NAME_GUID).debug
"$(GENFW)" -e $(MODULE_TYPE) -o ${dst} ${src} $(GENFW_FLAGS)
$(CP) ${dst} $(OUTPUT_DIR)
$(CP) ${dst} $(DEBUG_DIR)
$(CP) ${dst} $(BIN_DIR)(+)$(MODULE_NAME_GUID).efi
-$(CP) $(DEBUG_DIR)(+)*.map $(OUTPUT_DIR)
@ -382,7 +382,7 @@
# create symbol file for GDB debug
-$(DSYMUTIL) ${src}
"$(GENFW)" -e $(MODULE_TYPE) -o ${dst} $(DEBUG_DIR)(+)$(MODULE_NAME).pecoff $(GENFW_FLAGS)
$(CP) ${dst} $(OUTPUT_DIR)
$(CP) ${dst} $(DEBUG_DIR)
$(CP) ${dst} $(BIN_DIR)(+)$(MODULE_NAME_GUID).efi
-$(CP) $(DEBUG_DIR)(+)*.map $(OUTPUT_DIR)

View File

@ -13,6 +13,10 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include <sys/stat.h>
#endif
#ifdef __GNUC__
#include <unistd.h>
#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@ -154,6 +158,8 @@ Returns:
128K,256K,512K,1M,2M,4M,8M,16M\n");
fprintf (stdout, " -i SectionFile, --sectionfile SectionFile\n\
Section file will be contained in this FFS file.\n");
fprintf (stdout, " -oi SectionFile, --optionalsectionfile SectionFile\n\
If the Section file exists, it will be contained in this FFS file, otherwise, it will be ignored.\n");
fprintf (stdout, " -n SectionAlign, --sectionalign SectionAlign\n\
SectionAlign points to section alignment, which support\n\
the alignment scope 0~16M. If SectionAlign is specified\n\
@ -730,7 +736,7 @@ Returns:
continue;
}
if ((stricmp (argv[0], "-i") == 0) || (stricmp (argv[0], "--sectionfile") == 0)) {
if ((stricmp (argv[0], "-oi") == 0) || (stricmp (argv[0], "--optionalsectionfile") == 0) || (stricmp (argv[0], "-i") == 0) || (stricmp (argv[0], "--sectionfile") == 0)) {
//
// Get Input file name and its alignment
//
@ -738,7 +744,14 @@ Returns:
Error (NULL, 0, 1003, "Invalid option value", "input section file is missing for -i option");
goto Finish;
}
if ((stricmp (argv[0], "-oi") == 0) || (stricmp (argv[0], "--optionalsectionfile") == 0) ){
if (-1 == access(argv[1] , 0)){
Warning(NULL, 0, 0001, "File is not found.", argv[1]);
argc -= 2;
argv += 2;
continue;
}
}
//
// Allocate Input file name buffer and its alignment buffer.
//

View File

@ -710,7 +710,7 @@ cleanlib:
for index, Str in enumerate(FfsCmdList):
if '-o' == Str:
OutputFile = FfsCmdList[index + 1]
if '-i' == Str:
if '-i' == Str or "-oi" == Str:
if DepsFileList == []:
DepsFileList = [FfsCmdList[index + 1]]
else:

View File

@ -29,6 +29,7 @@ import Common.DataType as DataType
from Common.Misc import PathClass
from Common.LongFilePathSupport import OpenLongFilePath as open
from Common.MultipleWorkspace import MultipleWorkspace as mws
import Common.GlobalData as GlobalData
## Global variables
#
@ -495,6 +496,10 @@ class GenFdsGlobalVariable:
SaveFileOnChange(CommandFile, ' '.join(Cmd), False)
if IsMakefile:
if GlobalData.gGlobalDefines.get("FAMILY") == "MSFT":
Cmd = ['if', 'exist', Input[0]] + Cmd
else:
Cmd = ['test', '-e', Input[0], "&&"] + Cmd
if ' '.join(Cmd).strip() not in GenFdsGlobalVariable.SecCmdList:
GenFdsGlobalVariable.SecCmdList.append(' '.join(Cmd).strip())
elif GenFdsGlobalVariable.NeedsUpdate(Output, list(Input) + [CommandFile]):
@ -536,7 +541,10 @@ class GenFdsGlobalVariable:
Cmd += ("-o", Output)
for I in range(0, len(Input)):
Cmd += ("-i", Input[I])
if MakefilePath:
Cmd += ("-oi", Input[I])
else:
Cmd += ("-i", Input[I])
if SectionAlign and SectionAlign[I]:
Cmd += ("-n", SectionAlign[I])

View File

@ -314,6 +314,9 @@ class DscBuildData(PlatformBuildClassObject):
@property
def Arch(self):
return self._Arch
@property
def Dir(self):
return self.MetaFile.Dir
## Retrieve all information in [Defines] section
#

View File

@ -1663,7 +1663,7 @@ class Build():
# Add ffs build to makefile
CmdListDict = {}
if GlobalData.gEnableGenfdsMultiThread and self.Fdf:
CmdListDict = self._GenFfsCmd()
CmdListDict = self._GenFfsCmd(Wa.ArchList)
for Arch in Wa.ArchList:
GlobalData.gGlobalDefines['ARCH'] = Arch
@ -1756,7 +1756,7 @@ class Build():
# Add ffs build to makefile
CmdListDict = None
if GlobalData.gEnableGenfdsMultiThread and self.Fdf:
CmdListDict = self._GenFfsCmd()
CmdListDict = self._GenFfsCmd(Wa.ArchList)
self.Progress.Stop("done!")
MaList = []
ExitFlag = threading.Event()
@ -1875,11 +1875,11 @@ class Build():
#
self._SaveMapFile (MapBuffer, Wa)
def _GenFfsCmd(self):
def _GenFfsCmd(self,ArchList):
# convert dictionary of Cmd:(Inf,Arch)
# to a new dictionary of (Inf,Arch):Cmd,Cmd,Cmd...
CmdSetDict = defaultdict(set)
GenFfsDict = GenFds.GenFfsMakefile('', GlobalData.gFdfParser, self, self.ArchList, GlobalData)
GenFfsDict = GenFds.GenFfsMakefile('', GlobalData.gFdfParser, self, ArchList, GlobalData)
for Cmd in GenFfsDict:
tmpInf, tmpArch = GenFfsDict[Cmd]
CmdSetDict[tmpInf, tmpArch].add(Cmd)
@ -1923,7 +1923,7 @@ class Build():
# Add ffs build to makefile
CmdListDict = None
if GlobalData.gEnableGenfdsMultiThread and self.Fdf:
CmdListDict = self._GenFfsCmd()
CmdListDict = self._GenFfsCmd(Wa.ArchList)
# multi-thread exit flag
ExitFlag = threading.Event()