]> git.proxmox.com Git - mirror_edk2.git/blame - DuetPkg/build64.sh
DuetPkg: Add POSTBUILD in DSC files to run post-build automatically
[mirror_edk2.git] / DuetPkg / build64.sh
CommitLineData
65e9e352 1#!/bin/bash
2#
3# Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>
912065fe 4# Copyright (c) 2010 - 2016, Intel Corporation. All rights reserved.<BR>
65e9e352 5#
6# This program and the accompanying materials
7# are licensed and made available under the terms and conditions of the BSD License
8# which accompanies this distribution. The full text of the license may be found at
9# http://opensource.org/licenses/bsd-license.php
10#
11# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
13#
14
15set -e
16shopt -s nocasematch
17
18
19#
20# Setup workspace if it is not set
21#
22if [ -z "$WORKSPACE" ]
23then
24 echo Initializing workspace
25 if [ ! -e `pwd`/edksetup.sh ]
26 then
27 cd ..
28 fi
29# This version is for the tools in the BaseTools project.
30# this assumes svn pulls have the same root dir
31# export EDK_TOOLS_PATH=`pwd`/../BaseTools
32# This version is for the tools source in edk2
33 export EDK_TOOLS_PATH=`pwd`/BaseTools
34 echo $EDK_TOOLS_PATH
35 source edksetup.sh BaseTools
36else
37 echo Building from: $WORKSPACE
38fi
39
40PROCESSOR=X64
41
42#
43# Pick a default tool type for a given OS
44#
45TARGET_TOOLS=MYTOOLS
46case `uname` in
47 CYGWIN*) echo Cygwin not fully supported yet. ;;
48 Darwin*)
49 Major=$(uname -r | cut -f 1 -d '.')
50 if [[ $Major == 9 ]]
51 then
52 echo DuetPkg requires Snow Leopard or later OS
53 exit 1
54 else
55 TARGET_TOOLS=XCODE32
56 fi
57 ;;
58 Linux*)
912065fe
JJ
59 gcc_version=$(gcc -v 2>&1 | tail -1 | awk '{print $3}')
60 case $gcc_version in
61 4.5.*)
62 TARGET_TOOLS=GCC45
63 ;;
64 4.6.*)
65 TARGET_TOOLS=GCC46
66 ;;
67 4.7.*)
68 TARGET_TOOLS=GCC47
69 ;;
70 4.8.*)
71 TARGET_TOOLS=GCC48
72 ;;
73 4.9.*|4.1[0-9].*|5.*.*)
74 TARGET_TOOLS=GCC49
75 ;;
76 *)
77 TARGET_TOOLS=GCC44
78 ;;
79 esac
65e9e352 80 ;;
81
82esac
83
84BUILD_ROOT_ARCH=$WORKSPACE/Build/DuetPkg$PROCESSOR/DEBUG_"$TARGET_TOOLS"/$PROCESSOR
85FLOPPY_IMAGE=$WORKSPACE/Build/DuetPkg$PROCESSOR/floppy.img
86
87if [[ ! -f `which build` || ! -f `which GenFv` ]];
88then
89 # build the tools if they don't yet exist. Bin scheme
90 echo Building tools as they are not in the path
91 make -C $WORKSPACE/BaseTools
92elif [[ ( -f `which build` || -f `which GenFv` ) && ! -d $EDK_TOOLS_PATH/Source/C/bin ]];
93then
94 # build the tools if they don't yet exist. BinWrapper scheme
95 echo Building tools no $EDK_TOOLS_PATH/Source/C/bin directory
96 make -C $WORKSPACE/BaseTools
97else
98 echo using prebuilt tools
99fi
100
101
102for arg in "$@"
103do
104 if [[ $arg == qemu ]]; then
105 shift
106 qemu-system-x86_64 -fda $FLOPPY_IMAGE -boot a $*
107 exit
108 fi
109
110 if [[ $arg == cleanall ]]; then
111 make -C $WORKSPACE/BaseTools clean
112 build -p $WORKSPACE/DuetPkg/DuetPkg$PROCESSOR.dsc -a $PROCESSOR -t $TARGET_TOOLS -n 3 clean
113 exit $?
114 fi
115
116 if [[ $arg == clean ]]; then
117 build -p $WORKSPACE/DuetPkg/DuetPkg$PROCESSOR.dsc -a $PROCESSOR -t $TARGET_TOOLS -n 3 clean
118 exit $?
119 fi
120done
121
122
123#
124# Build the edk2 DuetPkg
125#
126echo Running edk2 build for DuetPkg$PROCESSOR
127build -p $WORKSPACE/DuetPkg/DuetPkg$PROCESSOR.dsc -a $PROCESSOR -t $TARGET_TOOLS -n 3 $*
65e9e352 128echo Running DuetPkg/CreateBootDisk.sh
129
bab82372 130$WORKSPACE/DuetPkg/CreateBootDisk.sh file $FLOPPY_IMAGE /dev/null FAT12 $PROCESSOR
65e9e352 131exit $?
132