From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 142C381E98 for ; Fri, 11 Nov 2016 00:26:47 -0800 (PST) Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga105.jf.intel.com with ESMTP; 11 Nov 2016 00:26:50 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.31,620,1473145200"; d="scan'208";a="30098475" Received: from shwdeopenpsi014.ccr.corp.intel.com ([10.239.9.34]) by fmsmga005.fm.intel.com with ESMTP; 11 Nov 2016 00:26:49 -0800 From: Hao Wu To: edk2-devel@lists.01.org Cc: Hao Wu , Ruiyu Ni Date: Fri, 11 Nov 2016 16:26:45 +0800 Message-Id: <1478852805-11900-4-git-send-email-hao.a.wu@intel.com> X-Mailer: git-send-email 1.9.5.msysgit.0 In-Reply-To: <1478852805-11900-1-git-send-email-hao.a.wu@intel.com> References: <1478852805-11900-1-git-send-email-hao.a.wu@intel.com> Subject: [PATCH 3/3] DuetPkg: Add POSTBUILD in DSC files to run post-build automatically X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 11 Nov 2016 08:26:47 -0000 https://bugzilla.tianocore.org/show_bug.cgi?id=220 Currently, the post-build scripts PostBuild.bat/PostBuild.sh in DuetPkg need to be run manually. Especially for Windows batch script, it also requires users to set the build options (like tool chain, target and arch) in file Conf/target.txt. If users using command line options via '-t' or '-a', the post-build script won't work properly. The package DSC files now support the feature to execute post-build script automatically by adding a 'POSTBUILD' definition. This feature also passes the build options into the post-build script as parameters. This commit uses this feature to make the post-build works for DuetPkg more user-friendly. Also, ReadMe.txt is updated to reflect the new steps for UEFI Emulation (DUET) development. Cc: Ruiyu Ni Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Hao Wu --- DuetPkg/CreateBootDisk.bat | 8 ++---- DuetPkg/CreateBootDisk.sh | 10 ++----- DuetPkg/DuetPkgIa32.dsc | 5 ++++ DuetPkg/DuetPkgX64.dsc | 5 ++++ DuetPkg/GetVariables.bat | 39 ------------------------- DuetPkg/PostBuild.bat | 49 ++++++++++++++++++++------------ DuetPkg/PostBuild.sh | 60 ++++++++++++++++----------------------- DuetPkg/ReadMe.txt | 71 +++++++++++++++++++++------------------------- DuetPkg/build32.sh | 4 +-- DuetPkg/build64.sh | 4 +-- 10 files changed, 105 insertions(+), 150 deletions(-) delete mode 100644 DuetPkg/GetVariables.bat diff --git a/DuetPkg/CreateBootDisk.bat b/DuetPkg/CreateBootDisk.bat index 7265837..cee04b8 100644 --- a/DuetPkg/CreateBootDisk.bat +++ b/DuetPkg/CreateBootDisk.bat @@ -1,7 +1,7 @@ @echo off @REM ## @file @REM # -@REM # Copyright (c) 2010 - 2014, Intel Corporation. All rights reserved.
+@REM # Copyright (c) 2010 - 2016, Intel Corporation. All rights reserved.
@REM # @REM # This program and the accompanying materials @REM # are licensed and made available under the terms and conditions of the BSD License @@ -15,14 +15,11 @@ @REM Set up environment at first. -set BASETOOLS_DIR=%WORKSPACE_TOOLS_PATH%\Bin\Win32 +set BASETOOLS_DIR=%EDK_TOOLS_BIN% set BOOTSECTOR_BIN_DIR=%WORKSPACE%\DuetPkg\BootSector\bin set DISK_LABEL=DUET set PROCESSOR="" set STEP=1 -call %WORKSPACE%\DuetPkg\GetVariables.bat - -echo on if "%1"=="" goto Help if "%2"=="" goto Help @@ -35,6 +32,7 @@ set EFI_BOOT_DISK=%2 if "%TARGET_ARCH%"=="IA32" set PROCESSOR=IA32 if "%TARGET_ARCH%"=="X64" set PROCESSOR=X64 if %PROCESSOR%=="" goto WrongArch +call %WORKSPACE%\DuetPkg\SetEnv_%PROCESSOR%.bat set BUILD_DIR=%WORKSPACE%\Build\DuetPkg%PROCESSOR%\%TARGET%_%TOOL_CHAIN_TAG% if "%1"=="floppy" goto CreateFloppy diff --git a/DuetPkg/CreateBootDisk.sh b/DuetPkg/CreateBootDisk.sh index fa00408..897ba9b 100755 --- a/DuetPkg/CreateBootDisk.sh +++ b/DuetPkg/CreateBootDisk.sh @@ -34,7 +34,7 @@ if [ \ "$*" = "--help" \ ] then - echo "Usage: CreateBootDisk [usb|floppy|ide|file] MediaPath DevicePath [FAT12|FAT16|FAT32] [IA32|X64] [GCC44|UNIXGCC]" + echo "Usage: CreateBootDisk [usb|floppy|ide|file] MediaPath DevicePath [FAT12|FAT16|FAT32] [IA32|X64]" echo "e.g. : CreateBootDisk floppy /media/floppy0 /dev/fd0 FAT12 IA32" PROCESS_MARK=FALSE fi @@ -51,13 +51,7 @@ case "$5" in return 1 esac -if [ -z "$6" ] -then - TOOLCHAIN=GCC44 -else - TOOLCHAIN=$6 -fi - +. $WORKSPACE/DuetPkg/SetEnv_$PROCESSOR.sh export BUILD_DIR=$WORKSPACE/Build/DuetPkg$PROCESSOR/DEBUG_$TOOLCHAIN diff --git a/DuetPkg/DuetPkgIa32.dsc b/DuetPkg/DuetPkgIa32.dsc index 86346f3..3b59343 100644 --- a/DuetPkg/DuetPkgIa32.dsc +++ b/DuetPkg/DuetPkgIa32.dsc @@ -31,6 +31,11 @@ BUILD_TARGETS = DEBUG SKUID_IDENTIFIER = DEFAULT FLASH_DEFINITION = DuetPkg/DuetPkg.fdf +!if $(TOOL_CHAIN_TAG) == GCC47 || $(TOOL_CHAIN_TAG) == GCC48 || $(TOOL_CHAIN_TAG) == GCC49 || $(TOOL_CHAIN_TAG) == GCC5 + POSTBUILD = DuetPkg/PostBuild.sh +!else + POSTBUILD = DuetPkg/PostBuild.bat +!endif ################################################################################ # diff --git a/DuetPkg/DuetPkgX64.dsc b/DuetPkg/DuetPkgX64.dsc index e0aeb5c..c23354a 100644 --- a/DuetPkg/DuetPkgX64.dsc +++ b/DuetPkg/DuetPkgX64.dsc @@ -31,6 +31,11 @@ BUILD_TARGETS = DEBUG SKUID_IDENTIFIER = DEFAULT FLASH_DEFINITION = DuetPkg/DuetPkg.fdf +!if $(TOOL_CHAIN_TAG) == GCC47 || $(TOOL_CHAIN_TAG) == GCC48 || $(TOOL_CHAIN_TAG) == GCC49 || $(TOOL_CHAIN_TAG) == GCC5 + POSTBUILD = DuetPkg/PostBuild.sh +!else + POSTBUILD = DuetPkg/PostBuild.bat +!endif ################################################################################ # diff --git a/DuetPkg/GetVariables.bat b/DuetPkg/GetVariables.bat deleted file mode 100644 index c81d3d1..0000000 --- a/DuetPkg/GetVariables.bat +++ /dev/null @@ -1,39 +0,0 @@ -@echo off -@REM ## @file -@REM # -@REM # Copyright (c) 2011, Intel Corporation. All rights reserved.
-@REM # -@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 # 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 # -@REM # -@REM ## - - -@REM Read the variables from Conf/target.txt -@REM Because we can't add '=' as a delimiter in 'for', each variable is read in 2 parts: -@REM First we read the "= xyz" part of the variable assignation which we use, along with -@REM the original equal sign for our first assignation. Then we trim any left whitespaces. -@REM NB: default token delimiters for "for /f" are tab and space. - -set CONFIG_FILE=%WORKSPACE%\Conf\target.txt - -for /f "tokens=1*" %%i in ('type %CONFIG_FILE% ^| find "TOOL_CHAIN_TAG" ^| find /V "#"') do @set TOOL_CHAIN_TAG%%j -for /f "tokens=*" %%i in ("%TOOL_CHAIN_TAG%") do @set TOOL_CHAIN_TAG=%%i - -for /f "tokens=1*" %%i in ('type %CONFIG_FILE% ^| find "TARGET" ^| find /V "#" ^| find /V "TARGET_ARCH"') do @set TARGET%%j -for /f "tokens=*" %%i in ("%TARGET%") do @set TARGET=%%i - -for /f "tokens=1*" %%i in ('type %CONFIG_FILE% ^| find "TARGET_ARCH" ^|find /V "#"') do @set TARGET_ARCH%%j -for /f "tokens=*" %%i in ("%TARGET_ARCH%") do @set TARGET_ARCH=%%i - - -REM Set defaults if above variables are undefined in target.txt - -if "%TOOL_CHAIN_TAG%%"=="" @set TOOL_CHAIN_TAG=MYTOOLS -if "%TARGET%"=="" @set TARGET=DEBUG -if "%TARGET_ARCH%"=="" @set TARGET_ARCH=IA32 diff --git a/DuetPkg/PostBuild.bat b/DuetPkg/PostBuild.bat index 28cab6b..e7f2778 100644 --- a/DuetPkg/PostBuild.bat +++ b/DuetPkg/PostBuild.bat @@ -1,11 +1,9 @@ @echo off @REM ## @file @REM # -@REM # Currently, Build system does not provide post build mechanism for module -@REM # and platform building, so just use a bat file to do post build commands. -@REM # Originally, following post building command is for EfiLoader module. +@REM # Post build script that will be automatically run after build. @REM # -@REM # Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.
+@REM # Copyright (c) 2010 - 2016, Intel Corporation. All rights reserved.
@REM # @REM # This program and the accompanying materials @REM # are licensed and made available under the terms and conditions of the BSD License @@ -17,18 +15,38 @@ @REM # @REM ## -set BASETOOLS_DIR=%WORKSPACE_TOOLS_PATH%\Bin\Win32 +set BASETOOLS_DIR=%EDK_TOOLS_BIN% set BOOTSECTOR_BIN_DIR=%WORKSPACE%\DuetPkg\BootSector\bin -set PROCESSOR="" -call %WORKSPACE%\DuetPkg\GetVariables.bat -if NOT "%1"=="" @set TARGET_ARCH=%1 -if "%TARGET_ARCH%"=="IA32" set PROCESSOR=IA32 -if "%TARGET_ARCH%"=="X64" set PROCESSOR=X64 -if %PROCESSOR%=="" goto WrongArch +:SetDefault +set TARGET_ARCH= +set TARGET= +set TOOL_CHAIN_TAG= +:ParseParamsLoop +if "%1"=="" goto EndPParseParamsLoop +if /I "%1"=="-p" goto ParseParamsLoopNext +if /I "%1"=="-a" set TARGET_ARCH=%2& goto ParseParamsLoopNext +if /I "%1"=="-b" set TARGET=%2& goto ParseParamsLoopNext +if /I "%1"=="-t" set TOOL_CHAIN_TAG=%2& goto ParseParamsLoopNext +if /I "%1"=="-h" goto Help + +:ParseParamsLoopNext +shift +shift +goto ParseParamsLoop + +:EndPParseParamsLoop +if "%TARGET_ARCH%"=="" goto Help +if "%TARGET%"=="" goto Help +if "%TOOL_CHAIN_TAG%"=="" goto Help + +set PROCESSOR=%TARGET_ARCH% set BUILD_DIR=%WORKSPACE%\Build\DuetPkg%PROCESSOR%\%TARGET%_%TOOL_CHAIN_TAG% +@REM Store environment variables used by CreateBootDisk.bat +echo set TARGET=%TARGET%> %WORKSPACE%\DuetPkg\SetEnv_%PROCESSOR%.bat +echo set TOOL_CHAIN_TAG=%TOOL_CHAIN_TAG%>> %WORKSPACE%\DuetPkg\SetEnv_%PROCESSOR%.bat echo Compressing DUETEFIMainFv.FV ... %BASETOOLS_DIR%\LzmaCompress -e -o %BUILD_DIR%\FV\DUETEFIMAINFV.z %BUILD_DIR%\FV\DUETEFIMAINFV.Fv @@ -60,11 +78,6 @@ copy /b %BOOTSECTOR_BIN_DIR%\St32_64.com+%BOOTSECTOR_BIN_DIR%\Efi64.com2+%BUILD_ %BASETOOLS_DIR%\GenPage.exe %BUILD_DIR%\FV\Efildr20Pure -o %BUILD_DIR%\FV\Efildr20 goto end - -:WrongArch -echo Error! Wrong architecture. -goto Help - :Help -echo Usage: "PostBuild [IA32|X64]" -:end \ No newline at end of file +echo Usage: This script will be run automatically after build. +:end diff --git a/DuetPkg/PostBuild.sh b/DuetPkg/PostBuild.sh index 6f307e1..524c9d7 100755 --- a/DuetPkg/PostBuild.sh +++ b/DuetPkg/PostBuild.sh @@ -2,9 +2,7 @@ ## @file # -# Currently, Build system does not provide post build mechanism for module -# and platform building, so just use a sh file to do post build commands. -# Originally, following post building command is for EfiLoader module. +# Post build script that will be automatically run after build. # # Copyright (c) 2010 - 2016, Intel Corporation. All rights reserved.
# @@ -26,43 +24,33 @@ fi export BOOTSECTOR_BIN_DIR=$WORKSPACE/DuetPkg/BootSector/bin export PROCESSOR="" -if [ \ - -z "$1" -o \ - "$1" = "-?" -o \ - "$1" = "-h" -o \ - "$1" = "--help" \ - ] -then - echo Error! Please specific the architecture. - echo Usage: "./PostBuild.sh [IA32|X64] [UNIXGCC|GCC44]" +export TOOLTAG="" + +while [ $# -gt 0 ]; do + if [ "$1" = "-a" ]; then + export PROCESSOR=$2 + elif [ "$1" = "-t" ]; then + export TOOLTAG=$2 + elif [ "$1" = "-h" ]; then + echo Usage: This script will be run automatically after build. + return 1 + fi + shift + shift +done + +if [ "$PROCESSOR" = "" -o "$TOOLTAG" = "" ]; then + echo Usage: This script will be run automatically after build. + return 1 fi -case "$1" in - IA32) - export PROCESSOR=IA32 - ;; - X64) - export PROCESSOR=X64 - ;; - *) - echo Invalid Architecture string, should be only IA32 or X64 - return 1 -esac - -case "$2" in - UNIXGCC) - export TOOLTAG=UNIXGCC - ;; - GCC4*) - export TOOLTAG=$2 - ;; - *) - echo Invalid tool tag, should be only UNIXGCC or GCC4\* - return 1 -esac - export BUILD_DIR=$WORKSPACE/Build/DuetPkg$PROCESSOR/DEBUG_$TOOLTAG +# +# Store environment variables used by CreateBootDisk.sh +# +echo export TOOLCHAIN=$TOOLTAG> $WORKSPACE/DuetPkg/SetEnv_$PROCESSOR.sh +chmod +x $WORKSPACE/DuetPkg/SetEnv_$PROCESSOR.sh # # Boot sector module could only be built under IA32 tool chain diff --git a/DuetPkg/ReadMe.txt b/DuetPkg/ReadMe.txt index d7ad3d6..f894d94 100644 --- a/DuetPkg/ReadMe.txt +++ b/DuetPkg/ReadMe.txt @@ -4,28 +4,22 @@ A. Build DUET image on Windows Platform ======================================== 1. Tools preparation -To build DUET image, following tools are required: + To build DUET image, Visual Studio is required: + 1). Base on below link to create Visual Studio build environment. + https://github.com/tianocore/tianocore.github.io/wiki/Windows-systems - 1). *Visual Studio 2005* - Assume installed at , - e.g.: C:\Program Files\Microsoft Visual Studio .NET 2003\. - 2). WinDDK - Assume installed at , e.g.: C:\WINDDK\3790.1830\. - -2. Build steps - -2.1 Build Duet Platform module +2. Build Duet Platform module 1). run cmd.exe to open command line window. 2). enter workspace root directory such as c:\edk2_tree - 2). run "edksetup.bat" - 3). run "build -p DuetPkg\DuetPkg.dsc -a IA32" for IA32 architecture platform or - "build -p DuetPkg\DuetPkg.dsc -a X64" for X64 architecture platform. + 3). set the environment variable EDK_TOOLS_BIN to point at the BaseTools binaries directory + i.e., "set EDK_TOOLS_BIN=c:\edk2-BaseTools-win32" + 4). run "edksetup.bat" + 5). run "build -p DuetPkg\DuetPkgIa32.dsc -a IA32 -t VS2015x86" for IA32 architecture platform (using 64-bit VS2015 for example) or + "build -p DuetPkg\DuetPkgX64.dsc -a X64 -t VS2015x86" for X64 architecture platform. + + NOTE: The post build script 'PostBuild.sh' will be automatically called after the build command. -2.2 Execute post build actions - 1). enter \DuetPkg directory. - 2). run "PostBuild.bat IA32" for IA32 architecture platform or - "PostBuild.bat X64" for X64 architecture platform. Create bootable disk ====================== @@ -56,34 +50,35 @@ B. Build DUET image on Linux Platform ====================================== 1. Tools preparation - To build DUET image, GCC44 is required: - 1). Base on below link to create GCC44 build environment. - http://tianocore.sourceforge.net/wiki/Using_EDK_II_with_Native_GCC + To build DUET image, GCC installation (4.4+) is required: + 1). Base on below link to create GCC build environment. + https://github.com/tianocore/tianocore.github.io/wiki/Using-EDK-II-with-Native-GCC -2. Build steps - -2.1 Build Duet Platform module +2. Build Duet Platform module 1). Open the terminal. 2). enter workspace root directory such as /edk2_tree 3). run ". edksetup.sh BaseTools" - 4). run "build -p DuetPkg/DuetPkg.dsc -a IA32 -t GCC44" for IA32 architecture platform or - "build -p DuetPkg/DuetPkg.dsc -a X64 -t GCC44" for X64 architecture platform. - -2.2 Execute post build actions - 1). enter /edk2_tree/DuetPkg directory. - 2). run "./PostBuild.sh IA32 GCC44" for IA32 architecture platform or - "./PostBuild.sh X64 GCC44" for X64 architecture platform. + 4). run "build -p DuetPkg/DuetPkgIa32.dsc -a IA32 -t GCC49" for IA32 architecture platform (using GCC 4.9 for example) or + "build -p DuetPkg/DuetPkgX64.dsc -a X64 -t GCC49" for X64 architecture platform. - NOTE: After post build action, you should check the size of EfiLdr at $WORKSPACE/Build/DuetPkg/DEBUG_GCC44 directory, it must less than 470k. - If not, you should manually remove some unnecessary drivers at DuetPkg.fdf file. + NOTE: The post build script 'PostBuild.sh' will be automatically called after the build command. + After post build action, you should check the size of EfiLdr at $WORKSPACE/Build/DuetPkgIA32(DuetPkgX64)/DEBUG_GCC49 directory, it must less than 470k. + If not, you should manually remove some unnecessary drivers at DuetPkg.fdf file. 3. Create bootable disk The following steps are same for IA32 architecture platform or X64 architecture platform. - Now only support floopy. - 3.1 Create floppy boot disk - 1). enter /edk2_tree/DuetPkg directory. - 2). Insert a floppy disk to drive - 3). run "CreateBootDisk.sh" to build floppy drive - such as "./CreateBootDisk.sh floppy /media/floppy0 /dev/fd0 FAT12 IA32" +3.1 Create floppy boot disk + 1). enter /edk2_tree/DuetPkg directory. + 2). Insert a floppy disk to drive + 3). run "CreateBootDisk.sh" to build floppy drive + such as "./CreateBootDisk.sh floppy /media/floppy0 /dev/fd0 FAT12 IA32" + +3.2 Create usb boot disk + 1). enter /edk2_tree/DuetPkg directory. + 2). Plugin usb disk + 3). run "CreateBootDisk.sh" to build usb drive + such as "./CreateBootDisk.sh usb /media/usb0 /dev/sdb0 FAT16 IA32" + 4). UnPlug usb disk and plugin it again. + 5). run "./CreateBootDisk.sh usb /media/usb0 /dev/sdb0 FAT16 IA32 step2" diff --git a/DuetPkg/build32.sh b/DuetPkg/build32.sh index c15c996..8aa2c3d 100755 --- a/DuetPkg/build32.sh +++ b/DuetPkg/build32.sh @@ -126,10 +126,8 @@ done # echo Running edk2 build for DuetPkg$Processor build -p $WORKSPACE/DuetPkg/DuetPkg$Processor.dsc -a $PROCESSOR -t $TARGET_TOOLS -n 3 $* -echo Running DuetPkg/PostBuild.sh -$WORKSPACE/DuetPkg/PostBuild.sh $PROCESSOR $TARGET_TOOLS echo Running DuetPkg/CreateBootDisk.sh -$WORKSPACE/DuetPkg/CreateBootDisk.sh file $FLOPPY_IMAGE /dev/null FAT12 $PROCESSOR $TARGET_TOOLS +$WORKSPACE/DuetPkg/CreateBootDisk.sh file $FLOPPY_IMAGE /dev/null FAT12 $PROCESSOR exit $? diff --git a/DuetPkg/build64.sh b/DuetPkg/build64.sh index 0401c56..1e07234 100755 --- a/DuetPkg/build64.sh +++ b/DuetPkg/build64.sh @@ -125,10 +125,8 @@ done # echo Running edk2 build for DuetPkg$PROCESSOR build -p $WORKSPACE/DuetPkg/DuetPkg$PROCESSOR.dsc -a $PROCESSOR -t $TARGET_TOOLS -n 3 $* -echo Running DuetPkg/PostBuild.sh -$WORKSPACE/DuetPkg/PostBuild.sh $PROCESSOR $TARGET_TOOLS echo Running DuetPkg/CreateBootDisk.sh -$WORKSPACE/DuetPkg/CreateBootDisk.sh file $FLOPPY_IMAGE /dev/null FAT12 $PROCESSOR $TARGET_TOOLS +$WORKSPACE/DuetPkg/CreateBootDisk.sh file $FLOPPY_IMAGE /dev/null FAT12 $PROCESSOR exit $? -- 1.9.5.msysgit.0