mirror of
https://github.com/tianocore/edk2.git
synced 2025-08-26 13:14:41 +00:00

Some checks are pending
CodeQL / Analyze (IA32, CryptoPkg) (push) Waiting to run
CodeQL / Analyze (IA32, MdeModulePkg) (push) Waiting to run
CodeQL / Analyze (IA32,X64, DynamicTablesPkg) (push) Waiting to run
CodeQL / Analyze (IA32,X64, FatPkg) (push) Waiting to run
CodeQL / Analyze (IA32,X64, FmpDevicePkg) (push) Waiting to run
CodeQL / Analyze (IA32,X64, IntelFsp2Pkg) (push) Waiting to run
CodeQL / Analyze (IA32,X64, IntelFsp2WrapperPkg) (push) Waiting to run
CodeQL / Analyze (IA32,X64, MdePkg) (push) Waiting to run
CodeQL / Analyze (IA32,X64, PcAtChipsetPkg) (push) Waiting to run
CodeQL / Analyze (IA32,X64, PrmPkg) (push) Waiting to run
CodeQL / Analyze (IA32,X64, SecurityPkg) (push) Waiting to run
CodeQL / Analyze (IA32,X64, ShellPkg) (push) Waiting to run
CodeQL / Analyze (IA32,X64, SourceLevelDebugPkg) (push) Waiting to run
CodeQL / Analyze (IA32,X64, StandaloneMmPkg) (push) Waiting to run
CodeQL / Analyze (IA32,X64, UefiCpuPkg) (push) Waiting to run
CodeQL / Analyze (IA32,X64, UnitTestFrameworkPkg) (push) Waiting to run
CodeQL / Analyze (X64, CryptoPkg) (push) Waiting to run
CodeQL / Analyze (X64, MdeModulePkg) (push) Waiting to run
UPL Build / Build UPL VS2022 (FIT_BUILD=FALSE, windows-latest, 3.12, DEBUG, VS2022) (push) Waiting to run
UPL Build / Build UPL VS2022 (FIT_BUILD=TRUE, windows-latest, 3.12, DEBUG, VS2022) (push) Waiting to run
UPL Build / Build UPL GCC (FIT_BUILD=FALSE, ubuntu-latest, 3.12, DEBUG, GCC) (push) Waiting to run
UPL Build / Build UPL GCC (FIT_BUILD=TRUE, ubuntu-latest, 3.12, DEBUG, GCC) (push) Waiting to run
Adds support for building the C language BaseTools for Windows using toolchains based on mingw-w64. Mingw-w64 is a collection of header files, libraries, and tools that when combined with a compiler enable development of Windows software. Mingw-w64 is a fork of the original MinGW (Minimalist GNU for Windows). Most active development on MinGW has ceased and mingw-w64 is now the actively maintained successor. Mingw-w64 provides a libc implementation built on top of Microsoft's UCRT (Universal C Runtime) with all nessesary compiler bindings needed to support the C++11 feature set. Modern mingw-w64 development appears to have coalesced around MSYS2, which produces a distributions of both GCC and LLVM/Clang that use mingw-w64 to target the Windows OS. This MSYS2 Clang distribution has a UNIX-like directory layout and includes Windows binaries of GNU Make. Combined with the open source licensing, MSYS2's Clang distribution is a highly attractive choice as an alternative Windows SDK for open source projects such as TianoCore. If one wishes to use EDK II to build UEFI firmware on the Windows platform, then the C BaseTools need to be compiled as Windows applications. This includes the PcdValueInit.exe program, which needs to be recompiled every time a firmware build is run in order to regenerate the initial values for structured PCDs. Currently, BaseTools only supports the Visual C++ toolchain on the Windows platform. The following new features have been added to enable usage of the toolchains derived from mingw-w64: - Fixes to the BaseTools C source code to support the use of a GCC-style compiler on the Windows OS. - The GNU Make-style Makefiles for the C BaseTools have been modified to support Windows. Both GCC + mingw-w64 and Clang + mingw-w64 have been tested and confirmed to build a working BaseTools. - BaseTools now supports generating GNU Make-style Makefiles on the Windows platform for the purpose of building firmware. - edksetup.bat has been modified to optionally build BaseTools via mingw-w64. There is no impact to the existing support for Visual C++ and Visual C++ remains the default toolchain. Usage Instructions: For the vast majority of users, the only system setup change nessesary to use a mingw-w64 toolchain is to set the BASETOOLS_MINGW_PATH to the directory containing the desired mingw-w64 based toolchain. A new command line argument has been added to edksetup.bat: Mingw-w64 If this command line argument is set, then the script will set the BASETOOLS_MINGW_BUILD environment variable. The user can also opt to set this environment variable manually before running edksetup.bat If BASETOOLS_MINGW_BUILD is defined, then the BASETOOLS_MINGW_PATH environment variable must point to the directory containing the mingw-w64 toolchain. If CLANG_BIN is not defined and %BASETOOLS_MINGW_PATH%\bin\clang.exe exists, then edksetup.bat will set CLANG_BIN=%BASETOOLS_MINGW_PATH%\bin\ This removes the requirement to configure the CLANG_BIN environment variable manually in order to run a CLANGPDB or CLANGDWARF build if one has the MSYS2 Clang distribution installed. If one wishes to use a different copy of Clang (for example official LLVM binaries) to build firmware and only use the MSYS2 Clang to build BaseTools, then one can continue to set the CLANG_BIN environment variable, same as before. I have tested the MSYS2 Clang distribution against the official LLVM distribution and can confirm that if the compiler version is the same the emitted machine code is identical between the two. Interestingly, the MSYS2 Clang distribution emits the path to the PDB file using "/" as the path seperator instead of "\". That appears to be the only difference in output. Therefore, using the MSYS2 Clang distribution to compile firmware seems a reasonable choice. If CLANG_HOST_BIN is not defined and BASETOOLS_MINGW_BUILD is defined and %BASETOOLS_MINGW_PATH%\bin\mingw32-make.exe exists, then edksetup.bat will add %BASETOOLS_MINGW_PATH%\bin\ to the PATH and set CLANG_HOST_BIN=mingw32- This enable usage of the GNU Make included in the mingw-w64 toolchain to build firmware in addition to BaseTools. if BASETOOLS_MINGW_BUILD is not defined, edksetup.bat will continue to set CLANG_HOST_BIN=n, which uses nmake to build firmware. This behavior can be overridden by manually setting the value of CLANG_HOST_BIN before executing edksetup.bat if one wishes to use a specific Make utility for the CLANGPDB/CLANGDWARF toolchains. References: - https://www.mingw-w64.org/ - https://www.msys2.org/ Co-authored-by: Sandesh Jain <sandesh.jain@intel.com> Signed-off-by: Nate DeSimone <nathaniel.l.desimone@intel.com>
165 lines
4.5 KiB
Batchfile
Executable File
165 lines
4.5 KiB
Batchfile
Executable File
@REM @file
|
|
@REM Windows batch file to setup a WORKSPACE environment
|
|
@REM
|
|
@REM Copyright (c) 2006 - 2025, Intel Corporation. All rights reserved.<BR>
|
|
@REM (C) Copyright 2016 Hewlett Packard Enterprise Development LP<BR>
|
|
@REM SPDX-License-Identifier: BSD-2-Clause-Patent
|
|
@REM
|
|
|
|
@REM set CYGWIN_HOME=C:\cygwin
|
|
|
|
@REM usage:
|
|
@REM edksetup.bat [--nt32] [AntBuild] [Rebuild] [ForceRebuild] [Reconfig]
|
|
@REM if the argument, skip is present, only the paths and the
|
|
@REM test and set of environment settings are performed.
|
|
|
|
@REM ##############################################################
|
|
@REM # You should not have to modify anything below this line
|
|
@REM #
|
|
|
|
@echo off
|
|
|
|
@REM
|
|
@REM Set the WORKSPACE to the current working directory
|
|
@REM
|
|
pushd .
|
|
cd %~dp0
|
|
|
|
if not defined WORKSPACE (
|
|
goto SetWorkSpace
|
|
)
|
|
|
|
if %WORKSPACE% == %CD% (
|
|
@REM Workspace is not changed.
|
|
goto ParseArgs
|
|
)
|
|
|
|
:SetWorkSpace
|
|
@REM set new workspace
|
|
if not defined WORKSPACE (
|
|
set WORKSPACE=%CD%
|
|
)
|
|
|
|
:ParseArgs
|
|
if /I "%1"=="-h" goto Usage
|
|
if /I "%1"=="-help" goto Usage
|
|
if /I "%1"=="--help" goto Usage
|
|
if /I "%1"=="/h" goto Usage
|
|
if /I "%1"=="/?" goto Usage
|
|
if /I "%1"=="/help" goto Usage
|
|
|
|
if /I "%1"=="NewBuild" shift
|
|
if not defined EDK_TOOLS_PATH (
|
|
goto SetEdkToolsPath
|
|
) else (
|
|
goto checkNt32Flag
|
|
)
|
|
|
|
:SetEdkToolsPath
|
|
if %WORKSPACE:~-1% EQU \ (
|
|
@set EDK_BASETOOLS=%WORKSPACE%BaseTools
|
|
) else (
|
|
@set EDK_BASETOOLS=%WORKSPACE%\BaseTools
|
|
)
|
|
if exist %EDK_BASETOOLS% (
|
|
set EDK_TOOLS_PATH=%EDK_BASETOOLS%
|
|
set EDK_BASETOOLS=
|
|
) else (
|
|
if defined PACKAGES_PATH (
|
|
for %%i IN (%PACKAGES_PATH%) DO (
|
|
if exist %%~fi\BaseTools (
|
|
set EDK_TOOLS_PATH=%%~fi\BaseTools
|
|
goto checkNt32Flag
|
|
)
|
|
)
|
|
) else (
|
|
echo.
|
|
echo !!! ERROR !!! Cannot find BaseTools !!!
|
|
echo.
|
|
goto BadBaseTools
|
|
)
|
|
)
|
|
|
|
:checkNt32Flag
|
|
if exist %EDK_TOOLS_PATH%\Source set BASE_TOOLS_PATH=%EDK_TOOLS_PATH%
|
|
|
|
:checkBaseTools
|
|
IF NOT EXIST "%EDK_TOOLS_PATH%\toolsetup.bat" goto BadBaseTools
|
|
call %EDK_TOOLS_PATH%\toolsetup.bat %*
|
|
if %ERRORLEVEL% NEQ 0 goto end
|
|
if /I "%1"=="Reconfig" shift
|
|
goto check_NASM
|
|
goto check_cygwin
|
|
|
|
:BadBaseTools
|
|
@REM
|
|
REM Need the BaseTools Package in order to build
|
|
@REM
|
|
@echo.
|
|
@echo !!! ERROR !!! The BaseTools Package was not found !!!
|
|
@echo.
|
|
@echo Set the system environment variable, EDK_TOOLS_PATH to the BaseTools,
|
|
@echo For example,
|
|
@echo set EDK_TOOLS_PATH=C:\MyTools\BaseTools
|
|
@echo The setup script, toolsetup.bat must reside in this folder.
|
|
@echo.
|
|
goto end
|
|
|
|
:check_NASM
|
|
if not defined NASM_PREFIX (
|
|
@echo.
|
|
@echo !!! WARNING !!! NASM_PREFIX environment variable is not set
|
|
@if exist "C:\nasm\nasm.exe" @set "NASM_PREFIX=C:\nasm\"
|
|
@if exist "C:\nasm\nasm.exe" @echo Found nasm.exe, setting the environment variable to C:\nasm\
|
|
@if not exist "C:\nasm\nasm.exe" echo Attempting to build modules that require NASM will fail.
|
|
)
|
|
|
|
:check_cygwin
|
|
if defined CYGWIN_HOME (
|
|
if not exist "%CYGWIN_HOME%" (
|
|
@echo.
|
|
@echo !!! WARNING !!! CYGWIN_HOME not found, gcc build may not be used !!!
|
|
@echo.
|
|
)
|
|
) else (
|
|
if exist c:\cygwin (
|
|
set CYGWIN_HOME=c:\cygwin
|
|
) else (
|
|
@echo.
|
|
@echo !!! WARNING !!! No CYGWIN_HOME set, gcc build may not be used !!!
|
|
@echo.
|
|
)
|
|
)
|
|
|
|
:cygwin_done
|
|
if /I "%1"=="Rebuild" shift
|
|
if /I "%1"=="ForceRebuild" shift
|
|
if /I "%1"=="Mingw-w64" shift
|
|
if /I "%1"=="VS2022" shift
|
|
if /I "%1"=="VS2019" shift
|
|
if /I "%1"=="VS2017" shift
|
|
if /I "%1"=="VS2015" shift
|
|
if "%1"=="" goto end
|
|
|
|
:Usage
|
|
@echo.
|
|
@echo Usage: "%0 [-h | -help | --help | /h | /help | /?] [Reconfig] [Rebuild] [ForceRebuild] [Mingw-w64] [VS2022] [VS2019] [VS2017] [VS2015]"
|
|
@echo.
|
|
@echo Reconfig Reinstall target.txt, tools_def.txt and build_rule.txt.
|
|
@echo Rebuild Perform incremental rebuild of BaseTools binaries.
|
|
@echo ForceRebuild Force a full rebuild of BaseTools binaries.
|
|
@echo Mingw-w64 Build BaseTools binaries using mingw-w64.
|
|
@echo VS2015 Set the env for VS2015 build.
|
|
@echo VS2017 Set the env for VS2017 build.
|
|
@echo VS2019 Set the env for VS2019 build.
|
|
@echo VS2022 Set the env for VS2022 build.
|
|
@echo.
|
|
@echo Note that target.template, tools_def.template and build_rules.template
|
|
@echo will only be copied to target.txt, tools_def.txt and build_rule.txt
|
|
@echo respectively if they do not exist. Use option [Reconfig] to force the copy.
|
|
@echo.
|
|
goto end
|
|
|
|
:end
|
|
popd
|