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