]> git.proxmox.com Git - mirror_edk2.git/commitdiff
DuetPkg: Add POSTBUILD in DSC files to run post-build automatically
authorHao Wu <hao.a.wu@intel.com>
Fri, 11 Nov 2016 08:21:35 +0000 (16:21 +0800)
committerHao Wu <hao.a.wu@intel.com>
Mon, 14 Nov 2016 11:33:11 +0000 (19:33 +0800)
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>
DuetPkg/CreateBootDisk.bat
DuetPkg/CreateBootDisk.sh
DuetPkg/DuetPkgIa32.dsc
DuetPkg/DuetPkgX64.dsc
DuetPkg/GetVariables.bat [deleted file]
DuetPkg/PostBuild.bat
DuetPkg/PostBuild.sh
DuetPkg/ReadMe.txt
DuetPkg/build32.sh
DuetPkg/build64.sh

index 7265837194cd367c02e9e6efb04b1ae932977af7..cee04b8cc56edde28d4be5b7c9c00109e6d06b09 100644 (file)
@@ -1,7 +1,7 @@
 @echo off\r
 @REM ## @file\r
 @REM #\r
-@REM #  Copyright (c) 2010 - 2014, Intel Corporation. All rights reserved.<BR>\r
+@REM #  Copyright (c) 2010 - 2016, Intel Corporation. All rights reserved.<BR>\r
 @REM #\r
 @REM #  This program and the accompanying materials\r
 @REM #  are licensed and made available under the terms and conditions of the BSD License\r
 \r
 @REM Set up environment at first.\r
 \r
-set BASETOOLS_DIR=%WORKSPACE_TOOLS_PATH%\Bin\Win32\r
+set BASETOOLS_DIR=%EDK_TOOLS_BIN%\r
 set BOOTSECTOR_BIN_DIR=%WORKSPACE%\DuetPkg\BootSector\bin\r
 set DISK_LABEL=DUET\r
 set PROCESSOR=""\r
 set STEP=1\r
-call %WORKSPACE%\DuetPkg\GetVariables.bat\r
-\r
-echo on\r
 \r
 if "%1"=="" goto Help\r
 if "%2"=="" goto Help\r
@@ -35,6 +32,7 @@ set EFI_BOOT_DISK=%2
 if "%TARGET_ARCH%"=="IA32" set PROCESSOR=IA32\r
 if "%TARGET_ARCH%"=="X64" set PROCESSOR=X64\r
 if %PROCESSOR%=="" goto WrongArch\r
+call %WORKSPACE%\DuetPkg\SetEnv_%PROCESSOR%.bat\r
 set BUILD_DIR=%WORKSPACE%\Build\DuetPkg%PROCESSOR%\%TARGET%_%TOOL_CHAIN_TAG%\r
 \r
 if "%1"=="floppy" goto CreateFloppy\r
index fa00408d842343af555cf4009fb05d9a50c95289..897ba9bc9369cfb193d0c026b02726c6a9a931f2 100755 (executable)
@@ -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
 
 
index 86346f30b6bb14e9abcab0147a9c88b3b576f3b7..3b59343154178425f443522ad6ad2a0b50733e71 100644 (file)
   BUILD_TARGETS                  = DEBUG\r
   SKUID_IDENTIFIER               = DEFAULT\r
   FLASH_DEFINITION               = DuetPkg/DuetPkg.fdf\r
+!if $(TOOL_CHAIN_TAG) == GCC47 || $(TOOL_CHAIN_TAG) == GCC48 || $(TOOL_CHAIN_TAG) == GCC49 || $(TOOL_CHAIN_TAG) == GCC5\r
+  POSTBUILD                      = DuetPkg/PostBuild.sh\r
+!else\r
+  POSTBUILD                      = DuetPkg/PostBuild.bat\r
+!endif\r
 \r
 ################################################################################\r
 #\r
index e0aeb5c1f0d6616789c724154632a4cf11714b7b..c23354a5aefb4a2c85d813ff656cd71b32d6c2c8 100644 (file)
   BUILD_TARGETS                  = DEBUG\r
   SKUID_IDENTIFIER               = DEFAULT\r
   FLASH_DEFINITION               = DuetPkg/DuetPkg.fdf\r
+!if $(TOOL_CHAIN_TAG) == GCC47 || $(TOOL_CHAIN_TAG) == GCC48 || $(TOOL_CHAIN_TAG) == GCC49 || $(TOOL_CHAIN_TAG) == GCC5\r
+  POSTBUILD                      = DuetPkg/PostBuild.sh\r
+!else\r
+  POSTBUILD                      = DuetPkg/PostBuild.bat\r
+!endif\r
 \r
 ################################################################################\r
 #\r
diff --git a/DuetPkg/GetVariables.bat b/DuetPkg/GetVariables.bat
deleted file mode 100644 (file)
index c81d3d1..0000000
+++ /dev/null
@@ -1,39 +0,0 @@
-@echo off\r
-@REM ## @file\r
-@REM #\r
-@REM #  Copyright (c) 2011, Intel Corporation. All rights reserved.<BR>\r
-@REM #\r
-@REM #  This program and the accompanying materials\r
-@REM #  are licensed and made available under the terms and conditions of the BSD License\r
-@REM #  which accompanies this distribution. The full text of the license may be found at\r
-@REM #  http://opensource.org/licenses/bsd-license.php\r
-@REM #  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-@REM #  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-@REM #\r
-@REM #\r
-@REM ##\r
-\r
-\r
-@REM Read the variables from Conf/target.txt\r
-@REM Because we can't add '=' as a delimiter in 'for', each variable is read in 2 parts:\r
-@REM First we read the "= xyz" part of the variable assignation which we use, along with\r
-@REM the original equal sign for our first assignation. Then we trim any left whitespaces.\r
-@REM NB: default token delimiters for "for /f" are tab and space.\r
-\r
-set CONFIG_FILE=%WORKSPACE%\Conf\target.txt\r
-\r
-for /f "tokens=1*" %%i in ('type %CONFIG_FILE% ^| find "TOOL_CHAIN_TAG" ^| find /V "#"') do @set TOOL_CHAIN_TAG%%j\r
-for /f "tokens=*" %%i in ("%TOOL_CHAIN_TAG%") do @set TOOL_CHAIN_TAG=%%i\r
-\r
-for /f "tokens=1*" %%i in ('type %CONFIG_FILE% ^| find "TARGET" ^| find /V "#" ^| find /V "TARGET_ARCH"') do @set TARGET%%j\r
-for /f "tokens=*" %%i in ("%TARGET%") do @set TARGET=%%i\r
-\r
-for /f "tokens=1*" %%i in ('type %CONFIG_FILE% ^| find "TARGET_ARCH" ^|find /V "#"') do @set TARGET_ARCH%%j\r
-for /f "tokens=*" %%i in ("%TARGET_ARCH%") do @set TARGET_ARCH=%%i\r
-\r
-\r
-REM Set defaults if above variables are undefined in target.txt\r
-\r
-if "%TOOL_CHAIN_TAG%%"=="" @set TOOL_CHAIN_TAG=MYTOOLS\r
-if "%TARGET%"=="" @set TARGET=DEBUG\r
-if "%TARGET_ARCH%"=="" @set TARGET_ARCH=IA32\r
index 28cab6b665ac4e5c426df60cebb5e23aa2574420..e7f27788acdfc9ef600980f8e59071a9fbe79bab 100644 (file)
@@ -1,11 +1,9 @@
 @echo off\r
 @REM ## @file\r
 @REM #\r
-@REM #  Currently, Build system does not provide post build mechanism for module\r
-@REM #  and platform building, so just use a bat file to do post build commands.\r
-@REM #  Originally, following post building command is for EfiLoader module.\r
+@REM #  Post build script that will be automatically run after build.\r
 @REM #\r
-@REM #  Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR>\r
+@REM #  Copyright (c) 2010 - 2016, Intel Corporation. All rights reserved.<BR>\r
 @REM #\r
 @REM #  This program and the accompanying materials\r
 @REM #  are licensed and made available under the terms and conditions of the BSD License\r
 @REM #\r
 @REM ##\r
 \r
-set BASETOOLS_DIR=%WORKSPACE_TOOLS_PATH%\Bin\Win32\r
+set BASETOOLS_DIR=%EDK_TOOLS_BIN%\r
 set BOOTSECTOR_BIN_DIR=%WORKSPACE%\DuetPkg\BootSector\bin\r
-set PROCESSOR=""\r
-call %WORKSPACE%\DuetPkg\GetVariables.bat\r
 \r
-if NOT "%1"=="" @set TARGET_ARCH=%1\r
-if "%TARGET_ARCH%"=="IA32" set PROCESSOR=IA32\r
-if "%TARGET_ARCH%"=="X64" set PROCESSOR=X64\r
-if %PROCESSOR%=="" goto WrongArch\r
+:SetDefault\r
+set TARGET_ARCH=\r
+set TARGET=\r
+set TOOL_CHAIN_TAG=\r
 \r
+:ParseParamsLoop\r
+if "%1"=="" goto EndPParseParamsLoop\r
+if /I "%1"=="-p" goto ParseParamsLoopNext\r
+if /I "%1"=="-a" set TARGET_ARCH=%2& goto ParseParamsLoopNext\r
+if /I "%1"=="-b" set TARGET=%2& goto ParseParamsLoopNext\r
+if /I "%1"=="-t" set TOOL_CHAIN_TAG=%2& goto ParseParamsLoopNext\r
+if /I "%1"=="-h" goto Help\r
+\r
+:ParseParamsLoopNext\r
+shift\r
+shift\r
+goto ParseParamsLoop\r
+\r
+:EndPParseParamsLoop\r
+if "%TARGET_ARCH%"=="" goto Help\r
+if "%TARGET%"=="" goto Help\r
+if "%TOOL_CHAIN_TAG%"=="" goto Help\r
+\r
+set PROCESSOR=%TARGET_ARCH%\r
 set BUILD_DIR=%WORKSPACE%\Build\DuetPkg%PROCESSOR%\%TARGET%_%TOOL_CHAIN_TAG%\r
 \r
+@REM Store environment variables used by CreateBootDisk.bat\r
+echo set TARGET=%TARGET%> %WORKSPACE%\DuetPkg\SetEnv_%PROCESSOR%.bat\r
+echo set TOOL_CHAIN_TAG=%TOOL_CHAIN_TAG%>> %WORKSPACE%\DuetPkg\SetEnv_%PROCESSOR%.bat\r
 \r
 echo Compressing DUETEFIMainFv.FV ...\r
 %BASETOOLS_DIR%\LzmaCompress -e -o %BUILD_DIR%\FV\DUETEFIMAINFV.z %BUILD_DIR%\FV\DUETEFIMAINFV.Fv\r
@@ -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\r
 goto end\r
 \r
-\r
-:WrongArch\r
-echo Error! Wrong architecture.\r
-goto Help\r
-\r
 :Help\r
-echo Usage: "PostBuild [IA32|X64]"\r
-:end
\ No newline at end of file
+echo Usage: This script will be run automatically after build.\r
+:end\r
index 6f307e1c7e244c8fe03931a316950c8af3da491a..524c9d7047f833142ac67642d1fa9b5b0857b19d 100755 (executable)
@@ -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
index d7ad3d601785188c0cbdf54efcbb3e89f9902a24..f894d94579ccd8b457f30e89d2b389f0062daa69 100644 (file)
@@ -4,28 +4,22 @@ A. Build DUET image on Windows Platform
 ========================================\r
 1. Tools preparation\r
 \r
-To build DUET image, following tools are required:\r
+  To build DUET image, Visual Studio is required:\r
+  1). Base on below link to create Visual Studio build environment.\r
+      https://github.com/tianocore/tianocore.github.io/wiki/Windows-systems\r
 \r
-  1). *Visual Studio 2005*\r
-      Assume installed at <VS_PATH>,\r
-      e.g.: C:\Program Files\Microsoft Visual Studio .NET 2003\.\r
-  2). WinDDK\r
-      Assume installed at <WIN_DDK_PATH>, e.g.: C:\WINDDK\3790.1830\.\r
-\r
-2. Build steps\r
-\r
-2.1 Build Duet Platform module\r
+2. Build Duet Platform module\r
 \r
   1). run cmd.exe to open command line window.\r
   2). enter workspace root directory such as c:\edk2_tree\r
-  2). run "edksetup.bat"\r
-  3). run "build -p DuetPkg\DuetPkg.dsc -a IA32" for IA32 architecture platform or\r
-          "build -p DuetPkg\DuetPkg.dsc -a X64" for X64 architecture platform.\r
+  3). set the environment variable EDK_TOOLS_BIN to point at the BaseTools binaries directory\r
+      i.e., "set EDK_TOOLS_BIN=c:\edk2-BaseTools-win32"\r
+  4). run "edksetup.bat"\r
+  5). run "build -p DuetPkg\DuetPkgIa32.dsc -a IA32 -t VS2015x86" for IA32 architecture platform (using 64-bit VS2015 for example) or\r
+          "build -p DuetPkg\DuetPkgX64.dsc -a X64 -t VS2015x86" for X64 architecture platform.\r
+\r
+  NOTE: The post build script 'PostBuild.sh' will be automatically called after the build command.\r
 \r
-2.2 Execute post build actions\r
-  1). enter <Workspace>\DuetPkg directory.\r
-  2). run "PostBuild.bat IA32" for IA32 architecture platform or\r
-          "PostBuild.bat X64" for X64 architecture platform.\r
 \r
 Create bootable disk\r
 ======================\r
@@ -56,34 +50,35 @@ B. Build DUET image on Linux Platform
 ======================================\r
 1. Tools preparation\r
 \r
-  To build DUET image, GCC44 is required:\r
-  1). Base on below link to create GCC44 build environment.\r
-      http://tianocore.sourceforge.net/wiki/Using_EDK_II_with_Native_GCC\r
+  To build DUET image, GCC installation (4.4+) is required:\r
+  1). Base on below link to create GCC build environment.\r
+      https://github.com/tianocore/tianocore.github.io/wiki/Using-EDK-II-with-Native-GCC\r
 \r
-2. Build steps\r
-\r
-2.1 Build Duet Platform module\r
+2. Build Duet Platform module\r
 \r
   1). Open the terminal.\r
   2). enter workspace root directory such as /edk2_tree\r
   3). run ". edksetup.sh BaseTools"\r
-  4). run "build -p DuetPkg/DuetPkg.dsc -a IA32 -t GCC44" for IA32 architecture platform or\r
-          "build -p DuetPkg/DuetPkg.dsc -a X64 -t GCC44" for X64 architecture platform.\r
-\r
-2.2 Execute post build actions\r
-  1). enter /edk2_tree/DuetPkg directory.\r
-  2). run "./PostBuild.sh IA32 GCC44" for IA32 architecture platform or\r
-          "./PostBuild.sh X64 GCC44" for X64 architecture platform.\r
+  4). run "build -p DuetPkg/DuetPkgIa32.dsc -a IA32 -t GCC49" for IA32 architecture platform (using GCC 4.9 for example) or\r
+          "build -p DuetPkg/DuetPkgX64.dsc -a X64 -t GCC49" for X64 architecture platform.\r
 \r
- NOTE: After post build action, you should check the size of EfiLdr at $WORKSPACE/Build/DuetPkg/DEBUG_GCC44 directory, it must less than 470k.\r
-       If not, you should manually remove some unnecessary drivers at DuetPkg.fdf file.\r
+  NOTE: The post build script 'PostBuild.sh' will be automatically called after the build command.\r
+        After post build action, you should check the size of EfiLdr at $WORKSPACE/Build/DuetPkgIA32(DuetPkgX64)/DEBUG_GCC49 directory, it must less than 470k.\r
+        If not, you should manually remove some unnecessary drivers at DuetPkg.fdf file.\r
 \r
 3. Create bootable disk\r
    The following steps are same for IA32 architecture platform or X64 architecture platform.\r
-   Now only support floopy.\r
 \r
-   3.1 Create floppy boot disk\r
-      1). enter /edk2_tree/DuetPkg directory.\r
-      2). Insert a floppy disk to drive\r
-      3). run "CreateBootDisk.sh" to build floppy drive\r
-          such as "./CreateBootDisk.sh floppy /media/floppy0 /dev/fd0 FAT12 IA32"\r
+3.1 Create floppy boot disk\r
+  1). enter /edk2_tree/DuetPkg directory.\r
+  2). Insert a floppy disk to drive\r
+  3). run "CreateBootDisk.sh" to build floppy drive\r
+      such as "./CreateBootDisk.sh floppy /media/floppy0 /dev/fd0 FAT12 IA32"\r
+\r
+3.2 Create usb boot disk\r
+  1). enter /edk2_tree/DuetPkg directory.\r
+  2). Plugin usb disk\r
+  3). run "CreateBootDisk.sh" to build usb drive\r
+      such as "./CreateBootDisk.sh usb /media/usb0 /dev/sdb0 FAT16 IA32"\r
+  4). UnPlug usb disk and plugin it again.\r
+  5). run "./CreateBootDisk.sh usb /media/usb0 /dev/sdb0 FAT16 IA32 step2"\r
index c15c9963f8f72f0072133a25ce989e894567a545..8aa2c3d50405e9dba7aa13671458fabf6bc0fc12 100755 (executable)
@@ -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 $?
 
index 0401c56e12d817d8465568bb313c37d7404c5ab5..1e072341771fb0201e8cdb9ef6f5f7472f8a3c7c 100755 (executable)
@@ -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 $?