Skip to content

Commit

Permalink
Add VS Compiler prebuild plugins and extdeps for GCC to match edk2
Browse files Browse the repository at this point in the history
  • Loading branch information
uefibot authored and kenlautner committed Jul 2, 2024
1 parent 3f36dc0 commit f22ba83
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 7 deletions.
50 changes: 46 additions & 4 deletions BaseTools/Conf/build_rule.template
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>
# Portions copyright (c) 2008 - 2010, Apple Inc. All rights reserved.<BR>
# Copyright (c) 2020, ARM Ltd. All rights reserved.<BR>
# Copyright (c) Microsoft Corporation
# SPDX-License-Identifier: BSD-2-Clause-Patent
#

Expand Down Expand Up @@ -108,6 +109,13 @@
## Build Rule Version Number
# build_rule_version=0.1
#
#
# 1.00 - Increase this version tag any time you want user to get warning about updating this file in the Conf dir. By default it does not do update existing conf dirs.
# 1.01 - Add MASM for Microsoft ARM assembly files. "MS-ARMx-Assembly-Code-File.COMMON.COMMON"
# 2.00 - Add .slib and .efi support in the sources file
# 2.01 - Add support for DEPS_FLAGS as well as

#!VERSION=2.01

[C-Code-File]
<InputFile>
Expand Down Expand Up @@ -170,8 +178,9 @@
# The C pre-processor is used to insert code snippets in assembly from preprocessor macros. Unfortunately
# the preprocessor doesn't also insert CR/LF and Microsoft's assembler expects each instruction to be on its own
# line. We search and replace a special string (__CR__) with CR.
type ${d_path}(+)${s_base}.i | python -c "import sys; print sys.stdin.read().replace('__CR__','\n')" > ${d_path}(+)${s_base}.ii
type ${d_path}(+)${s_base}.i | python -c "import sys; print (sys.stdin.read().replace('__CR__','\n'))" > ${d_path}(+)${s_base}.ii
Trim --trim-long --source-code -o ${d_path}(+)${s_base}.iii ${d_path}(+)${s_base}.ii
# NOTE- need to review why the command is different. Missing /Fo and /I options
"$(ASM)" $(ASM_FLAGS) -o ${dst} $(INC) ${d_path}(+)${s_base}.iii

[Assembly-Code-File.COMMON.COMMON]
Expand Down Expand Up @@ -363,7 +372,7 @@
<Command.XCODE>
"$(DLINK)" $(DLINK_FLAGS) -o ${dst} $(DLINK_SPATH) -filelist $(STATIC_LIBRARY_FILES_LIST) $(DLINK2_FLAGS)


[Static-Library-File.SEC.AARCH64, Static-Library-File.PEI_CORE.AARCH64, Static-Library-File.PEIM.AARCH64,Static-Library-File.SEC.ARM, Static-Library-File.PEI_CORE.ARM, Static-Library-File.PEIM.ARM]
<InputFile>
*.lib
Expand Down Expand Up @@ -398,7 +407,7 @@
<Command.XCODE>
"$(DLINK)" -o ${dst} $(DLINK_FLAGS) $(DLINK_SPATH) -filelist $(STATIC_LIBRARY_FILES_LIST) $(DLINK2_FLAGS)


[Dynamic-Library-File]
<InputFile>
?.dll
Expand Down Expand Up @@ -539,7 +548,7 @@
"$(MTOC)" -subsystem $(MODULE_TYPE) $(MTOC_FLAGS) $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.dll $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.pecoff
"$(GENFW)" -o ${dst} -c $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.pecoff $(GENFW_FLAGS)


[Masm16-Code-File]
<InputFile>
?.asm16, ?.Asm16, ?.ASM16, ?.s16, ?.S16
Expand Down Expand Up @@ -573,6 +582,39 @@
"$(SLINK)" $(SLINK_FLAGS) $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.slib $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.obj
otool -t $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.slib | hex2bin.py ${dst}

#MU_CHANGE
# Build Rule to support using precompiled
# LIB files. Just copies the LIB from src to output
# so the rest of the build system works.
#
[Precompiled-Lib-File]
<InputFile>
*.slib

<ExtraDependency>

<OutputFile>
$(OUTPUT_DIR)(+)$(MODULE_NAME).lib

<Command>
-$(CP) ${src} ${dst}

#MU_CHANGE
# Build Rule to support using precompiled
# EFI files. Just copies the EFI from src to output
# so the rest of the build system works.
#
[Precompiled-Efi-File]
<InputFile>
?.preefi

<ExtraDependency>

<OutputFile>
$(OUTPUT_DIR)(+)${s_base}.efi

<Command>
-$(CP) ${src} ${dst}

[Nasm-to-Binary-Code-File]
<InputFile>
Expand Down
7 changes: 4 additions & 3 deletions BaseTools/Conf/tools_def.template
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
# - Deprecate GCC48, GCC49 and GCC5.
# 3.01 - Update toolchain for VS2022
# 3.02 - Enable stack cookies for IA32, ARM, and AARCH64 builds for GCC and MSVC
# 3.03 - Remove WHOLEARCHIVE as this breaks the build for VS2017/VS2019 (MU_CHANGE)
#
#!VERSION=3.02

Expand Down Expand Up @@ -467,7 +468,7 @@ NOOPT_VS2015x86_X64_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /IGNORE:4001 /OPT:REF
*_VS2017_*_APP_FLAGS = /nologo /E /TC
*_VS2017_*_PP_FLAGS = /nologo /E /TC /FIAutoGen.h
*_VS2017_*_VFRPP_FLAGS = /nologo /E /TC /DVFRCOMPILE /FI$(MODULE_NAME)StrDefs.h
*_VS2017_*_DLINK2_FLAGS = /WHOLEARCHIVE
# *_VS2017_*_DLINK2_FLAGS = /WHOLEARCHIVE # MU_CHANGE
*_VS2017_*_ASM16_PATH = DEF(VS2017_BIN_IA32)\ml.exe
*_VS2017_*_DEPS_FLAGS = DEF(MSFT_DEPS_FLAGS)
##################
Expand Down Expand Up @@ -608,7 +609,7 @@ NOOPT_VS2017_AARCH64_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /IGNORE:4001 /OPT:REF
*_VS2019_*_APP_FLAGS = /nologo /E /TC
*_VS2019_*_PP_FLAGS = /nologo /E /TC /FIAutoGen.h
*_VS2019_*_VFRPP_FLAGS = /nologo /E /TC /DVFRCOMPILE /FI$(MODULE_NAME)StrDefs.h
*_VS2019_*_DLINK2_FLAGS = /WHOLEARCHIVE
# *_VS2019_*_DLINK2_FLAGS = /WHOLEARCHIVE # MU_CHANGE
*_VS2019_*_ASM16_PATH = DEF(VS2019_BIN_IA32)\ml.exe
*_VS2019_*_DEPS_FLAGS = DEF(MSFT_DEPS_FLAGS)
##################
Expand Down Expand Up @@ -2314,7 +2315,7 @@ RELEASE_XCODE5_X64_CC_FLAGS = -target x86_64-pc-win32-macho -c -Os -W
#################
# ASM 16 linker definitions
#################
*_*_*_ASMLINK_PATH = DEF(WINDDK_BIN16)\link16.exe
*_*_*_ASMLINK_PATH = ENV(LINK_16_PREFIX)link16.exe # MU_CHANGE - change to prefix
*_*_*_ASMLINK_FLAGS = /nologo /tiny

##################
Expand Down

0 comments on commit f22ba83

Please sign in to comment.