diff options
author | Hao Wu <hao.a.wu@intel.com> | 2016-11-11 16:21:35 +0800 |
---|---|---|
committer | Hao Wu <hao.a.wu@intel.com> | 2016-11-14 19:33:11 +0800 |
commit | bab82372a9e6ce066fa725a792e71d07191046ca (patch) | |
tree | 8f7f709bb0b64ce8e972f37a901c2b49e0a1d3f5 | |
parent | ea4511d127f45e5028996aba6613b4807c3c7902 (diff) | |
download | edk2-bab82372a9e6ce066fa725a792e71d07191046ca.tar.gz edk2-bab82372a9e6ce066fa725a792e71d07191046ca.tar.bz2 edk2-bab82372a9e6ce066fa725a792e71d07191046ca.zip |
DuetPkg: Add POSTBUILD in DSC files to run post-build automatically
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 <ruiyu.ni@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Hao Wu <hao.a.wu@intel.com>
Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>
-rw-r--r-- | DuetPkg/CreateBootDisk.bat | 8 | ||||
-rwxr-xr-x | DuetPkg/CreateBootDisk.sh | 10 | ||||
-rw-r--r-- | DuetPkg/DuetPkgIa32.dsc | 5 | ||||
-rw-r--r-- | DuetPkg/DuetPkgX64.dsc | 5 | ||||
-rw-r--r-- | DuetPkg/GetVariables.bat | 39 | ||||
-rw-r--r-- | DuetPkg/PostBuild.bat | 49 | ||||
-rwxr-xr-x | DuetPkg/PostBuild.sh | 60 | ||||
-rw-r--r-- | DuetPkg/ReadMe.txt | 71 | ||||
-rwxr-xr-x | DuetPkg/build32.sh | 4 | ||||
-rwxr-xr-x | DuetPkg/build64.sh | 4 |
10 files changed, 105 insertions, 150 deletions
diff --git a/DuetPkg/CreateBootDisk.bat b/DuetPkg/CreateBootDisk.bat index 7265837194..cee04b8cc5 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.<BR>
+@REM # Copyright (c) 2010 - 2016, Intel Corporation. All rights reserved.<BR>
@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 fa00408d84..897ba9bc93 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 86346f30b6..3b59343154 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 e0aeb5c1f0..c23354a5ae 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 c81d3d1604..0000000000 --- a/DuetPkg/GetVariables.bat +++ /dev/null @@ -1,39 +0,0 @@ -@echo off
-@REM ## @file
-@REM #
-@REM # Copyright (c) 2011, Intel Corporation. All rights reserved.<BR>
-@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 28cab6b665..e7f27788ac 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.<BR>
+@REM # Copyright (c) 2010 - 2016, Intel Corporation. All rights reserved.<BR>
@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 6f307e1c7e..524c9d7047 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.<BR> # @@ -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 d7ad3d6017..f894d94579 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 <VS_PATH>,
- e.g.: C:\Program Files\Microsoft Visual Studio .NET 2003\.
- 2). WinDDK
- Assume installed at <WIN_DDK_PATH>, 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 <Workspace>\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 c15c9963f8..8aa2c3d504 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 0401c56e12..1e07234177 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 $? |