]> git.proxmox.com Git - mirror_edk2.git/blame_incremental - edksetup.sh
Edk2Setup.bat: Support building platforms with Python source
[mirror_edk2.git] / edksetup.sh
... / ...
CommitLineData
1#
2# Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.<BR>
3# This program and the accompanying materials
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.
10#
11# In *inux environment, the build tools's source is required and need to be compiled
12# firstly, please reference https://github.com/tianocore/tianocore.github.io/wiki/SourceForge-to-Github-Quick-Start
13# to get how to setup build tool.
14#
15# Setup the environment for unix-like systems running a bash-like shell.
16# This file must be "sourced" not merely executed. For example: ". edksetup.sh"
17#
18# CYGWIN users: Your path and filename related environment variables should be
19# set up in the unix style. This script will make the necessary conversions to
20# windows style.
21#
22# 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
23#
24
25function HelpMsg()
26{
27 echo Please note: This script must be \'sourced\' so the environment can be changed.
28 echo ". edksetup.sh"
29 echo "source edksetup.sh"
30 return 1
31}
32
33function SetWorkspace()
34{
35 #
36 # If WORKSPACE is already set, then we can return right now
37 #
38 if [ -n "$WORKSPACE" ]
39 then
40 return 0
41 fi
42
43 if [ ! ${BASH_SOURCE[0]} -ef ./edksetup.sh ]
44 then
45 echo Run this script from the base of your tree. For example:
46 echo " cd /Path/To/Edk/Root"
47 echo " . edksetup.sh"
48 return 1
49 fi
50
51 #
52 # Check for BaseTools/BuildEnv before dirtying the user's environment.
53 #
54 if [ ! -f BaseTools/BuildEnv ] && [ -z "$EDK_TOOLS_PATH" ]
55 then
56 echo BaseTools not found in your tree, and EDK_TOOLS_PATH is not set.
57 echo Please point EDK_TOOLS_PATH at the directory that contains
58 echo the EDK2 BuildEnv script.
59 return 1
60 fi
61
62 #
63 # Set $WORKSPACE
64 #
65 export WORKSPACE=`pwd`
66
67 return 0
68}
69
70function SetupEnv()
71{
72 if [ -n "$EDK_TOOLS_PATH" ]
73 then
74 . $EDK_TOOLS_PATH/BuildEnv $*
75 elif [ -f "$WORKSPACE/BaseTools/BuildEnv" ]
76 then
77 . $WORKSPACE/BaseTools/BuildEnv $*
78 elif [ -n "$PACKAGES_PATH" ]
79 then
80 PATH_LIST=$PACKAGES_PATH
81 PATH_LIST=${PATH_LIST//:/ }
82 for DIR in $PATH_LIST
83 do
84 if [ -f "$DIR/BaseTools/BuildEnv" ]
85 then
86 export EDK_TOOLS_PATH=$DIR/BaseTools
87 . $DIR/BaseTools/BuildEnv $*
88 break
89 fi
90 done
91 else
92 echo BaseTools not found in your tree, and EDK_TOOLS_PATH is not set.
93 echo Please check that WORKSPACE or PACKAGES_PATH is not set incorrectly
94 echo in your shell, or point EDK_TOOLS_PATH at the directory that contains
95 echo the EDK2 BuildEnv script.
96 return 1
97 fi
98}
99
100function SourceEnv()
101{
102 if [ \
103 "$1" = "-?" -o \
104 "$1" = "-h" -o \
105 "$1" = "--help" \
106 ]
107 then
108 HelpMsg
109 else
110 SetWorkspace &&
111 SetupEnv "$*"
112 fi
113}
114
115if [ $# -gt 1 ]
116then
117 HelpMsg
118elif [ $# -eq 1 ] && [ "$1" != "BaseTools" ]
119then
120 HelpMsg
121fi
122
123RETVAL=$?
124if [ $RETVAL -ne 0 ]
125then
126 return $RETVAL
127fi
128
129SourceEnv "$*"
130