blob: 9d936e661f2e794733feb4f2d7738cb97cab24fe [file] [log] [blame]
klu271bd6db2009-03-02 12:12:46 +00001#!/bin/sh
klu2ab9cb4b2010-03-18 02:36:52 +00002
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#
hhtianb1f700a2010-04-28 12:39:50 +00009# Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>
klu2ab9cb4b2010-03-18 02:36:52 +000010#
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##
klu271bd6db2009-03-02 12:12:46 +000019
klu2e4c00742010-03-10 01:23:13 +000020
klu2fe9591c2009-03-16 04:59:21 +000021
klu2df6434f2009-09-17 02:16:30 +000022export BASETOOLS_DIR=$WORKSPACE/Conf/BaseToolsSource/Source/C/bin
klu2e88f3052009-06-22 03:01:53 +000023export BOOTSECTOR_BIN_DIR=$WORKSPACE/DuetPkg/BootSector/bin
gikidyf89afdd2009-03-02 08:37:23 +000024export PROCESSOR=""
25if [ \
26 -z "$1" -o \
27 "$1" = "-?" -o \
28 "$1" = "-h" -o \
29 "$1" = "--help" \
30 ]
31then
32 echo Error! Please specific the architecture.
klu263c89e02010-06-10 08:54:18 +000033 echo Usage: "./PostBuild.sh [IA32|X64] [UNIXGCC|GCC44]"
gikidyf89afdd2009-03-02 08:37:23 +000034fi
35
klu271bd6db2009-03-02 12:12:46 +000036case "$1" in
37 IA32)
38 export PROCESSOR=IA32
39 ;;
40 X64)
41 export PROCESSOR=X64
42 ;;
43 *)
44 echo Invalid Architecture string, should be only IA32 or X64
klu2f8b30ae2009-04-16 02:36:20 +000045 return 1
klu271bd6db2009-03-02 12:12:46 +000046esac
gikidyf89afdd2009-03-02 08:37:23 +000047
klu263c89e02010-06-10 08:54:18 +000048case "$2" in
49 UNIXGCC)
50 export TOOLTAG=UNIXGCC
51 ;;
52 GCC44)
53 export TOOLTAG=GCC44
54 ;;
55 *)
56 echo Invalid tool tag, should be only UNIXGCC or GCC44
57 return 1
58esac
59
60export BUILD_DIR=$WORKSPACE/Build/DuetPkg$PROCESSOR/DEBUG_$TOOLTAG
klu2ab9cb4b2010-03-18 02:36:52 +000061
62
klu271bd6db2009-03-02 12:12:46 +000063#
64# Boot sector module could only be built under IA32 tool chain
65#
gikidyf89afdd2009-03-02 08:37:23 +000066
67echo Compressing DUETEFIMainFv.FV ...
gikidy11d909a2009-05-06 09:03:11 +000068$BASETOOLS_DIR/LzmaCompress -e -o $BUILD_DIR/FV/DUETEFIMAINFV.z $BUILD_DIR/FV/DUETEFIMAINFV.Fv
gikidyf89afdd2009-03-02 08:37:23 +000069
70echo Compressing DxeMain.efi ...
gikidy11d909a2009-05-06 09:03:11 +000071$BASETOOLS_DIR/LzmaCompress -e -o $BUILD_DIR/FV/DxeMain.z $BUILD_DIR/$PROCESSOR/DxeCore.efi
gikidyf89afdd2009-03-02 08:37:23 +000072
73echo Compressing DxeIpl.efi ...
gikidy11d909a2009-05-06 09:03:11 +000074$BASETOOLS_DIR/LzmaCompress -e -o $BUILD_DIR/FV/DxeIpl.z $BUILD_DIR/$PROCESSOR/DxeIpl.efi
gikidyf89afdd2009-03-02 08:37:23 +000075
76echo Generate Loader Image ...
77
78if [ $PROCESSOR = IA32 ]
79then
klu263c89e02010-06-10 08:54:18 +000080 $BASETOOLS_DIR/GenFw --rebase 0x10000 -o $BUILD_DIR/$PROCESSOR/EfiLoader.efi $BUILD_DIR/$PROCESSOR/EfiLoader.efi
gikidyf89afdd2009-03-02 08:37:23 +000081 $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
klu263c89e02010-06-10 08:54:18 +000082 cat $BOOTSECTOR_BIN_DIR/Start.com $BOOTSECTOR_BIN_DIR/efi32.com2 $BUILD_DIR/FV/Efildr32 > $BUILD_DIR/FV/Efildr
klu2fe9591c2009-03-16 04:59:21 +000083 #
84 # It is safe to use "bcat" to cat following binary file, if bcat command is avaiable for your system
85 #
klu2df6434f2009-09-17 02:16:30 +000086 #bcat -o $BUILD_DIR/FV/Efildr.bcat $BOOTSECTOR_BIN_DIR/start.com $BOOTSECTOR_BIN_DIR/efi32.com2 $BUILD_DIR/FV/Efildr32
klu263c89e02010-06-10 08:54:18 +000087 cat $BOOTSECTOR_BIN_DIR/Start16.com $BOOTSECTOR_BIN_DIR/efi32.com2 $BUILD_DIR/FV/Efildr32 > $BUILD_DIR/FV/Efildr16
klu2df6434f2009-09-17 02:16:30 +000088 #bcat -o $BUILD_DIR/FV/Efildr16.bcat $BOOTSECTOR_BIN_DIR/start16.com $BOOTSECTOR_BIN_DIR/efi32.com2 $BUILD_DIR/FV/Efildr32
klu263c89e02010-06-10 08:54:18 +000089 cat $BOOTSECTOR_BIN_DIR/Start32.com $BOOTSECTOR_BIN_DIR/efi32.com2 $BUILD_DIR/FV/Efildr32 > $BUILD_DIR/FV/Efildr20
klu2df6434f2009-09-17 02:16:30 +000090 #bcat -o $BUILD_DIR/FV/Efildr20.bcat $BOOTSECTOR_BIN_DIR/start32.com $BOOTSECTOR_BIN_DIR/efi32.com2 $BUILD_DIR/FV/Efildr32
gikidyf89afdd2009-03-02 08:37:23 +000091 echo Done!
92fi
93
94if [ $PROCESSOR = X64 ]
95then
klu263c89e02010-06-10 08:54:18 +000096 $BASETOOLS_DIR/GenFw --rebase 0x10000 -o $BUILD_DIR/$PROCESSOR/EfiLoader.efi $BUILD_DIR/$PROCESSOR/EfiLoader.efi
gikidyf89afdd2009-03-02 08:37:23 +000097 $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
klu29e8c32c2009-07-08 07:25:02 +000098 cat $BOOTSECTOR_BIN_DIR/Start64.com $BOOTSECTOR_BIN_DIR/efi64.com2 $BUILD_DIR/FV/Efildr64 > $BUILD_DIR/FV/EfildrPure
klu2df6434f2009-09-17 02:16:30 +000099 #bcat -o $BUILD_DIR/FV/EfildrPure $BOOTSECTOR_BIN_DIR/start64.com $BOOTSECTOR_BIN_DIR/efi64.com2 $BUILD_DIR/FV/Efildr64
gikidyf89afdd2009-03-02 08:37:23 +0000100 $BASETOOLS_DIR/GenPage $BUILD_DIR/FV/EfildrPure -o $BUILD_DIR/FV/Efildr
klu29e8c32c2009-07-08 07:25:02 +0000101 cat $BOOTSECTOR_BIN_DIR/St16_64.com $BOOTSECTOR_BIN_DIR/efi64.com2 $BUILD_DIR/FV/Efildr64 > $BUILD_DIR/FV/Efildr16Pure
klu2e88f3052009-06-22 03:01:53 +0000102 #bcat -o $BUILD_DIR/FV/Efildr16Pure $BOOTSECTOR_BIN_DIR/st16_64.com $BOOTSECTOR_BIN_DIR/efi64.com2 $BUILD_DIR/FV/Efildr64
gikidyf89afdd2009-03-02 08:37:23 +0000103 $BASETOOLS_DIR/GenPage $BUILD_DIR/FV/Efildr16Pure -o $BUILD_DIR/FV/Efildr16
klu29e8c32c2009-07-08 07:25:02 +0000104 cat $BOOTSECTOR_BIN_DIR/St32_64.com $BOOTSECTOR_BIN_DIR/efi64.com2 $BUILD_DIR/FV/Efildr64 > $BUILD_DIR/FV/Efildr20Pure
klu2e88f3052009-06-22 03:01:53 +0000105 #bcat -o $BUILD_DIR/FV/Efildr20Pure $BOOTSECTOR_BIN_DIR/st32_64.com $BOOTSECTOR_BIN_DIR/efi64.com2 $BUILD_DIR/FV/Efildr64
gikidyf89afdd2009-03-02 08:37:23 +0000106 $BASETOOLS_DIR/GenPage $BUILD_DIR/FV/Efildr20Pure -o $BUILD_DIR/FV/Efildr20
107
108 echo Done!
109fi
110
klu2f8b30ae2009-04-16 02:36:20 +0000111