Update the POSTBUILD step that creates the installer for the test framework to use a python script. This expands the OS compatibility to include Windows, Linux, and Mac OS X.
Cc: Andrew Fish <af...@apple.com> Cc: Supreeth Venkatesh <supreeth.venkat...@arm.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Michael Kinney <michael.d.kin...@intel.com> --- TestCasePkg/GenFramework.cmd | 86 --------------- TestCasePkg/GenFramework.py | 179 ++++++++++++++++++++++++++++++ TestCasePkg/TestCasePkg.dsc | 2 +- TestFrameworkPkg/GenFramework.cmd | 111 ------------------- TestFrameworkPkg/GenFramework.py | 199 ++++++++++++++++++++++++++++++++++ TestFrameworkPkg/TestFrameworkPkg.dsc | 2 +- 6 files changed, 380 insertions(+), 199 deletions(-) delete mode 100644 TestCasePkg/GenFramework.cmd create mode 100644 TestCasePkg/GenFramework.py delete mode 100644 TestFrameworkPkg/GenFramework.cmd create mode 100644 TestFrameworkPkg/GenFramework.py diff --git a/TestCasePkg/GenFramework.cmd b/TestCasePkg/GenFramework.cmd deleted file mode 100644 index 280ca70aa..000000000 --- a/TestCasePkg/GenFramework.cmd +++ /dev/null @@ -1,86 +0,0 @@ -@REM @file -@REM Windows batch file used to create installer in build output directory -@REM -@REM Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.<BR> -@REM This program and the accompanying materials -@REM are licensed and made available under the terms and conditions of the BSD License -@REM which accompanies this distribution. The full text of the license may be found at -@REM http://opensource.org/licenses/bsd-license.php -@REM -@REM THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -@REM WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -@REM - -@echo off - -::********************************************************************** -:: Parse command line arguments -::********************************************************************** -set ARCHLIST= -set CLEAN="" -:ArgLoop -if /i "%~1"=="" (goto Done) -if /i "%~1"=="clean" ( - set CLEAN=%~1 - shift - goto ArgLoop -) -if /i "%~2"=="" (goto Done) -if /i "%~1"=="-a" ( - set ARCHLIST=%ARCHLIST% %~2 - shift - shift - goto ArgLoop -) -if /i "%~1"=="-b" ( - set TARGET=%~2 - shift - shift - goto ArgLoop -) -if /i "%~1"=="-t" ( - set TOOLCHAIN=%~2 - shift - shift - goto ArgLoop -) -shift -goto ArgLoop -:Done - -for %%G in (%ARCHLIST%) do ( - set ARCH=%%G - call :CopyFiles -) - -goto Finished - -:CopyFiles -set Framework=%WORKSPACE%\Build\SctPackage\%ARCH% -set BuildOutput=%WORKSPACE%\Build\TestCasePkg\%TARGET%_%TOOLCHAIN%\%ARCH% - -if not %CLEAN%=="" ( - if exist %Framework%\Test rmdir /s/q %Framework%\Test - exit /b -) - -rem ********************************************* -rem Create target directories -rem ********************************************* - -if not exist %Framework% mkdir %Framework% -for %%G in (Data, Dependency, Support, Test, Sequence, Report, Proxy) do ( - if not exist %Framework%\%%G mkdir %Framework%\%%G -) - -::***************************************************** -:: Copy all test cases -::***************************************************** - -copy %BuildOutput%\*.efi %Framework%\Test > NUL -exit /b - -:Finished - - - diff --git a/TestCasePkg/GenFramework.py b/TestCasePkg/GenFramework.py new file mode 100644 index 000000000..affac89cf --- /dev/null +++ b/TestCasePkg/GenFramework.py @@ -0,0 +1,179 @@ +## @file +# Create EDK II Test Framework installer in build output directory +# +# Copyright (c) 2017, Intel Corporation. All rights reserved.<BR> +# 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 +# http://opensource.org/licenses/bsd-license.php +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# + +''' +GenFramework +''' + +import os +import sys +import argparse +import glob +import shutil + +# +# Globals for help information +# +__prog__ = 'GenFramework' +__version__ = '%s Version %s' % (__prog__, '1.0') +__copyright__ = 'Copyright (c) 2017, Intel Corporation. All rights reserved.' +__description__ = 'Create EDK II Test Framework installer in build output directory.\n' + +# +# Globals +# +gWorkspace = '' +gArgs = None + +def Log(Message): + if not gArgs.Verbose: + return + sys.stdout.write (__prog__ + ': ' + Message + '\n') + +def Error(Message, ExitValue=1): + sys.stderr.write (__prog__ + ': ERROR: ' + Message + '\n') + sys.exit (ExitValue) + +def RelativePath(target): + return os.path.relpath (target, gWorkspace) + +def NormalizePath(target): + if isinstance(target, tuple): + return os.path.normpath (os.path.join (*target)) + else: + return os.path.normpath (target) + +def RemoveDirectory(target): + target = NormalizePath(target) + if os.path.exists(target): + Log ('rmdir %s' % (RelativePath (target))) + shutil.rmtree(target) + +def CreateDirectory(target): + target = NormalizePath(target) + if not os.path.exists(target): + Log ('mkdir %s' % (RelativePath (target))) + os.mkdir (target) + +def Copy(src, dst): + src = NormalizePath(src) + dst = NormalizePath(dst) + Log ('copy %s -> %s' % (RelativePath (src), RelativePath (dst))) + shutil.copy (src, dst) + +if __name__ == '__main__': + # + # Create command line argument parser object + # + parser = argparse.ArgumentParser ( + prog = __prog__, + version = __version__, + description = __description__ + __copyright__, + conflict_handler = 'resolve' + ) + parser.add_argument ( + '-a', '--arch', dest = 'Arch', nargs = '+', action = 'append', + required = True, + help = '''ARCHS is one of list: IA32, X64, IPF, ARM, AARCH64 or EBC, + which overrides target.txt's TARGET_ARCH definition. To + specify more archs, please repeat this option.''' + ) + parser.add_argument ( + '-t', '--tagname', dest = 'ToolChain', required = True, + help = '''Using the Tool Chain Tagname to build the platform, + overriding target.txt's TOOL_CHAIN_TAG definition.''' + ) + parser.add_argument ( + '-p', '--platform', dest = 'PlatformFile', required = True, + help = '''Build the platform specified by the DSC file name argument, + overriding target.txt's ACTIVE_PLATFORM definition.''' + ) + parser.add_argument ( + '-b', '--buildtarget', dest = 'BuildTarget', required = True, + help = '''Using the TARGET to build the platform, overriding + target.txt's TARGET definition.''' + ) + parser.add_argument ( + '--conf=', dest = 'ConfDirectory', required = True, + help = '''Specify the customized Conf directory.''' + ) + parser.add_argument ( + '-D', '--define', dest = 'Define', nargs='*', action = 'append', + help = '''Macro: "Name [= Value]".''' + ) + parser.add_argument ( + '-v', '--verbose', dest = 'Verbose', action = 'store_true', + help = '''Turn on verbose output with informational messages printed''' + ) + + # + # Parse command line arguments + # + gArgs, remaining = parser.parse_known_args() + gArgs.BuildType = 'all' + for BuildType in ['all', 'fds', 'genc', 'genmake', 'clean', 'cleanall', 'modules', 'libraries', 'run']: + if BuildType in remaining: + gArgs.BuildType = BuildType + remaining.remove(BuildType) + break + gArgs.Remaining = ' '.join(remaining) + + # + # Start + # + Log ('Start') + + # + # Get WORKSPACE environment variable + # + try: + gWorkspace = os.environ['WORKSPACE'] + except: + Error ('WORKSPACE environment variable not set') + + # + # Process build target + # + SctPackage = NormalizePath((gWorkspace, 'Build/SctPackage')) + if gArgs.BuildType == 'clean': + # + # Remove the installer + # + Log ('Remove TestFrameworkPkg installer from build output directory') + RemoveDirectory (SctPackage) + else: + # + # Copy files for each CPU architcture specified on command line + # + Log ('Create TestFrameworkPkg installer in build output directory') + CreateDirectory (SctPackage) + for Item in gArgs.Arch: + Arch = Item[0] + Framework = NormalizePath((SctPackage, Arch)) + BuildOutput = NormalizePath(( + gWorkspace, + 'Build/TestCasePkg', + gArgs.BuildTarget + '_' + gArgs.ToolChain, + Arch + )) + CreateDirectory (Framework) + for Directory in ['Data', 'Dependency', 'Support', 'Test', 'Sequence', 'Report', 'Proxy']: + CreateDirectory ((Framework, Directory)) + + for File in glob.glob(NormalizePath((BuildOutput, '*.efi'))): + Copy (File, (Framework, 'Test')) + + # + # Done + # + Log ('Done') diff --git a/TestCasePkg/TestCasePkg.dsc b/TestCasePkg/TestCasePkg.dsc index c2f1832ae..a85870d4d 100644 --- a/TestCasePkg/TestCasePkg.dsc +++ b/TestCasePkg/TestCasePkg.dsc @@ -22,7 +22,7 @@ SUPPORTED_ARCHITECTURES = IA32|IPF|X64|EBC|ARM BUILD_TARGETS = DEBUG|RELEASE SKUID_IDENTIFIER = DEFAULT - POSTBUILD = TestCasePkg/GenFramework.cmd + POSTBUILD = python TestCasePkg/GenFramework.py [LibraryClasses] UefiDriverEntryPoint|MdePkg/Library/UefiDriverEntryPoint/UefiDriverEntryPoint.inf diff --git a/TestFrameworkPkg/GenFramework.cmd b/TestFrameworkPkg/GenFramework.cmd deleted file mode 100644 index 256294801..000000000 --- a/TestFrameworkPkg/GenFramework.cmd +++ /dev/null @@ -1,111 +0,0 @@ -@REM @file -@REM Windows batch file used to create installer in build output directory -@REM -@REM Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.<BR> -@REM This program and the accompanying materials -@REM are licensed and made available under the terms and conditions of the BSD License -@REM which accompanies this distribution. The full text of the license may be found at -@REM http://opensource.org/licenses/bsd-license.php -@REM -@REM THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -@REM WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -@REM - -@echo off - -::********************************************************************** -:: Parse command line arguments -::********************************************************************** -set ARCHLIST= -set CLEAN="" -:ArgLoop -if /i "%~1"=="" (goto Done) -if /i "%~1"=="clean" ( - set CLEAN=%~1 - shift - goto ArgLoop -) -if /i "%~2"=="" (goto Done) -if /i "%~1"=="-a" ( - set ARCHLIST=%ARCHLIST% %~2 - shift - shift - goto ArgLoop -) -if /i "%~1"=="-b" ( - set TARGET=%~2 - shift - shift - goto ArgLoop -) -if /i "%~1"=="-t" ( - set TOOLCHAIN=%~2 - shift - shift - goto ArgLoop -) -shift -goto ArgLoop -:Done - - -@set TEST_FRAMEWORK_PKG_PATH=%WORKSPACE%\TestFrameworkPkg -@if defined PACKAGES_PATH ( - @for %%i IN (%PACKAGES_PATH%) DO ( - @if exist %%~fi\TestFrameworkPkg ( - @set TEST_FRAMEWORK_PKG_PATH=%%~fi\TestFrameworkPkg - @goto ProcessArchList - ) - ) -) - -:ProcessArchList -for %%G in (%ARCHLIST%) do ( - set ARCH=%%G - call :CopyFiles -) - -goto Finished - -:CopyFiles -set Framework=%WORKSPACE%\Build\SctPackage\%ARCH% -set BuildOutput=%WORKSPACE%\Build\TestFrameworkPkg\%TARGET%_%TOOLCHAIN%\%ARCH% -if not %CLEAN%=="" ( - if exist %Framework%\.. rmdir /s/q %Framework%\.. - exit /b -) - -rem ********************************************* -rem Create target directories -rem ********************************************* - -if not exist %Framework% mkdir %Framework% -for %%G in (Data, Dependency, Support, Test, Sequence, Report, Proxy) do ( - if not exist %Framework%\%%G mkdir %Framework%\%%G -) - -::***************************************************** -:: Copy the SCT framework and the related application -::***************************************************** - -copy %BuildOutput%\InstallSct.efi %Framework% > NUL -copy %BuildOutput%\StallForKey.efi %Framework% > NUL - -copy %BuildOutput%\SCT.efi %Framework% > NUL - -copy %BuildOutput%\StandardTest.efi %Framework%\Support > NUL -copy %BuildOutput%\TestProfile.efi %Framework%\Support > NUL -copy %BuildOutput%\TestRecovery.efi %Framework%\Support > NUL -copy %BuildOutput%\TestLogging.efi %Framework%\Support > NUL - - -::********************************************* -:: Copy the SCT configuration data -::********************************************* - -copy %TEST_FRAMEWORK_PKG_PATH%\Scripts\SctStartup.nsh %Framework%\.. -copy %TEST_FRAMEWORK_PKG_PATH%\Data\Category.ini %Framework%\Data > NUL -copy %TEST_FRAMEWORK_PKG_PATH%\Data\GuidFile.txt %Framework%\Data > NUL -exit /b - -:Finished diff --git a/TestFrameworkPkg/GenFramework.py b/TestFrameworkPkg/GenFramework.py new file mode 100644 index 000000000..c16820a45 --- /dev/null +++ b/TestFrameworkPkg/GenFramework.py @@ -0,0 +1,199 @@ +## @file +# Create EDK II Test Framework installer in build output directory +# +# Copyright (c) 2017, Intel Corporation. All rights reserved.<BR> +# 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 +# http://opensource.org/licenses/bsd-license.php +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# + +''' +GenFramework +''' + +import os +import sys +import argparse +import shutil + +# +# Globals for help information +# +__prog__ = 'GenFramework' +__version__ = '%s Version %s' % (__prog__, '1.0') +__copyright__ = 'Copyright (c) 2017, Intel Corporation. All rights reserved.' +__description__ = 'Create EDK II Test Framework installer in build output directory.\n' + +# +# Globals +# +gWorkspace = '' +gArgs = None + +def Log(Message): + if not gArgs.Verbose: + return + sys.stdout.write (__prog__ + ': ' + Message + '\n') + +def Error(Message, ExitValue=1): + sys.stderr.write (__prog__ + ': ERROR: ' + Message + '\n') + sys.exit (ExitValue) + +def RelativePath(target): + return os.path.relpath (target, gWorkspace) + +def NormalizePath(target): + if isinstance(target, tuple): + return os.path.normpath (os.path.join (*target)) + else: + return os.path.normpath (target) + +def RemoveDirectory(target): + target = NormalizePath(target) + if os.path.exists(target): + Log ('rmdir %s' % (RelativePath (target))) + shutil.rmtree(target) + +def CreateDirectory(target): + target = NormalizePath(target) + if not os.path.exists(target): + Log ('mkdir %s' % (RelativePath (target))) + os.mkdir (target) + +def Copy(src, dst): + src = NormalizePath(src) + dst = NormalizePath(dst) + Log ('copy %s -> %s' % (RelativePath (src), RelativePath (dst))) + shutil.copy (src, dst) + +if __name__ == '__main__': + # + # Create command line argument parser object + # + parser = argparse.ArgumentParser ( + prog = __prog__, + version = __version__, + description = __description__ + __copyright__, + conflict_handler = 'resolve' + ) + parser.add_argument ( + '-a', '--arch', dest = 'Arch', nargs = '+', action = 'append', + required = True, + help = '''ARCHS is one of list: IA32, X64, IPF, ARM, AARCH64 or EBC, + which overrides target.txt's TARGET_ARCH definition. To + specify more archs, please repeat this option.''' + ) + parser.add_argument ( + '-t', '--tagname', dest = 'ToolChain', required = True, + help = '''Using the Tool Chain Tagname to build the platform, + overriding target.txt's TOOL_CHAIN_TAG definition.''' + ) + parser.add_argument ( + '-p', '--platform', dest = 'PlatformFile', required = True, + help = '''Build the platform specified by the DSC file name argument, + overriding target.txt's ACTIVE_PLATFORM definition.''' + ) + parser.add_argument ( + '-b', '--buildtarget', dest = 'BuildTarget', required = True, + help = '''Using the TARGET to build the platform, overriding + target.txt's TARGET definition.''' + ) + parser.add_argument ( + '--conf=', dest = 'ConfDirectory', required = True, + help = '''Specify the customized Conf directory.''' + ) + parser.add_argument ( + '-D', '--define', dest = 'Define', nargs='*', action = 'append', + help = '''Macro: "Name [= Value]".''' + ) + parser.add_argument ( + '-v', '--verbose', dest = 'Verbose', action = 'store_true', + help = '''Turn on verbose output with informational messages printed''' + ) + + # + # Parse command line arguments + # + gArgs, remaining = parser.parse_known_args() + gArgs.BuildType = 'all' + for BuildType in ['all', 'fds', 'genc', 'genmake', 'clean', 'cleanall', 'modules', 'libraries', 'run']: + if BuildType in remaining: + gArgs.BuildType = BuildType + remaining.remove(BuildType) + break + gArgs.Remaining = ' '.join(remaining) + + # + # Start + # + Log ('Start') + + # + # Get WORKSPACE environment variable + # + try: + gWorkspace = os.environ['WORKSPACE'] + except: + Error ('WORKSPACE environment variable not set') + + # + # Find TestFrameworkPkg directory in WORKSPACE or PACKAGES_PATH + # + PathList = [gWorkspace] + try: + PathList += os.environ['PACKAGES_PATH'].split(os.pathsep) + except: + pass + for Path in PathList: + TestFrameworkPkgPath = NormalizePath((Path, 'TestFrameworkPkg')) + if os.path.exists(TestFrameworkPkgPath): + break + if not os.path.exists(TestFrameworkPkgPath): + Error ('TestFrameworkPkg directory not found in WORKSPACE or PACKAGES_PATH') + + # + # Process build target + # + SctPackage = NormalizePath((gWorkspace, 'Build/SctPackage')) + if gArgs.BuildType == 'clean': + # + # Remove the installer + # + Log ('Remove TestFrameworkPkg installer from build output directory') + RemoveDirectory (SctPackage) + else: + # + # Copy files for each CPU architcture specified on command line + # + Log ('Create TestFrameworkPkg installer in build output directory') + CreateDirectory (SctPackage) + for Item in gArgs.Arch: + Arch = Item[0] + Framework = NormalizePath((SctPackage, Arch)) + BuildOutput = NormalizePath(( + gWorkspace, + 'Build/TestFrameworkPkg', + gArgs.BuildTarget + '_' + gArgs.ToolChain, + Arch + )) + CreateDirectory (Framework) + for Directory in ['Data', 'Dependency', 'Support', 'Test', 'Sequence', 'Report', 'Proxy']: + CreateDirectory ((Framework, Directory)) + + for File in ['InstallSct.efi', 'StallForKey.efi', 'Sct.efi']: + Copy ((BuildOutput, File), Framework) + for File in ['StandardTest.efi', 'TestProfile.efi', 'TestRecovery.efi', 'TestLogging.efi']: + Copy ((BuildOutput, File), (Framework, 'Support')) + Copy ((TestFrameworkPkgPath, 'Scripts/SctStartup.nsh'), (Framework, '..')) + Copy ((TestFrameworkPkgPath, 'Data/Category.ini'), (Framework, 'Data')) + Copy ((TestFrameworkPkgPath, 'Data/GuidFile.txt'), (Framework, 'Data')) + Copy ((TestFrameworkPkgPath, 'Data/GuidFile.txt'), (Framework, 'Data')) + + # + # Done + # + Log ('Done') diff --git a/TestFrameworkPkg/TestFrameworkPkg.dsc b/TestFrameworkPkg/TestFrameworkPkg.dsc index 93c8886af..b906839a1 100644 --- a/TestFrameworkPkg/TestFrameworkPkg.dsc +++ b/TestFrameworkPkg/TestFrameworkPkg.dsc @@ -22,7 +22,7 @@ SUPPORTED_ARCHITECTURES = IA32|IPF|X64|EBC|ARM BUILD_TARGETS = DEBUG|RELEASE SKUID_IDENTIFIER = DEFAULT - POSTBUILD = TestFrameworkPkg/GenFramework.cmd + POSTBUILD = python TestFrameworkPkg/GenFramework.py [LibraryClasses] UefiDriverEntryPoint|MdePkg/Library/UefiDriverEntryPoint/UefiDriverEntryPoint.inf -- 2.13.1.windows.2 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel