DuetPkg scripts: Support building with GCC45 - GCC49
[mirror_edk2.git] / DuetPkg / PostBuild.sh
CommitLineData
71bd6db1 1#!/bin/sh
ab9cb4b1 2
3## @file
4#
5# Currently, Build system does not provide post build mechanism for module
6# and platform building, so just use a sh file to do post build commands.
7# Originally, following post building command is for EfiLoader module.
8#
912065fe 9# Copyright (c) 2010 - 2016, Intel Corporation. All rights reserved.<BR>
ab9cb4b1 10#
11# This program and the accompanying materials
12# are licensed and made available under the terms and conditions of the BSD License
13# which accompanies this distribution. The full text of the license may be found at
14# http://opensource.org/licenses/bsd-license.php
15# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
16# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
17#
18##
e4c0074b 19
9046a2f9 20if [ -z "$EDK_TOOLS_PATH" ]
21then
df6434f2 22export BASETOOLS_DIR=$WORKSPACE/Conf/BaseToolsSource/Source/C/bin
9046a2f9 23else
24export BASETOOLS_DIR=$EDK_TOOLS_PATH/Source/C/bin
25fi
26
e88f3056 27export BOOTSECTOR_BIN_DIR=$WORKSPACE/DuetPkg/BootSector/bin
f89afddb 28export PROCESSOR=""
29if [ \
30 -z "$1" -o \
31 "$1" = "-?" -o \
32 "$1" = "-h" -o \
33 "$1" = "--help" \
34 ]
35then
36 echo Error! Please specific the architecture.
63c89e04 37 echo Usage: "./PostBuild.sh [IA32|X64] [UNIXGCC|GCC44]"
f89afddb 38fi
39
71bd6db1 40case "$1" in
41 IA32)
42 export PROCESSOR=IA32
43 ;;
44 X64)
45 export PROCESSOR=X64
46 ;;
47 *)
48 echo Invalid Architecture string, should be only IA32 or X64
f8b30ae5 49 return 1
71bd6db1 50esac
f89afddb 51
63c89e04 52case "$2" in
53 UNIXGCC)
54 export TOOLTAG=UNIXGCC
55 ;;
912065fe
JJ
56 GCC4*)
57 export TOOLTAG=$2
63c89e04 58 ;;
59 *)
912065fe 60 echo Invalid tool tag, should be only UNIXGCC or GCC4\*
63c89e04 61 return 1
62esac
63
64export BUILD_DIR=$WORKSPACE/Build/DuetPkg$PROCESSOR/DEBUG_$TOOLTAG
ab9cb4b1 65
66
71bd6db1 67#
68# Boot sector module could only be built under IA32 tool chain
69#
f89afddb 70
71echo Compressing DUETEFIMainFv.FV ...
11d909a4 72$BASETOOLS_DIR/LzmaCompress -e -o $BUILD_DIR/FV/DUETEFIMAINFV.z $BUILD_DIR/FV/DUETEFIMAINFV.Fv
f89afddb 73
74echo Compressing DxeMain.efi ...
11d909a4 75$BASETOOLS_DIR/LzmaCompress -e -o $BUILD_DIR/FV/DxeMain.z $BUILD_DIR/$PROCESSOR/DxeCore.efi
f89afddb 76
77echo Compressing DxeIpl.efi ...
11d909a4 78$BASETOOLS_DIR/LzmaCompress -e -o $BUILD_DIR/FV/DxeIpl.z $BUILD_DIR/$PROCESSOR/DxeIpl.efi
f89afddb 79
80echo Generate Loader Image ...
81
82if [ $PROCESSOR = IA32 ]
83then
63c89e04 84 $BASETOOLS_DIR/GenFw --rebase 0x10000 -o $BUILD_DIR/$PROCESSOR/EfiLoader.efi $BUILD_DIR/$PROCESSOR/EfiLoader.efi
f89afddb 85 $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
63c89e04 86 cat $BOOTSECTOR_BIN_DIR/Start.com $BOOTSECTOR_BIN_DIR/efi32.com2 $BUILD_DIR/FV/Efildr32 > $BUILD_DIR/FV/Efildr
fe9591c5 87 #
88 # It is safe to use "bcat" to cat following binary file, if bcat command is avaiable for your system
89 #
df6434f2 90 #bcat -o $BUILD_DIR/FV/Efildr.bcat $BOOTSECTOR_BIN_DIR/start.com $BOOTSECTOR_BIN_DIR/efi32.com2 $BUILD_DIR/FV/Efildr32
63c89e04 91 cat $BOOTSECTOR_BIN_DIR/Start16.com $BOOTSECTOR_BIN_DIR/efi32.com2 $BUILD_DIR/FV/Efildr32 > $BUILD_DIR/FV/Efildr16
df6434f2 92 #bcat -o $BUILD_DIR/FV/Efildr16.bcat $BOOTSECTOR_BIN_DIR/start16.com $BOOTSECTOR_BIN_DIR/efi32.com2 $BUILD_DIR/FV/Efildr32
63c89e04 93 cat $BOOTSECTOR_BIN_DIR/Start32.com $BOOTSECTOR_BIN_DIR/efi32.com2 $BUILD_DIR/FV/Efildr32 > $BUILD_DIR/FV/Efildr20
df6434f2 94 #bcat -o $BUILD_DIR/FV/Efildr20.bcat $BOOTSECTOR_BIN_DIR/start32.com $BOOTSECTOR_BIN_DIR/efi32.com2 $BUILD_DIR/FV/Efildr32
f89afddb 95 echo Done!
96fi
97
98if [ $PROCESSOR = X64 ]
99then
63c89e04 100 $BASETOOLS_DIR/GenFw --rebase 0x10000 -o $BUILD_DIR/$PROCESSOR/EfiLoader.efi $BUILD_DIR/$PROCESSOR/EfiLoader.efi
f89afddb 101 $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
9e8c32c6 102 cat $BOOTSECTOR_BIN_DIR/Start64.com $BOOTSECTOR_BIN_DIR/efi64.com2 $BUILD_DIR/FV/Efildr64 > $BUILD_DIR/FV/EfildrPure
df6434f2 103 #bcat -o $BUILD_DIR/FV/EfildrPure $BOOTSECTOR_BIN_DIR/start64.com $BOOTSECTOR_BIN_DIR/efi64.com2 $BUILD_DIR/FV/Efildr64
f89afddb 104 $BASETOOLS_DIR/GenPage $BUILD_DIR/FV/EfildrPure -o $BUILD_DIR/FV/Efildr
9e8c32c6 105 cat $BOOTSECTOR_BIN_DIR/St16_64.com $BOOTSECTOR_BIN_DIR/efi64.com2 $BUILD_DIR/FV/Efildr64 > $BUILD_DIR/FV/Efildr16Pure
e88f3056 106 #bcat -o $BUILD_DIR/FV/Efildr16Pure $BOOTSECTOR_BIN_DIR/st16_64.com $BOOTSECTOR_BIN_DIR/efi64.com2 $BUILD_DIR/FV/Efildr64
f89afddb 107 $BASETOOLS_DIR/GenPage $BUILD_DIR/FV/Efildr16Pure -o $BUILD_DIR/FV/Efildr16
9e8c32c6 108 cat $BOOTSECTOR_BIN_DIR/St32_64.com $BOOTSECTOR_BIN_DIR/efi64.com2 $BUILD_DIR/FV/Efildr64 > $BUILD_DIR/FV/Efildr20Pure
e88f3056 109 #bcat -o $BUILD_DIR/FV/Efildr20Pure $BOOTSECTOR_BIN_DIR/st32_64.com $BOOTSECTOR_BIN_DIR/efi64.com2 $BUILD_DIR/FV/Efildr64
f89afddb 110 $BASETOOLS_DIR/GenPage $BUILD_DIR/FV/Efildr20Pure -o $BUILD_DIR/FV/Efildr20
111
112 echo Done!
113fi
114
f8b30ae5 115