BZ:https://bugzilla.tianocore.org/show_bug.cgi?id=1985 Reconfig option should not only update build config files. This option should reset environment value set by edksetup script, such as EDK_TOOLS_PATH/PYTHONPATH. If so, this option will be valuable for the user to switch the different WORKSPACEs. We can locate BASETOOLS by setting the WORKSPACE in a directory separate from BASETOOLS,but it can't switch workspaces. for example, set WORKSPACE=C:\work\edk2 in directory C:\ run C:\work\edk2\edksetup in directory C:\ switch workspaces, set WORKSPACE=C:\workspace\edk2 run C:\workspace\edk2\edksetup in directory C:\ This situation does not apply with Reconfig, So I use the "clean" option to clear the environment variables associated with edksetup run "C:\workspace\edk2\edksetup clean" in directory C:\, run "C:\workspace\edk2\edksetup" in directory C:\ This patch is going to fix that issue. Cc: Bob Feng Cc: Liming Gao Signed-off-by: Zhiju.Fan --- edksetup.bat | 28 ++++++++++++++++++++++++++-- edksetup.sh | 31 ++++++++++++++++++++++++++++--- 2 files changed, 54 insertions(+), 5 deletions(-) diff --git a/edksetup.bat b/edksetup.bat index 024f57a4b7..00075ca48e 100755 --- a/edksetup.bat +++ b/edksetup.bat @@ -25,6 +25,29 @@ pushd . cd %~dp0 +if /I "%1" neq "Reconfig" ( + if /I "%1" neq "EnvClean" ( + goto CheckCD + ) +) + +set EDK_TOOLS_BIN= +set CONF_PATH= +set BASETOOLS_PYTHON_SOURCE= +set EDK_TOOLS_PATH= +set WORKSPACE= + +if /I "%1"=="Reconfig" ( + echo reset environment value set by edksetup script + goto CheckCD +) + +if /I "%1"=="EnvClean" ( + echo clean environment value set by edksetup script + goto end +) + +:CheckCD if not defined WORKSPACE ( goto SetWorkSpace ) @@ -142,9 +165,10 @@ if "%1"=="" goto end :Usage @echo. - @echo Usage: "%0 [-h | -help | --help | /h | /help | /?] [Reconfig] [Rebuild] [ForceRebuild] [VS2019] [VS2017] [VS2015] [VS2013] [VS2012]" + @echo Usage: "%0 [-h | -help | --help | /h | /help | /?] [Reconfig] [Rebuild] [EnvClean] [ForceRebuild] [VS2019] [VS2017] [VS2015] [VS2013] [VS2012]" @echo. - @echo Reconfig Reinstall target.txt, tools_def.txt and build_rule.txt. + @echo Reconfig Reinstall target.txt, tools_def.txt, build_rule.txt and reset environment value set by edksetup script. + @echo EnvClean Clean environment value by edksetup script. @echo Rebuild Perform incremental rebuild of BaseTools binaries. @echo ForceRebuild Force a full rebuild of BaseTools binaries. @echo VS2012 Set the env for VS2012 build. diff --git a/edksetup.sh b/edksetup.sh index 06d2f041e6..211cdc7230 100755 --- a/edksetup.sh +++ b/edksetup.sh @@ -33,6 +33,8 @@ function HelpMsg() echo " --reconfig Overwrite the WORKSPACE/Conf/*.txt files with the" echo " template files from the BaseTools/Conf directory." echo + echo " --envclean Clean environment value by edksetup script." + echo echo Please note: This script must be \'sourced\' so the environment can be changed. echo ". $SCRIPTNAME" echo "source $SCRIPTNAME" @@ -44,6 +46,20 @@ function SetWorkspace() # If WORKSPACE is already set, then we can return right now # export PYTHONHASHSEED=1 + if [ -n $RECONFIG ] + then + echo reset environment value set by edksetup script + WORKSPACE= + CONF_PATH= + fi + + if [ -n $ENVCLEAN ] + then + echo clean environment value by edksetup script + WORKSPACE= + CONF_PATH= + return 0 + fi if [ -n "$WORKSPACE" ] then return 0 @@ -177,9 +193,14 @@ function SetupPython() function SourceEnv() { - SetWorkspace && - SetupEnv - SetupPython + if [ -n $ENVCLEAN ] + then + SetWorkspace + else + SetWorkspace && + SetupEnv && + SetupPython + fi } I=$# @@ -194,6 +215,10 @@ do RECONFIG=TRUE shift ;; + --envclean) + ENVCLEAN=TRUE + shift + ;; *) HelpMsg break -- 2.14.1.windows.1