bbahnsen | b9e16a8 | 2006-04-24 16:38:10 +0000 | [diff] [blame] | 1 | # |
Yonghong Zhu | 445bfd9 | 2016-09-14 13:27:06 +0800 | [diff] [blame] | 2 | # Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.<BR> |
Leif Lindholm | 44f7942 | 2016-10-20 15:47:31 +0100 | [diff] [blame] | 3 | # Copyright (c) 2016, Linaro Ltd. All rights reserved.<BR> |
hhtian | 24542fb | 2010-04-29 15:17:20 +0000 | [diff] [blame] | 4 | # This program and the accompanying materials |
bbahnsen | b9e16a8 | 2006-04-24 16:38:10 +0000 | [diff] [blame] | 5 | # are licensed and made available under the terms and conditions of the BSD License |
| 6 | # which accompanies this distribution. The full text of the license may be found at |
| 7 | # http://opensource.org/licenses/bsd-license.php |
| 8 | # |
| 9 | # THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, |
| 10 | # WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. |
klu2 | 2b1473c | 2009-07-08 05:54:53 +0000 | [diff] [blame] | 11 | # |
| 12 | # In *inux environment, the build tools's source is required and need to be compiled |
Yonghong Zhu | 445bfd9 | 2016-09-14 13:27:06 +0800 | [diff] [blame] | 13 | # firstly, please reference https://github.com/tianocore/tianocore.github.io/wiki/SourceForge-to-Github-Quick-Start |
klu2 | 2b1473c | 2009-07-08 05:54:53 +0000 | [diff] [blame] | 14 | # to get how to setup build tool. |
| 15 | # |
bbahnsen | b9e16a8 | 2006-04-24 16:38:10 +0000 | [diff] [blame] | 16 | # Setup the environment for unix-like systems running a bash-like shell. |
bbahnsen | 6dbea97 | 2006-11-14 17:57:07 +0000 | [diff] [blame] | 17 | # This file must be "sourced" not merely executed. For example: ". edksetup.sh" |
klu2 | 2b1473c | 2009-07-08 05:54:53 +0000 | [diff] [blame] | 18 | # |
bbahnsen | 6dbea97 | 2006-11-14 17:57:07 +0000 | [diff] [blame] | 19 | # CYGWIN users: Your path and filename related environment variables should be |
| 20 | # set up in the unix style. This script will make the necessary conversions to |
| 21 | # windows style. |
klu2 | 2b1473c | 2009-07-08 05:54:53 +0000 | [diff] [blame] | 22 | # |
Yonghong Zhu | 445bfd9 | 2016-09-14 13:27:06 +0800 | [diff] [blame] | 23 | # Please reference edk2 user manual for more detail descriptions at https://github.com/tianocore-docs/Docs/raw/master/User_Docs/EDK_II_UserManual_0_7.pdf |
klu2 | 2b1473c | 2009-07-08 05:54:53 +0000 | [diff] [blame] | 24 | # |
bbahnsen | b9e16a8 | 2006-04-24 16:38:10 +0000 | [diff] [blame] | 25 | |
Leif Lindholm | 44f7942 | 2016-10-20 15:47:31 +0100 | [diff] [blame] | 26 | SCRIPTNAME="edksetup.sh" |
Leif Lindholm | c112e37 | 2016-10-20 16:29:46 +0100 | [diff] [blame] | 27 | RECONFIG=FALSE |
Leif Lindholm | 44f7942 | 2016-10-20 15:47:31 +0100 | [diff] [blame] | 28 | |
Parmeshwr Prasad | 729220e | 2014-01-28 02:18:23 +0000 | [diff] [blame] | 29 | function HelpMsg() |
| 30 | { |
Leif Lindholm | 44f7942 | 2016-10-20 15:47:31 +0100 | [diff] [blame] | 31 | echo "Usage: $SCRIPTNAME [Options]" |
| 32 | echo |
| 33 | echo "The system environment variable, WORKSPACE, is always set to the current" |
| 34 | echo "working directory." |
| 35 | echo |
| 36 | echo "Options: " |
| 37 | echo " --help, -h, -? Print this help screen and exit." |
| 38 | echo |
Leif Lindholm | c112e37 | 2016-10-20 16:29:46 +0100 | [diff] [blame] | 39 | echo " --reconfig Overwrite the WORKSPACE/Conf/*.txt files with the" |
| 40 | echo " template files from the BaseTools/Conf directory." |
| 41 | echo |
Parmeshwr Prasad | 729220e | 2014-01-28 02:18:23 +0000 | [diff] [blame] | 42 | echo Please note: This script must be \'sourced\' so the environment can be changed. |
Leif Lindholm | 44f7942 | 2016-10-20 15:47:31 +0100 | [diff] [blame] | 43 | echo ". $SCRIPTNAME" |
| 44 | echo "source $SCRIPTNAME" |
Parmeshwr Prasad | 729220e | 2014-01-28 02:18:23 +0000 | [diff] [blame] | 45 | } |
| 46 | |
Paolo Bonzini | d549344 | 2014-07-28 17:37:40 +0000 | [diff] [blame] | 47 | function SetWorkspace() |
| 48 | { |
| 49 | # |
| 50 | # If WORKSPACE is already set, then we can return right now |
| 51 | # |
| 52 | if [ -n "$WORKSPACE" ] |
| 53 | then |
| 54 | return 0 |
| 55 | fi |
| 56 | |
| 57 | if [ ! ${BASH_SOURCE[0]} -ef ./edksetup.sh ] |
| 58 | then |
| 59 | echo Run this script from the base of your tree. For example: |
| 60 | echo " cd /Path/To/Edk/Root" |
| 61 | echo " . edksetup.sh" |
| 62 | return 1 |
| 63 | fi |
| 64 | |
| 65 | # |
| 66 | # Check for BaseTools/BuildEnv before dirtying the user's environment. |
| 67 | # |
| 68 | if [ ! -f BaseTools/BuildEnv ] && [ -z "$EDK_TOOLS_PATH" ] |
| 69 | then |
| 70 | echo BaseTools not found in your tree, and EDK_TOOLS_PATH is not set. |
| 71 | echo Please point EDK_TOOLS_PATH at the directory that contains |
| 72 | echo the EDK2 BuildEnv script. |
| 73 | return 1 |
| 74 | fi |
| 75 | |
| 76 | # |
| 77 | # Set $WORKSPACE |
| 78 | # |
| 79 | export WORKSPACE=`pwd` |
| 80 | |
| 81 | return 0 |
| 82 | } |
| 83 | |
Parmeshwr Prasad | 729220e | 2014-01-28 02:18:23 +0000 | [diff] [blame] | 84 | function SetupEnv() |
| 85 | { |
Paolo Bonzini | 7bc1421 | 2014-07-28 17:37:35 +0000 | [diff] [blame] | 86 | if [ -n "$EDK_TOOLS_PATH" ] |
Parmeshwr Prasad | 729220e | 2014-01-28 02:18:23 +0000 | [diff] [blame] | 87 | then |
Leif Lindholm | 44f7942 | 2016-10-20 15:47:31 +0100 | [diff] [blame] | 88 | . $EDK_TOOLS_PATH/BuildEnv |
Paolo Bonzini | d549344 | 2014-07-28 17:37:40 +0000 | [diff] [blame] | 89 | elif [ -f "$WORKSPACE/BaseTools/BuildEnv" ] |
Paolo Bonzini | 7bc1421 | 2014-07-28 17:37:35 +0000 | [diff] [blame] | 90 | then |
Leif Lindholm | 44f7942 | 2016-10-20 15:47:31 +0100 | [diff] [blame] | 91 | . $WORKSPACE/BaseTools/BuildEnv |
Liming Gao | 094a673 | 2015-10-08 09:29:56 +0000 | [diff] [blame] | 92 | elif [ -n "$PACKAGES_PATH" ] |
| 93 | then |
| 94 | PATH_LIST=$PACKAGES_PATH |
| 95 | PATH_LIST=${PATH_LIST//:/ } |
| 96 | for DIR in $PATH_LIST |
| 97 | do |
| 98 | if [ -f "$DIR/BaseTools/BuildEnv" ] |
| 99 | then |
| 100 | export EDK_TOOLS_PATH=$DIR/BaseTools |
Leif Lindholm | 44f7942 | 2016-10-20 15:47:31 +0100 | [diff] [blame] | 101 | . $DIR/BaseTools/BuildEnv |
Liming Gao | 094a673 | 2015-10-08 09:29:56 +0000 | [diff] [blame] | 102 | break |
| 103 | fi |
| 104 | done |
Paolo Bonzini | 7bc1421 | 2014-07-28 17:37:35 +0000 | [diff] [blame] | 105 | else |
Paolo Bonzini | d549344 | 2014-07-28 17:37:40 +0000 | [diff] [blame] | 106 | echo BaseTools not found in your tree, and EDK_TOOLS_PATH is not set. |
Liming Gao | 094a673 | 2015-10-08 09:29:56 +0000 | [diff] [blame] | 107 | echo Please check that WORKSPACE or PACKAGES_PATH is not set incorrectly |
| 108 | echo in your shell, or point EDK_TOOLS_PATH at the directory that contains |
Paolo Bonzini | d549344 | 2014-07-28 17:37:40 +0000 | [diff] [blame] | 109 | echo the EDK2 BuildEnv script. |
| 110 | return 1 |
Parmeshwr Prasad | 729220e | 2014-01-28 02:18:23 +0000 | [diff] [blame] | 111 | fi |
| 112 | } |
| 113 | |
| 114 | function SourceEnv() |
| 115 | { |
Leif Lindholm | 44f7942 | 2016-10-20 15:47:31 +0100 | [diff] [blame] | 116 | SetWorkspace && |
| 117 | SetupEnv |
Parmeshwr Prasad | 729220e | 2014-01-28 02:18:23 +0000 | [diff] [blame] | 118 | } |
Jordan Justen | ef9086c | 2014-01-30 19:26:46 +0000 | [diff] [blame] | 119 | |
Leif Lindholm | 44f7942 | 2016-10-20 15:47:31 +0100 | [diff] [blame] | 120 | I=$# |
| 121 | while [ $I -gt 0 ] |
| 122 | do |
| 123 | case "$1" in |
| 124 | BaseTools) |
| 125 | # Ignore argument for backwards compatibility |
| 126 | shift |
| 127 | ;; |
Leif Lindholm | c112e37 | 2016-10-20 16:29:46 +0100 | [diff] [blame] | 128 | --reconfig) |
| 129 | RECONFIG=TRUE |
| 130 | shift |
| 131 | ;; |
Leif Lindholm | 44f7942 | 2016-10-20 15:47:31 +0100 | [diff] [blame] | 132 | -?|-h|--help|*) |
| 133 | HelpMsg |
| 134 | break |
| 135 | ;; |
| 136 | esac |
| 137 | I=$(($I - 1)) |
| 138 | done |
| 139 | |
| 140 | if [ $I -gt 0 ] |
Parmeshwr Prasad | 729220e | 2014-01-28 02:18:23 +0000 | [diff] [blame] | 141 | then |
Leif Lindholm | 44f7942 | 2016-10-20 15:47:31 +0100 | [diff] [blame] | 142 | return 1 |
Leif Lindholm | 1bb6bfa | 2014-01-30 19:26:53 +0000 | [diff] [blame] | 143 | fi |
| 144 | |
Leif Lindholm | 44f7942 | 2016-10-20 15:47:31 +0100 | [diff] [blame] | 145 | SourceEnv |
Jordan Justen | ef9086c | 2014-01-30 19:26:46 +0000 | [diff] [blame] | 146 | |
Leif Lindholm | c112e37 | 2016-10-20 16:29:46 +0100 | [diff] [blame] | 147 | unset SCRIPTNAME RECONFIG |
| 148 | |
Leif Lindholm | 44f7942 | 2016-10-20 15:47:31 +0100 | [diff] [blame] | 149 | return $? |