mirror of
https://github.com/tianocore/edk2
synced 2026-08-27 00:23:19 -04:00
BaseTools/Source/Python/Trim: Add -f/--source-code-format option
Add --source-code-format option that can be NASM or not specified. This can be used for file format specific actions when --source-code is used. A NASM specific action is added to convert #line to %line to preserve reference the originating NASM source file for source level debug in NASM format. Without this change, the source level debug of NASM files loads the generated intermediate file in the build output directory. Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
This commit is contained in:
parent
2bfde627ff
commit
e22f4a61c9
2 changed files with 12 additions and 4 deletions
|
|
@ -72,7 +72,7 @@ gIncludedAslFile = []
|
|||
# @param Target File to store the trimmed content
|
||||
# @param Convert If True, convert standard HEX format to MASM format
|
||||
#
|
||||
def TrimPreprocessedFile(Source, Target, ConvertHex, TrimLong):
|
||||
def TrimPreprocessedFile(Source, Target, ConvertHex, TrimLong, FileFormat):
|
||||
CreateDirectory(os.path.dirname(Target))
|
||||
try:
|
||||
with open(Source, "r") as File:
|
||||
|
|
@ -104,6 +104,12 @@ def TrimPreprocessedFile(Source, Target, ConvertHex, TrimLong):
|
|||
# The first injected file must be the preprocessed file itself
|
||||
if PreprocessedFile == "":
|
||||
PreprocessedFile = InjectedFile
|
||||
if PreprocessedFile == InjectedFile:
|
||||
# If this is a NASM source file, then keep the current
|
||||
# #line statement replacing #line with NASM syntax %line to
|
||||
# allow source debug to resolve to the NASM source file.
|
||||
if FileFormat == 'NASM':
|
||||
NewLines.append(Line.replace('#line', '%line', 1))
|
||||
LineControlDirectiveFound = True
|
||||
continue
|
||||
elif PreprocessedFile == "" or InjectedFile != PreprocessedFile:
|
||||
|
|
@ -529,6 +535,8 @@ def Options():
|
|||
OptionList = [
|
||||
make_option("-s", "--source-code", dest="FileType", const="SourceCode", action="store_const",
|
||||
help="The input file is preprocessed source code, including C or assembly code"),
|
||||
make_option("-f", "--source-code-format", dest="FileFormat", type="choice", choices=["NASM","NONE"], default="NONE",
|
||||
help="The format of the input file(NASM)"),
|
||||
make_option("-r", "--vfr-file", dest="FileType", const="Vfr", action="store_const",
|
||||
help="The input file is preprocessed VFR file"),
|
||||
make_option("--Vfr-Uni-Offset", dest="FileType", const="VfrOffsetBin", action="store_const",
|
||||
|
|
@ -620,7 +628,7 @@ def Main():
|
|||
else :
|
||||
if CommandOptions.OutputFile is None:
|
||||
CommandOptions.OutputFile = os.path.splitext(InputFile)[0] + '.iii'
|
||||
TrimPreprocessedFile(InputFile, CommandOptions.OutputFile, CommandOptions.ConvertHex, CommandOptions.TrimLong)
|
||||
TrimPreprocessedFile(InputFile, CommandOptions.OutputFile, CommandOptions.ConvertHex, CommandOptions.TrimLong, CommandOptions.FileFormat)
|
||||
except FatalError as X:
|
||||
import platform
|
||||
import traceback
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue