2 # Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.<BR>
3 # Copyright (c) 2016, Linaro Ltd. All rights reserved.<BR>
4 # SPDX-License-Identifier: BSD-2-Clause-Patent
6 # In *inux environment, the build tools's source is required and need to be compiled
7 # firstly, please reference https://github.com/tianocore/tianocore.github.io/wiki/SourceForge-to-Github-Quick-Start
8 # to get how to setup build tool.
10 # Setup the environment for unix-like systems running a bash-like shell.
11 # This file must be "sourced" not merely executed. For example: ". edksetup.sh"
13 # CYGWIN users: Your path and filename related environment variables should be
14 # set up in the unix style. This script will make the necessary conversions to
17 # 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
20 SCRIPTNAME
="edksetup.sh"
25 echo "Usage: $SCRIPTNAME [Options]"
27 echo "The system environment variable, WORKSPACE, is always set to the current"
28 echo "working directory."
31 echo " --help, -h, -? Print this help screen and exit."
33 echo " --reconfig Overwrite the WORKSPACE/Conf/*.txt files with the"
34 echo " template files from the BaseTools/Conf directory."
36 echo Please note
: This
script must be
\'sourced
\' so the environment can be changed.
38 echo "source $SCRIPTNAME"
41 function SetWorkspace
()
44 # If WORKSPACE is already set, then we can return right now
46 export PYTHONHASHSEED
=1
47 if [ -n "$WORKSPACE" ]
52 if [ ! ${BASH_SOURCE[0]} -ef .
/$SCRIPTNAME ] && [ -z "$PACKAGES_PATH" ]
54 echo Run this
script from the base of your tree. For example
:
55 echo " cd /Path/To/Edk/Root"
61 # Check for BaseTools/BuildEnv before dirtying the user's environment.
63 if [ ! -f BaseTools
/BuildEnv
] && [ -z "$EDK_TOOLS_PATH" ]
65 echo BaseTools not found
in your tree
, and EDK_TOOLS_PATH is not
set.
66 echo Please point EDK_TOOLS_PATH
at the directory that contains
67 echo the EDK2 BuildEnv
script.
80 if [ -n "$EDK_TOOLS_PATH" ]
82 .
$EDK_TOOLS_PATH/BuildEnv
83 elif [ -f "$WORKSPACE/BaseTools/BuildEnv" ]
85 .
$WORKSPACE/BaseTools
/BuildEnv
86 elif [ -n "$PACKAGES_PATH" ]
88 PATH_LIST
=$PACKAGES_PATH
89 PATH_LIST
=${PATH_LIST//:/ }
92 if [ -f "$DIR/BaseTools/BuildEnv" ]
94 export EDK_TOOLS_PATH
=$DIR/BaseTools
95 .
$DIR/BaseTools
/BuildEnv
100 echo BaseTools not found
in your tree
, and EDK_TOOLS_PATH is not
set.
101 echo Please check that WORKSPACE or PACKAGES_PATH is not
set incorrectly
102 echo in your shell
, or point EDK_TOOLS_PATH
at the directory that contains
103 echo the EDK2 BuildEnv
script.
108 function SetupPython3
()
110 if [ $origin_version ];then
113 for python
in $
(whereis python3
)
115 python
=$
(echo $python |
grep "[[:digit:]]$" || true
)
116 python_version
=${python##*python}
117 if [ -z "${python_version}" ] ||
(! command -v $python >/dev
/null
2>&1);then
120 if [ -z $origin_version ];then
121 origin_version
=$python_version
122 export PYTHON_COMMAND
=$python
125 if [[ "$origin_version" < "$python_version" ]]; then
126 origin_version
=$python_version
127 export PYTHON_COMMAND
=$python
133 function SetupPython
()
135 if [ $PYTHON_COMMAND ] && [ -z $PYTHON3_ENABLE ];then
136 if ( command -v $PYTHON_COMMAND >/dev
/null
2>&1 );then
139 echo $PYTHON_COMMAND Cannot be used to build or execute the python tools.
144 if [ $PYTHON3_ENABLE ] && [ $PYTHON3_ENABLE == TRUE
]
149 if [ $PYTHON3_ENABLE ] && [ $PYTHON3_ENABLE != TRUE
]
151 if [ $origin_version ];then
154 for python
in $
(whereis python2
)
156 python
=$
(echo $python |
grep "[[:digit:]]$" || true
)
157 python_version
=${python##*python}
158 if [ -z "${python_version}" ] ||
(! command -v $python >/dev
/null
2>&1);then
161 if [ -z $origin_version ]
163 origin_version
=$python_version
164 export PYTHON_COMMAND
=$python
167 if [[ "$origin_version" < "$python_version" ]]; then
168 origin_version
=$python_version
169 export PYTHON_COMMAND
=$python
190 # Ignore argument for backwards compatibility
212 unset SCRIPTNAME RECONFIG