--- /dev/null
+@REM @file\r
+@REM Windows batch file to set up the Microsoft Visual Studio environment\r
+@REM\r
+@REM This script is used to set up one of the Microsoft Visual Studio\r
+@REM environments, VS2008x86, VS2010x86, VS2012x86 or VS2013x86 for\r
+@REM building the Nt32Pkg/Nt32Pkg.dsc emulation environment to run on\r
+@REM an X64 version of Windows.\r
+@REM The system environment variables in this script are set by the\r
+@rem Edk2Setup.bat script (that will be renamed to edksetup.bat).\r
+@REM\r
+@REM This script can also be used to build the Win32 binaries\r
+@REM\r
+@REM Copyright (c) 2014, Intel Corporation. All rights reserved.<BR>\r
+@REM This program and the accompanying materials\r
+@REM are licensed and made available under the terms and conditions of the BSD License\r
+@REM which accompanies this distribution. The full text of the license may be found at\r
+@REM http://opensource.org/licenses/bsd-license.php\r
+@REM\r
+@REM THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+@REM WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+@REM\r
+@echo off\r
+@if defined NT32_X64 @goto CheckLatest\r
+@if "%REBUILD_TOOLS%"=="TRUE" @goto RebuildTools\r
+\r
+:CheckLatest\r
+echo.\r
+@if defined VS120COMNTOOLS (\r
+ @set "COMMONTOOLSx64=C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\x86_amd64"\r
+ @goto SetVs\r
+)\r
+\r
+@if defined VS110COMNTOOLS (\r
+ @set "COMMONTOOLSx64=C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\bin\x86_amd64"\r
+ @goto SetVs\r
+)\r
+\r
+@if defined VS100COMNTOOLS (\r
+ @set "COMMONTOOLSx64=C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\x86_amd64"\r
+ @goto SetVs\r
+)\r
+\r
+@if defined VS90COMNTOOLS (\r
+ @set "COMMONTOOLSx64=C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\bin\x86_amd64"\r
+ @goto SetVs\r
+)\r
+@echo.\r
+@echo No version of Microsoft Visual Studio was found on this system\r
+@echo.\r
+@exit /B 1\r
+\r
+@REM Set up the X64 environment for building Nt32Pkg/Nt32Pkg.dsc to run on an X64 platform\r
+:SetVs\r
+if exist "%COMMONTOOLSx64%\vcvarsx86_amd64.bat" (\r
+ @call "%COMMONTOOLSx64%\vcvarsx86_amd64.bat"\r
+ @if errorlevel 1 (\r
+ @echo. ERROR setting Microsoft Visual Studio %1\r
+ @set COMMONTOOLSx64=\r
+ @exit /B 1\r
+ )\r
+)\r
+if not exist "%COMMONTOOLSx64%\vcvarsx86_amd64.bat" (\r
+ @echo ERROR : This script does not exist: "%COMMONTOOLSx64%\vcvarsx86_amd64.bat"\r
+ @set COMMONTOOLSx64=\r
+ @exit /B 1\r
+)\r
+@set COMMONTOOLSx64=\r
+@goto End\r
+\r
+:RebuildTools\r
+@call python "%WORKSPACE%\BaseTools\Scripts\UpdateBuildVersions.py"\r
+@set "BIN_DIR=%EDK_TOOLS_PATH%\Bin\Win32"\r
+if not exist "%BIN_DIR%" @mkdir "%BIN_DIR%"\r
+@echo Removing temporary and binary files\r
+@cd "%BASE_TOOLS_PATH%"\r
+@call nmake cleanall\r
+@echo Rebuilding the EDK II BaseTools\r
+@cd "%BASE_TOOLS_PATH%\Source\C"\r
+@call nmake -nologo -a -f Makefile\r
+@if errorlevel 1 (\r
+@echo Error building the C-based BaseTools\r
+@cd "%WORKSPACE%"\r
+@exit /B1\r
+)\r
+@cd %BASE_TOOLS_PATH%\Source\Python\r
+@call nmake -nologo -a -f Makefile\r
+@if errorlevel 1 (\r
+@echo Error building the Python-based BaseTools\r
+@cd %WORKSPACE%\r
+@exit /B1\r
+)\r
+@cd %WORKSPACE%\r
+\r
+@goto End\r
+\r
+:VersionNotFound\r
+@echo.\r
+@echo This Microsoft Visual Studio version is in not installed on this system: %1\r
+@echo.\r
+@exit /B 1\r
+\r
+:End\r
+@exit /B 0\r
--- /dev/null
+@REM @file\r
+@REM Windows batch file to display the Windows environment\r
+@REM\r
+@REM This script will be used to show the current EDK II build environment.\r
+@REM it may be called by the Edk2Setup.bat (that will be renamed to edksetup.bat) or\r
+@REM run as stand-alone application.\r
+@REM\r
+@REM Copyright (c) 2014, Intel Corporation. All rights reserved.<BR>\r
+@REM This program and the accompanying materials\r
+@REM are licensed and made available under the terms and conditions of the BSD License\r
+@REM which accompanies this distribution. The full text of the license may be found at\r
+@REM http://opensource.org/licenses/bsd-license.php\r
+@REM\r
+@REM THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+@REM WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+@REM\r
+@echo off\r
+@set SE_SVN_REVISION=$Revision: 8 $\r
+@set SE_VERSION=0.7.0.\r
+@if "%SCRIPT%"=="EDKSETUP_BAT" goto SkipCmdlineArgumentCheck\r
+\r
+:parse_cmd_line\r
+@if /I "%1"=="-h" @goto Usage\r
+@if /I "%1"=="--help" @goto Usage\r
+@if /I "%1"=="/?" @goto Usage\r
+@if /I "%1"=="-v" @goto Version\r
+@if /I "%1"=="--version" @goto Version\r
+\r
+:Usage\r
+@echo Usage: ShowEnvironment.bat [Options]\r
+@echo Copyright(c) 2014, Intel Corporation. All rights reserved.\r
+@echo.\r
+@echo Options:\r
+@echo --help, -h Print this help screen and exit\r
+@echo --version, -v Print this tool's version and exit\r
+@echo.\r
+@goto End\r
+\r
+:Version\r
+@echo ShowEnvironment.bat Version: %SE_VERSION%%SE_SVN_REVISION:~11,-1%\r
+@echo Copyright(c) 2014, Intel Corporation. All rights reserved.\r
+\r
+:SkipCmdlineArgumentCheck\r
+if defined SRC_CONF @goto SetEnv\r
+\r
+@echo.\r
+@echo #############################################################################\r
+@if defined WORKSPACE @echo WORKSPACE = %WORKSPACE%\r
+@if not defined WORKSPACE @echo WORKSPACE = Not Set\r
+@if defined EDK_TOOLS_PATH @echo EDK_TOOLS_PATH = %EDK_TOOLS_PATH%\r
+@if not defined EDK_TOOLS_PATH @echo EDK_TOOLS_PATH = Not Set\r
+@if defined BASE_TOOLS_PATH @echo BASE_TOOLS_PATH = %BASE_TOOLS_PATH%\r
+@if defined PYTHON_FREEZER_PATH @echo PYTHON_FREEZER_PATH = %PYTHON_FREEZER_PATH%\r
+@if "%NT32PKG%"=="TRUE" (\r
+ @echo.\r
+ @echo NOTE: Please configure your build to use the following TOOL_CHAIN_TAG \r
+ @echo when building NT32Pkg/Nt32Pkg.dsc\r
+ @if defined VCINSTALLDIR @call :CheckVsVer\r
+ @set TEST_VS=\r
+)\r
+@if defined HIDE_PATH goto End\r
+\r
+\r
+@echo ############################## PATH #########################################\r
+@setlocal DisableDelayedExpansion\r
+@set "var=%PATH%"\r
+@set "var=%var:"=""%"\r
+@set "var=%var:^=^^%"\r
+@set "var=%var:&=^&%"\r
+@set "var=%var:|=^|%"\r
+@set "var=%var:<=^<%"\r
+@set "var=%var:>=^>%"\r
+@set "var=%var:;=^;^;%"\r
+@set var=%var:""="%\r
+@set "var=%var:"=""Q%"\r
+@set "var=%var:;;="S"S%"\r
+@set "var=%var:^;^;=;%"\r
+@set "var=%var:""="%"\r
+@setlocal EnableDelayedExpansion\r
+@set "var=!var:"Q=!"\r
+@for %%a in ("!var:"S"S=";"!") do (\r
+ @if "!!"=="" endlocal\r
+ @if %%a neq "" echo %%~a\r
+)\r
+@goto End\r
+\r
+:CheckVsVer\r
+@set "TEST_VS=C:\Program Files (x86)\Microsoft Visual Studio 9.0\"\r
+@if "%VSINSTALLDIR%"=="%TEST_VS%" (\r
+ @echo TOOL_CHAIN_TAG = VS2008x86\r
+ @goto :EOF\r
+)\r
+@set "TEST_VS=C:\Program Files\Microsoft Visual Studio 9.0\"\r
+@if "%VSINSTALLDIR%"=="%TEST_VS%" (\r
+ @echo TOOL_CHAIN_TAG = VS2008\r
+ @goto :EOF\r
+)\r
+\r
+@set "TEST_VS=C:\Program Files (x86)\Microsoft Visual Studio 10.0\"\r
+@if "%VSINSTALLDIR%"=="%TEST_VS%" (\r
+ @echo TOOL_CHAIN_TAG = VS2010x86\r
+ @goto :EOF\r
+)\r
+@set "TEST_VS=C:\Program Files\Microsoft Visual Studio 10.0\"\r
+@if "%VSINSTALLDIR%"=="%TEST_VS%" (\r
+ @echo TOOL_CHAIN_TAG = VS2010\r
+ @goto :EOF\r
+)\r
+\r
+@set "TEST_VS=C:\Program Files (x86)\Microsoft Visual Studio 11.0\"\r
+@if "%VSINSTALLDIR%"=="%TEST_VS%" (\r
+ @echo TOOL_CHAIN_TAG = VS2012x86\r
+ @goto :EOF\r
+)\r
+@set "TEST_VS=C:\Program Files\Microsoft Visual Studio 11.0\"\r
+@if "%VSINSTALLDIR%"=="%TEST_VS%" (\r
+ @echo TOOL_CHAIN_TAG = VS2012\r
+ @goto :EOF\r
+)\r
+\r
+@set "TEST_VS=C:\Program Files (x86)\Microsoft Visual Studio 12.0\"\r
+@if "%VSINSTALLDIR%"=="%TEST_VS%" (\r
+ @echo TOOL_CHAIN_TAG = VS2013x86\r
+ @goto :EOF\r
+)\r
+@set "TEST_VS=C:\Program Files\Microsoft Visual Studio 12.0\"\r
+@if "%VSINSTALLDIR%"=="%TEST_VS%" (\r
+ @echo TOOL_CHAIN_TAG = VS2013\r
+ @goto :EOF\r
+)\r
+@goto :EOF\r
+\r
+:SetEnv\r
+@set FIRST_COPY=FALSE\r
+@set MISSING_TARGET_TEMPLATE=FALSE\r
+@set MISSING_TOOLS_DEF_TEMPLATE=FALSE\r
+@set MISSING_BUILD_RULE_TEMPLATE=FALSE\r
+@if not exist "%SRC_CONF%\target.template" @set MISSING_TARGET_TEMPLATE=TRUE\r
+@if not exist "%SRC_CONF%\tools_def.template" @set MISSING_TOOLS_DEF_TEMPLATE=TRUE\r
+@if not exist "%SRC_CONF%\build_rule.template" @set MISSING_BUILD_RULE_TEMPLATE=TRUE\r
+\r
+@if not exist "%WORKSPACE%\Conf\target.txt" (\r
+ @if "%MISSING_TARGET_TEMPLATE%"=="TRUE" @goto MissingTemplates\r
+ @echo copying ... target.template to %WORKSPACE%\Conf\target.txt\r
+ @copy /Y "%SRC_CONF%\target.template" "%WORKSPACE%\Conf\target.txt" > nul\r
+ @set FIRST_COPY=TRUE\r
+)\r
+@if not exist "%WORKSPACE%\Conf\tools_def.txt" (\r
+ @if "%MISSING_TOOLS_DEF_TEMPLATE%"=="TRUE" @goto MissingTemplates\r
+ @echo copying ... tools_def.template to %WORKSPACE%\Conf\tools_def.txt\r
+ @copy /Y "%SRC_CONF%\tools_def.template" "%WORKSPACE%\Conf\tools_def.txt" > nul\r
+ @set FIRST_COPY=TRUE\r
+)\r
+@if not exist "%WORKSPACE%\Conf\build_rule.txt" ( \r
+ @if "%MISSING_BUILD_RULE_TEMPLATE%"=="TRUE" @goto MissingTemplates\r
+ @echo copying ... build_rule.template to %WORKSPACE%\Conf\build_rule.txt\r
+ @copy /Y "%SRC_CONF%\build_rule.template" "%WORKSPACE%\Conf\build_rule.txt" > nul\r
+ @set FIRST_COPY=TRUE\r
+)\r
+\r
+@if "%FIRST_COPY%"=="TRUE" @goto End\r
+@if not "%RECONFIG%"=="TRUE" @goto End\r
+\r
+@if "%RECONFIG%"=="TRUE" (\r
+ @echo.\r
+ @echo Over-writing the files in the WORKSPACE\Conf directory\r
+ @echo using the default template files\r
+ @echo.\r
+ @if "%MISSING_TARGET_TEMPLATE%"=="TRUE" @goto MissingTemplates\r
+ @echo over-write ... target.template to %WORKSPACE%\Conf\target.txt\r
+ @copy /Y "%SRC_CONF%\target.template" "%WORKSPACE%\Conf\target.txt" > nul\r
+ \r
+ @if "%MISSING_TOOLS_DEF_TEMPLATE%"=="TRUE" @goto MissingTemplates\r
+ @echo over-write ... tools_def.template to %WORKSPACE%\Conf\tools_def.txt\r
+ @copy /Y "%SRC_CONF%\tools_def.template" "%WORKSPACE%\Conf\tools_def.txt" > nul\r
+ \r
+ @if "%MISSING_BUILD_RULE_TEMPLATE%"=="TRUE" @goto MissingTemplates\r
+ @echo over-write ... build_rule.template to %WORKSPACE%\Conf\build_rule.txt\r
+ @copy /Y "%SRC_CONF%\build_rule.template" "%WORKSPACE%\Conf\build_rule.txt" > nul\r
+ @goto End\r
+)\r
+\r
+:MissingTemplates\r
+@echo.\r
+@if "%RECONFIG%"=="TRUE" @echo ERROR : Reconfig failed\r
+@if "%MISSING_TARGET_TEMPLATE%"=="TRUE" @echo ERROR : Unable to locate: "%SRC_CONF%\target.template"\r
+@if "%MISSING_TOOLS_DEF_TEMPLATE%"=="TRUE" @echo ERROR : Unable to locate: "%SRC_CONF%\tools_def.template"\r
+@if "%MISSING_BUILD_RULE_TEMPLATE%"=="TRUE" @echo ERROR : Unable to locate: "%SRC_CONF%\build_rule.template"\r
+@echo.\r
+@set MISSING_TARGET_TEMPLATE=\r
+@set MISSING_TOOLS_DEF_TEMPLATE=\r
+@set MISSING_BUILD_RULE_TEMPLATE=\r
+@set FIRST_COPY=\r
+@set SE_VERSION=\r
+@set SE_SVN_REVISION=\r
+@if not "%SCRIPT%"=="EDKSETUP_BAT" @echo on\r
+exit /B 1\r
+\r
+:End\r
+@set MISSING_TARGET_TEMPLATE=\r
+@set MISSING_TOOLS_DEF_TEMPLATE=\r
+@set MISSING_BUILD_RULE_TEMPLATE=\r
+@set FIRST_COPY=\r
+@set SE_VERSION=\r
+@set SE_SVN_REVISION=\r
+@if not "%SCRIPT%"=="EDKSETUP_BAT" @echo on\r
+exit /B 0\r
--- /dev/null
+## @file\r
+# Update build revisions of the tools when performing a developer build\r
+#\r
+# This script will modife the C/Include/Common/BuildVersion.h file and the two\r
+# Python scripts, Python/Common/BuildVersion.py and Python/UPT/BuildVersion.py.\r
+# If SVN is available, the tool will obtain the current checked out version of\r
+# the source tree for including the the --version commands.\r
+\r
+# Copyright (c) 2014, Intel Corporation. All rights reserved.<BR>\r
+#\r
+# This program and the accompanying materials\r
+# are licensed and made available under the terms and conditions of the BSD License\r
+# which accompanies this distribution. The full text of the license may be found at\r
+# http://opensource.org/licenses/bsd-license.php\r
+#\r
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+##\r
+""" This program will update the BuildVersion.py and BuildVersion.h files used to set a tool's version value """\r
+from __future__ import absolute_import\r
+\r
+import os\r
+import shlex\r
+import subprocess\r
+import sys\r
+\r
+from argparse import ArgumentParser, SUPPRESS\r
+from tempfile import NamedTemporaryFile\r
+from types import IntType, ListType\r
+\r
+\r
+SYS_ENV_ERR = "ERROR : %s system environment variable must be set prior to running this tool.\n"\r
+\r
+__execname__ = "UpdateBuildVersions.py"\r
+SVN_REVISION = "$Revision: 3 $"\r
+SVN_REVISION = SVN_REVISION.replace("$Revision:", "").replace("$", "").strip()\r
+__copyright__ = "Copyright (c) 2014, Intel Corporation. All rights reserved."\r
+VERSION_NUMBER = "0.7.0"\r
+__version__ = "Version %s.%s" % (VERSION_NUMBER, SVN_REVISION)\r
+\r
+\r
+def ParseOptions():\r
+ """\r
+ Parse the command-line options.\r
+ The options for this tool will be passed along to the MkBinPkg tool.\r
+ """\r
+ parser = ArgumentParser(\r
+ usage=("%s [options]" % __execname__),\r
+ description=__copyright__,\r
+ conflict_handler='resolve')\r
+\r
+ # Standard Tool Options\r
+ parser.add_argument("--version", action="version",\r
+ version=__execname__ + " " + __version__)\r
+ parser.add_argument("-s", "--silent", action="store_true",\r
+ dest="silent",\r
+ help="All output will be disabled, pass/fail determined by the exit code")\r
+ parser.add_argument("-v", "--verbose", action="store_true",\r
+ dest="verbose",\r
+ help="Enable verbose output")\r
+ # Tool specific options\r
+ parser.add_argument("--revert", action="store_true",\r
+ dest="REVERT", default=False,\r
+ help="Revert the BuildVersion files only")\r
+ parser.add_argument("--svn-test", action="store_true",\r
+ dest="TEST_SVN", default=False,\r
+ help="Test if the svn command is available")\r
+ parser.add_argument("--svnFlag", action="store_true",\r
+ dest="HAVE_SVN", default=False,\r
+ help=SUPPRESS)\r
+\r
+ return(parser.parse_args())\r
+\r
+\r
+def ShellCommandResults(CmdLine, Opt):\r
+ """ Execute the comand, returning the output content """\r
+ file_list = NamedTemporaryFile(delete=False)\r
+ filename = file_list.name\r
+ Results = []\r
+\r
+ returnValue = 0\r
+ try:\r
+ subprocess.check_call(args=shlex.split(CmdLine), stderr=subprocess.STDOUT, stdout=file_list)\r
+ except subprocess.CalledProcessError as err_val:\r
+ file_list.close()\r
+ if not Opt.silent:\r
+ sys.stderr.write("ERROR : %d : %s\n" % (err_val.returncode, err_val.__str__()))\r
+ if os.path.exists(filename):\r
+ sys.stderr.write(" : Partial results may be in this file: %s\n" % filename)\r
+ sys.stderr.flush()\r
+ returnValue = err_val.returncode\r
+\r
+ except IOError as (errno, strerror):\r
+ file_list.close()\r
+ if not Opt.silent:\r
+ sys.stderr.write("I/O ERROR : %s : %s\n" % (str(errno), strerror))\r
+ sys.stderr.write("ERROR : this command failed : %s\n" % CmdLine)\r
+ if os.path.exists(filename):\r
+ sys.stderr.write(" : Partial results may be in this file: %s\n" % filename)\r
+ sys.stderr.flush()\r
+ returnValue = errno\r
+\r
+ except OSError as (errno, strerror):\r
+ file_list.close()\r
+ if not Opt.silent:\r
+ sys.stderr.write("OS ERROR : %s : %s\n" % (str(errno), strerror))\r
+ sys.stderr.write("ERROR : this command failed : %s\n" % CmdLine)\r
+ if os.path.exists(filename):\r
+ sys.stderr.write(" : Partial results may be in this file: %s\n" % filename)\r
+ sys.stderr.flush()\r
+ returnValue = errno\r
+\r
+ except KeyboardInterrupt:\r
+ file_list.close()\r
+ if not Opt.silent:\r
+ sys.stderr.write("ERROR : Command terminated by user : %s\n" % CmdLine)\r
+ if os.path.exists(filename):\r
+ sys.stderr.write(" : Partial results may be in this file: %s\n" % filename)\r
+ sys.stderr.flush()\r
+ returnValue = 1\r
+\r
+ finally:\r
+ if not file_list.closed:\r
+ file_list.flush()\r
+ os.fsync(file_list.fileno())\r
+ file_list.close()\r
+\r
+ if os.path.exists(filename):\r
+ fd_ = open(filename, 'r')\r
+ Results = fd_.readlines()\r
+ fd_.close()\r
+ os.unlink(filename)\r
+\r
+ if returnValue > 0:\r
+ return returnValue\r
+\r
+ return Results\r
+\r
+\r
+def UpdateBuildVersionPython(Rev, UserModified, opts):\r
+ """ This routine will update the BuildVersion.h files in the C source tree """\r
+ for SubDir in ["Common", "UPT"]:\r
+ PyPath = os.path.join(os.environ['BASE_TOOLS_PATH'], "Source", "Python", SubDir)\r
+ BuildVersionPy = os.path.join(PyPath, "BuildVersion.py")\r
+ fd_ = open(os.path.normpath(BuildVersionPy), 'r')\r
+ contents = fd_.readlines()\r
+ fd_.close()\r
+ if opts.HAVE_SVN is False:\r
+ BuildVersionOrig = os.path.join(PyPath, "orig_BuildVersion.py")\r
+ fd_ = open (BuildVersionOrig, 'w')\r
+ for line in contents:\r
+ fd_.write(line)\r
+ fd_.flush()\r
+ fd_.close()\r
+ new_content = []\r
+ for line in contents:\r
+ if line.strip().startswith("gBUILD_VERSION"):\r
+ new_line = "gBUILD_VERSION = \"Developer Build based on Revision: %s\"" % Rev\r
+ if UserModified:\r
+ new_line = "gBUILD_VERSION = \"Developer Build based on Revision: %s with Modified Sources\"" % Rev\r
+ new_content.append(new_line)\r
+ continue\r
+ new_content.append(line)\r
+\r
+ fd_ = open(os.path.normpath(BuildVersionPy), 'w')\r
+ for line in new_content:\r
+ fd_.write(line)\r
+ fd_.close()\r
+\r
+\r
+def UpdateBuildVersionH(Rev, UserModified, opts):\r
+ """ This routine will update the BuildVersion.h files in the C source tree """\r
+ CPath = os.path.join(os.environ['BASE_TOOLS_PATH'], "Source", "C", "Include", "Common")\r
+ BuildVersionH = os.path.join(CPath, "BuildVersion.h")\r
+ fd_ = open(os.path.normpath(BuildVersionH), 'r')\r
+ contents = fd_.readlines()\r
+ fd_.close()\r
+ if opts.HAVE_SVN is False:\r
+ BuildVersionOrig = os.path.join(CPath, "orig_BuildVersion.h")\r
+ fd_ = open(BuildVersionOrig, 'w')\r
+ for line in contents:\r
+ fd_.write(line)\r
+ fd_.flush()\r
+ fd_.close()\r
+\r
+ new_content = []\r
+ for line in contents:\r
+ if line.strip().startswith("#define"):\r
+ new_line = "#define __BUILD_VERSION \"Developer Build based on Revision: %s\"" % Rev\r
+ if UserModified:\r
+ new_line = "#define __BUILD_VERSION \"Developer Build based on Revision: %s with Modified Sources\"" % \\r
+ Rev\r
+ new_content.append(new_line)\r
+ continue\r
+ new_content.append(line)\r
+\r
+ fd_ = open(os.path.normpath(BuildVersionH), 'w')\r
+ for line in new_content:\r
+ fd_.write(line)\r
+ fd_.close()\r
+\r
+\r
+def RevertCmd(Filename, Opt):\r
+ """ This is the shell command that does the SVN revert """\r
+ CmdLine = "svn revert %s" % Filename.replace("\\", "/").strip()\r
+ try:\r
+ subprocess.check_output(args=shlex.split(CmdLine))\r
+ except subprocess.CalledProcessError as err_val:\r
+ if not Opt.silent:\r
+ sys.stderr.write("Subprocess ERROR : %s\n" % err_val)\r
+ sys.stderr.flush()\r
+\r
+ except IOError as (errno, strerror):\r
+ if not Opt.silent:\r
+ sys.stderr.write("I/O ERROR : %d : %s\n" % (str(errno), strerror))\r
+ sys.stderr.write("ERROR : this command failed : %s\n" % CmdLine)\r
+ sys.stderr.flush()\r
+\r
+ except OSError as (errno, strerror):\r
+ if not Opt.silent:\r
+ sys.stderr.write("OS ERROR : %d : %s\n" % (str(errno), strerror))\r
+ sys.stderr.write("ERROR : this command failed : %s\n" % CmdLine)\r
+ sys.stderr.flush()\r
+\r
+ except KeyboardInterrupt:\r
+ if not Opt.silent:\r
+ sys.stderr.write("ERROR : Command terminated by user : %s\n" % CmdLine)\r
+ sys.stderr.flush()\r
+\r
+ if Opt.verbose:\r
+ sys.stdout.write("Reverted this file: %s\n" % Filename)\r
+ sys.stdout.flush()\r
+\r
+\r
+def GetSvnRevision(opts):\r
+ """ Get the current revision of the BaseTools/Source tree, and check if any of the files have been modified """\r
+ Revision = "Unknown"\r
+ Modified = False\r
+\r
+ if opts.HAVE_SVN is False:\r
+ sys.stderr.write("WARNING: the svn command-line tool is not available.\n")\r
+ return (Revision, Modified)\r
+\r
+ SrcPath = os.path.join(os.environ['BASE_TOOLS_PATH'], "Source")\r
+ # Check if there are modified files.\r
+ Cwd = os.getcwd()\r
+ os.chdir(SrcPath)\r
+\r
+ StatusCmd = "svn st -v --depth infinity --non-interactive"\r
+ contents = ShellCommandResults(StatusCmd, opts)\r
+ os.chdir(Cwd)\r
+ if type(contents) is ListType:\r
+ for line in contents:\r
+ if line.startswith("M "):\r
+ Modified = True\r
+ break\r
+\r
+ # Get the repository revision of BaseTools/Source\r
+ InfoCmd = "svn info %s" % SrcPath.replace("\\", "/").strip()\r
+ Revision = 0\r
+ contents = ShellCommandResults(InfoCmd, opts)\r
+ if type(contents) is IntType:\r
+ return 0, Modified\r
+ for line in contents:\r
+ line = line.strip()\r
+ if line.startswith("Revision:"):\r
+ Revision = line.replace("Revision:", "").strip()\r
+ break\r
+\r
+ return (Revision, Modified)\r
+\r
+\r
+def CheckSvn(opts):\r
+ """\r
+ This routine will return True if an svn --version command succeeds, or False if it fails.\r
+ If it failed, SVN is not available.\r
+ """\r
+ OriginalSilent = opts.silent\r
+ opts.silent = True\r
+ VerCmd = "svn --version"\r
+ contents = ShellCommandResults(VerCmd, opts)\r
+ opts.silent = OriginalSilent\r
+ if type(contents) is IntType:\r
+ if opts.verbose:\r
+ sys.stdout.write("SVN does not appear to be available.\n")\r
+ sys.stdout.flush()\r
+ return False\r
+\r
+ if opts.verbose:\r
+ sys.stdout.write("Found %s" % contents[0])\r
+ sys.stdout.flush()\r
+ return True\r
+\r
+\r
+def CopyOrig(Src, Dest, Opt):\r
+ """ Overwrite the Dest File with the Src File content """\r
+ try:\r
+ fd_ = open(Src, 'r')\r
+ contents = fd_.readlines()\r
+ fd_.close()\r
+ fd_ = open(Dest, 'w')\r
+ for line in contents:\r
+ fd_.write(line)\r
+ fd_.flush()\r
+ fd_.close()\r
+ except IOError:\r
+ if not Opt.silent:\r
+ sys.stderr.write("Unable to restore this file: %s\n" % Dest)\r
+ sys.stderr.flush()\r
+ return 1\r
+\r
+ os.remove(Src)\r
+ if Opt.verbose:\r
+ sys.stdout.write("Restored this file: %s\n" % Src)\r
+ sys.stdout.flush()\r
+\r
+ return 0\r
+\r
+\r
+def CheckOriginals(Opts):\r
+ """\r
+ If SVN was not available, then the tools may have made copies of the original BuildVersion.* files using\r
+ orig_BuildVersion.* for the name. If they exist, replace the existing BuildVersion.* file with the corresponding\r
+ orig_BuildVersion.* file.\r
+ Returns 0 if this succeeds, or 1 if the copy function fails. It will also return 0 if the orig_BuildVersion.* file\r
+ does not exist.\r
+ """\r
+ CPath = os.path.join(os.environ['BASE_TOOLS_PATH'], "Source", "C", "Include", "Common")\r
+ BuildVersionH = os.path.join(CPath, "BuildVersion.h")\r
+ OrigBuildVersionH = os.path.join(CPath, "orig_BuildVersion.h")\r
+ if not os.path.exists(OrigBuildVersionH):\r
+ return 0\r
+ if CopyOrig(OrigBuildVersionH, BuildVersionH, Opts):\r
+ return 1\r
+ for SubDir in ["Common", "UPT"]:\r
+ PyPath = os.path.join(os.environ['BASE_TOOLS_PATH'], "Source", "Python", SubDir)\r
+ BuildVersionPy = os.path.join(PyPath, "BuildVersion.h")\r
+ OrigBuildVersionPy = os.path.join(PyPath, "orig_BuildVersion.h")\r
+ if not os.path.exists(OrigBuildVersionPy):\r
+ return 0\r
+ if CopyOrig(OrigBuildVersionPy, BuildVersionPy, Opts):\r
+ return 1\r
+\r
+ return 0\r
+\r
+\r
+def RevertBuildVersionFiles(opts):\r
+ """\r
+ This routine will attempt to perform an SVN --revert on each of the BuildVersion.* files\r
+ """\r
+ if not opts.HAVE_SVN:\r
+ if CheckOriginals(opts):\r
+ return 1\r
+ return 0\r
+ # SVN is available\r
+ BuildVersionH = os.path.join(os.environ['BASE_TOOLS_PATH'], "Source", "C", "Include", "Common", "BuildVersion.h")\r
+ RevertCmd(BuildVersionH, opts)\r
+ for SubDir in ["Common", "UPT"]:\r
+ BuildVersionPy = os.path.join(os.environ['BASE_TOOLS_PATH'], "Source", "Python", SubDir, "BuildVersion.py")\r
+ RevertCmd(BuildVersionPy, opts)\r
+\r
+def UpdateRevisionFiles():\r
+ """ Main routine that will update the BuildVersion.py and BuildVersion.h files."""\r
+ options = ParseOptions()\r
+ # Check the working environment\r
+ if "WORKSPACE" not in os.environ.keys():\r
+ sys.stderr.write(SYS_ENV_ERR % 'WORKSPACE')\r
+ return 1\r
+ if 'BASE_TOOLS_PATH' not in os.environ.keys():\r
+ sys.stderr.write(SYS_ENV_ERR % 'BASE_TOOLS_PATH')\r
+ return 1\r
+ if not os.path.exists(os.environ['BASE_TOOLS_PATH']):\r
+ sys.stderr.write("Unable to locate the %s directory." % os.environ['BASE_TOOLS_PATH'])\r
+ return 1\r
+\r
+\r
+ options.HAVE_SVN = CheckSvn(options)\r
+ if options.TEST_SVN:\r
+ return (not options.HAVE_SVN)\r
+ # done processing the option, now use the option.HAVE_SVN as a flag. True = Have it, False = Don't have it.\r
+ if options.REVERT:\r
+ # Just revert the tools an exit\r
+ RevertBuildVersionFiles(options)\r
+ else:\r
+ # Revert any changes in the BuildVersion.* files before setting them again.\r
+ RevertBuildVersionFiles(options)\r
+ Revision, Modified = GetSvnRevision(options)\r
+ if options.verbose:\r
+ sys.stdout.write("Revision: %s is Modified: %s\n" % (Revision, Modified))\r
+ sys.stdout.flush()\r
+ UpdateBuildVersionH(Revision, Modified, options)\r
+ UpdateBuildVersionPython(Revision, Modified, options)\r
+\r
+ return 0\r
+\r
+\r
+if __name__ == "__main__":\r
+ sys.exit(UpdateRevisionFiles())\r
+\r
+\r
--- /dev/null
+@REM @file\r
+@REM Windows batch file, Edk2Setup.bat, to set up an EDK II build environment\r
+@REM\r
+@REM This script will be renamed to edksetup.bat after initial testing and\r
+@REM acceptance by the open source community.\r
+@REM\r
+@REM This script will set the following system environment variables:\r
+@REM WORKSPACE, EDK_TOOLS_PATH, PATH\r
+@REM If rebuilding the tools:\r
+@REM BASE_TOOLS_PATH, PYTHON_FREEZER_PATH, PYTHONPATH\r
+@REM It will also create a Conf/target.txt, tools_def.txt and build_rule.txt files\r
+@REM if they do not exist\r
+@REM If the reset flag is set, all environment variables will be reset and \r
+@REM the Conf/target.txt, tools_def.txt and build_rule.txt files will be overwritten\r
+@REM\r
+@REM Three other scripts, located in the BaseTools\Scripts directory, may be called\r
+@REM by this script.\r
+@REM SetVisualStudio.bat - will set the Visual Studio environment based on the --vs* flags\r
+@REM it is also used to build the Win32 binaries, calling nmake \r
+@REM using the WORKSPACE\BaseTools\Makefile\r
+@REM ShowEnvironment.bat - will display the current EDK II Build environment\r
+@REM UpdateBuildVersions.py - script is called prior to building the EDK II BaseTools from\r
+@REM Sources. This tool will modify the BuildVersion.* files so that\r
+@REM when the tools get built, they will have a custom version entry\r
+@REM similar to the following:\r
+@REM e:\edk2>build --version\r
+@REM build.exe Version 0.51 Developer Build based on Revision: 15668\r
+@REM\r
+@REM Copyright (c) 2014, Intel Corporation. All rights reserved.<BR>\r
+@REM This program and the accompanying materials\r
+@REM are licensed and made available under the terms and conditions of the BSD License\r
+@REM which accompanies this distribution. The full text of the license may be found at\r
+@REM http://opensource.org/licenses/bsd-license.php\r
+@REM\r
+@REM THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+@REM WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+@REM\r
+@REM\r
+@REM usage:\r
+@REM Edk2Setup.bat [--help | -h] [-v | --version] [-r | --reset] \r
+@REM [--reconfig] [--edk-tools-path DirName]\r
+@REM [--pull [Directory]| --rebuild [Directory]]\r
+@REM [--nt32 [X64]]\r
+\r
+@REM ##############################################################\r
+@REM # You should not have to modify anything below this line\r
+@REM #\r
+@echo off\r
+@set SCRIPT_NAME=%0\r
+@set SCRIPT_VERSION=0.9.0.\r
+@set SVN_REVISION=$Revision: 8 $\r
+@set RESET_ENVIRONMENT=FALSE\r
+@set NT32PKG=FALSE\r
+@set NT32_64=FALSE\r
+@set BUILD_TOOLS_WITH=\r
+@set LOCATION=\r
+@set REBUILD_TOOLS=\r
+@set SVN_PULL=\r
+@set SRC_CONF=\r
+@set ARGUMENT=\r
+@set SCRIPT=EDKSETUP_BAT\r
+\r
+@if not defined ORIGINAL_PATH set "ORIGINAL_PATH=%PATH%"\r
+@REM Always set the WORKSPACE environment variable to the current directory\r
+@set "WORKSPACE=%CD%"\r
+@if exist "%WORKSPACE%\BaseTools" @set "BASE_TOOLS_PATH=%WORKSPACE%\BaseTools"\r
+@if not exist "%WORKSPACE%\Conf" @mkdir "%WORKSPACE%\Conf"\r
+\r
+@@if not defined EDK_TOOLS_PATH @set "EDK_TOOLS_PATH=%WORKSPACE%\BaseTools"\r
+@rem @set "PATH=%WORKSPACE%\BaseTools\Bin\Win32;%PATH%"\r
+@rem @set WORKSPACE_TOOLS_PATH=%WORKSPACE%\BaseTools\r
+@rem )\r
+\r
+@REM Keep the existing EDK_TOOLS_PATH value, the --reset flag will set it\r
+@REM back to WORKSPACE\BaseTools while the --location DIRECTORY flag will\r
+@REM still take precedence if the location option follows the reset option\r
+@REM on the command line.\r
+@if defined EDK_TOOLS_PATH @set "LOCATION=%EDK_TOOLS_PATH%"\r
+\r
+:parse_cmd_line\r
+@if "%1"=="" @goto MainRoutine\r
+@if /I "%1"=="-h" @goto Usage\r
+@if /I "%1"=="--help" @goto Usage\r
+@if /I "%1"=="/?" @goto Usage\r
+@if /I "%1"=="--version" @goto Version\r
+\r
+@REM These options will reset the system environment\r
+@if /I "%1"=="-r" (\r
+ @setlocal EnableDelayedExpansion\r
+ @set "WORKSPACE=%CD%"\r
+ @set "EDK_TOOLS_PATH=%CD%\BaseTools"\r
+ @set "LOCATION=!EDK_TOOLS_PATH!"\r
+ @endlocal\r
+ @shift\r
+ @goto parse_cmd_line\r
+)\r
+@if /I "%1"=="--reset" (\r
+ @set "WORKSPACE=%CD%"\r
+ @set "EDK_TOOLS_PATH=%WORKSPACE%\BaseTools"\r
+ @set "LOCATION=%WORKSPACE%\BaseTools"\r
+ @shift\r
+ @goto parse_cmd_line\r
+)\r
+\r
+@REM This option is used to overwrite the Conf/*.txt files with the\r
+@REM WORKSPACE\BaseTools\Conf\*.template files.\r
+@if /I "%1"=="--reconfig" (\r
+ @set RECONFIG=TRUE\r
+ @shift\r
+ @goto parse_cmd_line\r
+)\r
+\r
+@REM This option can be used to set the EDK_TOOLS_PATH containing the Win32 binaries to an\r
+@REM alternate directory\r
+@if /I "%1"=="--edk-tools-path" (\r
+ @setlocal EnableDelayedExpansion\r
+ @set ARGUMENT=%2\r
+ @if "!ARGUMENT:~0,2!"=="--" (\r
+ @echo.\r
+ @echo ERROR : The --edk-tools-path flag requires an argument\r
+ @echo.\r
+ @endlocal\r
+ @goto Usage\r
+ )\r
+ @endlocal\r
+ @set "LOCATION=%WORKSPACE%\%2"\r
+ @shift\r
+ @shift\r
+ @goto parse_cmd_line\r
+)\r
+\r
+@REM Force pulling updated (or checkout if they do not exist) from SVN for the BaseTools\Bin\Win32 directory\r
+@REM or the directory pointed to by the --location option\r
+@if /I "%1"=="--pull" (\r
+ @if "%REBUILD_TOOLS%"=="TRUE" (\r
+ @echo.\r
+ @echo ERROR: The --pull option may not be used with the --rebuild option\r
+ @shift\r
+ @goto ExitFailure\r
+ )\r
+ @set SVN_PULL=TRUE\r
+ @setlocal EnableDelayedExpansion\r
+ @set ARGUMENT=%2\r
+ @if not "!ARGUMENT:~0,2!"=="--" (\r
+ @endlocal\r
+ @set "LOCATION=%2"\r
+ @shift\r
+ )\r
+ @shift\r
+ @goto parse_cmd_line\r
+)\r
+\r
+@REM This options forces rebuilding the tools (provided the required tools are available\r
+@if /I "%1"=="--rebuild" (\r
+ @if "%SVN_PULL%"=="TRUE" (\r
+ @echo.\r
+ @echo ERROR: The --reset option may not be used with the --pull option\r
+ @shift\r
+ @goto ExitFailure\r
+ )\r
+ @set REBUILD_TOOLS=TRUE\r
+ @setlocal EnableDelayedExpansion\r
+ @set ARGUMENT=%2\r
+ @if not "!ARGUMENT:~0,2!"=="--" (\r
+ @endlocal\r
+ @set "LOCATION=%2"\r
+ @shift\r
+ )\r
+ @shift\r
+ goto parse_cmd_line\r
+)\r
+\r
+@REM This option will try to set the compiler environment for building Nt32Pkg/Nt32Pkg.dsc\r
+@REM If the compiler environment is already installed, then no additional work is required.\r
+@if /I "%1"=="--nt32" (\r
+ @set NT32PKG=TRUE\r
+ @if not defined BUILD_TOOLS_WITH (\r
+ @set BUILD_TOOLS_WITH=Latest\r
+ )\r
+ @REM This option will try to set the environment for building the Nt32Pkg/Nt32Pkg; on a 64-bit \r
+ @REM Windows OS\r
+ @if /I "%2"=="X64" (\r
+ @set NT32_64=TRUE\r
+ @shift\r
+ )\r
+ @shift\r
+ @goto parse_cmd_line\r
+)\r
+\r
+@if not "%1"=="" goto UnknownOptionOrArgument\r
+@goto MainRoutine\r
+\r
+:Usage\r
+@echo Usage: %SCRIPT_NAME% [Options]\r
+@echo Copyright(c) 2014, Intel Corporation. All rights reserved.\r
+@echo.\r
+@echo The system environment variable, WORKSPACE, is always set to the current \r
+@echo working directory.\r
+@echo.\r
+@echo Options:\r
+@echo --help, -h Print this help screen and exit.\r
+@echo.\r
+@echo --version Print this script's version and exit.\r
+@echo.\r
+@echo --reset, -r Reset the EDK_TOOLS_PATH and PATH system environment\r
+@echo variables. The EDK_TOOLS_PATH default is \r
+@echo WORKSPACE\BaseTools, however, it may be overridden by\r
+@echo arguments given to the --edk-tools-path, --pull and/or\r
+@echo --rebuild options.\r
+@echo Once set, the EDK_TOOLS_PATH environment variable reset\r
+@echo by opening up a new command prompt window or through one\r
+@echo of the options provided by this tool\r
+@echo.\r
+@echo --reconfig Overwrite the WORKSPACE/Conf/*.txt files with the\r
+@echo template files from the BaseTools/Conf directory.\r
+@echo.\r
+@echo --edk-tools-path DIRECTORY\r
+@echo This option sets the EDK_TOOLS_PATH to the DIRECTORY\r
+@echo value instead of the default (WORKSPACE\BaseTools).\r
+@echo.\r
+@echo --nt32 [X64] If a compiler tool chain is not available in the\r
+@echo environment, call a script to attempt to set one up.\r
+@echo This flag is only required if building the\r
+@echo Nt32Pkg/Nt32Pkg.dsc system emulator.\r
+@echo If the X64 argument is set, and a compiler tool chain is\r
+@echo not available, attempt to set up a tool chain that will\r
+@echo create X64 binaries. Setting these two options have the\r
+@echo potential side effect of changing tool chains used for a\r
+@echo rebuild.\r
+@echo.\r
+@pause\r
+@echo.\r
+@echo --pull [DIRECTORY] Get the EDK II BaseTools binaries from source control \r
+@echo (must not be used with --rebuild).\r
+@echo If the optional DIRECTORY argument is specified, the tool\r
+@echo sets EDK_TOOLS_PATH to DIRECTORY.\r
+@echo If the DIRECTORY argument is not specified, the tools are\r
+@echo placed in the directory tree pointed to by the current \r
+@echo EDK_TOOLS_PATH environment variable. If the binaries\r
+@echo cannot be obtained from source control, the \r
+@echo EDK_TOOLS_PATH will be set to the default, \r
+@echo WORKSPACE\BaseTools directory.\r
+@echo.\r
+@echo --rebuild [DIRECTORY]\r
+@echo Force Rebuilding the EDK II BaseTools from source\r
+@echo (must not be used with --pull).\r
+@echo NOTE: The build will use whatever compiler tool set\r
+@echo is available in the environment prior to\r
+@echo running edksetup.bat.\r
+@echo If the optional DIRECTORY argument is specified, the tool\r
+@echo sets EDK_TOOLS_PATH to DIRECTORY. Tools binaries will be\r
+@echo placed in the appropriate subdirectory in the \r
+@echo EDK_TOOLS_PATH directory. If the build fails, the\r
+@echo EDK_TOOLS_PATH will be set to the default,\r
+@echo WORKSPACE\BaseTools directory.\r
+@goto ExitSuccess\r
+\r
+:Version\r
+@echo %SCRIPT_NAME% Version: %SCRIPT_VERSION%%SVN_REVISION:~11,-1%\r
+@echo Copyright(c) 2014, Intel Corporation. All rights reserved.\r
+@set HIDE_PATH=TRUE\r
+@call "%WORKSPACE%\BaseTools\Scripts\ShowEnvironment.bat"\r
+@set HIDE_PATH=\r
+@goto ExitSuccess\r
+\r
+:UnknownOptionOrArgument\r
+@echo. ERROR : This argument is not valid: %1\r
+@echo.\r
+@goto ExitFailure\r
+\r
+:NoVisualStudio\r
+@echo ERROR : Unable to determine if a compiler tool chain has been enabled in this\r
+@echo command-prompt window. Rebuilding of the tools with this script is not\r
+@echo possible.\r
+@echo Refer to the BaseTools\BuildNotes.txt for directions for building \r
+@echo the BaseTools binaries.\r
+@echo.\r
+@goto ExitFailure\r
+\r
+:NoPython\r
+@echo ERROR : Unable to rebuild the BaseTools binaries, python does not appear to be\r
+@echo installed. If python is installed, please set the environment\r
+@echo variable, PYTHONHOME to the Path to the python.exe, for example,\r
+@echo if python.exe is located in the C:\Python27 directory, then:\r
+@echo set PYTHONHOME=C:\Python27\r
+@echo.\r
+@goto ExitFailure\r
+\r
+:BadPython\r
+@echo ERROR : Unable to rebuild the BaseTools binaries, python does not appear to be\r
+@echo installed. \r
+@echo The python executable was not found in the PYTHONHOME: %PYTHONHOME%\r
+@echo If python is installed, please set the environment variable, PYTHONHOME \r
+@echo to the Path that contains python.exe, for example, if python.exe is\r
+@echo located in the C:\Python27 directory, then:\r
+@echo set PYTHONHOME=C:\Python27\r
+@echo.\r
+@goto ExitFailure\r
+\r
+:NoCxFreeze\r
+@echo ERROR : Unable to locate cx_Freeze 4.2.3. The cxfreeze.bat file must be located\r
+@echo in the %PYTHONHOME%\Scripts directoryin order to rebuild the BaseTools\r
+@echo binaries.\r
+@echo.\r
+@goto ExitFailure\r
+\r
+:NoBaseTools\r
+@echo ERROR: Unable to locate the BaseTools directory containing the Source tree\r
+@echo.\r
+@goto ExitFailure\r
+\r
+@REM #########################################################################################\r
+@REM MAIN ROUTINE\r
+@REM Set up the Build System environment\r
+@REM #########################################################################################\r
+:MainRoutine\r
+@if defined LOCATION @set "EDK_TOOLS_PATH=%LOCATION%"\r
+@REM SET the EDK_TOOLS_PATH.\r
+@if not exist "%EDK_TOOLS_PATH%" (\r
+ @mkdir %EDK_TOOLS_PATH%\r
+)\r
+\r
+@REM Set up the path to include the EDK_TOOLS_PATH\Bin\Win32 directory; this test determines\r
+@REM whether the path is in the workspace or a fully qualified path that may be outside of\r
+@REM the workspace\r
+@if exist "%WORKSPACE%\%EDK_TOOLS_PATH%" @set "EDK_TOOLS_PATH=%WORKSPACE%\%EDK_TOOLS_PATH%"\r
+\r
+@if defined REBUILD_TOOLS goto SetConf\r
+@if defined SVN_PULL goto SetConf\r
+@if not exist "%EDK_TOOLS_PATH%\Bin\Win32\build.exe" (\r
+ @echo ERROR : %EDK_TOOLS_PATH%\Bin\Win32\build.exe does not exist\r
+ @echo Re-run this script using --reset, --pull or --rebuild\r
+ @echo.\r
+ @goto ExitFailure\r
+)\r
+@echo.\r
+@echo Rebuilding of the tools is not required. Binaries of the latest,\r
+@echo tested versions of the tools have been tested and included in the\r
+@echo EDK II repository.\r
+@echo.\r
+@echo If you really want to build the tools, use the --rebuild option.\r
+@echo.\r
+@if not defined CYGWIN_HOME @echo "!!! WARNING !!! No CYGWIN_HOME set, gcc build may not be used !!!"\r
+@if not defined CYGWIN_HOME @echo.\r
+@REM Make sure the WORKSPACE\Conf directory contains the required text files that will be\r
+@REM copied or replaced from the WORKSPACE\BaseTools\Conf directories' template files.\r
+:SetConf\r
+@if not exist "%EDK_TOOLS_PATH%\Conf" (\r
+ @if exist "%WORKSPACE%\BaseTools\Conf" (\r
+ @set "SRC_CONF=%WORKSPACE%\BaseTools\Conf"\r
+ )\r
+) else (\r
+ @set "SRC_CONF=%EDK_TOOLS_PATH%\Conf"\r
+)\r
+@if not defined SRC_CONF (\r
+ @echo ERROR : Unable to locate the BaseTools directory tree\r
+ @goto ExitFailure\r
+)\r
+\r
+@REM The script will test to see if the files exist, and also use the RESET_ENVIRONMENT flag\r
+@REM to overwrite the WORKSPACE\Conf *.txt files.\r
+@call "%WORKSPACE%\BaseTools\Scripts\ShowEnvironment.bat"\r
+@if errorlevel 1 (\r
+ @echo Unable to copy the template files from "%SRC_CONF%" to "%WORKSPACE%\Conf"\r
+ @goto ExitFailure\r
+)\r
+@set SRC_CONF=\r
+\r
+@REM Set up Visual Studio if required to build the Nt32Pkg/Nt32Pkg.dsc emulator\r
+@if "%NT32PKG%"=="TRUE" (\r
+ @if not defined VSINSTALLDIR @set "PATH=%ORIGINAL_PATH%"\r
+ @if not defined NT32_X64 @call "%WORKSPACE%\BaseTools\get_vsvars.bat"\r
+ @if defined NT32_X64 call "%WORKSPACE%\BaseTools\Scripts\SetVisualStudio.bat\r
+ @set NT32_X64=\r
+)\r
+@if "%NT32PKG%"=="TRUE" (\r
+ @if not defined VS_PATH set "VS_PATH=%PATH%"\r
+)\r
+@if defined VS_PATH @set "PATH=%VS_PATH%"\r
+@if not defined VS_PATH @set "PATH=%ORIGINAL_PATH%"\r
+@set "PATH=%EDK_TOOLS_PATH%\Bin\Win32;%PATH%"\r
+\r
+@if "%REBUILD_TOOLS%"=="TRUE" @goto Rebuild\r
+@if "%SVN_PULL%"== "TRUE" (\r
+ if defined PYTHONHOME (\r
+ @REM Use the python script if possible to test is the svn command is available, if it fails, the user may be\r
+ @REM able to rebuild the Win32 binaries\r
+ @call "%WORKSPACE%\BaseTools\Scripts\UpdateBuildVersions.py" --svn-test -v\r
+ @if errorlevel 1 (\r
+ @echo ERROR : The command-line svn tool is not available and the Win32 binaries do not exist\r
+ @echo Please re-run this script again with the --rebuild option to attempt to build \r
+ @echo the binaries\r
+ @echo.\r
+ @goto ExitFailure\r
+ )\r
+ @if exist %EDK_TOOLS_PATH%\Bin\Win32 @rmdir /S /Q %EDK_TOOLS_PATH%\Bin\Win32\r
+ @call svn co https://svn.code.sf.net/p/edk2-toolbinaries/code/trunk/Win32 "%EDK_TOOLS_PATH%\Bin\Win32"\r
+ ) else (\r
+ @call svn co https://svn.code.sf.net/p/edk2-toolbinaries/code/trunk/Win32 "%EDK_TOOLS_PATH%\Bin\Win32"\r
+ @if errorlevel 1 (\r
+ @echo ERROR : The command-line svn tool is not available and the Win32 binaries do not exist\r
+ @echo Python does not appear to be available either. This script cannot be used to\r
+ @echo build the Win32 binaries or to obtain them from this repository:\r
+ @echo https://svn.code.sf.net/p/edk2-toolbinaries/code/trunk/Win32\r
+ @goto ExitFailure\r
+ )\r
+ )\r
+ @goto ShowAndExit\r
+)\r
+\r
+@if not "%REBUILD_TOOLS%"=="TRUE" @goto ShowAndExit\r
+\r
+@REM The following code is used to rebuild the Win32 BaseTools binaries - check that required tools are available\r
+:Rebuild\r
+@if not defined BASE_TOOLS_PATH @set "BASE_TOOLS_PATH=%WORKSPACE%\BaseTools"\r
+@if not exist "%BASE_TOOLS_PATH%\Source" @goto NoBaseTools\r
+@endlocal\r
+@if not defined VCINSTALLDIR @goto NoVisualStudio\r
+@if not defined PYTHONHOME @goto NoPython\r
+@if not exist "%PYTHONHOME%\python.exe" @goto BadPython\r
+@REM python.exe has been located, now make sure it's in the PATH\r
+@call python --version > nul 2>&1\r
+@if errorlevel 1 @set "PATH=%PYTHONHOME%\python.exe;%PATH%"\r
+@if not defined PYTHON_FREEZER_PATH (\r
+ @if not exist %PYTHONHOME%\Scripts\cxfreeze.bat @goto NoCxFreeze\r
+ @set PYTHON_FREEZER_PATH=%PYTHONHOME%\Scripts\r
+)\r
+@call "%WORKSPACE%\BaseTools\Scripts\SetVisualStudio.bat"\r
+@if errorlevel 1 @goto ExitFailure\r
+\r
+:ShowAndExit\r
+@call "%WORKSPACE%\BaseTools\Scripts\ShowEnvironment.bat"\r
+\r
+@REM #########################################################################################\r
+@REM EXIT ROUTINES\r
+@REM #########################################################################################\r
+:ExitSuccess\r
+@set SCRIPT_NAME=\r
+@set SCRIPT_VERSION=\r
+@set SVN_REVISION=\r
+@set RESET_ENVIRONMENT=\r
+@set RECONFIG=\r
+@set NT32PKG=\r
+@set NT32_64=\r
+@set BUILD_TOOLS_WITH=\r
+@set LOCATION=\r
+@set REBUILD_TOOLS=\r
+@set SVN_PULL=\r
+@set SRC_CONF=\r
+@set ARGUMENT=\r
+@set SCRIPT=\r
+@set LIST_VS_VERSIONS=\r
+@set PYTHON_FREEZER_PATH=\r
+@echo on\r
+@exit /B 0\r
+\r
+:ExitFailure\r
+@set SCRIPT_NAME=\r
+@set SCRIPT_VERSION=\r
+@set SVN_REVISION=\r
+@set RESET_ENVIRONMENT=\r
+@set RECONFIG=\r
+@set NT32PKG=\r
+@set NT32_64=\r
+@set BUILD_TOOLS_WITH=\r
+@set LOCATION=\r
+@set REBUILD_TOOLS=\r
+@set SVN_PULL=\r
+@set SRC_CONF=\r
+@set ARGUMENT=\r
+@set SCRIPT=\r
+@set LIST_VS_VERSIONS=\r
+@set PYTHON_FREEZER_PATH=\r
+@echo on\r
+@exit /B 1\r