public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [PATCH 0/3] Enable POSTBUILD feature in DuetPkg DSC files
@ 2016-11-11  8:26 Hao Wu
  2016-11-11  8:26 ` [PATCH 1/3] DuetPkg: Resolve white-space issues for post-build scripts & ReadMe Hao Wu
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Hao Wu @ 2016-11-11  8:26 UTC (permalink / raw)
  To: edk2-devel; +Cc: Hao Wu, Ruiyu Ni

This patch series uses the POSTBUILD feature in package DSC files to make
the post-build steps for DuetPkg more user-friendly.

Cc: Ruiyu Ni <ruiyu.ni@intel.com>

Hao Wu (3):
  DuetPkg: Resolve white-space issues for post-build scripts & ReadMe
  DuetPkg: Use 'echo off' in BATCH script files
  DuetPkg: Add POSTBUILD in DSC files to run post-build automatically

 DuetPkg/CreateBootDisk.bat | 199 ++++++++++++++---------------
 DuetPkg/CreateBootDisk.sh  | 312 ++++++++++++++++++++++-----------------------
 DuetPkg/DuetPkgIa32.dsc    |   5 +
 DuetPkg/DuetPkgX64.dsc     |   5 +
 DuetPkg/GetVariables.bat   |  38 ------
 DuetPkg/PostBuild.bat      |  98 ++++++++------
 DuetPkg/PostBuild.sh       | 112 ++++++++--------
 DuetPkg/ReadMe.txt         |  85 ++++++------
 DuetPkg/build32.sh         |   4 +-
 DuetPkg/build64.sh         |   4 +-
 10 files changed, 410 insertions(+), 452 deletions(-)
 delete mode 100644 DuetPkg/GetVariables.bat

-- 
1.9.5.msysgit.0



^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 1/3] DuetPkg: Resolve white-space issues for post-build scripts & ReadMe
  2016-11-11  8:26 [PATCH 0/3] Enable POSTBUILD feature in DuetPkg DSC files Hao Wu
@ 2016-11-11  8:26 ` Hao Wu
  2016-11-11  8:32   ` Ni, Ruiyu
  2016-11-11  8:26 ` [PATCH 2/3] DuetPkg: Use 'echo off' in BATCH script files Hao Wu
  2016-11-11  8:26 ` [PATCH 3/3] DuetPkg: Add POSTBUILD in DSC files to run post-build automatically Hao Wu
  2 siblings, 1 reply; 7+ messages in thread
From: Hao Wu @ 2016-11-11  8:26 UTC (permalink / raw)
  To: edk2-devel; +Cc: Hao Wu, Ruiyu Ni

Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Hao Wu <hao.a.wu@intel.com>
---
 DuetPkg/CreateBootDisk.bat |  14 +--
 DuetPkg/CreateBootDisk.sh  | 304 ++++++++++++++++++++++-----------------------
 DuetPkg/PostBuild.bat      |   2 +-
 DuetPkg/PostBuild.sh       |  58 ++++-----
 DuetPkg/ReadMe.txt         |  44 +++----
 5 files changed, 211 insertions(+), 211 deletions(-)

diff --git a/DuetPkg/CreateBootDisk.bat b/DuetPkg/CreateBootDisk.bat
index 541de81..214b5b6 100644
--- a/DuetPkg/CreateBootDisk.bat
+++ b/DuetPkg/CreateBootDisk.bat
@@ -56,7 +56,7 @@ goto Help
 @copy %BOOTSECTOR_BIN_DIR%\Bootsect.com FDBs-1.com
 @%BASETOOLS_DIR%\Bootsectimage.exe -g FDBs.com FDBs-1.com -f
 @REM @del FDBS.com
-@%BASETOOLS_DIR%\Genbootsector.exe -o %EFI_BOOT_DISK% -i FDBs-1.com 
+@%BASETOOLS_DIR%\Genbootsector.exe -o %EFI_BOOT_DISK% -i FDBs-1.com
 @del FDBs-1.com
 @echo Done.
 @copy %BUILD_DIR%\FV\EfiLdr %EFI_BOOT_DISK%
@@ -70,7 +70,7 @@ goto Help
 @copy %BOOTSECTOR_BIN_DIR%\Bootsect.com FDBs-1.com
 @%BASETOOLS_DIR%\Bootsectimage.exe -g FDBs.com FDBs-1.com -f
 @REM @del FDBS.com
-@%BASETOOLS_DIR%\Genbootsector.exe -o %EFI_BOOT_DISK% -i FDBs-1.com 
+@%BASETOOLS_DIR%\Genbootsector.exe -o %EFI_BOOT_DISK% -i FDBs-1.com
 @del FDBs-1.com
 @echo Done.
 @goto end
@@ -89,8 +89,8 @@ goto Help
 @del FormatCommandInput.txt
 @echo Create boot sector ...
 @%BASETOOLS_DIR%\Genbootsector.exe -i %EFI_BOOT_DISK% -o UsbBs16.com
-@copy %BOOTSECTOR_BIN_DIR%\Bs16.com Bs16-1.com 
-@%BASETOOLS_DIR%\Bootsectimage.exe -g UsbBs16.com Bs16-1.com -f 
+@copy %BOOTSECTOR_BIN_DIR%\Bs16.com Bs16-1.com
+@%BASETOOLS_DIR%\Bootsectimage.exe -g UsbBs16.com Bs16-1.com -f
 @%BASETOOLS_DIR%\Genbootsector.exe -o %EFI_BOOT_DISK% -i Bs16-1.com
 @del Bs16-1.com
 @%BASETOOLS_DIR%\Genbootsector.exe -m -o %EFI_BOOT_DISK% -i %BOOTSECTOR_BIN_DIR%\Mbr.com
@@ -110,15 +110,15 @@ goto Help
 @del FormatCommandInput.txt
 @echo Create boot sector ...
 @%BASETOOLS_DIR%\Genbootsector.exe -i %EFI_BOOT_DISK% -o UsbBs32.com
-@copy %BOOTSECTOR_BIN_DIR%\Bs32.com Bs32-1.com 
-@%BASETOOLS_DIR%\Bootsectimage.exe -g UsbBs32.com Bs32-1.com -f 
+@copy %BOOTSECTOR_BIN_DIR%\Bs32.com Bs32-1.com
+@%BASETOOLS_DIR%\Bootsectimage.exe -g UsbBs32.com Bs32-1.com -f
 @del UsbBs32.com
 @%BASETOOLS_DIR%\Genbootsector.exe -o %EFI_BOOT_DISK% -i Bs32-1.com
 @del Bs32-1.com
 @%BASETOOLS_DIR%\Genbootsector.exe -m -o %EFI_BOOT_DISK% -i %BOOTSECTOR_BIN_DIR%\Mbr.com
 @echo Done.
 @echo PLEASE UNPLUG USB, THEN PLUG IT AGAIN!
-@goto end  
+@goto end
 
 :CreateUsb_FAT32_step2
 @copy %BUILD_DIR%\FV\EfiLdr20 %EFI_BOOT_DISK%
diff --git a/DuetPkg/CreateBootDisk.sh b/DuetPkg/CreateBootDisk.sh
index f2ff571..fa00408 100755
--- a/DuetPkg/CreateBootDisk.sh
+++ b/DuetPkg/CreateBootDisk.sh
@@ -34,9 +34,9 @@ if [ \
      "$*" = "--help" \
    ]
 then
-	echo "Usage: CreateBootDisk [usb|floppy|ide|file] MediaPath DevicePath [FAT12|FAT16|FAT32] [IA32|X64] [GCC44|UNIXGCC]"
-	echo "e.g. : CreateBootDisk floppy /media/floppy0 /dev/fd0 FAT12 IA32"
-	PROCESS_MARK=FALSE
+    echo "Usage: CreateBootDisk [usb|floppy|ide|file] MediaPath DevicePath [FAT12|FAT16|FAT32] [IA32|X64] [GCC44|UNIXGCC]"
+    echo "e.g. : CreateBootDisk floppy /media/floppy0 /dev/fd0 FAT12 IA32"
+    PROCESS_MARK=FALSE
 fi
 
 case "$5" in
@@ -66,153 +66,153 @@ export EFI_BOOT_DEVICE=$3
 
 if [ "$PROCESS_MARK" = TRUE ]
 then
-	case "$1" in
-		floppy)
-			if [ "$4" = FAT12 ]
-			then
-				echo Start to create floppy boot disk ...
-				echo Format $EFI_BOOT_MEDIA ...
-				## Format floppy disk
-				umount $EFI_BOOT_MEDIA
-				mkfs.msdos $EFI_BOOT_DEVICE
-				mount $EFI_BOOT_DEVICE $EFI_BOOT_MEDIA
-				echo Create boot sector ...
-				## Linux version of GenBootSector has not pass build yet.
-				$BASETOOLS_DIR/GnuGenBootSector -i $EFI_BOOT_DEVICE -o FDBs.com
-				cp $BOOTSECTOR_BIN_DIR/bootsect.com FDBs-1.com
-				$BASETOOLS_DIR/BootSectImage -g FDBs.com FDBs-1.com -f
-				$BASETOOLS_DIR/GnuGenBootSector -o $EFI_BOOT_DEVICE -i FDBs-1.com
-				rm FDBs-1.com
-				cp $BUILD_DIR/FV/Efildr $EFI_BOOT_MEDIA
-	
-				mkdir -p $EFI_BOOT_MEDIA/efi
-				mkdir -p $EFI_BOOT_MEDIA/efi/boot
-				if [ "$5" = IA32 ]
-				then
-					cp $WORKSPACE/ShellBinPkg/UefiShell/Ia32/Shell.efi $EFI_BOOT_MEDIA/efi/boot/boot$5.efi
-				else
-					if [ "$5" = X64 ]
-					then
-						cp $WORKSPACE/ShellBinPkg/UefiShell/X64/Shell.efi $EFI_BOOT_MEDIA/efi/boot/boot$5.efi
-					else
-						echo Wrong Arch!
-					fi
-				fi
-				echo Done.
-			else
-				echo "Wrong FAT type $4 for floppy!"
-			fi
-			;;
-
-		file) # CreateFile
-			if [ "$4" = FAT12 ]
-				then
-				echo "Start to create file boot disk ..."
-				dd bs=512 count=2880 if=/dev/zero of=$EFI_BOOT_MEDIA
-				mkfs.msdos -F 12 $EFI_BOOT_MEDIA
-
-				mcopy -i $EFI_BOOT_MEDIA $BUILD_DIR/FV/Efildr ::/Efildr
-				mmd -i $EFI_BOOT_MEDIA ::/efi ::/efi/boot
-				if [ "$5" = IA32 ]
-				then
-					mcopy -i $EFI_BOOT_MEDIA $WORKSPACE/ShellBinPkg/UefiShell/Ia32/Shell.efi ::/efi/boot/boot$5.efi
-				elif [ "$5" = X64 ]
-				then
-					mcopy -i $EFI_BOOT_MEDIA $WORKSPACE/ShellBinPkg/UefiShell/X64/Shell.efi ::/efi/boot/boot$5.efi
-				else
-					echo Wrong Arch!
-				fi
-				mdir -i $EFI_BOOT_MEDIA -s ::
-
-				## Linux version of GenBootSector has not pass build yet.
-				$BASETOOLS_DIR/GnuGenBootSector -i $EFI_BOOT_MEDIA -o $EFI_BOOT_MEDIA.bs0
-				cp $BOOTSECTOR_BIN_DIR/bootsect.com $EFI_BOOT_MEDIA.bs1
-				$BASETOOLS_DIR/BootSectImage -g $EFI_BOOT_MEDIA.bs0 $EFI_BOOT_MEDIA.bs1
-				$BASETOOLS_DIR/GnuGenBootSector -o $EFI_BOOT_MEDIA -i $EFI_BOOT_MEDIA.bs1
-				rm $EFI_BOOT_MEDIA.bs[0-1]
-				echo Done.
-			else
-				echo "Wrong FAT type" $4 "for floppy!"
-			fi
-			;;
-
-		usb) # CreateUsb
-
-			if [ "$4" = FAT16 ]
-			then
-				if [ "$6" = step2 ]
-				then
-					cp $BUILD_DIR/FV/Efildr16 $EFI_BOOT_MEDIA
-					mkdir $EFI_BOOT_MEDIA/efi/boot
-					if [ "$5" = IA32 ]
-					then
-						cp $WORKSPACE/ShellBinPkg/UefiShell/Ia32/Shell.efi $EFI_BOOT_MEDIA/efi/boot/boot$5.efi
-					else
-						if [ "$5" = X64 ]
-						then
-							cp $WORKSPACE/ShellBinPkg/UefiShell/X64/Shell.efi $EFI_BOOT_MEDIA/efi/boot/boot$5.efi
-						else
-							echo Wrong Arch!
-						fi
-					fi
-					echo "step2 Done!"
-				else
-					echo Format $EFI_BOOT_DEVICE ...
-					#Do format command.
-					echo Create boot sector ...
-					## Linux version of GenBootSector & Bootsectimage has not pass build yet.
-					$BASETOOLS_DIR/GnuGenBootSector -i $EFI_BOOT_DEVICE -o UsbBs16.com
-					cp $BOOTSECTOR_BIN_DIR/bs16.com Bs16-1.com
-					$BASETOOLS_DIR/BootSectImage -g UsbBs16.com Bs16-1.com -f
-					$BASETOOLS_DIR/GnuGenBootSector -o $EFI_BOOT_DEVICE -i Bs16-1.com
-					rm Bs16-1.com
-					$BASETOOLS_DIR/GnuGenBootSector -m -o $EFI_BOOT_DEVICE -i $BOOTSECTOR_BIN_DIR/Mbr.com
-					echo Done.
-					echo PLEASE UNPLUG USB, THEN PLUG IT AGAIN TO DO STEP2!
-				fi
-			elif [ "$4" = FAT32 ]
-			then 
-				if [ "$6" = step2 ]
-				then
-					cp $BUILD_DIR/FV/Efildr20 $EFI_BOOT_MEDIA
-					mkdir $EFI_BOOT_MEDIA/efi/boot
-					if [ "$5" = IA32 ]
-					then
-						cp $WORKSPACE/ShellBinPkg/UefiShell/Ia32/Shell.efi $EFI_BOOT_MEDIA/efi/boot/boot$5.efi
-					else
-						if [ "$5" = X64 ]
-						then
-							cp $WORKSPACE/ShellBinPkg/UefiShell/X64/Shell.efi $EFI_BOOT_MEDIA/efi/boot/boot$5.efi
-						else
-							echo Wrong Arch!
-						fi
-					fi
-					echo "step2 Done!"
-				else
-					echo Format $EFI_BOOT_DEVICE ...
-					#Do format command.
-					echo Create boot sector ...
-					## Linux version of GenBootSector & Bootsectimage has not pass build yet.
-					$BASETOOLS_DIR/GnuGenBootSector -i $EFI_BOOT_DEVICE -o UsbBs32.com
-					cp $BOOTSECTOR_BIN_DIR/bs32.com Bs32-1.com
-					$BASETOOLS_DIR/BootSectImage -g UsbBs32.com Bs32-1.com -f
-					$BASETOOLS_DIR/GnuGenBootSector -o $EFI_BOOT_DEVICE -i Bs32-1.com
-					rm Bs32-1.com
-					$BASETOOLS_DIR/GnuGenBootSector -m -o $EFI_BOOT_DEVICE -i $BOOTSECTOR_BIN_DIR/Mbr.com
-					echo Done.
-					echo PLEASE UNPLUG USB, THEN PLUG IT AGAIN TO DO STEP2!
-				fi			
-			else
-				echo "Wrong FAT type $1 for floppy!"
-			fi
-	
-			;;
-
-		ide) # CreateIde
-		echo "Not support yet!"
-		;;
-		*)
-		echo "Arg1 should be [floppy | file | usb | ide] !"
-
-	esac
+    case "$1" in
+        floppy)
+            if [ "$4" = FAT12 ]
+            then
+                echo Start to create floppy boot disk ...
+                echo Format $EFI_BOOT_MEDIA ...
+                ## Format floppy disk
+                umount $EFI_BOOT_MEDIA
+                mkfs.msdos $EFI_BOOT_DEVICE
+                mount $EFI_BOOT_DEVICE $EFI_BOOT_MEDIA
+                echo Create boot sector ...
+                ## Linux version of GenBootSector has not pass build yet.
+                $BASETOOLS_DIR/GnuGenBootSector -i $EFI_BOOT_DEVICE -o FDBs.com
+                cp $BOOTSECTOR_BIN_DIR/bootsect.com FDBs-1.com
+                $BASETOOLS_DIR/BootSectImage -g FDBs.com FDBs-1.com -f
+                $BASETOOLS_DIR/GnuGenBootSector -o $EFI_BOOT_DEVICE -i FDBs-1.com
+                rm FDBs-1.com
+                cp $BUILD_DIR/FV/Efildr $EFI_BOOT_MEDIA
+
+                mkdir -p $EFI_BOOT_MEDIA/efi
+                mkdir -p $EFI_BOOT_MEDIA/efi/boot
+                if [ "$5" = IA32 ]
+                then
+                    cp $WORKSPACE/ShellBinPkg/UefiShell/Ia32/Shell.efi $EFI_BOOT_MEDIA/efi/boot/boot$5.efi
+                else
+                    if [ "$5" = X64 ]
+                    then
+                        cp $WORKSPACE/ShellBinPkg/UefiShell/X64/Shell.efi $EFI_BOOT_MEDIA/efi/boot/boot$5.efi
+                    else
+                        echo Wrong Arch!
+                    fi
+                fi
+                echo Done.
+            else
+                echo "Wrong FAT type $4 for floppy!"
+            fi
+            ;;
+
+        file) # CreateFile
+            if [ "$4" = FAT12 ]
+                then
+                echo "Start to create file boot disk ..."
+                dd bs=512 count=2880 if=/dev/zero of=$EFI_BOOT_MEDIA
+                mkfs.msdos -F 12 $EFI_BOOT_MEDIA
+
+                mcopy -i $EFI_BOOT_MEDIA $BUILD_DIR/FV/Efildr ::/Efildr
+                mmd -i $EFI_BOOT_MEDIA ::/efi ::/efi/boot
+                if [ "$5" = IA32 ]
+                then
+                    mcopy -i $EFI_BOOT_MEDIA $WORKSPACE/ShellBinPkg/UefiShell/Ia32/Shell.efi ::/efi/boot/boot$5.efi
+                elif [ "$5" = X64 ]
+                then
+                    mcopy -i $EFI_BOOT_MEDIA $WORKSPACE/ShellBinPkg/UefiShell/X64/Shell.efi ::/efi/boot/boot$5.efi
+                else
+                    echo Wrong Arch!
+                fi
+                mdir -i $EFI_BOOT_MEDIA -s ::
+
+                ## Linux version of GenBootSector has not pass build yet.
+                $BASETOOLS_DIR/GnuGenBootSector -i $EFI_BOOT_MEDIA -o $EFI_BOOT_MEDIA.bs0
+                cp $BOOTSECTOR_BIN_DIR/bootsect.com $EFI_BOOT_MEDIA.bs1
+                $BASETOOLS_DIR/BootSectImage -g $EFI_BOOT_MEDIA.bs0 $EFI_BOOT_MEDIA.bs1
+                $BASETOOLS_DIR/GnuGenBootSector -o $EFI_BOOT_MEDIA -i $EFI_BOOT_MEDIA.bs1
+                rm $EFI_BOOT_MEDIA.bs[0-1]
+                echo Done.
+            else
+                echo "Wrong FAT type" $4 "for floppy!"
+            fi
+            ;;
+
+        usb) # CreateUsb
+
+            if [ "$4" = FAT16 ]
+            then
+                if [ "$6" = step2 ]
+                then
+                    cp $BUILD_DIR/FV/Efildr16 $EFI_BOOT_MEDIA
+                    mkdir $EFI_BOOT_MEDIA/efi/boot
+                    if [ "$5" = IA32 ]
+                    then
+                        cp $WORKSPACE/ShellBinPkg/UefiShell/Ia32/Shell.efi $EFI_BOOT_MEDIA/efi/boot/boot$5.efi
+                    else
+                        if [ "$5" = X64 ]
+                        then
+                            cp $WORKSPACE/ShellBinPkg/UefiShell/X64/Shell.efi $EFI_BOOT_MEDIA/efi/boot/boot$5.efi
+                        else
+                            echo Wrong Arch!
+                        fi
+                    fi
+                    echo "step2 Done!"
+                else
+                    echo Format $EFI_BOOT_DEVICE ...
+                    #Do format command.
+                    echo Create boot sector ...
+                    ## Linux version of GenBootSector & Bootsectimage has not pass build yet.
+                    $BASETOOLS_DIR/GnuGenBootSector -i $EFI_BOOT_DEVICE -o UsbBs16.com
+                    cp $BOOTSECTOR_BIN_DIR/bs16.com Bs16-1.com
+                    $BASETOOLS_DIR/BootSectImage -g UsbBs16.com Bs16-1.com -f
+                    $BASETOOLS_DIR/GnuGenBootSector -o $EFI_BOOT_DEVICE -i Bs16-1.com
+                    rm Bs16-1.com
+                    $BASETOOLS_DIR/GnuGenBootSector -m -o $EFI_BOOT_DEVICE -i $BOOTSECTOR_BIN_DIR/Mbr.com
+                    echo Done.
+                    echo PLEASE UNPLUG USB, THEN PLUG IT AGAIN TO DO STEP2!
+                fi
+            elif [ "$4" = FAT32 ]
+            then
+                if [ "$6" = step2 ]
+                then
+                    cp $BUILD_DIR/FV/Efildr20 $EFI_BOOT_MEDIA
+                    mkdir $EFI_BOOT_MEDIA/efi/boot
+                    if [ "$5" = IA32 ]
+                    then
+                        cp $WORKSPACE/ShellBinPkg/UefiShell/Ia32/Shell.efi $EFI_BOOT_MEDIA/efi/boot/boot$5.efi
+                    else
+                        if [ "$5" = X64 ]
+                        then
+                            cp $WORKSPACE/ShellBinPkg/UefiShell/X64/Shell.efi $EFI_BOOT_MEDIA/efi/boot/boot$5.efi
+                        else
+                            echo Wrong Arch!
+                        fi
+                    fi
+                    echo "step2 Done!"
+                else
+                    echo Format $EFI_BOOT_DEVICE ...
+                    #Do format command.
+                    echo Create boot sector ...
+                    ## Linux version of GenBootSector & Bootsectimage has not pass build yet.
+                    $BASETOOLS_DIR/GnuGenBootSector -i $EFI_BOOT_DEVICE -o UsbBs32.com
+                    cp $BOOTSECTOR_BIN_DIR/bs32.com Bs32-1.com
+                    $BASETOOLS_DIR/BootSectImage -g UsbBs32.com Bs32-1.com -f
+                    $BASETOOLS_DIR/GnuGenBootSector -o $EFI_BOOT_DEVICE -i Bs32-1.com
+                    rm Bs32-1.com
+                    $BASETOOLS_DIR/GnuGenBootSector -m -o $EFI_BOOT_DEVICE -i $BOOTSECTOR_BIN_DIR/Mbr.com
+                    echo Done.
+                    echo PLEASE UNPLUG USB, THEN PLUG IT AGAIN TO DO STEP2!
+                fi
+            else
+                echo "Wrong FAT type $1 for floppy!"
+            fi
+
+            ;;
+
+        ide) # CreateIde
+        echo "Not support yet!"
+        ;;
+        *)
+        echo "Arg1 should be [floppy | file | usb | ide] !"
+
+    esac
 fi
diff --git a/DuetPkg/PostBuild.bat b/DuetPkg/PostBuild.bat
index bdcafb8..df34fa7 100644
--- a/DuetPkg/PostBuild.bat
+++ b/DuetPkg/PostBuild.bat
@@ -1,6 +1,6 @@
 @REM ## @file
 @REM #
-@REM #  Currently, Build system does not provide post build mechanism for module 
+@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 #
diff --git a/DuetPkg/PostBuild.sh b/DuetPkg/PostBuild.sh
index f032de3..6f307e1 100755
--- a/DuetPkg/PostBuild.sh
+++ b/DuetPkg/PostBuild.sh
@@ -2,7 +2,7 @@
 
 ## @file
 #
-#  Currently, Build system does not provide post build mechanism for module 
+#  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.
 #
@@ -33,8 +33,8 @@ if [ \
      "$1" = "--help" \
    ]
 then
-	echo Error! Please specific the architecture. 
-	echo Usage: "./PostBuild.sh [IA32|X64] [UNIXGCC|GCC44]"
+    echo Error! Please specific the architecture.
+    echo Usage: "./PostBuild.sh [IA32|X64] [UNIXGCC|GCC44]"
 fi
 
 case "$1" in
@@ -75,41 +75,41 @@ echo Compressing DxeMain.efi ...
 $BASETOOLS_DIR/LzmaCompress -e -o $BUILD_DIR/FV/DxeMain.z $BUILD_DIR/$PROCESSOR/DxeCore.efi
 
 echo Compressing DxeIpl.efi ...
-$BASETOOLS_DIR/LzmaCompress -e -o $BUILD_DIR/FV/DxeIpl.z $BUILD_DIR/$PROCESSOR/DxeIpl.efi	
+$BASETOOLS_DIR/LzmaCompress -e -o $BUILD_DIR/FV/DxeIpl.z $BUILD_DIR/$PROCESSOR/DxeIpl.efi
 
 echo Generate Loader Image ...
 
 if [ $PROCESSOR = IA32 ]
 then
-        $BASETOOLS_DIR/GenFw --rebase 0x10000 -o $BUILD_DIR/$PROCESSOR/EfiLoader.efi $BUILD_DIR/$PROCESSOR/EfiLoader.efi
-	$BASETOOLS_DIR/EfiLdrImage -o $BUILD_DIR/FV/Efildr32 $BUILD_DIR/$PROCESSOR/EfiLoader.efi $BUILD_DIR/FV/DxeIpl.z $BUILD_DIR/FV/DxeMain.z $BUILD_DIR/FV/DUETEFIMAINFV.z
-	cat $BOOTSECTOR_BIN_DIR/Start.com $BOOTSECTOR_BIN_DIR/efi32.com2 $BUILD_DIR/FV/Efildr32   > $BUILD_DIR/FV/Efildr
-	#
-	# It is safe to use "bcat" to cat following binary file, if bcat command is avaiable for your system
-	#
-	#bcat -o $BUILD_DIR/FV/Efildr.bcat $BOOTSECTOR_BIN_DIR/start.com $BOOTSECTOR_BIN_DIR/efi32.com2 $BUILD_DIR/FV/Efildr32
-	cat $BOOTSECTOR_BIN_DIR/Start16.com $BOOTSECTOR_BIN_DIR/efi32.com2 $BUILD_DIR/FV/Efildr32 > $BUILD_DIR/FV/Efildr16
-	#bcat -o $BUILD_DIR/FV/Efildr16.bcat $BOOTSECTOR_BIN_DIR/start16.com $BOOTSECTOR_BIN_DIR/efi32.com2 $BUILD_DIR/FV/Efildr32
-	cat $BOOTSECTOR_BIN_DIR/Start32.com $BOOTSECTOR_BIN_DIR/efi32.com2 $BUILD_DIR/FV/Efildr32 > $BUILD_DIR/FV/Efildr20	
-	#bcat -o $BUILD_DIR/FV/Efildr20.bcat $BOOTSECTOR_BIN_DIR/start32.com $BOOTSECTOR_BIN_DIR/efi32.com2 $BUILD_DIR/FV/Efildr32
-	echo Done!
+    $BASETOOLS_DIR/GenFw --rebase 0x10000 -o $BUILD_DIR/$PROCESSOR/EfiLoader.efi $BUILD_DIR/$PROCESSOR/EfiLoader.efi
+    $BASETOOLS_DIR/EfiLdrImage -o $BUILD_DIR/FV/Efildr32 $BUILD_DIR/$PROCESSOR/EfiLoader.efi $BUILD_DIR/FV/DxeIpl.z $BUILD_DIR/FV/DxeMain.z $BUILD_DIR/FV/DUETEFIMAINFV.z
+    cat $BOOTSECTOR_BIN_DIR/Start.com $BOOTSECTOR_BIN_DIR/efi32.com2 $BUILD_DIR/FV/Efildr32   > $BUILD_DIR/FV/Efildr
+    #
+    # It is safe to use "bcat" to cat following binary file, if bcat command is avaiable for your system
+    #
+    #bcat -o $BUILD_DIR/FV/Efildr.bcat $BOOTSECTOR_BIN_DIR/start.com $BOOTSECTOR_BIN_DIR/efi32.com2 $BUILD_DIR/FV/Efildr32
+    cat $BOOTSECTOR_BIN_DIR/Start16.com $BOOTSECTOR_BIN_DIR/efi32.com2 $BUILD_DIR/FV/Efildr32 > $BUILD_DIR/FV/Efildr16
+    #bcat -o $BUILD_DIR/FV/Efildr16.bcat $BOOTSECTOR_BIN_DIR/start16.com $BOOTSECTOR_BIN_DIR/efi32.com2 $BUILD_DIR/FV/Efildr32
+    cat $BOOTSECTOR_BIN_DIR/Start32.com $BOOTSECTOR_BIN_DIR/efi32.com2 $BUILD_DIR/FV/Efildr32 > $BUILD_DIR/FV/Efildr20
+    #bcat -o $BUILD_DIR/FV/Efildr20.bcat $BOOTSECTOR_BIN_DIR/start32.com $BOOTSECTOR_BIN_DIR/efi32.com2 $BUILD_DIR/FV/Efildr32
+    echo Done!
 fi
 
 if [ $PROCESSOR = X64 ]
 then
-         $BASETOOLS_DIR/GenFw --rebase 0x10000 -o $BUILD_DIR/$PROCESSOR/EfiLoader.efi $BUILD_DIR/$PROCESSOR/EfiLoader.efi
-	$BASETOOLS_DIR/EfiLdrImage -o $BUILD_DIR/FV/Efildr64 $BUILD_DIR/$PROCESSOR/EfiLoader.efi $BUILD_DIR/FV/DxeIpl.z $BUILD_DIR/FV/DxeMain.z $BUILD_DIR/FV/DUETEFIMAINFV.z
-	cat $BOOTSECTOR_BIN_DIR/Start64.com $BOOTSECTOR_BIN_DIR/efi64.com2 $BUILD_DIR/FV/Efildr64 > $BUILD_DIR/FV/EfildrPure
-	#bcat -o $BUILD_DIR/FV/EfildrPure $BOOTSECTOR_BIN_DIR/start64.com $BOOTSECTOR_BIN_DIR/efi64.com2 $BUILD_DIR/FV/Efildr64 
-	$BASETOOLS_DIR/GenPage $BUILD_DIR/FV/EfildrPure -o $BUILD_DIR/FV/Efildr
-	cat $BOOTSECTOR_BIN_DIR/St16_64.com $BOOTSECTOR_BIN_DIR/efi64.com2 $BUILD_DIR/FV/Efildr64 > $BUILD_DIR/FV/Efildr16Pure
-	#bcat -o $BUILD_DIR/FV/Efildr16Pure $BOOTSECTOR_BIN_DIR/st16_64.com $BOOTSECTOR_BIN_DIR/efi64.com2 $BUILD_DIR/FV/Efildr64
-	$BASETOOLS_DIR/GenPage $BUILD_DIR/FV/Efildr16Pure -o $BUILD_DIR/FV/Efildr16
-	cat $BOOTSECTOR_BIN_DIR/St32_64.com $BOOTSECTOR_BIN_DIR/efi64.com2 $BUILD_DIR/FV/Efildr64 > $BUILD_DIR/FV/Efildr20Pure
-	#bcat -o $BUILD_DIR/FV/Efildr20Pure $BOOTSECTOR_BIN_DIR/st32_64.com $BOOTSECTOR_BIN_DIR/efi64.com2 $BUILD_DIR/FV/Efildr64
-	$BASETOOLS_DIR/GenPage $BUILD_DIR/FV/Efildr20Pure -o $BUILD_DIR/FV/Efildr20
-	
-	echo Done!
+    $BASETOOLS_DIR/GenFw --rebase 0x10000 -o $BUILD_DIR/$PROCESSOR/EfiLoader.efi $BUILD_DIR/$PROCESSOR/EfiLoader.efi
+    $BASETOOLS_DIR/EfiLdrImage -o $BUILD_DIR/FV/Efildr64 $BUILD_DIR/$PROCESSOR/EfiLoader.efi $BUILD_DIR/FV/DxeIpl.z $BUILD_DIR/FV/DxeMain.z $BUILD_DIR/FV/DUETEFIMAINFV.z
+    cat $BOOTSECTOR_BIN_DIR/Start64.com $BOOTSECTOR_BIN_DIR/efi64.com2 $BUILD_DIR/FV/Efildr64 > $BUILD_DIR/FV/EfildrPure
+    #bcat -o $BUILD_DIR/FV/EfildrPure $BOOTSECTOR_BIN_DIR/start64.com $BOOTSECTOR_BIN_DIR/efi64.com2 $BUILD_DIR/FV/Efildr64
+    $BASETOOLS_DIR/GenPage $BUILD_DIR/FV/EfildrPure -o $BUILD_DIR/FV/Efildr
+    cat $BOOTSECTOR_BIN_DIR/St16_64.com $BOOTSECTOR_BIN_DIR/efi64.com2 $BUILD_DIR/FV/Efildr64 > $BUILD_DIR/FV/Efildr16Pure
+    #bcat -o $BUILD_DIR/FV/Efildr16Pure $BOOTSECTOR_BIN_DIR/st16_64.com $BOOTSECTOR_BIN_DIR/efi64.com2 $BUILD_DIR/FV/Efildr64
+    $BASETOOLS_DIR/GenPage $BUILD_DIR/FV/Efildr16Pure -o $BUILD_DIR/FV/Efildr16
+    cat $BOOTSECTOR_BIN_DIR/St32_64.com $BOOTSECTOR_BIN_DIR/efi64.com2 $BUILD_DIR/FV/Efildr64 > $BUILD_DIR/FV/Efildr20Pure
+    #bcat -o $BUILD_DIR/FV/Efildr20Pure $BOOTSECTOR_BIN_DIR/st32_64.com $BOOTSECTOR_BIN_DIR/efi64.com2 $BUILD_DIR/FV/Efildr64
+    $BASETOOLS_DIR/GenPage $BUILD_DIR/FV/Efildr20Pure -o $BUILD_DIR/FV/Efildr20
+
+    echo Done!
 fi
 
 
diff --git a/DuetPkg/ReadMe.txt b/DuetPkg/ReadMe.txt
index f280679..d7ad3d6 100644
--- a/DuetPkg/ReadMe.txt
+++ b/DuetPkg/ReadMe.txt
@@ -7,32 +7,32 @@ A. Build DUET image on Windows Platform
 To build DUET image, following tools are required:
 
   1). *Visual Studio 2005*
-      Assume installed at <VS_PATH>, 
+      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.1 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 
+  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.
- 
-2.2 Execute post build actions  
+
+2.2 Execute post build actions
   1). enter <Workspace>\DuetPkg directory.
-  2). run "PostBuild.bat IA32" for IA32 architecture platform or 
+  2). run "PostBuild.bat IA32" for IA32 architecture platform or
           "PostBuild.bat X64" for X64 architecture platform.
 
 Create bootable disk
 ======================
-  
+
 3. Create boot disk
   The following steps are same for IA32 architecture platform or X64 architecture platform.
-  
+
 3.1 Create floppy boot disk
   1). enter <Workspace>\DuetPkg directory.
   2). Insert a floppy disk to drive
@@ -51,9 +51,9 @@ Create bootable disk
       or "CreateBootDisk.bat usb e: FAT16 X64 step2" if usb drive is e: and FAT format is FAT16 and Arch to boot is X64.
       or "CreateBootDisk.bat usb e: FAT32 IA32 step2" if usb drive is e: and FAT format is FAT32 and Arch to boot is IA32.
       or "CreateBootDisk.bat usb e: FAT32 X64 step2" if usb drive is e: and FAT format is FAT32 and Arch to boot is X64.
-          
+
 B. Build DUET image on Linux Platform
-======================================        
+======================================
 1. Tools preparation
 
   To build DUET image, GCC44 is required:
@@ -62,28 +62,28 @@ B. Build DUET image on Linux Platform
 
 2. Build steps
 
-2.1 Build Duet Platform module   
+2.1 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 
+  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  
+
+2.2 Execute post build actions
   1). enter /edk2_tree/DuetPkg directory.
-  2). run "./PostBuild.sh IA32 GCC44" for IA32 architecture platform or 
+  2). run "./PostBuild.sh IA32 GCC44" for IA32 architecture platform or
           "./PostBuild.sh X64 GCC44" 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.
- 
+
 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"
\ No newline at end of file
+      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"
-- 
1.9.5.msysgit.0



^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 2/3] DuetPkg: Use 'echo off' in BATCH script files
  2016-11-11  8:26 [PATCH 0/3] Enable POSTBUILD feature in DuetPkg DSC files Hao Wu
  2016-11-11  8:26 ` [PATCH 1/3] DuetPkg: Resolve white-space issues for post-build scripts & ReadMe Hao Wu
@ 2016-11-11  8:26 ` Hao Wu
  2016-11-11  8:32   ` Ni, Ruiyu
  2016-11-11  8:26 ` [PATCH 3/3] DuetPkg: Add POSTBUILD in DSC files to run post-build automatically Hao Wu
  2 siblings, 1 reply; 7+ messages in thread
From: Hao Wu @ 2016-11-11  8:26 UTC (permalink / raw)
  To: edk2-devel; +Cc: Hao Wu, Ruiyu Ni

Instead of putting a '@' at the beginning of every command in BATCH script
files, use 'echo off' at the beginning of each file.

Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Hao Wu <hao.a.wu@intel.com>
---
 DuetPkg/CreateBootDisk.bat | 197 +++++++++++++++++++++++----------------------
 DuetPkg/GetVariables.bat   |  23 +++---
 DuetPkg/PostBuild.bat      |  69 ++++++++--------
 3 files changed, 146 insertions(+), 143 deletions(-)

diff --git a/DuetPkg/CreateBootDisk.bat b/DuetPkg/CreateBootDisk.bat
index 214b5b6..7265837 100644
--- a/DuetPkg/CreateBootDisk.bat
+++ b/DuetPkg/CreateBootDisk.bat
@@ -1,3 +1,4 @@
+@echo off
 @REM ## @file
 @REM #
 @REM #  Copyright (c) 2010 - 2014, Intel Corporation. All rights reserved.<BR>
@@ -14,133 +15,133 @@
 
 @REM Set up environment at first.
 
-@set BASETOOLS_DIR=%WORKSPACE_TOOLS_PATH%\Bin\Win32
-@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
-@if "%3"=="" goto Help
-@if "%4"=="" goto Set_BootDisk
-@if "%4"=="step2" (@set STEP=2) else @set TARGET_ARCH=%4
-@if "%5"=="step2" @set STEP=2
+set BASETOOLS_DIR=%WORKSPACE_TOOLS_PATH%\Bin\Win32
+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
+if "%3"=="" goto Help
+if "%4"=="" goto Set_BootDisk
+if "%4"=="step2" (@set STEP=2) else @set TARGET_ARCH=%4
+if "%5"=="step2" @set STEP=2
 :Set_BootDisk
-@set EFI_BOOT_DISK=%2
-@if "%TARGET_ARCH%"=="IA32" set PROCESSOR=IA32
-@if "%TARGET_ARCH%"=="X64" set PROCESSOR=X64
-@if %PROCESSOR%=="" goto WrongArch
-@set BUILD_DIR=%WORKSPACE%\Build\DuetPkg%PROCESSOR%\%TARGET%_%TOOL_CHAIN_TAG%
+set EFI_BOOT_DISK=%2
+if "%TARGET_ARCH%"=="IA32" set PROCESSOR=IA32
+if "%TARGET_ARCH%"=="X64" set PROCESSOR=X64
+if %PROCESSOR%=="" goto WrongArch
+set BUILD_DIR=%WORKSPACE%\Build\DuetPkg%PROCESSOR%\%TARGET%_%TOOL_CHAIN_TAG%
 
-@if "%1"=="floppy" goto CreateFloppy
-@if "%1"=="file" goto CreateFile
-@if "%1"=="usb" goto CreateUsb
-@if "%1"=="ide" goto CreateIde
+if "%1"=="floppy" goto CreateFloppy
+if "%1"=="file" goto CreateFile
+if "%1"=="usb" goto CreateUsb
+if "%1"=="ide" goto CreateIde
 
 goto Help
 
 :CreateFloppy
-@if NOT "%3"=="FAT12" goto WrongFATType
-@echo Start to create floppy boot disk ...
-@echo Format %EFI_BOOT_DISK% ...
-@echo.> FormatCommandInput.txt
-@echo.n>> FormatCommandInput.txt
-@format /v:%DISK_LABEL% /q %EFI_BOOT_DISK% < FormatCommandInput.txt > NUL
-@del FormatCommandInput.txt
-@echo Create boot sector ...
-@%BASETOOLS_DIR%\Genbootsector.exe -i %EFI_BOOT_DISK% -o FDBs.com
-@copy %BOOTSECTOR_BIN_DIR%\Bootsect.com FDBs-1.com
-@%BASETOOLS_DIR%\Bootsectimage.exe -g FDBs.com FDBs-1.com -f
+if NOT "%3"=="FAT12" goto WrongFATType
+echo Start to create floppy boot disk ...
+echo Format %EFI_BOOT_DISK% ...
+echo.> FormatCommandInput.txt
+echo.n>> FormatCommandInput.txt
+format /v:%DISK_LABEL% /q %EFI_BOOT_DISK% < FormatCommandInput.txt > NUL
+del FormatCommandInput.txt
+echo Create boot sector ...
+%BASETOOLS_DIR%\Genbootsector.exe -i %EFI_BOOT_DISK% -o FDBs.com
+copy %BOOTSECTOR_BIN_DIR%\Bootsect.com FDBs-1.com
+%BASETOOLS_DIR%\Bootsectimage.exe -g FDBs.com FDBs-1.com -f
 @REM @del FDBS.com
-@%BASETOOLS_DIR%\Genbootsector.exe -o %EFI_BOOT_DISK% -i FDBs-1.com
-@del FDBs-1.com
-@echo Done.
-@copy %BUILD_DIR%\FV\EfiLdr %EFI_BOOT_DISK%
-@goto CreateBootFile
+%BASETOOLS_DIR%\Genbootsector.exe -o %EFI_BOOT_DISK% -i FDBs-1.com
+del FDBs-1.com
+echo Done.
+copy %BUILD_DIR%\FV\EfiLdr %EFI_BOOT_DISK%
+goto CreateBootFile
 
 :CreateFile
-@if NOT "%3"=="FAT12" goto WrongFATType
-@echo Start to create file boot disk ...
-@echo Create boot sector ...
+if NOT "%3"=="FAT12" goto WrongFATType
+echo Start to create file boot disk ...
+echo Create boot sector ...
 %BASETOOLS_DIR%\Genbootsector.exe -i %EFI_BOOT_DISK% -o FDBs.com
-@copy %BOOTSECTOR_BIN_DIR%\Bootsect.com FDBs-1.com
-@%BASETOOLS_DIR%\Bootsectimage.exe -g FDBs.com FDBs-1.com -f
-@REM @del FDBS.com
-@%BASETOOLS_DIR%\Genbootsector.exe -o %EFI_BOOT_DISK% -i FDBs-1.com
-@del FDBs-1.com
-@echo Done.
-@goto end
+copy %BOOTSECTOR_BIN_DIR%\Bootsect.com FDBs-1.com
+%BASETOOLS_DIR%\Bootsectimage.exe -g FDBs.com FDBs-1.com -f
+REM @del FDBS.com
+%BASETOOLS_DIR%\Genbootsector.exe -o %EFI_BOOT_DISK% -i FDBs-1.com
+del FDBs-1.com
+echo Done.
+goto end
 
 :CreateUsb
-@echo Start to create usb boot disk ...
-@if "%3"=="FAT16" goto CreateUsb_FAT16
-@if "%3"=="FAT32" goto CreateUsb_FAT32
-@if "%3"=="FAT12" goto WrongFATType
+echo Start to create usb boot disk ...
+if "%3"=="FAT16" goto CreateUsb_FAT16
+if "%3"=="FAT32" goto CreateUsb_FAT32
+if "%3"=="FAT12" goto WrongFATType
 
 :CreateUsb_FAT16
-@if "%STEP%"=="2" goto CreateUsb_FAT16_step2
-@echo Format %EFI_BOOT_DISK% ...
-@echo.> FormatCommandInput.txt
-@format /FS:FAT /v:%DISK_LABEL% /q %EFI_BOOT_DISK% < FormatCommandInput.txt > NUL
-@del FormatCommandInput.txt
-@echo Create boot sector ...
-@%BASETOOLS_DIR%\Genbootsector.exe -i %EFI_BOOT_DISK% -o UsbBs16.com
-@copy %BOOTSECTOR_BIN_DIR%\Bs16.com Bs16-1.com
-@%BASETOOLS_DIR%\Bootsectimage.exe -g UsbBs16.com Bs16-1.com -f
-@%BASETOOLS_DIR%\Genbootsector.exe -o %EFI_BOOT_DISK% -i Bs16-1.com
-@del Bs16-1.com
-@%BASETOOLS_DIR%\Genbootsector.exe -m -o %EFI_BOOT_DISK% -i %BOOTSECTOR_BIN_DIR%\Mbr.com
-@echo Done.
-@echo PLEASE UNPLUG USB, THEN PLUG IT AGAIN!
-@goto end
+if "%STEP%"=="2" goto CreateUsb_FAT16_step2
+echo Format %EFI_BOOT_DISK% ...
+echo.> FormatCommandInput.txt
+format /FS:FAT /v:%DISK_LABEL% /q %EFI_BOOT_DISK% < FormatCommandInput.txt > NUL
+del FormatCommandInput.txt
+echo Create boot sector ...
+%BASETOOLS_DIR%\Genbootsector.exe -i %EFI_BOOT_DISK% -o UsbBs16.com
+copy %BOOTSECTOR_BIN_DIR%\Bs16.com Bs16-1.com
+%BASETOOLS_DIR%\Bootsectimage.exe -g UsbBs16.com Bs16-1.com -f
+%BASETOOLS_DIR%\Genbootsector.exe -o %EFI_BOOT_DISK% -i Bs16-1.com
+del Bs16-1.com
+%BASETOOLS_DIR%\Genbootsector.exe -m -o %EFI_BOOT_DISK% -i %BOOTSECTOR_BIN_DIR%\Mbr.com
+echo Done.
+echo PLEASE UNPLUG USB, THEN PLUG IT AGAIN!
+goto end
 
 :CreateUsb_FAT16_step2
-@copy %BUILD_DIR%\FV\EfiLdr16 %EFI_BOOT_DISK%
-@goto CreateBootFile
+copy %BUILD_DIR%\FV\EfiLdr16 %EFI_BOOT_DISK%
+goto CreateBootFile
 
 :CreateUsb_FAT32
-@if "%STEP%"=="2" goto CreateUsb_FAT32_step2
-@echo Format %EFI_BOOT_DISK% ...
-@echo.> FormatCommandInput.txt
-@format /FS:FAT32 /v:%DISK_LABEL% /q %EFI_BOOT_DISK% < FormatCommandInput.txt > NUL
-@del FormatCommandInput.txt
-@echo Create boot sector ...
-@%BASETOOLS_DIR%\Genbootsector.exe -i %EFI_BOOT_DISK% -o UsbBs32.com
-@copy %BOOTSECTOR_BIN_DIR%\Bs32.com Bs32-1.com
-@%BASETOOLS_DIR%\Bootsectimage.exe -g UsbBs32.com Bs32-1.com -f
-@del UsbBs32.com
-@%BASETOOLS_DIR%\Genbootsector.exe -o %EFI_BOOT_DISK% -i Bs32-1.com
-@del Bs32-1.com
-@%BASETOOLS_DIR%\Genbootsector.exe -m -o %EFI_BOOT_DISK% -i %BOOTSECTOR_BIN_DIR%\Mbr.com
-@echo Done.
-@echo PLEASE UNPLUG USB, THEN PLUG IT AGAIN!
-@goto end
+if "%STEP%"=="2" goto CreateUsb_FAT32_step2
+echo Format %EFI_BOOT_DISK% ...
+echo.> FormatCommandInput.txt
+format /FS:FAT32 /v:%DISK_LABEL% /q %EFI_BOOT_DISK% < FormatCommandInput.txt > NUL
+del FormatCommandInput.txt
+echo Create boot sector ...
+%BASETOOLS_DIR%\Genbootsector.exe -i %EFI_BOOT_DISK% -o UsbBs32.com
+copy %BOOTSECTOR_BIN_DIR%\Bs32.com Bs32-1.com
+%BASETOOLS_DIR%\Bootsectimage.exe -g UsbBs32.com Bs32-1.com -f
+del UsbBs32.com
+%BASETOOLS_DIR%\Genbootsector.exe -o %EFI_BOOT_DISK% -i Bs32-1.com
+del Bs32-1.com
+%BASETOOLS_DIR%\Genbootsector.exe -m -o %EFI_BOOT_DISK% -i %BOOTSECTOR_BIN_DIR%\Mbr.com
+echo Done.
+echo PLEASE UNPLUG USB, THEN PLUG IT AGAIN!
+goto end
 
 :CreateUsb_FAT32_step2
-@copy %BUILD_DIR%\FV\EfiLdr20 %EFI_BOOT_DISK%
-@goto CreateBootFile
+copy %BUILD_DIR%\FV\EfiLdr20 %EFI_BOOT_DISK%
+goto CreateBootFile
 
 :CreateIde
-@goto end
+goto end
 
 :CreateBootFile
-@mkdir %EFI_BOOT_DISK%\efi\boot
+mkdir %EFI_BOOT_DISK%\efi\boot
 copy %WORKSPACE%\ShellBinPkg\UefiShell\%PROCESSOR%\Shell.efi %EFI_BOOT_DISK%\efi\boot\boot%PROCESSOR%.efi /y
-@goto end
+goto end
 
 :WrongFATType
-@echo Wrong FAT type %3 for %1
-@goto end
+echo Wrong FAT type %3 for %1
+goto end
 
 :WrongArch
-@echo Error! Wrong architecture.
-@goto Help
+echo Error! Wrong architecture.
+goto Help
 
 :Help
-@echo "Usage: CreateBootDisk [usb|floppy|ide] DiskNumber [FAT12|FAT16|FAT32] [IA32|X64]"
+echo "Usage: CreateBootDisk [usb|floppy|ide] DiskNumber [FAT12|FAT16|FAT32] [IA32|X64]"
 :end
-@echo on
+echo on
diff --git a/DuetPkg/GetVariables.bat b/DuetPkg/GetVariables.bat
index c781228..c81d3d1 100644
--- a/DuetPkg/GetVariables.bat
+++ b/DuetPkg/GetVariables.bat
@@ -1,3 +1,4 @@
+@echo off
 @REM ## @file
 @REM #
 @REM #  Copyright (c) 2011, Intel Corporation. All rights reserved.<BR>
@@ -19,20 +20,20 @@
 @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
+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 "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" ^| 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
+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
+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
+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 df34fa7..28cab6b 100644
--- a/DuetPkg/PostBuild.bat
+++ b/DuetPkg/PostBuild.bat
@@ -1,3 +1,4 @@
+@echo off
 @REM ## @file
 @REM #
 @REM #  Currently, Build system does not provide post build mechanism for module
@@ -16,54 +17,54 @@
 @REM #
 @REM ##
 
-@set BASETOOLS_DIR=%WORKSPACE_TOOLS_PATH%\Bin\Win32
-@set BOOTSECTOR_BIN_DIR=%WORKSPACE%\DuetPkg\BootSector\bin
-@set PROCESSOR=""
-@call %WORKSPACE%\DuetPkg\GetVariables.bat
+set BASETOOLS_DIR=%WORKSPACE_TOOLS_PATH%\Bin\Win32
+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
+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
 
-@set BUILD_DIR=%WORKSPACE%\Build\DuetPkg%PROCESSOR%\%TARGET%_%TOOL_CHAIN_TAG%
+set BUILD_DIR=%WORKSPACE%\Build\DuetPkg%PROCESSOR%\%TARGET%_%TOOL_CHAIN_TAG%
 
 
-@echo Compressing DUETEFIMainFv.FV ...
-@%BASETOOLS_DIR%\LzmaCompress -e -o %BUILD_DIR%\FV\DUETEFIMAINFV.z %BUILD_DIR%\FV\DUETEFIMAINFV.Fv
+echo Compressing DUETEFIMainFv.FV ...
+%BASETOOLS_DIR%\LzmaCompress -e -o %BUILD_DIR%\FV\DUETEFIMAINFV.z %BUILD_DIR%\FV\DUETEFIMAINFV.Fv
 
-@echo Compressing DxeMain.efi ...
-@%BASETOOLS_DIR%\LzmaCompress -e -o %BUILD_DIR%\FV\DxeMain.z %BUILD_DIR%\%PROCESSOR%\DxeCore.efi
+echo Compressing DxeMain.efi ...
+%BASETOOLS_DIR%\LzmaCompress -e -o %BUILD_DIR%\FV\DxeMain.z %BUILD_DIR%\%PROCESSOR%\DxeCore.efi
 
-@echo Compressing DxeIpl.efi ...
-@%BASETOOLS_DIR%\LzmaCompress -e -o %BUILD_DIR%\FV\DxeIpl.z %BUILD_DIR%\%PROCESSOR%\DxeIpl.efi
+echo Compressing DxeIpl.efi ...
+%BASETOOLS_DIR%\LzmaCompress -e -o %BUILD_DIR%\FV\DxeIpl.z %BUILD_DIR%\%PROCESSOR%\DxeIpl.efi
 
-@echo Generate Loader Image ...
-@if "%PROCESSOR%"=="IA32" goto GENERATE_IMAGE_IA32
-@if "%PROCESSOR%"=="X64" goto GENERATE_IMAGE_X64
+echo Generate Loader Image ...
+if "%PROCESSOR%"=="IA32" goto GENERATE_IMAGE_IA32
+if "%PROCESSOR%"=="X64" goto GENERATE_IMAGE_X64
 
 :GENERATE_IMAGE_IA32
-@%BASETOOLS_DIR%\EfiLdrImage.exe -o %BUILD_DIR%\FV\Efildr32 %BUILD_DIR%\%PROCESSOR%\EfiLoader.efi %BUILD_DIR%\FV\DxeIpl.z %BUILD_DIR%\FV\DxeMain.z %BUILD_DIR%\FV\DUETEFIMAINFV.z
-@copy /b %BOOTSECTOR_BIN_DIR%\Start.com+%BOOTSECTOR_BIN_DIR%\Efi32.com2+%BUILD_DIR%\FV\Efildr32 %BUILD_DIR%\FV\Efildr
-@copy /b %BOOTSECTOR_BIN_DIR%\Start16.com+%BOOTSECTOR_BIN_DIR%\Efi32.com2+%BUILD_DIR%\FV\Efildr32 %BUILD_DIR%\FV\Efildr16
-@copy /b %BOOTSECTOR_BIN_DIR%\Start32.com+%BOOTSECTOR_BIN_DIR%\Efi32.com2+%BUILD_DIR%\FV\Efildr32 %BUILD_DIR%\FV\Efildr20
-@goto end
+%BASETOOLS_DIR%\EfiLdrImage.exe -o %BUILD_DIR%\FV\Efildr32 %BUILD_DIR%\%PROCESSOR%\EfiLoader.efi %BUILD_DIR%\FV\DxeIpl.z %BUILD_DIR%\FV\DxeMain.z %BUILD_DIR%\FV\DUETEFIMAINFV.z
+copy /b %BOOTSECTOR_BIN_DIR%\Start.com+%BOOTSECTOR_BIN_DIR%\Efi32.com2+%BUILD_DIR%\FV\Efildr32 %BUILD_DIR%\FV\Efildr
+copy /b %BOOTSECTOR_BIN_DIR%\Start16.com+%BOOTSECTOR_BIN_DIR%\Efi32.com2+%BUILD_DIR%\FV\Efildr32 %BUILD_DIR%\FV\Efildr16
+copy /b %BOOTSECTOR_BIN_DIR%\Start32.com+%BOOTSECTOR_BIN_DIR%\Efi32.com2+%BUILD_DIR%\FV\Efildr32 %BUILD_DIR%\FV\Efildr20
+goto end
 
 :GENERATE_IMAGE_X64
-@%BASETOOLS_DIR%\EfiLdrImage.exe -o %BUILD_DIR%\FV\Efildr64 %BUILD_DIR%\%PROCESSOR%\EfiLoader.efi %BUILD_DIR%\FV\DxeIpl.z %BUILD_DIR%\FV\DxeMain.z %BUILD_DIR%\FV\DUETEFIMAINFV.z
-@copy /b %BOOTSECTOR_BIN_DIR%\Start64.com+%BOOTSECTOR_BIN_DIR%\Efi64.com2+%BUILD_DIR%\FV\Efildr64 %BUILD_DIR%\FV\EfildrPure
-@%BASETOOLS_DIR%\GenPage.exe %BUILD_DIR%\FV\EfildrPure -o %BUILD_DIR%\FV\Efildr
-@copy /b %BOOTSECTOR_BIN_DIR%\St16_64.com+%BOOTSECTOR_BIN_DIR%\Efi64.com2+%BUILD_DIR%\FV\Efildr64 %BUILD_DIR%\FV\Efildr16Pure
-@%BASETOOLS_DIR%\GenPage.exe %BUILD_DIR%\FV\Efildr16Pure -o %BUILD_DIR%\FV\Efildr16
-@copy /b %BOOTSECTOR_BIN_DIR%\St32_64.com+%BOOTSECTOR_BIN_DIR%\Efi64.com2+%BUILD_DIR%\FV\Efildr64 %BUILD_DIR%\FV\Efildr20Pure
-@%BASETOOLS_DIR%\GenPage.exe %BUILD_DIR%\FV\Efildr20Pure -o %BUILD_DIR%\FV\Efildr20
-@goto end
+%BASETOOLS_DIR%\EfiLdrImage.exe -o %BUILD_DIR%\FV\Efildr64 %BUILD_DIR%\%PROCESSOR%\EfiLoader.efi %BUILD_DIR%\FV\DxeIpl.z %BUILD_DIR%\FV\DxeMain.z %BUILD_DIR%\FV\DUETEFIMAINFV.z
+copy /b %BOOTSECTOR_BIN_DIR%\Start64.com+%BOOTSECTOR_BIN_DIR%\Efi64.com2+%BUILD_DIR%\FV\Efildr64 %BUILD_DIR%\FV\EfildrPure
+%BASETOOLS_DIR%\GenPage.exe %BUILD_DIR%\FV\EfildrPure -o %BUILD_DIR%\FV\Efildr
+copy /b %BOOTSECTOR_BIN_DIR%\St16_64.com+%BOOTSECTOR_BIN_DIR%\Efi64.com2+%BUILD_DIR%\FV\Efildr64 %BUILD_DIR%\FV\Efildr16Pure
+%BASETOOLS_DIR%\GenPage.exe %BUILD_DIR%\FV\Efildr16Pure -o %BUILD_DIR%\FV\Efildr16
+copy /b %BOOTSECTOR_BIN_DIR%\St32_64.com+%BOOTSECTOR_BIN_DIR%\Efi64.com2+%BUILD_DIR%\FV\Efildr64 %BUILD_DIR%\FV\Efildr20Pure
+%BASETOOLS_DIR%\GenPage.exe %BUILD_DIR%\FV\Efildr20Pure -o %BUILD_DIR%\FV\Efildr20
+goto end
 
 
 :WrongArch
-@echo Error! Wrong architecture.
-@goto Help
+echo Error! Wrong architecture.
+goto Help
 
 :Help
-@echo Usage: "PostBuild [IA32|X64]"
+echo Usage: "PostBuild [IA32|X64]"
 :end
\ No newline at end of file
-- 
1.9.5.msysgit.0



^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 3/3] DuetPkg: Add POSTBUILD in DSC files to run post-build automatically
  2016-11-11  8:26 [PATCH 0/3] Enable POSTBUILD feature in DuetPkg DSC files Hao Wu
  2016-11-11  8:26 ` [PATCH 1/3] DuetPkg: Resolve white-space issues for post-build scripts & ReadMe Hao Wu
  2016-11-11  8:26 ` [PATCH 2/3] DuetPkg: Use 'echo off' in BATCH script files Hao Wu
@ 2016-11-11  8:26 ` Hao Wu
  2016-11-11  8:32   ` Ni, Ruiyu
  2 siblings, 1 reply; 7+ messages in thread
From: Hao Wu @ 2016-11-11  8:26 UTC (permalink / raw)
  To: edk2-devel; +Cc: Hao Wu, Ruiyu Ni

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>
---
 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.<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 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.<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 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.<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 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.<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 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 <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 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



^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH 2/3] DuetPkg: Use 'echo off' in BATCH script files
  2016-11-11  8:26 ` [PATCH 2/3] DuetPkg: Use 'echo off' in BATCH script files Hao Wu
@ 2016-11-11  8:32   ` Ni, Ruiyu
  0 siblings, 0 replies; 7+ messages in thread
From: Ni, Ruiyu @ 2016-11-11  8:32 UTC (permalink / raw)
  To: Wu, Hao A, edk2-devel@lists.01.org

Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>

Regards,
Ray

>-----Original Message-----
>From: Wu, Hao A
>Sent: Friday, November 11, 2016 4:27 PM
>To: edk2-devel@lists.01.org
>Cc: Wu, Hao A <hao.a.wu@intel.com>; Ni, Ruiyu <ruiyu.ni@intel.com>
>Subject: [PATCH 2/3] DuetPkg: Use 'echo off' in BATCH script files
>
>Instead of putting a '@' at the beginning of every command in BATCH script
>files, use 'echo off' at the beginning of each file.
>
>Cc: Ruiyu Ni <ruiyu.ni@intel.com>
>Contributed-under: TianoCore Contribution Agreement 1.0
>Signed-off-by: Hao Wu <hao.a.wu@intel.com>
>---
> DuetPkg/CreateBootDisk.bat | 197 +++++++++++++++++++++++----------------------
> DuetPkg/GetVariables.bat   |  23 +++---
> DuetPkg/PostBuild.bat      |  69 ++++++++--------
> 3 files changed, 146 insertions(+), 143 deletions(-)
>
>diff --git a/DuetPkg/CreateBootDisk.bat b/DuetPkg/CreateBootDisk.bat
>index 214b5b6..7265837 100644
>--- a/DuetPkg/CreateBootDisk.bat
>+++ b/DuetPkg/CreateBootDisk.bat
>@@ -1,3 +1,4 @@
>+@echo off
> @REM ## @file
> @REM #
> @REM #  Copyright (c) 2010 - 2014, Intel Corporation. All rights reserved.<BR>
>@@ -14,133 +15,133 @@
>
> @REM Set up environment at first.
>
>-@set BASETOOLS_DIR=%WORKSPACE_TOOLS_PATH%\Bin\Win32
>-@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
>-@if "%3"=="" goto Help
>-@if "%4"=="" goto Set_BootDisk
>-@if "%4"=="step2" (@set STEP=2) else @set TARGET_ARCH=%4
>-@if "%5"=="step2" @set STEP=2
>+set BASETOOLS_DIR=%WORKSPACE_TOOLS_PATH%\Bin\Win32
>+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
>+if "%3"=="" goto Help
>+if "%4"=="" goto Set_BootDisk
>+if "%4"=="step2" (@set STEP=2) else @set TARGET_ARCH=%4
>+if "%5"=="step2" @set STEP=2
> :Set_BootDisk
>-@set EFI_BOOT_DISK=%2
>-@if "%TARGET_ARCH%"=="IA32" set PROCESSOR=IA32
>-@if "%TARGET_ARCH%"=="X64" set PROCESSOR=X64
>-@if %PROCESSOR%=="" goto WrongArch
>-@set BUILD_DIR=%WORKSPACE%\Build\DuetPkg%PROCESSOR%\%TARGET%_%TOOL_CHAIN_TAG%
>+set EFI_BOOT_DISK=%2
>+if "%TARGET_ARCH%"=="IA32" set PROCESSOR=IA32
>+if "%TARGET_ARCH%"=="X64" set PROCESSOR=X64
>+if %PROCESSOR%=="" goto WrongArch
>+set BUILD_DIR=%WORKSPACE%\Build\DuetPkg%PROCESSOR%\%TARGET%_%TOOL_CHAIN_TAG%
>
>-@if "%1"=="floppy" goto CreateFloppy
>-@if "%1"=="file" goto CreateFile
>-@if "%1"=="usb" goto CreateUsb
>-@if "%1"=="ide" goto CreateIde
>+if "%1"=="floppy" goto CreateFloppy
>+if "%1"=="file" goto CreateFile
>+if "%1"=="usb" goto CreateUsb
>+if "%1"=="ide" goto CreateIde
>
> goto Help
>
> :CreateFloppy
>-@if NOT "%3"=="FAT12" goto WrongFATType
>-@echo Start to create floppy boot disk ...
>-@echo Format %EFI_BOOT_DISK% ...
>-@echo.> FormatCommandInput.txt
>-@echo.n>> FormatCommandInput.txt
>-@format /v:%DISK_LABEL% /q %EFI_BOOT_DISK% < FormatCommandInput.txt > NUL
>-@del FormatCommandInput.txt
>-@echo Create boot sector ...
>-@%BASETOOLS_DIR%\Genbootsector.exe -i %EFI_BOOT_DISK% -o FDBs.com
>-@copy %BOOTSECTOR_BIN_DIR%\Bootsect.com FDBs-1.com
>-@%BASETOOLS_DIR%\Bootsectimage.exe -g FDBs.com FDBs-1.com -f
>+if NOT "%3"=="FAT12" goto WrongFATType
>+echo Start to create floppy boot disk ...
>+echo Format %EFI_BOOT_DISK% ...
>+echo.> FormatCommandInput.txt
>+echo.n>> FormatCommandInput.txt
>+format /v:%DISK_LABEL% /q %EFI_BOOT_DISK% < FormatCommandInput.txt > NUL
>+del FormatCommandInput.txt
>+echo Create boot sector ...
>+%BASETOOLS_DIR%\Genbootsector.exe -i %EFI_BOOT_DISK% -o FDBs.com
>+copy %BOOTSECTOR_BIN_DIR%\Bootsect.com FDBs-1.com
>+%BASETOOLS_DIR%\Bootsectimage.exe -g FDBs.com FDBs-1.com -f
> @REM @del FDBS.com
>-@%BASETOOLS_DIR%\Genbootsector.exe -o %EFI_BOOT_DISK% -i FDBs-1.com
>-@del FDBs-1.com
>-@echo Done.
>-@copy %BUILD_DIR%\FV\EfiLdr %EFI_BOOT_DISK%
>-@goto CreateBootFile
>+%BASETOOLS_DIR%\Genbootsector.exe -o %EFI_BOOT_DISK% -i FDBs-1.com
>+del FDBs-1.com
>+echo Done.
>+copy %BUILD_DIR%\FV\EfiLdr %EFI_BOOT_DISK%
>+goto CreateBootFile
>
> :CreateFile
>-@if NOT "%3"=="FAT12" goto WrongFATType
>-@echo Start to create file boot disk ...
>-@echo Create boot sector ...
>+if NOT "%3"=="FAT12" goto WrongFATType
>+echo Start to create file boot disk ...
>+echo Create boot sector ...
> %BASETOOLS_DIR%\Genbootsector.exe -i %EFI_BOOT_DISK% -o FDBs.com
>-@copy %BOOTSECTOR_BIN_DIR%\Bootsect.com FDBs-1.com
>-@%BASETOOLS_DIR%\Bootsectimage.exe -g FDBs.com FDBs-1.com -f
>-@REM @del FDBS.com
>-@%BASETOOLS_DIR%\Genbootsector.exe -o %EFI_BOOT_DISK% -i FDBs-1.com
>-@del FDBs-1.com
>-@echo Done.
>-@goto end
>+copy %BOOTSECTOR_BIN_DIR%\Bootsect.com FDBs-1.com
>+%BASETOOLS_DIR%\Bootsectimage.exe -g FDBs.com FDBs-1.com -f
>+REM @del FDBS.com
>+%BASETOOLS_DIR%\Genbootsector.exe -o %EFI_BOOT_DISK% -i FDBs-1.com
>+del FDBs-1.com
>+echo Done.
>+goto end
>
> :CreateUsb
>-@echo Start to create usb boot disk ...
>-@if "%3"=="FAT16" goto CreateUsb_FAT16
>-@if "%3"=="FAT32" goto CreateUsb_FAT32
>-@if "%3"=="FAT12" goto WrongFATType
>+echo Start to create usb boot disk ...
>+if "%3"=="FAT16" goto CreateUsb_FAT16
>+if "%3"=="FAT32" goto CreateUsb_FAT32
>+if "%3"=="FAT12" goto WrongFATType
>
> :CreateUsb_FAT16
>-@if "%STEP%"=="2" goto CreateUsb_FAT16_step2
>-@echo Format %EFI_BOOT_DISK% ...
>-@echo.> FormatCommandInput.txt
>-@format /FS:FAT /v:%DISK_LABEL% /q %EFI_BOOT_DISK% < FormatCommandInput.txt > NUL
>-@del FormatCommandInput.txt
>-@echo Create boot sector ...
>-@%BASETOOLS_DIR%\Genbootsector.exe -i %EFI_BOOT_DISK% -o UsbBs16.com
>-@copy %BOOTSECTOR_BIN_DIR%\Bs16.com Bs16-1.com
>-@%BASETOOLS_DIR%\Bootsectimage.exe -g UsbBs16.com Bs16-1.com -f
>-@%BASETOOLS_DIR%\Genbootsector.exe -o %EFI_BOOT_DISK% -i Bs16-1.com
>-@del Bs16-1.com
>-@%BASETOOLS_DIR%\Genbootsector.exe -m -o %EFI_BOOT_DISK% -i %BOOTSECTOR_BIN_DIR%\Mbr.com
>-@echo Done.
>-@echo PLEASE UNPLUG USB, THEN PLUG IT AGAIN!
>-@goto end
>+if "%STEP%"=="2" goto CreateUsb_FAT16_step2
>+echo Format %EFI_BOOT_DISK% ...
>+echo.> FormatCommandInput.txt
>+format /FS:FAT /v:%DISK_LABEL% /q %EFI_BOOT_DISK% < FormatCommandInput.txt > NUL
>+del FormatCommandInput.txt
>+echo Create boot sector ...
>+%BASETOOLS_DIR%\Genbootsector.exe -i %EFI_BOOT_DISK% -o UsbBs16.com
>+copy %BOOTSECTOR_BIN_DIR%\Bs16.com Bs16-1.com
>+%BASETOOLS_DIR%\Bootsectimage.exe -g UsbBs16.com Bs16-1.com -f
>+%BASETOOLS_DIR%\Genbootsector.exe -o %EFI_BOOT_DISK% -i Bs16-1.com
>+del Bs16-1.com
>+%BASETOOLS_DIR%\Genbootsector.exe -m -o %EFI_BOOT_DISK% -i %BOOTSECTOR_BIN_DIR%\Mbr.com
>+echo Done.
>+echo PLEASE UNPLUG USB, THEN PLUG IT AGAIN!
>+goto end
>
> :CreateUsb_FAT16_step2
>-@copy %BUILD_DIR%\FV\EfiLdr16 %EFI_BOOT_DISK%
>-@goto CreateBootFile
>+copy %BUILD_DIR%\FV\EfiLdr16 %EFI_BOOT_DISK%
>+goto CreateBootFile
>
> :CreateUsb_FAT32
>-@if "%STEP%"=="2" goto CreateUsb_FAT32_step2
>-@echo Format %EFI_BOOT_DISK% ...
>-@echo.> FormatCommandInput.txt
>-@format /FS:FAT32 /v:%DISK_LABEL% /q %EFI_BOOT_DISK% < FormatCommandInput.txt > NUL
>-@del FormatCommandInput.txt
>-@echo Create boot sector ...
>-@%BASETOOLS_DIR%\Genbootsector.exe -i %EFI_BOOT_DISK% -o UsbBs32.com
>-@copy %BOOTSECTOR_BIN_DIR%\Bs32.com Bs32-1.com
>-@%BASETOOLS_DIR%\Bootsectimage.exe -g UsbBs32.com Bs32-1.com -f
>-@del UsbBs32.com
>-@%BASETOOLS_DIR%\Genbootsector.exe -o %EFI_BOOT_DISK% -i Bs32-1.com
>-@del Bs32-1.com
>-@%BASETOOLS_DIR%\Genbootsector.exe -m -o %EFI_BOOT_DISK% -i %BOOTSECTOR_BIN_DIR%\Mbr.com
>-@echo Done.
>-@echo PLEASE UNPLUG USB, THEN PLUG IT AGAIN!
>-@goto end
>+if "%STEP%"=="2" goto CreateUsb_FAT32_step2
>+echo Format %EFI_BOOT_DISK% ...
>+echo.> FormatCommandInput.txt
>+format /FS:FAT32 /v:%DISK_LABEL% /q %EFI_BOOT_DISK% < FormatCommandInput.txt > NUL
>+del FormatCommandInput.txt
>+echo Create boot sector ...
>+%BASETOOLS_DIR%\Genbootsector.exe -i %EFI_BOOT_DISK% -o UsbBs32.com
>+copy %BOOTSECTOR_BIN_DIR%\Bs32.com Bs32-1.com
>+%BASETOOLS_DIR%\Bootsectimage.exe -g UsbBs32.com Bs32-1.com -f
>+del UsbBs32.com
>+%BASETOOLS_DIR%\Genbootsector.exe -o %EFI_BOOT_DISK% -i Bs32-1.com
>+del Bs32-1.com
>+%BASETOOLS_DIR%\Genbootsector.exe -m -o %EFI_BOOT_DISK% -i %BOOTSECTOR_BIN_DIR%\Mbr.com
>+echo Done.
>+echo PLEASE UNPLUG USB, THEN PLUG IT AGAIN!
>+goto end
>
> :CreateUsb_FAT32_step2
>-@copy %BUILD_DIR%\FV\EfiLdr20 %EFI_BOOT_DISK%
>-@goto CreateBootFile
>+copy %BUILD_DIR%\FV\EfiLdr20 %EFI_BOOT_DISK%
>+goto CreateBootFile
>
> :CreateIde
>-@goto end
>+goto end
>
> :CreateBootFile
>-@mkdir %EFI_BOOT_DISK%\efi\boot
>+mkdir %EFI_BOOT_DISK%\efi\boot
> copy %WORKSPACE%\ShellBinPkg\UefiShell\%PROCESSOR%\Shell.efi %EFI_BOOT_DISK%\efi\boot\boot%PROCESSOR%.efi
>/y
>-@goto end
>+goto end
>
> :WrongFATType
>-@echo Wrong FAT type %3 for %1
>-@goto end
>+echo Wrong FAT type %3 for %1
>+goto end
>
> :WrongArch
>-@echo Error! Wrong architecture.
>-@goto Help
>+echo Error! Wrong architecture.
>+goto Help
>
> :Help
>-@echo "Usage: CreateBootDisk [usb|floppy|ide] DiskNumber [FAT12|FAT16|FAT32] [IA32|X64]"
>+echo "Usage: CreateBootDisk [usb|floppy|ide] DiskNumber [FAT12|FAT16|FAT32] [IA32|X64]"
> :end
>-@echo on
>+echo on
>diff --git a/DuetPkg/GetVariables.bat b/DuetPkg/GetVariables.bat
>index c781228..c81d3d1 100644
>--- a/DuetPkg/GetVariables.bat
>+++ b/DuetPkg/GetVariables.bat
>@@ -1,3 +1,4 @@
>+@echo off
> @REM ## @file
> @REM #
> @REM #  Copyright (c) 2011, Intel Corporation. All rights reserved.<BR>
>@@ -19,20 +20,20 @@
> @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
>+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 "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" ^| 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
>+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
>+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
>+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 df34fa7..28cab6b 100644
>--- a/DuetPkg/PostBuild.bat
>+++ b/DuetPkg/PostBuild.bat
>@@ -1,3 +1,4 @@
>+@echo off
> @REM ## @file
> @REM #
> @REM #  Currently, Build system does not provide post build mechanism for module
>@@ -16,54 +17,54 @@
> @REM #
> @REM ##
>
>-@set BASETOOLS_DIR=%WORKSPACE_TOOLS_PATH%\Bin\Win32
>-@set BOOTSECTOR_BIN_DIR=%WORKSPACE%\DuetPkg\BootSector\bin
>-@set PROCESSOR=""
>-@call %WORKSPACE%\DuetPkg\GetVariables.bat
>+set BASETOOLS_DIR=%WORKSPACE_TOOLS_PATH%\Bin\Win32
>+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
>+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
>
>-@set BUILD_DIR=%WORKSPACE%\Build\DuetPkg%PROCESSOR%\%TARGET%_%TOOL_CHAIN_TAG%
>+set BUILD_DIR=%WORKSPACE%\Build\DuetPkg%PROCESSOR%\%TARGET%_%TOOL_CHAIN_TAG%
>
>
>-@echo Compressing DUETEFIMainFv.FV ...
>-@%BASETOOLS_DIR%\LzmaCompress -e -o %BUILD_DIR%\FV\DUETEFIMAINFV.z %BUILD_DIR%\FV\DUETEFIMAINFV.Fv
>+echo Compressing DUETEFIMainFv.FV ...
>+%BASETOOLS_DIR%\LzmaCompress -e -o %BUILD_DIR%\FV\DUETEFIMAINFV.z %BUILD_DIR%\FV\DUETEFIMAINFV.Fv
>
>-@echo Compressing DxeMain.efi ...
>-@%BASETOOLS_DIR%\LzmaCompress -e -o %BUILD_DIR%\FV\DxeMain.z %BUILD_DIR%\%PROCESSOR%\DxeCore.efi
>+echo Compressing DxeMain.efi ...
>+%BASETOOLS_DIR%\LzmaCompress -e -o %BUILD_DIR%\FV\DxeMain.z %BUILD_DIR%\%PROCESSOR%\DxeCore.efi
>
>-@echo Compressing DxeIpl.efi ...
>-@%BASETOOLS_DIR%\LzmaCompress -e -o %BUILD_DIR%\FV\DxeIpl.z %BUILD_DIR%\%PROCESSOR%\DxeIpl.efi
>+echo Compressing DxeIpl.efi ...
>+%BASETOOLS_DIR%\LzmaCompress -e -o %BUILD_DIR%\FV\DxeIpl.z %BUILD_DIR%\%PROCESSOR%\DxeIpl.efi
>
>-@echo Generate Loader Image ...
>-@if "%PROCESSOR%"=="IA32" goto GENERATE_IMAGE_IA32
>-@if "%PROCESSOR%"=="X64" goto GENERATE_IMAGE_X64
>+echo Generate Loader Image ...
>+if "%PROCESSOR%"=="IA32" goto GENERATE_IMAGE_IA32
>+if "%PROCESSOR%"=="X64" goto GENERATE_IMAGE_X64
>
> :GENERATE_IMAGE_IA32
>-@%BASETOOLS_DIR%\EfiLdrImage.exe
>-o %BUILD_DIR%\FV\Efildr32 %BUILD_DIR%\%PROCESSOR%\EfiLoader.efi %BUILD_DIR%\FV\DxeIpl.z %BUILD_DIR%\FV\Dx
>eMain.z %BUILD_DIR%\FV\DUETEFIMAINFV.z
>-@copy
>/b %BOOTSECTOR_BIN_DIR%\Start.com+%BOOTSECTOR_BIN_DIR%\Efi32.com2+%BUILD_DIR%\FV\Efildr32 %BUILD_DIR%
>\FV\Efildr
>-@copy
>/b %BOOTSECTOR_BIN_DIR%\Start16.com+%BOOTSECTOR_BIN_DIR%\Efi32.com2+%BUILD_DIR%\FV\Efildr32 %BUILD_DIR
>%\FV\Efildr16
>-@copy
>/b %BOOTSECTOR_BIN_DIR%\Start32.com+%BOOTSECTOR_BIN_DIR%\Efi32.com2+%BUILD_DIR%\FV\Efildr32 %BUILD_DIR
>%\FV\Efildr20
>-@goto end
>+%BASETOOLS_DIR%\EfiLdrImage.exe
>-o %BUILD_DIR%\FV\Efildr32 %BUILD_DIR%\%PROCESSOR%\EfiLoader.efi %BUILD_DIR%\FV\DxeIpl.z %BUILD_DIR%\FV\Dx
>eMain.z %BUILD_DIR%\FV\DUETEFIMAINFV.z
>+copy
>/b %BOOTSECTOR_BIN_DIR%\Start.com+%BOOTSECTOR_BIN_DIR%\Efi32.com2+%BUILD_DIR%\FV\Efildr32 %BUILD_DIR%
>\FV\Efildr
>+copy
>/b %BOOTSECTOR_BIN_DIR%\Start16.com+%BOOTSECTOR_BIN_DIR%\Efi32.com2+%BUILD_DIR%\FV\Efildr32 %BUILD_DIR
>%\FV\Efildr16
>+copy
>/b %BOOTSECTOR_BIN_DIR%\Start32.com+%BOOTSECTOR_BIN_DIR%\Efi32.com2+%BUILD_DIR%\FV\Efildr32 %BUILD_DIR
>%\FV\Efildr20
>+goto end
>
> :GENERATE_IMAGE_X64
>-@%BASETOOLS_DIR%\EfiLdrImage.exe
>-o %BUILD_DIR%\FV\Efildr64 %BUILD_DIR%\%PROCESSOR%\EfiLoader.efi %BUILD_DIR%\FV\DxeIpl.z %BUILD_DIR%\FV\Dx
>eMain.z %BUILD_DIR%\FV\DUETEFIMAINFV.z
>-@copy
>/b %BOOTSECTOR_BIN_DIR%\Start64.com+%BOOTSECTOR_BIN_DIR%\Efi64.com2+%BUILD_DIR%\FV\Efildr64 %BUILD_DIR
>%\FV\EfildrPure
>-@%BASETOOLS_DIR%\GenPage.exe %BUILD_DIR%\FV\EfildrPure -o %BUILD_DIR%\FV\Efildr
>-@copy
>/b %BOOTSECTOR_BIN_DIR%\St16_64.com+%BOOTSECTOR_BIN_DIR%\Efi64.com2+%BUILD_DIR%\FV\Efildr64 %BUILD_DI
>R%\FV\Efildr16Pure
>-@%BASETOOLS_DIR%\GenPage.exe %BUILD_DIR%\FV\Efildr16Pure -o %BUILD_DIR%\FV\Efildr16
>-@copy
>/b %BOOTSECTOR_BIN_DIR%\St32_64.com+%BOOTSECTOR_BIN_DIR%\Efi64.com2+%BUILD_DIR%\FV\Efildr64 %BUILD_DI
>R%\FV\Efildr20Pure
>-@%BASETOOLS_DIR%\GenPage.exe %BUILD_DIR%\FV\Efildr20Pure -o %BUILD_DIR%\FV\Efildr20
>-@goto end
>+%BASETOOLS_DIR%\EfiLdrImage.exe
>-o %BUILD_DIR%\FV\Efildr64 %BUILD_DIR%\%PROCESSOR%\EfiLoader.efi %BUILD_DIR%\FV\DxeIpl.z %BUILD_DIR%\FV\Dx
>eMain.z %BUILD_DIR%\FV\DUETEFIMAINFV.z
>+copy
>/b %BOOTSECTOR_BIN_DIR%\Start64.com+%BOOTSECTOR_BIN_DIR%\Efi64.com2+%BUILD_DIR%\FV\Efildr64 %BUILD_DIR
>%\FV\EfildrPure
>+%BASETOOLS_DIR%\GenPage.exe %BUILD_DIR%\FV\EfildrPure -o %BUILD_DIR%\FV\Efildr
>+copy
>/b %BOOTSECTOR_BIN_DIR%\St16_64.com+%BOOTSECTOR_BIN_DIR%\Efi64.com2+%BUILD_DIR%\FV\Efildr64 %BUILD_DI
>R%\FV\Efildr16Pure
>+%BASETOOLS_DIR%\GenPage.exe %BUILD_DIR%\FV\Efildr16Pure -o %BUILD_DIR%\FV\Efildr16
>+copy
>/b %BOOTSECTOR_BIN_DIR%\St32_64.com+%BOOTSECTOR_BIN_DIR%\Efi64.com2+%BUILD_DIR%\FV\Efildr64 %BUILD_DI
>R%\FV\Efildr20Pure
>+%BASETOOLS_DIR%\GenPage.exe %BUILD_DIR%\FV\Efildr20Pure -o %BUILD_DIR%\FV\Efildr20
>+goto end
>
>
> :WrongArch
>-@echo Error! Wrong architecture.
>-@goto Help
>+echo Error! Wrong architecture.
>+goto Help
>
> :Help
>-@echo Usage: "PostBuild [IA32|X64]"
>+echo Usage: "PostBuild [IA32|X64]"
> :end
>\ No newline at end of file
>--
>1.9.5.msysgit.0



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/3] DuetPkg: Resolve white-space issues for post-build scripts & ReadMe
  2016-11-11  8:26 ` [PATCH 1/3] DuetPkg: Resolve white-space issues for post-build scripts & ReadMe Hao Wu
@ 2016-11-11  8:32   ` Ni, Ruiyu
  0 siblings, 0 replies; 7+ messages in thread
From: Ni, Ruiyu @ 2016-11-11  8:32 UTC (permalink / raw)
  To: Wu, Hao A, edk2-devel@lists.01.org

Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>

Regards,
Ray

>-----Original Message-----
>From: Wu, Hao A
>Sent: Friday, November 11, 2016 4:27 PM
>To: edk2-devel@lists.01.org
>Cc: Wu, Hao A <hao.a.wu@intel.com>; Ni, Ruiyu <ruiyu.ni@intel.com>
>Subject: [PATCH 1/3] DuetPkg: Resolve white-space issues for post-build scripts & ReadMe
>
>Cc: Ruiyu Ni <ruiyu.ni@intel.com>
>Contributed-under: TianoCore Contribution Agreement 1.0
>Signed-off-by: Hao Wu <hao.a.wu@intel.com>
>---
> DuetPkg/CreateBootDisk.bat |  14 +--
> DuetPkg/CreateBootDisk.sh  | 304 ++++++++++++++++++++++-----------------------
> DuetPkg/PostBuild.bat      |   2 +-
> DuetPkg/PostBuild.sh       |  58 ++++-----
> DuetPkg/ReadMe.txt         |  44 +++----
> 5 files changed, 211 insertions(+), 211 deletions(-)
>
>diff --git a/DuetPkg/CreateBootDisk.bat b/DuetPkg/CreateBootDisk.bat
>index 541de81..214b5b6 100644
>--- a/DuetPkg/CreateBootDisk.bat
>+++ b/DuetPkg/CreateBootDisk.bat
>@@ -56,7 +56,7 @@ goto Help
> @copy %BOOTSECTOR_BIN_DIR%\Bootsect.com FDBs-1.com
> @%BASETOOLS_DIR%\Bootsectimage.exe -g FDBs.com FDBs-1.com -f
> @REM @del FDBS.com
>-@%BASETOOLS_DIR%\Genbootsector.exe -o %EFI_BOOT_DISK% -i FDBs-1.com
>+@%BASETOOLS_DIR%\Genbootsector.exe -o %EFI_BOOT_DISK% -i FDBs-1.com
> @del FDBs-1.com
> @echo Done.
> @copy %BUILD_DIR%\FV\EfiLdr %EFI_BOOT_DISK%
>@@ -70,7 +70,7 @@ goto Help
> @copy %BOOTSECTOR_BIN_DIR%\Bootsect.com FDBs-1.com
> @%BASETOOLS_DIR%\Bootsectimage.exe -g FDBs.com FDBs-1.com -f
> @REM @del FDBS.com
>-@%BASETOOLS_DIR%\Genbootsector.exe -o %EFI_BOOT_DISK% -i FDBs-1.com
>+@%BASETOOLS_DIR%\Genbootsector.exe -o %EFI_BOOT_DISK% -i FDBs-1.com
> @del FDBs-1.com
> @echo Done.
> @goto end
>@@ -89,8 +89,8 @@ goto Help
> @del FormatCommandInput.txt
> @echo Create boot sector ...
> @%BASETOOLS_DIR%\Genbootsector.exe -i %EFI_BOOT_DISK% -o UsbBs16.com
>-@copy %BOOTSECTOR_BIN_DIR%\Bs16.com Bs16-1.com
>-@%BASETOOLS_DIR%\Bootsectimage.exe -g UsbBs16.com Bs16-1.com -f
>+@copy %BOOTSECTOR_BIN_DIR%\Bs16.com Bs16-1.com
>+@%BASETOOLS_DIR%\Bootsectimage.exe -g UsbBs16.com Bs16-1.com -f
> @%BASETOOLS_DIR%\Genbootsector.exe -o %EFI_BOOT_DISK% -i Bs16-1.com
> @del Bs16-1.com
> @%BASETOOLS_DIR%\Genbootsector.exe -m -o %EFI_BOOT_DISK% -i %BOOTSECTOR_BIN_DIR%\Mbr.com
>@@ -110,15 +110,15 @@ goto Help
> @del FormatCommandInput.txt
> @echo Create boot sector ...
> @%BASETOOLS_DIR%\Genbootsector.exe -i %EFI_BOOT_DISK% -o UsbBs32.com
>-@copy %BOOTSECTOR_BIN_DIR%\Bs32.com Bs32-1.com
>-@%BASETOOLS_DIR%\Bootsectimage.exe -g UsbBs32.com Bs32-1.com -f
>+@copy %BOOTSECTOR_BIN_DIR%\Bs32.com Bs32-1.com
>+@%BASETOOLS_DIR%\Bootsectimage.exe -g UsbBs32.com Bs32-1.com -f
> @del UsbBs32.com
> @%BASETOOLS_DIR%\Genbootsector.exe -o %EFI_BOOT_DISK% -i Bs32-1.com
> @del Bs32-1.com
> @%BASETOOLS_DIR%\Genbootsector.exe -m -o %EFI_BOOT_DISK% -i %BOOTSECTOR_BIN_DIR%\Mbr.com
> @echo Done.
> @echo PLEASE UNPLUG USB, THEN PLUG IT AGAIN!
>-@goto end
>+@goto end
>
> :CreateUsb_FAT32_step2
> @copy %BUILD_DIR%\FV\EfiLdr20 %EFI_BOOT_DISK%
>diff --git a/DuetPkg/CreateBootDisk.sh b/DuetPkg/CreateBootDisk.sh
>index f2ff571..fa00408 100755
>--- a/DuetPkg/CreateBootDisk.sh
>+++ b/DuetPkg/CreateBootDisk.sh
>@@ -34,9 +34,9 @@ if [ \
>      "$*" = "--help" \
>    ]
> then
>-	echo "Usage: CreateBootDisk [usb|floppy|ide|file] MediaPath DevicePath [FAT12|FAT16|FAT32] [IA32|X64]
>[GCC44|UNIXGCC]"
>-	echo "e.g. : CreateBootDisk floppy /media/floppy0 /dev/fd0 FAT12 IA32"
>-	PROCESS_MARK=FALSE
>+    echo "Usage: CreateBootDisk [usb|floppy|ide|file] MediaPath DevicePath [FAT12|FAT16|FAT32] [IA32|X64]
>[GCC44|UNIXGCC]"
>+    echo "e.g. : CreateBootDisk floppy /media/floppy0 /dev/fd0 FAT12 IA32"
>+    PROCESS_MARK=FALSE
> fi
>
> case "$5" in
>@@ -66,153 +66,153 @@ export EFI_BOOT_DEVICE=$3
>
> if [ "$PROCESS_MARK" = TRUE ]
> then
>-	case "$1" in
>-		floppy)
>-			if [ "$4" = FAT12 ]
>-			then
>-				echo Start to create floppy boot disk ...
>-				echo Format $EFI_BOOT_MEDIA ...
>-				## Format floppy disk
>-				umount $EFI_BOOT_MEDIA
>-				mkfs.msdos $EFI_BOOT_DEVICE
>-				mount $EFI_BOOT_DEVICE $EFI_BOOT_MEDIA
>-				echo Create boot sector ...
>-				## Linux version of GenBootSector has not pass build yet.
>-				$BASETOOLS_DIR/GnuGenBootSector -i $EFI_BOOT_DEVICE -o FDBs.com
>-				cp $BOOTSECTOR_BIN_DIR/bootsect.com FDBs-1.com
>-				$BASETOOLS_DIR/BootSectImage -g FDBs.com FDBs-1.com -f
>-				$BASETOOLS_DIR/GnuGenBootSector -o $EFI_BOOT_DEVICE -i FDBs-1.com
>-				rm FDBs-1.com
>-				cp $BUILD_DIR/FV/Efildr $EFI_BOOT_MEDIA
>-
>-				mkdir -p $EFI_BOOT_MEDIA/efi
>-				mkdir -p $EFI_BOOT_MEDIA/efi/boot
>-				if [ "$5" = IA32 ]
>-				then
>-					cp $WORKSPACE/ShellBinPkg/UefiShell/Ia32/Shell.efi $EFI_BOOT_MEDIA/efi/boot/boot$5.efi
>-				else
>-					if [ "$5" = X64 ]
>-					then
>-						cp $WORKSPACE/ShellBinPkg/UefiShell/X64/Shell.efi $EFI_BOOT_MEDIA/efi/boot/boot$5.efi
>-					else
>-						echo Wrong Arch!
>-					fi
>-				fi
>-				echo Done.
>-			else
>-				echo "Wrong FAT type $4 for floppy!"
>-			fi
>-			;;
>-
>-		file) # CreateFile
>-			if [ "$4" = FAT12 ]
>-				then
>-				echo "Start to create file boot disk ..."
>-				dd bs=512 count=2880 if=/dev/zero of=$EFI_BOOT_MEDIA
>-				mkfs.msdos -F 12 $EFI_BOOT_MEDIA
>-
>-				mcopy -i $EFI_BOOT_MEDIA $BUILD_DIR/FV/Efildr ::/Efildr
>-				mmd -i $EFI_BOOT_MEDIA ::/efi ::/efi/boot
>-				if [ "$5" = IA32 ]
>-				then
>-					mcopy -i $EFI_BOOT_MEDIA
>$WORKSPACE/ShellBinPkg/UefiShell/Ia32/Shell.efi ::/efi/boot/boot$5.efi
>-				elif [ "$5" = X64 ]
>-				then
>-					mcopy -i $EFI_BOOT_MEDIA
>$WORKSPACE/ShellBinPkg/UefiShell/X64/Shell.efi ::/efi/boot/boot$5.efi
>-				else
>-					echo Wrong Arch!
>-				fi
>-				mdir -i $EFI_BOOT_MEDIA -s ::
>-
>-				## Linux version of GenBootSector has not pass build yet.
>-				$BASETOOLS_DIR/GnuGenBootSector -i $EFI_BOOT_MEDIA -o $EFI_BOOT_MEDIA.bs0
>-				cp $BOOTSECTOR_BIN_DIR/bootsect.com $EFI_BOOT_MEDIA.bs1
>-				$BASETOOLS_DIR/BootSectImage -g $EFI_BOOT_MEDIA.bs0 $EFI_BOOT_MEDIA.bs1
>-				$BASETOOLS_DIR/GnuGenBootSector -o $EFI_BOOT_MEDIA -i $EFI_BOOT_MEDIA.bs1
>-				rm $EFI_BOOT_MEDIA.bs[0-1]
>-				echo Done.
>-			else
>-				echo "Wrong FAT type" $4 "for floppy!"
>-			fi
>-			;;
>-
>-		usb) # CreateUsb
>-
>-			if [ "$4" = FAT16 ]
>-			then
>-				if [ "$6" = step2 ]
>-				then
>-					cp $BUILD_DIR/FV/Efildr16 $EFI_BOOT_MEDIA
>-					mkdir $EFI_BOOT_MEDIA/efi/boot
>-					if [ "$5" = IA32 ]
>-					then
>-						cp $WORKSPACE/ShellBinPkg/UefiShell/Ia32/Shell.efi $EFI_BOOT_MEDIA/efi/boot/boot$5.efi
>-					else
>-						if [ "$5" = X64 ]
>-						then
>-							cp $WORKSPACE/ShellBinPkg/UefiShell/X64/Shell.efi
>$EFI_BOOT_MEDIA/efi/boot/boot$5.efi
>-						else
>-							echo Wrong Arch!
>-						fi
>-					fi
>-					echo "step2 Done!"
>-				else
>-					echo Format $EFI_BOOT_DEVICE ...
>-					#Do format command.
>-					echo Create boot sector ...
>-					## Linux version of GenBootSector & Bootsectimage has not pass build yet.
>-					$BASETOOLS_DIR/GnuGenBootSector -i $EFI_BOOT_DEVICE -o UsbBs16.com
>-					cp $BOOTSECTOR_BIN_DIR/bs16.com Bs16-1.com
>-					$BASETOOLS_DIR/BootSectImage -g UsbBs16.com Bs16-1.com -f
>-					$BASETOOLS_DIR/GnuGenBootSector -o $EFI_BOOT_DEVICE -i Bs16-1.com
>-					rm Bs16-1.com
>-					$BASETOOLS_DIR/GnuGenBootSector -m -o $EFI_BOOT_DEVICE -i
>$BOOTSECTOR_BIN_DIR/Mbr.com
>-					echo Done.
>-					echo PLEASE UNPLUG USB, THEN PLUG IT AGAIN TO DO STEP2!
>-				fi
>-			elif [ "$4" = FAT32 ]
>-			then
>-				if [ "$6" = step2 ]
>-				then
>-					cp $BUILD_DIR/FV/Efildr20 $EFI_BOOT_MEDIA
>-					mkdir $EFI_BOOT_MEDIA/efi/boot
>-					if [ "$5" = IA32 ]
>-					then
>-						cp $WORKSPACE/ShellBinPkg/UefiShell/Ia32/Shell.efi $EFI_BOOT_MEDIA/efi/boot/boot$5.efi
>-					else
>-						if [ "$5" = X64 ]
>-						then
>-							cp $WORKSPACE/ShellBinPkg/UefiShell/X64/Shell.efi
>$EFI_BOOT_MEDIA/efi/boot/boot$5.efi
>-						else
>-							echo Wrong Arch!
>-						fi
>-					fi
>-					echo "step2 Done!"
>-				else
>-					echo Format $EFI_BOOT_DEVICE ...
>-					#Do format command.
>-					echo Create boot sector ...
>-					## Linux version of GenBootSector & Bootsectimage has not pass build yet.
>-					$BASETOOLS_DIR/GnuGenBootSector -i $EFI_BOOT_DEVICE -o UsbBs32.com
>-					cp $BOOTSECTOR_BIN_DIR/bs32.com Bs32-1.com
>-					$BASETOOLS_DIR/BootSectImage -g UsbBs32.com Bs32-1.com -f
>-					$BASETOOLS_DIR/GnuGenBootSector -o $EFI_BOOT_DEVICE -i Bs32-1.com
>-					rm Bs32-1.com
>-					$BASETOOLS_DIR/GnuGenBootSector -m -o $EFI_BOOT_DEVICE -i
>$BOOTSECTOR_BIN_DIR/Mbr.com
>-					echo Done.
>-					echo PLEASE UNPLUG USB, THEN PLUG IT AGAIN TO DO STEP2!
>-				fi
>-			else
>-				echo "Wrong FAT type $1 for floppy!"
>-			fi
>-
>-			;;
>-
>-		ide) # CreateIde
>-		echo "Not support yet!"
>-		;;
>-		*)
>-		echo "Arg1 should be [floppy | file | usb | ide] !"
>-
>-	esac
>+    case "$1" in
>+        floppy)
>+            if [ "$4" = FAT12 ]
>+            then
>+                echo Start to create floppy boot disk ...
>+                echo Format $EFI_BOOT_MEDIA ...
>+                ## Format floppy disk
>+                umount $EFI_BOOT_MEDIA
>+                mkfs.msdos $EFI_BOOT_DEVICE
>+                mount $EFI_BOOT_DEVICE $EFI_BOOT_MEDIA
>+                echo Create boot sector ...
>+                ## Linux version of GenBootSector has not pass build yet.
>+                $BASETOOLS_DIR/GnuGenBootSector -i $EFI_BOOT_DEVICE -o FDBs.com
>+                cp $BOOTSECTOR_BIN_DIR/bootsect.com FDBs-1.com
>+                $BASETOOLS_DIR/BootSectImage -g FDBs.com FDBs-1.com -f
>+                $BASETOOLS_DIR/GnuGenBootSector -o $EFI_BOOT_DEVICE -i FDBs-1.com
>+                rm FDBs-1.com
>+                cp $BUILD_DIR/FV/Efildr $EFI_BOOT_MEDIA
>+
>+                mkdir -p $EFI_BOOT_MEDIA/efi
>+                mkdir -p $EFI_BOOT_MEDIA/efi/boot
>+                if [ "$5" = IA32 ]
>+                then
>+                    cp $WORKSPACE/ShellBinPkg/UefiShell/Ia32/Shell.efi $EFI_BOOT_MEDIA/efi/boot/boot$5.efi
>+                else
>+                    if [ "$5" = X64 ]
>+                    then
>+                        cp $WORKSPACE/ShellBinPkg/UefiShell/X64/Shell.efi $EFI_BOOT_MEDIA/efi/boot/boot$5.efi
>+                    else
>+                        echo Wrong Arch!
>+                    fi
>+                fi
>+                echo Done.
>+            else
>+                echo "Wrong FAT type $4 for floppy!"
>+            fi
>+            ;;
>+
>+        file) # CreateFile
>+            if [ "$4" = FAT12 ]
>+                then
>+                echo "Start to create file boot disk ..."
>+                dd bs=512 count=2880 if=/dev/zero of=$EFI_BOOT_MEDIA
>+                mkfs.msdos -F 12 $EFI_BOOT_MEDIA
>+
>+                mcopy -i $EFI_BOOT_MEDIA $BUILD_DIR/FV/Efildr ::/Efildr
>+                mmd -i $EFI_BOOT_MEDIA ::/efi ::/efi/boot
>+                if [ "$5" = IA32 ]
>+                then
>+                    mcopy -i $EFI_BOOT_MEDIA
>$WORKSPACE/ShellBinPkg/UefiShell/Ia32/Shell.efi ::/efi/boot/boot$5.efi
>+                elif [ "$5" = X64 ]
>+                then
>+                    mcopy -i $EFI_BOOT_MEDIA
>$WORKSPACE/ShellBinPkg/UefiShell/X64/Shell.efi ::/efi/boot/boot$5.efi
>+                else
>+                    echo Wrong Arch!
>+                fi
>+                mdir -i $EFI_BOOT_MEDIA -s ::
>+
>+                ## Linux version of GenBootSector has not pass build yet.
>+                $BASETOOLS_DIR/GnuGenBootSector -i $EFI_BOOT_MEDIA -o $EFI_BOOT_MEDIA.bs0
>+                cp $BOOTSECTOR_BIN_DIR/bootsect.com $EFI_BOOT_MEDIA.bs1
>+                $BASETOOLS_DIR/BootSectImage -g $EFI_BOOT_MEDIA.bs0 $EFI_BOOT_MEDIA.bs1
>+                $BASETOOLS_DIR/GnuGenBootSector -o $EFI_BOOT_MEDIA -i $EFI_BOOT_MEDIA.bs1
>+                rm $EFI_BOOT_MEDIA.bs[0-1]
>+                echo Done.
>+            else
>+                echo "Wrong FAT type" $4 "for floppy!"
>+            fi
>+            ;;
>+
>+        usb) # CreateUsb
>+
>+            if [ "$4" = FAT16 ]
>+            then
>+                if [ "$6" = step2 ]
>+                then
>+                    cp $BUILD_DIR/FV/Efildr16 $EFI_BOOT_MEDIA
>+                    mkdir $EFI_BOOT_MEDIA/efi/boot
>+                    if [ "$5" = IA32 ]
>+                    then
>+                        cp $WORKSPACE/ShellBinPkg/UefiShell/Ia32/Shell.efi $EFI_BOOT_MEDIA/efi/boot/boot$5.efi
>+                    else
>+                        if [ "$5" = X64 ]
>+                        then
>+                            cp $WORKSPACE/ShellBinPkg/UefiShell/X64/Shell.efi
>$EFI_BOOT_MEDIA/efi/boot/boot$5.efi
>+                        else
>+                            echo Wrong Arch!
>+                        fi
>+                    fi
>+                    echo "step2 Done!"
>+                else
>+                    echo Format $EFI_BOOT_DEVICE ...
>+                    #Do format command.
>+                    echo Create boot sector ...
>+                    ## Linux version of GenBootSector & Bootsectimage has not pass build yet.
>+                    $BASETOOLS_DIR/GnuGenBootSector -i $EFI_BOOT_DEVICE -o UsbBs16.com
>+                    cp $BOOTSECTOR_BIN_DIR/bs16.com Bs16-1.com
>+                    $BASETOOLS_DIR/BootSectImage -g UsbBs16.com Bs16-1.com -f
>+                    $BASETOOLS_DIR/GnuGenBootSector -o $EFI_BOOT_DEVICE -i Bs16-1.com
>+                    rm Bs16-1.com
>+                    $BASETOOLS_DIR/GnuGenBootSector -m -o $EFI_BOOT_DEVICE -i
>$BOOTSECTOR_BIN_DIR/Mbr.com
>+                    echo Done.
>+                    echo PLEASE UNPLUG USB, THEN PLUG IT AGAIN TO DO STEP2!
>+                fi
>+            elif [ "$4" = FAT32 ]
>+            then
>+                if [ "$6" = step2 ]
>+                then
>+                    cp $BUILD_DIR/FV/Efildr20 $EFI_BOOT_MEDIA
>+                    mkdir $EFI_BOOT_MEDIA/efi/boot
>+                    if [ "$5" = IA32 ]
>+                    then
>+                        cp $WORKSPACE/ShellBinPkg/UefiShell/Ia32/Shell.efi $EFI_BOOT_MEDIA/efi/boot/boot$5.efi
>+                    else
>+                        if [ "$5" = X64 ]
>+                        then
>+                            cp $WORKSPACE/ShellBinPkg/UefiShell/X64/Shell.efi
>$EFI_BOOT_MEDIA/efi/boot/boot$5.efi
>+                        else
>+                            echo Wrong Arch!
>+                        fi
>+                    fi
>+                    echo "step2 Done!"
>+                else
>+                    echo Format $EFI_BOOT_DEVICE ...
>+                    #Do format command.
>+                    echo Create boot sector ...
>+                    ## Linux version of GenBootSector & Bootsectimage has not pass build yet.
>+                    $BASETOOLS_DIR/GnuGenBootSector -i $EFI_BOOT_DEVICE -o UsbBs32.com
>+                    cp $BOOTSECTOR_BIN_DIR/bs32.com Bs32-1.com
>+                    $BASETOOLS_DIR/BootSectImage -g UsbBs32.com Bs32-1.com -f
>+                    $BASETOOLS_DIR/GnuGenBootSector -o $EFI_BOOT_DEVICE -i Bs32-1.com
>+                    rm Bs32-1.com
>+                    $BASETOOLS_DIR/GnuGenBootSector -m -o $EFI_BOOT_DEVICE -i
>$BOOTSECTOR_BIN_DIR/Mbr.com
>+                    echo Done.
>+                    echo PLEASE UNPLUG USB, THEN PLUG IT AGAIN TO DO STEP2!
>+                fi
>+            else
>+                echo "Wrong FAT type $1 for floppy!"
>+            fi
>+
>+            ;;
>+
>+        ide) # CreateIde
>+        echo "Not support yet!"
>+        ;;
>+        *)
>+        echo "Arg1 should be [floppy | file | usb | ide] !"
>+
>+    esac
> fi
>diff --git a/DuetPkg/PostBuild.bat b/DuetPkg/PostBuild.bat
>index bdcafb8..df34fa7 100644
>--- a/DuetPkg/PostBuild.bat
>+++ b/DuetPkg/PostBuild.bat
>@@ -1,6 +1,6 @@
> @REM ## @file
> @REM #
>-@REM #  Currently, Build system does not provide post build mechanism for module
>+@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 #
>diff --git a/DuetPkg/PostBuild.sh b/DuetPkg/PostBuild.sh
>index f032de3..6f307e1 100755
>--- a/DuetPkg/PostBuild.sh
>+++ b/DuetPkg/PostBuild.sh
>@@ -2,7 +2,7 @@
>
> ## @file
> #
>-#  Currently, Build system does not provide post build mechanism for module
>+#  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.
> #
>@@ -33,8 +33,8 @@ if [ \
>      "$1" = "--help" \
>    ]
> then
>-	echo Error! Please specific the architecture.
>-	echo Usage: "./PostBuild.sh [IA32|X64] [UNIXGCC|GCC44]"
>+    echo Error! Please specific the architecture.
>+    echo Usage: "./PostBuild.sh [IA32|X64] [UNIXGCC|GCC44]"
> fi
>
> case "$1" in
>@@ -75,41 +75,41 @@ echo Compressing DxeMain.efi ...
> $BASETOOLS_DIR/LzmaCompress -e -o $BUILD_DIR/FV/DxeMain.z $BUILD_DIR/$PROCESSOR/DxeCore.efi
>
> echo Compressing DxeIpl.efi ...
>-$BASETOOLS_DIR/LzmaCompress -e -o $BUILD_DIR/FV/DxeIpl.z $BUILD_DIR/$PROCESSOR/DxeIpl.efi
>+$BASETOOLS_DIR/LzmaCompress -e -o $BUILD_DIR/FV/DxeIpl.z $BUILD_DIR/$PROCESSOR/DxeIpl.efi
>
> echo Generate Loader Image ...
>
> if [ $PROCESSOR = IA32 ]
> then
>-        $BASETOOLS_DIR/GenFw --rebase 0x10000 -o $BUILD_DIR/$PROCESSOR/EfiLoader.efi
>$BUILD_DIR/$PROCESSOR/EfiLoader.efi
>-	$BASETOOLS_DIR/EfiLdrImage -o $BUILD_DIR/FV/Efildr32 $BUILD_DIR/$PROCESSOR/EfiLoader.efi
>$BUILD_DIR/FV/DxeIpl.z $BUILD_DIR/FV/DxeMain.z $BUILD_DIR/FV/DUETEFIMAINFV.z
>-	cat $BOOTSECTOR_BIN_DIR/Start.com $BOOTSECTOR_BIN_DIR/efi32.com2 $BUILD_DIR/FV/Efildr32   >
>$BUILD_DIR/FV/Efildr
>-	#
>-	# It is safe to use "bcat" to cat following binary file, if bcat command is avaiable for your system
>-	#
>-	#bcat -o $BUILD_DIR/FV/Efildr.bcat $BOOTSECTOR_BIN_DIR/start.com $BOOTSECTOR_BIN_DIR/efi32.com2
>$BUILD_DIR/FV/Efildr32
>-	cat $BOOTSECTOR_BIN_DIR/Start16.com $BOOTSECTOR_BIN_DIR/efi32.com2 $BUILD_DIR/FV/Efildr32 >
>$BUILD_DIR/FV/Efildr16
>-	#bcat -o $BUILD_DIR/FV/Efildr16.bcat $BOOTSECTOR_BIN_DIR/start16.com $BOOTSECTOR_BIN_DIR/efi32.com2
>$BUILD_DIR/FV/Efildr32
>-	cat $BOOTSECTOR_BIN_DIR/Start32.com $BOOTSECTOR_BIN_DIR/efi32.com2 $BUILD_DIR/FV/Efildr32 >
>$BUILD_DIR/FV/Efildr20
>-	#bcat -o $BUILD_DIR/FV/Efildr20.bcat $BOOTSECTOR_BIN_DIR/start32.com $BOOTSECTOR_BIN_DIR/efi32.com2
>$BUILD_DIR/FV/Efildr32
>-	echo Done!
>+    $BASETOOLS_DIR/GenFw --rebase 0x10000 -o $BUILD_DIR/$PROCESSOR/EfiLoader.efi
>$BUILD_DIR/$PROCESSOR/EfiLoader.efi
>+    $BASETOOLS_DIR/EfiLdrImage -o $BUILD_DIR/FV/Efildr32 $BUILD_DIR/$PROCESSOR/EfiLoader.efi
>$BUILD_DIR/FV/DxeIpl.z $BUILD_DIR/FV/DxeMain.z $BUILD_DIR/FV/DUETEFIMAINFV.z
>+    cat $BOOTSECTOR_BIN_DIR/Start.com $BOOTSECTOR_BIN_DIR/efi32.com2 $BUILD_DIR/FV/Efildr32   >
>$BUILD_DIR/FV/Efildr
>+    #
>+    # It is safe to use "bcat" to cat following binary file, if bcat command is avaiable for your system
>+    #
>+    #bcat -o $BUILD_DIR/FV/Efildr.bcat $BOOTSECTOR_BIN_DIR/start.com $BOOTSECTOR_BIN_DIR/efi32.com2
>$BUILD_DIR/FV/Efildr32
>+    cat $BOOTSECTOR_BIN_DIR/Start16.com $BOOTSECTOR_BIN_DIR/efi32.com2 $BUILD_DIR/FV/Efildr32 >
>$BUILD_DIR/FV/Efildr16
>+    #bcat -o $BUILD_DIR/FV/Efildr16.bcat $BOOTSECTOR_BIN_DIR/start16.com $BOOTSECTOR_BIN_DIR/efi32.com2
>$BUILD_DIR/FV/Efildr32
>+    cat $BOOTSECTOR_BIN_DIR/Start32.com $BOOTSECTOR_BIN_DIR/efi32.com2 $BUILD_DIR/FV/Efildr32 >
>$BUILD_DIR/FV/Efildr20
>+    #bcat -o $BUILD_DIR/FV/Efildr20.bcat $BOOTSECTOR_BIN_DIR/start32.com $BOOTSECTOR_BIN_DIR/efi32.com2
>$BUILD_DIR/FV/Efildr32
>+    echo Done!
> fi
>
> if [ $PROCESSOR = X64 ]
> then
>-         $BASETOOLS_DIR/GenFw --rebase 0x10000 -o $BUILD_DIR/$PROCESSOR/EfiLoader.efi
>$BUILD_DIR/$PROCESSOR/EfiLoader.efi
>-	$BASETOOLS_DIR/EfiLdrImage -o $BUILD_DIR/FV/Efildr64 $BUILD_DIR/$PROCESSOR/EfiLoader.efi
>$BUILD_DIR/FV/DxeIpl.z $BUILD_DIR/FV/DxeMain.z $BUILD_DIR/FV/DUETEFIMAINFV.z
>-	cat $BOOTSECTOR_BIN_DIR/Start64.com $BOOTSECTOR_BIN_DIR/efi64.com2 $BUILD_DIR/FV/Efildr64 >
>$BUILD_DIR/FV/EfildrPure
>-	#bcat -o $BUILD_DIR/FV/EfildrPure $BOOTSECTOR_BIN_DIR/start64.com $BOOTSECTOR_BIN_DIR/efi64.com2
>$BUILD_DIR/FV/Efildr64
>-	$BASETOOLS_DIR/GenPage $BUILD_DIR/FV/EfildrPure -o $BUILD_DIR/FV/Efildr
>-	cat $BOOTSECTOR_BIN_DIR/St16_64.com $BOOTSECTOR_BIN_DIR/efi64.com2 $BUILD_DIR/FV/Efildr64 >
>$BUILD_DIR/FV/Efildr16Pure
>-	#bcat -o $BUILD_DIR/FV/Efildr16Pure $BOOTSECTOR_BIN_DIR/st16_64.com $BOOTSECTOR_BIN_DIR/efi64.com2
>$BUILD_DIR/FV/Efildr64
>-	$BASETOOLS_DIR/GenPage $BUILD_DIR/FV/Efildr16Pure -o $BUILD_DIR/FV/Efildr16
>-	cat $BOOTSECTOR_BIN_DIR/St32_64.com $BOOTSECTOR_BIN_DIR/efi64.com2 $BUILD_DIR/FV/Efildr64 >
>$BUILD_DIR/FV/Efildr20Pure
>-	#bcat -o $BUILD_DIR/FV/Efildr20Pure $BOOTSECTOR_BIN_DIR/st32_64.com $BOOTSECTOR_BIN_DIR/efi64.com2
>$BUILD_DIR/FV/Efildr64
>-	$BASETOOLS_DIR/GenPage $BUILD_DIR/FV/Efildr20Pure -o $BUILD_DIR/FV/Efildr20
>-
>-	echo Done!
>+    $BASETOOLS_DIR/GenFw --rebase 0x10000 -o $BUILD_DIR/$PROCESSOR/EfiLoader.efi
>$BUILD_DIR/$PROCESSOR/EfiLoader.efi
>+    $BASETOOLS_DIR/EfiLdrImage -o $BUILD_DIR/FV/Efildr64 $BUILD_DIR/$PROCESSOR/EfiLoader.efi
>$BUILD_DIR/FV/DxeIpl.z $BUILD_DIR/FV/DxeMain.z $BUILD_DIR/FV/DUETEFIMAINFV.z
>+    cat $BOOTSECTOR_BIN_DIR/Start64.com $BOOTSECTOR_BIN_DIR/efi64.com2 $BUILD_DIR/FV/Efildr64 >
>$BUILD_DIR/FV/EfildrPure
>+    #bcat -o $BUILD_DIR/FV/EfildrPure $BOOTSECTOR_BIN_DIR/start64.com $BOOTSECTOR_BIN_DIR/efi64.com2
>$BUILD_DIR/FV/Efildr64
>+    $BASETOOLS_DIR/GenPage $BUILD_DIR/FV/EfildrPure -o $BUILD_DIR/FV/Efildr
>+    cat $BOOTSECTOR_BIN_DIR/St16_64.com $BOOTSECTOR_BIN_DIR/efi64.com2 $BUILD_DIR/FV/Efildr64 >
>$BUILD_DIR/FV/Efildr16Pure
>+    #bcat -o $BUILD_DIR/FV/Efildr16Pure $BOOTSECTOR_BIN_DIR/st16_64.com $BOOTSECTOR_BIN_DIR/efi64.com2
>$BUILD_DIR/FV/Efildr64
>+    $BASETOOLS_DIR/GenPage $BUILD_DIR/FV/Efildr16Pure -o $BUILD_DIR/FV/Efildr16
>+    cat $BOOTSECTOR_BIN_DIR/St32_64.com $BOOTSECTOR_BIN_DIR/efi64.com2 $BUILD_DIR/FV/Efildr64 >
>$BUILD_DIR/FV/Efildr20Pure
>+    #bcat -o $BUILD_DIR/FV/Efildr20Pure $BOOTSECTOR_BIN_DIR/st32_64.com $BOOTSECTOR_BIN_DIR/efi64.com2
>$BUILD_DIR/FV/Efildr64
>+    $BASETOOLS_DIR/GenPage $BUILD_DIR/FV/Efildr20Pure -o $BUILD_DIR/FV/Efildr20
>+
>+    echo Done!
> fi
>
>
>diff --git a/DuetPkg/ReadMe.txt b/DuetPkg/ReadMe.txt
>index f280679..d7ad3d6 100644
>--- a/DuetPkg/ReadMe.txt
>+++ b/DuetPkg/ReadMe.txt
>@@ -7,32 +7,32 @@ A. Build DUET image on Windows Platform
> To build DUET image, following tools are required:
>
>   1). *Visual Studio 2005*
>-      Assume installed at <VS_PATH>,
>+      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.1 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
>+  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.
>-
>-2.2 Execute post build actions
>+
>+2.2 Execute post build actions
>   1). enter <Workspace>\DuetPkg directory.
>-  2). run "PostBuild.bat IA32" for IA32 architecture platform or
>+  2). run "PostBuild.bat IA32" for IA32 architecture platform or
>           "PostBuild.bat X64" for X64 architecture platform.
>
> Create bootable disk
> ======================
>-
>+
> 3. Create boot disk
>   The following steps are same for IA32 architecture platform or X64 architecture platform.
>-
>+
> 3.1 Create floppy boot disk
>   1). enter <Workspace>\DuetPkg directory.
>   2). Insert a floppy disk to drive
>@@ -51,9 +51,9 @@ Create bootable disk
>       or "CreateBootDisk.bat usb e: FAT16 X64 step2" if usb drive is e: and FAT format is FAT16 and Arch to boot is X64.
>       or "CreateBootDisk.bat usb e: FAT32 IA32 step2" if usb drive is e: and FAT format is FAT32 and Arch to boot is IA32.
>       or "CreateBootDisk.bat usb e: FAT32 X64 step2" if usb drive is e: and FAT format is FAT32 and Arch to boot is X64.
>-
>+
> B. Build DUET image on Linux Platform
>-======================================
>+======================================
> 1. Tools preparation
>
>   To build DUET image, GCC44 is required:
>@@ -62,28 +62,28 @@ B. Build DUET image on Linux Platform
>
> 2. Build steps
>
>-2.1 Build Duet Platform module
>+2.1 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
>+  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
>+
>+2.2 Execute post build actions
>   1). enter /edk2_tree/DuetPkg directory.
>-  2). run "./PostBuild.sh IA32 GCC44" for IA32 architecture platform or
>+  2). run "./PostBuild.sh IA32 GCC44" for IA32 architecture platform or
>           "./PostBuild.sh X64 GCC44" 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.
>-
>+
> 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"
>\ No newline at end of file
>+      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"
>--
>1.9.5.msysgit.0



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 3/3] DuetPkg: Add POSTBUILD in DSC files to run post-build automatically
  2016-11-11  8:26 ` [PATCH 3/3] DuetPkg: Add POSTBUILD in DSC files to run post-build automatically Hao Wu
@ 2016-11-11  8:32   ` Ni, Ruiyu
  0 siblings, 0 replies; 7+ messages in thread
From: Ni, Ruiyu @ 2016-11-11  8:32 UTC (permalink / raw)
  To: Wu, Hao A, edk2-devel@lists.01.org

Hao,
Thanks for making this helpful updates.

Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>

>-----Original Message-----
>From: Wu, Hao A
>Sent: Friday, November 11, 2016 4:27 PM
>To: edk2-devel@lists.01.org
>Cc: Wu, Hao A <hao.a.wu@intel.com>; Ni, Ruiyu <ruiyu.ni@intel.com>
>Subject: [PATCH 3/3] 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>
>---
> 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.<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 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.<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 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.<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 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.<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 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 <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 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



^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2016-11-11  8:32 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-11-11  8:26 [PATCH 0/3] Enable POSTBUILD feature in DuetPkg DSC files Hao Wu
2016-11-11  8:26 ` [PATCH 1/3] DuetPkg: Resolve white-space issues for post-build scripts & ReadMe Hao Wu
2016-11-11  8:32   ` Ni, Ruiyu
2016-11-11  8:26 ` [PATCH 2/3] DuetPkg: Use 'echo off' in BATCH script files Hao Wu
2016-11-11  8:32   ` Ni, Ruiyu
2016-11-11  8:26 ` [PATCH 3/3] DuetPkg: Add POSTBUILD in DSC files to run post-build automatically Hao Wu
2016-11-11  8:32   ` Ni, Ruiyu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox