From 22c4de1ac8f1fc72e8d72af6a315e584490a44b0 Mon Sep 17 00:00:00 2001 From: Hess Chen Date: Tue, 9 Oct 2018 12:44:35 +0800 Subject: BaseTools/Ecc/EOT: Add Python 3 support on ECC and EOT tools. 1. Add Python 3 support on ECC and EOT tools 2. Add C grammar file of ANTLR4 and fix some bugs Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Hess Chen Reviewed-by: Liming Gao --- BaseTools/Source/Python/Eot/Parser.py | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) (limited to 'BaseTools/Source/Python/Eot/Parser.py') diff --git a/BaseTools/Source/Python/Eot/Parser.py b/BaseTools/Source/Python/Eot/Parser.py index e01a9770be..04afa8f2b8 100644 --- a/BaseTools/Source/Python/Eot/Parser.py +++ b/BaseTools/Source/Python/Eot/Parser.py @@ -2,7 +2,7 @@ # This file is used to define common parsing related functions used in parsing # Inf/Dsc/Makefile process # -# Copyright (c) 2008 - 2014, Intel Corporation. All rights reserved.
+# Copyright (c) 2008 - 2018, Intel Corporation. All rights reserved.
# This program and the accompanying materials # are licensed and made available under the terms and conditions of the BSD License # which accompanies this distribution. The full text of the license may be found at @@ -25,6 +25,32 @@ from . import EotGlobalData from Common.StringUtils import GetSplitList from Common.LongFilePathSupport import OpenLongFilePath as open +import subprocess + +## DeCompress +# +# Call external decompress tool to decompress the fv section +# +def DeCompress(Method, Input): + # Write the input to a temp file + open('_Temp.bin', 'wb').write(Input) + cmd = '' + if Method == 'Lzma': + cmd = r'LzmaCompress -o _New.bin -d _Temp.bin' + if Method == 'Efi': + cmd = r'TianoCompress -d --uefi -o _New.bin _Temp.bin' + if Method == 'Framework': + cmd = r'TianoCompress -d -o _New.bin _Temp.bin' + + # Call tool to create the decompressed output file + Process = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) + Process.communicate()[0] + + # Return the beffer of New.bin + if os.path.exists('New.bin'): + return open('New.bin', 'rb').read() + + ## PreProcess() method # # Pre process a file -- cgit v1.2.3