From nobody Fri Dec 27 01:57:41 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1502476959842934.0155406435244; Fri, 11 Aug 2017 11:42:39 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 9A50F2007D094; Fri, 11 Aug 2017 11:40:16 -0700 (PDT) Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 409162095E016 for ; Fri, 11 Aug 2017 11:40:15 -0700 (PDT) Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga105.jf.intel.com with ESMTP; 11 Aug 2017 11:42:32 -0700 Received: from mdkinney-mobl1.amr.corp.intel.com ([10.252.137.26]) by fmsmga001.fm.intel.com with ESMTP; 11 Aug 2017 11:42:32 -0700 X-Original-To: edk2-devel@lists.01.org X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.41,359,1498546800"; d="scan'208";a="1181845859" From: Michael D Kinney To: edk2-devel@lists.01.org Date: Fri, 11 Aug 2017 11:42:30 -0700 Message-Id: <20170811184230.816-1-michael.d.kinney@intel.com> X-Mailer: git-send-email 2.13.1.windows.2 Subject: [edk2] [edk2-staging/edk2-test Patch] TestFrameworkPkg: Replace POSTBUILD batch file with python script X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Michael Kinney , Andrew Fish MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" 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 Cc: Supreeth Venkatesh Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Michael Kinney Reviewed-by: Andrew Fish --- TestFrameworkPkg/GenFramework.cmd | 111 ------------------- TestFrameworkPkg/GenFramework.py | 199 ++++++++++++++++++++++++++++++= ++++ TestFrameworkPkg/TestFrameworkPkg.dsc | 2 +- 3 files changed, 200 insertions(+), 112 deletions(-) delete mode 100644 TestFrameworkPkg/GenFramework.cmd create mode 100644 TestFrameworkPkg/GenFramework.py diff --git a/TestFrameworkPkg/GenFramework.cmd b/TestFrameworkPkg/GenFramew= ork.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.
-@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 ma= y 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=3D -set CLEAN=3D"" -:ArgLoop -if /i "%~1"=3D=3D"" (goto Done) -if /i "%~1"=3D=3D"clean" ( - set CLEAN=3D%~1 - shift - goto ArgLoop -) -if /i "%~2"=3D=3D"" (goto Done) -if /i "%~1"=3D=3D"-a" ( - set ARCHLIST=3D%ARCHLIST% %~2 - shift - shift - goto ArgLoop -) -if /i "%~1"=3D=3D"-b" ( - set TARGET=3D%~2 - shift - shift - goto ArgLoop -) -if /i "%~1"=3D=3D"-t" ( - set TOOLCHAIN=3D%~2 - shift - shift - goto ArgLoop -) -shift -goto ArgLoop -:Done - - -@set TEST_FRAMEWORK_PKG_PATH=3D%WORKSPACE%\TestFrameworkPkg -@if defined PACKAGES_PATH ( - @for %%i IN (%PACKAGES_PATH%) DO ( - @if exist %%~fi\TestFrameworkPkg ( - @set TEST_FRAMEWORK_PKG_PATH=3D%%~fi\TestFrameworkPkg - @goto ProcessArchList - ) - ) -) - -:ProcessArchList -for %%G in (%ARCHLIST%) do ( - set ARCH=3D%%G - call :CopyFiles -) - -goto Finished - -:CopyFiles -set Framework=3D%WORKSPACE%\Build\SctPackage\%ARCH% -set BuildOutput=3D%WORKSPACE%\Build\TestFrameworkPkg\%TARGET%_%TOOLCHAIN%\= %ARCH% -if not %CLEAN%=3D=3D"" ( - 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%\.. =20 -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/GenFramewo= rk.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.
+# This program and the accompanying materials +# are licensed and made available under the terms and conditions of the BS= D License +# which accompanies this distribution. The full text of the license may b= e 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 IMP= LIED. +# + +''' +GenFramework +''' + +import os +import sys +import argparse +import shutil + +# +# Globals for help information +# +__prog__ =3D 'GenFramework' +__version__ =3D '%s Version %s' % (__prog__, '1.0') +__copyright__ =3D 'Copyright (c) 2017, Intel Corporation. All rights res= erved.' +__description__ =3D 'Create EDK II Test Framework installer in build outpu= t directory.\n' + +# +# Globals +# +gWorkspace =3D '' +gArgs =3D None + +def Log(Message): + if not gArgs.Verbose: + return + sys.stdout.write (__prog__ + ': ' + Message + '\n') + +def Error(Message, ExitValue=3D1): + 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 =3D NormalizePath(target) + if os.path.exists(target): + Log ('rmdir %s' % (RelativePath (target))) + shutil.rmtree(target) + +def CreateDirectory(target): + target =3D NormalizePath(target) + if not os.path.exists(target): + Log ('mkdir %s' % (RelativePath (target))) + os.mkdir (target) + +def Copy(src, dst): + src =3D NormalizePath(src) + dst =3D NormalizePath(dst) + Log ('copy %s -> %s' % (RelativePath (src), RelativePath (dst))) + shutil.copy (src, dst) + +if __name__ =3D=3D '__main__': + # + # Create command line argument parser object + # + parser =3D argparse.ArgumentParser ( + prog =3D __prog__, + version =3D __version__, + description =3D __description__ + __copyright__, + conflict_handler =3D 'resolve' + ) + parser.add_argument ( + '-a', '--arch', dest =3D 'Arch', nargs =3D '+', action =3D 'app= end', + required =3D True, + help =3D '''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 =3D 'ToolChain', required =3D True, + help =3D '''Using the Tool Chain Tagname to build the platform, + overriding target.txt's TOOL_CHAIN_TAG definition.''' + ) + parser.add_argument ( + '-p', '--platform', dest =3D 'PlatformFile', required =3D True, + help =3D '''Build the platform specified by the DSC file name a= rgument, + overriding target.txt's ACTIVE_PLATFORM definition.''' + ) + parser.add_argument ( + '-b', '--buildtarget', dest =3D 'BuildTarget', required =3D Tru= e, + help =3D '''Using the TARGET to build the platform, overriding + target.txt's TARGET definition.''' + ) + parser.add_argument ( + '--conf=3D', dest =3D 'ConfDirectory', required =3D True, + help =3D '''Specify the customized Conf directory.''' + ) + parser.add_argument ( + '-D', '--define', dest =3D 'Define', nargs=3D'*', action =3D 'a= ppend', + help =3D '''Macro: "Name [=3D Value]".''' + ) + parser.add_argument ( + '-v', '--verbose', dest =3D 'Verbose', action =3D 'store_true', + help =3D '''Turn on verbose output with informational messages = printed''' + ) + + # + # Parse command line arguments + # + gArgs, remaining =3D parser.parse_known_args() + gArgs.BuildType =3D 'all' + for BuildType in ['all', 'fds', 'genc', 'genmake', 'clean', 'cleanall', = 'modules', 'libraries', 'run']: + if BuildType in remaining: + gArgs.BuildType =3D BuildType + remaining.remove(BuildType) + break + gArgs.Remaining =3D ' '.join(remaining) + + # + # Start + # + Log ('Start') + + # + # Get WORKSPACE environment variable + # + try: + gWorkspace =3D os.environ['WORKSPACE'] + except: + Error ('WORKSPACE environment variable not set') + + # + # Find TestFrameworkPkg directory in WORKSPACE or PACKAGES_PATH + # + PathList =3D [gWorkspace] + try: + PathList +=3D os.environ['PACKAGES_PATH'].split(os.pathsep) + except: + pass + for Path in PathList: + TestFrameworkPkgPath =3D 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 =3D NormalizePath((gWorkspace, 'Build/SctPackage')) + if gArgs.BuildType =3D=3D '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 =3D Item[0] + Framework =3D NormalizePath((SctPackage, Arch)) + BuildOutput =3D 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.ef= i', '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/TestF= rameworkPkg.dsc index 93c8886af..b906839a1 100644 --- a/TestFrameworkPkg/TestFrameworkPkg.dsc +++ b/TestFrameworkPkg/TestFrameworkPkg.dsc @@ -22,7 +22,7 @@ SUPPORTED_ARCHITECTURES =3D IA32|IPF|X64|EBC|ARM BUILD_TARGETS =3D DEBUG|RELEASE SKUID_IDENTIFIER =3D DEFAULT - POSTBUILD =3D TestFrameworkPkg/GenFramework.cmd + POSTBUILD =3D python TestFrameworkPkg/GenFramework.= py =20 [LibraryClasses] UefiDriverEntryPoint|MdePkg/Library/UefiDriverEntryPoint/UefiDriverEntry= Point.inf --=20 2.13.1.windows.2 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel