BaseTools/BinToPcd: Fix Python 2.7.x compatibility issue
[mirror_edk2.git] / DuetPkg / PostBuild.sh
CommitLineData
71bd6db1 1#!/bin/sh
ab9cb4b1 2
3## @file
4#
bab82372 5# Post build script that will be automatically run after build.
ab9cb4b1 6#
912065fe 7# Copyright (c) 2010 - 2016, Intel Corporation. All rights reserved.<BR>
ab9cb4b1 8#
9# This program and the accompanying materials
10# are licensed and made available under the terms and conditions of the BSD License
11# which accompanies this distribution. The full text of the license may be found at
12# http://opensource.org/licenses/bsd-license.php
13# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
14# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
15#
16##
e4c0074b 17
9046a2f9 18if [ -z "$EDK_TOOLS_PATH" ]
19then
df6434f2 20export BASETOOLS_DIR=$WORKSPACE/Conf/BaseToolsSource/Source/C/bin
9046a2f9 21else
22export BASETOOLS_DIR=$EDK_TOOLS_PATH/Source/C/bin
23fi
24
e88f3056 25export BOOTSECTOR_BIN_DIR=$WORKSPACE/DuetPkg/BootSector/bin
f89afddb 26export PROCESSOR=""
bab82372 27export TOOLTAG=""
f89afddb 28
bab82372
HW
29while [ $# -gt 0 ]; do
30 if [ "$1" = "-a" ]; then
31 export PROCESSOR=$2
32 elif [ "$1" = "-t" ]; then
33 export TOOLTAG=$2
34 elif [ "$1" = "-h" ]; then
35 echo Usage: This script will be run automatically after build.
36 return 1
37 fi
38 shift
39 shift
40done
f89afddb 41
bab82372
HW
42if [ "$PROCESSOR" = "" -o "$TOOLTAG" = "" ]; then
43 echo Usage: This script will be run automatically after build.
44 return 1
45fi
63c89e04 46
47export BUILD_DIR=$WORKSPACE/Build/DuetPkg$PROCESSOR/DEBUG_$TOOLTAG
ab9cb4b1 48
bab82372
HW
49#
50# Store environment variables used by CreateBootDisk.sh
51#
52echo export TOOLCHAIN=$TOOLTAG> $WORKSPACE/DuetPkg/SetEnv_$PROCESSOR.sh
53chmod +x $WORKSPACE/DuetPkg/SetEnv_$PROCESSOR.sh
ab9cb4b1 54
71bd6db1 55#
56# Boot sector module could only be built under IA32 tool chain
57#
f89afddb 58
59echo Compressing DUETEFIMainFv.FV ...
11d909a4 60$BASETOOLS_DIR/LzmaCompress -e -o $BUILD_DIR/FV/DUETEFIMAINFV.z $BUILD_DIR/FV/DUETEFIMAINFV.Fv
f89afddb 61
62echo Compressing DxeMain.efi ...
11d909a4 63$BASETOOLS_DIR/LzmaCompress -e -o $BUILD_DIR/FV/DxeMain.z $BUILD_DIR/$PROCESSOR/DxeCore.efi
f89afddb 64
65echo Compressing DxeIpl.efi ...
24476311 66$BASETOOLS_DIR/LzmaCompress -e -o $BUILD_DIR/FV/DxeIpl.z $BUILD_DIR/$PROCESSOR/DxeIpl.efi
f89afddb 67
68echo Generate Loader Image ...
69
70if [ $PROCESSOR = IA32 ]
71then
24476311
HW
72 $BASETOOLS_DIR/GenFw --rebase 0x10000 -o $BUILD_DIR/$PROCESSOR/EfiLoader.efi $BUILD_DIR/$PROCESSOR/EfiLoader.efi
73 $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
74 cat $BOOTSECTOR_BIN_DIR/Start.com $BOOTSECTOR_BIN_DIR/efi32.com2 $BUILD_DIR/FV/Efildr32 > $BUILD_DIR/FV/Efildr
75 #
76 # It is safe to use "bcat" to cat following binary file, if bcat command is avaiable for your system
77 #
78 #bcat -o $BUILD_DIR/FV/Efildr.bcat $BOOTSECTOR_BIN_DIR/start.com $BOOTSECTOR_BIN_DIR/efi32.com2 $BUILD_DIR/FV/Efildr32
79 cat $BOOTSECTOR_BIN_DIR/Start16.com $BOOTSECTOR_BIN_DIR/efi32.com2 $BUILD_DIR/FV/Efildr32 > $BUILD_DIR/FV/Efildr16
80 #bcat -o $BUILD_DIR/FV/Efildr16.bcat $BOOTSECTOR_BIN_DIR/start16.com $BOOTSECTOR_BIN_DIR/efi32.com2 $BUILD_DIR/FV/Efildr32
81 cat $BOOTSECTOR_BIN_DIR/Start32.com $BOOTSECTOR_BIN_DIR/efi32.com2 $BUILD_DIR/FV/Efildr32 > $BUILD_DIR/FV/Efildr20
82 #bcat -o $BUILD_DIR/FV/Efildr20.bcat $BOOTSECTOR_BIN_DIR/start32.com $BOOTSECTOR_BIN_DIR/efi32.com2 $BUILD_DIR/FV/Efildr32
83 echo Done!
f89afddb 84fi
85
86if [ $PROCESSOR = X64 ]
87then
24476311
HW
88 $BASETOOLS_DIR/GenFw --rebase 0x10000 -o $BUILD_DIR/$PROCESSOR/EfiLoader.efi $BUILD_DIR/$PROCESSOR/EfiLoader.efi
89 $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
90 cat $BOOTSECTOR_BIN_DIR/Start64.com $BOOTSECTOR_BIN_DIR/efi64.com2 $BUILD_DIR/FV/Efildr64 > $BUILD_DIR/FV/EfildrPure
91 #bcat -o $BUILD_DIR/FV/EfildrPure $BOOTSECTOR_BIN_DIR/start64.com $BOOTSECTOR_BIN_DIR/efi64.com2 $BUILD_DIR/FV/Efildr64
92 $BASETOOLS_DIR/GenPage $BUILD_DIR/FV/EfildrPure -o $BUILD_DIR/FV/Efildr
93 cat $BOOTSECTOR_BIN_DIR/St16_64.com $BOOTSECTOR_BIN_DIR/efi64.com2 $BUILD_DIR/FV/Efildr64 > $BUILD_DIR/FV/Efildr16Pure
94 #bcat -o $BUILD_DIR/FV/Efildr16Pure $BOOTSECTOR_BIN_DIR/st16_64.com $BOOTSECTOR_BIN_DIR/efi64.com2 $BUILD_DIR/FV/Efildr64
95 $BASETOOLS_DIR/GenPage $BUILD_DIR/FV/Efildr16Pure -o $BUILD_DIR/FV/Efildr16
96 cat $BOOTSECTOR_BIN_DIR/St32_64.com $BOOTSECTOR_BIN_DIR/efi64.com2 $BUILD_DIR/FV/Efildr64 > $BUILD_DIR/FV/Efildr20Pure
97 #bcat -o $BUILD_DIR/FV/Efildr20Pure $BOOTSECTOR_BIN_DIR/st32_64.com $BOOTSECTOR_BIN_DIR/efi64.com2 $BUILD_DIR/FV/Efildr64
98 $BASETOOLS_DIR/GenPage $BUILD_DIR/FV/Efildr20Pure -o $BUILD_DIR/FV/Efildr20
99
100 echo Done!
f89afddb 101fi
102
f8b30ae5 103