blob: f00154e25abf93f6d36b0e08fe2ed1cb2f2b0a9c [file] [log] [blame]
bbahnsenb9e16a82006-04-24 16:38:10 +00001#
hhtian92063c42011-02-16 12:21:31 +00002# Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
hhtian24542fb2010-04-29 15:17:20 +00003# This program and the accompanying materials
bbahnsenb9e16a82006-04-24 16:38:10 +00004# 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.
klu22b1473c2009-07-08 05:54:53 +000010#
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#
bbahnsenb9e16a82006-04-24 16:38:10 +000018# Setup the environment for unix-like systems running a bash-like shell.
bbahnsen6dbea972006-11-14 17:57:07 +000019# This file must be "sourced" not merely executed. For example: ". edksetup.sh"
klu22b1473c2009-07-08 05:54:53 +000020#
bbahnsen6dbea972006-11-14 17:57:07 +000021# 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.
klu22b1473c2009-07-08 05:54:53 +000024#
25# Please reference edk2 user manual for more detail descriptions at https://edk2.tianocore.org/files/documents/64/494/EDKII_UserManual.pdf
26#
bbahnsenb9e16a82006-04-24 16:38:10 +000027
Parmeshwr Prasad729220e2014-01-28 02:18:23 +000028function 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 Lindholm1bb6bfa2014-01-30 19:26:53 +000033 return 1
Parmeshwr Prasad729220e2014-01-28 02:18:23 +000034}
35
36function SetupEnv()
37{
Paolo Bonzini7bc14212014-07-28 17:37:35 +000038 if [ -n "$EDK_TOOLS_PATH" ]
Parmeshwr Prasad729220e2014-01-28 02:18:23 +000039 then
Paolo Bonzini7bc14212014-07-28 17:37:35 +000040 . $EDK_TOOLS_PATH/BuildEnv $*
41 elif [ -n "$WORKSPACE" ]
42 then
Parmeshwr Prasad729220e2014-01-28 02:18:23 +000043 . $WORKSPACE/BaseTools/BuildEnv $*
Paolo Bonzini7bc14212014-07-28 17:37:35 +000044 else
45 . BaseTools/BuildEnv $*
Parmeshwr Prasad729220e2014-01-28 02:18:23 +000046 fi
47}
48
49function SourceEnv()
50{
Jordan Justenef9086c2014-01-30 19:26:46 +000051 if [ \
52 "$1" = "-?" -o \
53 "$1" = "-h" -o \
54 "$1" = "--help" \
55 ]
56 then
57 HelpMsg
Jordan Justenef9086c2014-01-30 19:26:46 +000058 else
59 SetupEnv "$*"
60 fi
Parmeshwr Prasad729220e2014-01-28 02:18:23 +000061}
Jordan Justenef9086c2014-01-30 19:26:46 +000062
63if [ $# -gt 1 ]
Parmeshwr Prasad729220e2014-01-28 02:18:23 +000064then
65 HelpMsg
Leif Lindholm1bb6bfa2014-01-30 19:26:53 +000066elif [ $# -eq 1 ] && [ "$1" != "BaseTools" ]
Parmeshwr Prasad729220e2014-01-28 02:18:23 +000067then
68 HelpMsg
Leif Lindholm1bb6bfa2014-01-30 19:26:53 +000069fi
70
71RETVAL=$?
72if [ $RETVAL -ne 0 ]
73then
74 return $RETVAL
Jordan Justenef9086c2014-01-30 19:26:46 +000075fi
76
Parmeshwr Prasad729220e2014-01-28 02:18:23 +000077SourceEnv "$*"
jljustena3108862007-10-16 20:52:46 +000078