]> git.proxmox.com Git - mirror_edk2.git/blobdiff - Edk2Setup.bat
SignedCapsulePkg: Replace [Ascii|Unicode]ValueToString
[mirror_edk2.git] / Edk2Setup.bat
index 0aa786d9ab94fbcec87314f31a9704a948904228..017e88de86c4b8495ec50e26a02ba543acb00f81 100755 (executable)
@@ -27,6 +27,7 @@
 @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 (C) Copyright 2016 Hewlett Packard Enterprise Development LP<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
 @set SRC_CONF=\r
 @set ARGUMENT=\r
 @set SCRIPT=EDKSETUP_BAT\r
+@set PYTHON_BUILD=\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 defined WORKSPACE (\r
+  @set "WORKSPACE=%CD%"\r
+)\r
+@if not exist "%BASE_TOOLS_PATH%" (\r
+  @if exist "%WORKSPACE%\BaseTools" (\r
+    set "BASE_TOOLS_PATH=%WORKSPACE%\BaseTools"\r
+  ) else (\r
+    @if defined PACKAGES_PATH (\r
+      @for %%i IN (%PACKAGES_PATH%) DO (\r
+        @if exist %%~fi\BaseTools (\r
+          @set BASE_TOOLS_PATH=%%~fi\BaseTools\r
+          @goto checkBaseTools\r
+        )\r
+      )\r
+    )\r
+  )\r
+)\r
+:checkBaseTools\r
+@if not defined BASE_TOOLS_PATH (\r
+  @echo.\r
+  @echo !!! ERROR !!! The BaseTools Package was not found !!!\r
+  @echo.\r
+  @goto ExitFailure\r
+)\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
+@@if not defined EDK_TOOLS_PATH @set "EDK_TOOLS_PATH=%BASE_TOOLS_PATH%"\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
 @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
+@call "%BASE_TOOLS_PATH%\Scripts\ShowEnvironment.bat"\r
 @set HIDE_PATH=\r
 @goto ExitSuccess\r
 \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
+@REM call set_vsprefix_envs.bat to set up the PREFIX env for VS tool path.\r
+@IF NOT exist "%EDK_TOOLS_PATH%\set_vsprefix_envs.bat" (\r
+  @echo.\r
+  @echo !!! ERROR !!! The set_vsprefix_envs.bat was not found !!!\r
+  @echo.\r
+  @goto ExitFailure\r
 )\r
+@call %EDK_TOOLS_PATH%\set_vsprefix_envs.bat\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
 @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
+    @if exist "%BASE_TOOLS_PATH%\Conf" (\r
+        @set "SRC_CONF=%BASE_TOOLS_PATH%\Conf"\r
     )\r
 ) else (\r
     @set "SRC_CONF=%EDK_TOOLS_PATH%\Conf"\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
+@call "%BASE_TOOLS_PATH%\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
 @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
+    @if not defined NT32_X64 @call "%BASE_TOOLS_PATH%\get_vsvars.bat"\r
+    @if defined NT32_X64 call "%BASE_TOOLS_PATH%\Scripts\SetVisualStudio.bat"\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
+@if not defined EDK_TOOLS_BIN (\r
+  @if exist %EDK_TOOLS_PATH%\Bin\Win32 (\r
+    @set EDK_TOOLS_BIN=%EDK_TOOLS_PATH%\Bin\Win32\r
+  ) else (\r
+    @echo.\r
+    @echo !!! ERROR !!! Cannot find BaseTools Bin Win32!!!\r
+    @echo Please check the directory %EDK_TOOLS_PATH%\Bin\Win32\r
+    @echo Or configure EDK_TOOLS_BIN env to point Win32 directory.\r
+    @echo. \r
+    @goto ExitFailure\r
+  )\r
+)\r
+@set "PATH=%EDK_TOOLS_BIN%;%PATH%"\r
+\r
+@if NOT EXIST "%EDK_TOOLS_BIN%\build.exe" @set PYTHON_BUILD=TRUE\r
+@if NOT EXIST "%EDK_TOOLS_BIN%\GenFds.exe" @set PYTHON_BUILD=TRUE\r
+@if NOT EXIST "%EDK_TOOLS_BIN%\TargetTool.exe" @set PYTHON_BUILD=TRUE\r
+@if NOT EXIST "%EDK_TOOLS_BIN%\Trim.exe" @set PYTHON_BUILD=TRUE\r
+\r
+@if not defined PYTHON_BUILD goto SvnPull\r
+\r
+@echo  !!! WARNING !!! Setup environment to run Python scripts directly.\r
+\r
+@if not defined PYTHON_HOME (\r
+  @if defined PYTHONHOME (\r
+    @set PYTHON_HOME=%PYTHONHOME%\r
+  ) else (\r
+    @echo.\r
+    @echo  !!! ERROR !!! PYTHON_HOME is required to build or execute the tools, please set it. !!!\r
+    @echo.\r
+    @goto ExitFailure\r
+  )\r
+)\r
+\r
+@set PATH=%PATH%;%BASE_TOOLS_PATH%\BinWrappers\WindowsLike\r
+@set BASETOOLS_PYTHON_SOURCE=%BASE_TOOLS_PATH%\Source\Python\r
+@set PYTHONPATH=%BASETOOLS_PYTHON_SOURCE%;%PYTHONPATH%\r
 \r
+:SvnPull\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
+        @call "%BASE_TOOLS_PATH%\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
 \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 exist "%PYTHONHOME%\Scripts\cxfreeze.bat" @goto NoCxFreeze\r
     @set "PYTHON_FREEZER_PATH=%PYTHONHOME%\Scripts"\r
 )\r
-@call "%WORKSPACE%\BaseTools\Scripts\SetVisualStudio.bat"\r
+@call "%BASE_TOOLS_PATH%\Scripts\SetVisualStudio.bat"\r
 @if errorlevel 1 @goto ExitFailure\r
 \r
 :ShowAndExit\r
-@call "%WORKSPACE%\BaseTools\Scripts\ShowEnvironment.bat"\r
+@call "%BASE_TOOLS_PATH%\Scripts\ShowEnvironment.bat"\r
 \r
 @REM #########################################################################################\r
 @REM EXIT ROUTINES\r
 @set SCRIPT=\r
 @set LIST_VS_VERSIONS=\r
 @set PYTHON_FREEZER_PATH=\r
+@set PYTHON_BUILD=\r
 @echo on\r
 @exit /B 0\r
 \r
 @set SCRIPT=\r
 @set LIST_VS_VERSIONS=\r
 @set PYTHON_FREEZER_PATH=\r
+@set PYTHON_BUILD=\r
 @echo on\r
 @exit /B 1\r