2 # Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.<BR>
3 # Copyright (c) 2016, Linaro Ltd. All rights reserved.<BR>
4 # This program and the accompanying materials
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
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.
12 # In *inux environment, the build tools's source is required and need to be compiled
13 # firstly, please reference https://github.com/tianocore/tianocore.github.io/wiki/SourceForge-to-Github-Quick-Start
14 # to get how to setup build tool.
16 # Setup the environment for unix-like systems running a bash-like shell.
17 # This file must be "sourced" not merely executed. For example: ". edksetup.sh"
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
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
26 SCRIPTNAME
="edksetup.sh"
31 echo "Usage: $SCRIPTNAME [Options]"
33 echo "The system environment variable, WORKSPACE, is always set to the current"
34 echo "working directory."
37 echo " --help, -h, -? Print this help screen and exit."
39 echo " --reconfig Overwrite the WORKSPACE/Conf/*.txt files with the"
40 echo " template files from the BaseTools/Conf directory."
42 echo Please note
: This
script must be
\'sourced
\' so the environment can be changed.
44 echo "source $SCRIPTNAME"
47 function SetWorkspace
()
50 # If WORKSPACE is already set, then we can return right now
52 export PYTHONHASHSEED
=1
53 if [ -n "$WORKSPACE" ]
58 if [ ! ${BASH_SOURCE[0]} -ef .
/edksetup.sh
] && [ -z "$PACKAGES_PATH" ]
60 echo Run this
script from the base of your tree. For example
:
61 echo " cd /Path/To/Edk/Root"
67 # Check for BaseTools/BuildEnv before dirtying the user's environment.
69 if [ ! -f BaseTools
/BuildEnv
] && [ -z "$EDK_TOOLS_PATH" ]
71 echo BaseTools not found
in your tree
, and EDK_TOOLS_PATH is not
set.
72 echo Please point EDK_TOOLS_PATH
at the directory that contains
73 echo the EDK2 BuildEnv
script.
80 export WORKSPACE
=`pwd`
86 if [ -n "$EDK_TOOLS_PATH" ]
88 .
$EDK_TOOLS_PATH/BuildEnv
89 elif [ -f "$WORKSPACE/BaseTools/BuildEnv" ]
91 .
$WORKSPACE/BaseTools
/BuildEnv
92 elif [ -n "$PACKAGES_PATH" ]
94 PATH_LIST
=$PACKAGES_PATH
95 PATH_LIST
=${PATH_LIST//:/ }
98 if [ -f "$DIR/BaseTools/BuildEnv" ]
100 export EDK_TOOLS_PATH
=$DIR/BaseTools
101 .
$DIR/BaseTools
/BuildEnv
106 echo BaseTools not found
in your tree
, and EDK_TOOLS_PATH is not
set.
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
109 echo the EDK2 BuildEnv
script.
114 function SetupPython3
()
116 if [ $origin_version ];then
119 for python
in $
(whereis python3
)
121 python
=$
(echo $python |
grep "[[:digit:]]$" || true
)
122 python_version
=${python##*python}
123 if [ -z "${python_version}" ] ||
(! command -v $python >/dev
/null
2>&1);then
126 if [ -z $origin_version ];then
127 origin_version
=$python_version
128 export PYTHON_COMMAND
=$python
131 ret
=`echo "$origin_version < $python_version" |bc`
132 if [ "$ret" -eq 1 ]; then
133 origin_version
=$python_version
134 export PYTHON_COMMAND
=$python
140 function SetupPython
()
142 if [ $PYTHON_COMMAND ] && [ -z $PYTHON3_ENABLE ];then
143 if ( command -v $PYTHON_COMMAND >/dev
/null
2>&1 );then
146 echo $PYTHON_COMMAND Cannot be used to build or execute the python tools.
151 if [ $PYTHON3_ENABLE ] && [ $PYTHON3_ENABLE == TRUE
]
156 if [ $PYTHON3_ENABLE ] && [ $PYTHON3_ENABLE != TRUE
]
158 if [ $origin_version ];then
161 for python
in $
(whereis python2
)
163 python
=$
(echo $python |
grep "[[:digit:]]$" || true
)
164 python_version
=${python##*python}
165 if [ -z "${python_version}" ] ||
(! command -v $python >/dev
/null
2>&1);then
168 if [ -z $origin_version ]
170 origin_version
=$python_version
171 export PYTHON_COMMAND
=$python
174 ret
=`echo "$origin_version < $python_version" |bc`
175 if [ "$ret" -eq 1 ]; then
176 origin_version
=$python_version
177 export PYTHON_COMMAND
=$python
198 # Ignore argument for backwards compatibility
220 unset SCRIPTNAME RECONFIG