]>
Commit | Line | Data |
---|---|---|
b9e16a84 | 1 | # |
92063c4e | 2 | # Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR> |
24542fb2 | 3 | # This program and the accompanying materials |
b9e16a84 | 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. | |
2b1473c1 | 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 | # | |
b9e16a84 | 18 | # Setup the environment for unix-like systems running a bash-like shell. |
6dbea978 | 19 | # This file must be "sourced" not merely executed. For example: ". edksetup.sh" |
2b1473c1 | 20 | # |
6dbea978 | 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. | |
2b1473c1 | 24 | # |
25 | # Please reference edk2 user manual for more detail descriptions at https://edk2.tianocore.org/files/documents/64/494/EDKII_UserManual.pdf | |
26 | # | |
b9e16a84 | 27 | |
729220ea PP |
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" | |
1bb6bfaa | 33 | return 1 |
729220ea PP |
34 | } |
35 | ||
d5493449 PB |
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 | ||
729220ea PP |
73 | function SetupEnv() |
74 | { | |
7bc14212 PB |
75 | if [ -n "$EDK_TOOLS_PATH" ] |
76 | then | |
77 | . $EDK_TOOLS_PATH/BuildEnv $* | |
d5493449 | 78 | elif [ -f "$WORKSPACE/BaseTools/BuildEnv" ] |
729220ea | 79 | then |
729220ea | 80 | . $WORKSPACE/BaseTools/BuildEnv $* |
7bc14212 | 81 | else |
d5493449 PB |
82 | echo BaseTools not found in your tree, and EDK_TOOLS_PATH is not set. |
83 | echo Please check that WORKSPACE is not set incorrectly in your | |
84 | echo shell, or point EDK_TOOLS_PATH at the directory that contains | |
85 | echo the EDK2 BuildEnv script. | |
86 | return 1 | |
729220ea PP |
87 | fi |
88 | } | |
89 | ||
90 | function SourceEnv() | |
91 | { | |
ef9086c3 JJ |
92 | if [ \ |
93 | "$1" = "-?" -o \ | |
94 | "$1" = "-h" -o \ | |
95 | "$1" = "--help" \ | |
96 | ] | |
97 | then | |
98 | HelpMsg | |
ef9086c3 | 99 | else |
d5493449 | 100 | SetWorkspace && |
ef9086c3 JJ |
101 | SetupEnv "$*" |
102 | fi | |
729220ea | 103 | } |
ef9086c3 JJ |
104 | |
105 | if [ $# -gt 1 ] | |
729220ea PP |
106 | then |
107 | HelpMsg | |
1bb6bfaa | 108 | elif [ $# -eq 1 ] && [ "$1" != "BaseTools" ] |
729220ea PP |
109 | then |
110 | HelpMsg | |
1bb6bfaa LL |
111 | fi |
112 | ||
113 | RETVAL=$? | |
114 | if [ $RETVAL -ne 0 ] | |
115 | then | |
116 | return $RETVAL | |
ef9086c3 JJ |
117 | fi |
118 | ||
729220ea | 119 | SourceEnv "$*" |
b9e16a84 | 120 |