build -a X64 -p AppPkg\AppPkg.dsc -t VS2019 (特别注意, VS2019 必须大写)
之后就遇到了第一个错误:
“Socket.c
c:\buildbs\edk202008\StdLib\EfiSocketLib\Socket.c(573): error C2220: the following warning is treated as an error
c:\buildbs\edk202008\StdLib\EfiSocketLib\Socket.c(573): warning C4459: declaration of 'errno' hides global declaration
c:\buildbs\edk202008\StdLib\Include\errno.h(43): note: see declaration of 'errno'
c:\buildbs\edk202008\StdLib\EfiSocketLib\Socket.c(1337): warning C4459: declaration of 'errno' hides global declaration
c:\buildbs\edk202008\StdLib\Include\errno.h(43): note: see declaration of 'errno'
c:\buildbs\edk202008\StdLib\EfiSocketLib\Socket.c(1480): warning C4459: declaration of 'errno' hides global declaration
c:\buildbs\edk202008\StdLib\Include\errno.h(43): note: see declaration of 'errno'
c:\buildbs\edk202008\StdLib\EfiSocketLib\Socket.c(1892): warning C4459: declaration of 'errno' hides global declaration
c:\buildbs\edk202008\StdLib\Include\errno.h(43): note: see declaration of 'errno'
c:\buildbs\edk202008\StdLib\EfiSocketLib\Socket.c(2754): warning C4459: declaration of 'errno' hides global declaration
c:\buildbs\edk202008\StdLib\Include\errno.h(43): note: see declaration of 'errno'
c:\buildbs\edk202008\StdLib\EfiSocketLib\Socket.c(2974): warning C4459: declaration of 'errno' hides global declaration
c:\buildbs\edk202008\StdLib\Include\errno.h(43): note: see declaration of 'errno'
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.26.28801\bin\Hostx86\x64\cl.exe"' : return code '0x2'
Stop.”
解决方法是:在 StdLib.inc 末尾添加下面的内容:
# Temporarily restrict compiler warnings to those produced by VS2012.
# Code that fails when these flags are removed will have to be rewritten
# in order to pass. This may be as simple as renaming an object, but may
# require more significant changes.
MSFT:*_VS2015_*_CC_FLAGS = /Wv:11
MSFT:*_VS2015x86_*_CC_FLAGS = /Wv:11
MSFT:*_VS2015xASL_*_CC_FLAGS = /Wv:11
MSFT:*_VS2015x86xASL_*_CC_FLAGS = /Wv:11
#LABZ_Start
# Temporarily restrict compiler warnings to those produced by VS2012.
# Code that fails when these flags are removed will have to be rewritten
# in order to pass. This may be as simple as renaming an object, but may
# require more significant changes.
MSFT:*_VS2019_*_CC_FLAGS = /Wv:11
MSFT:*_VS2019x86_*_CC_FLAGS = /Wv:11
MSFT:*_VS2019xASL_*_CC_FLAGS = /Wv:11
MSFT:*_VS2019x86xASL_*_CC_FLAGS = /Wv:11
#LABZ_End
Force the linker to include all object files in the static library in the linked executable.
Syntax
/WHOLEARCHIVE /WHOLEARCHIVE:library
Arguments
library An optional pathname to a static library. The linker includes every object file from this library.
Remarks
The /WHOLEARCHIVE option forces the linker to include every object file from either a specified static library, or if no library is specified, from all static libraries specified to the LINK command. To specify the /WHOLEARCHIVE option for multiple libraries, you can use more than one /WHOLEARCHIVE switch on the linker command line. By default, the linker includes object files in the linked output only if they export symbols referenced by other object files in the executable. The /WHOLEARCHIVE option makes the linker treat all object files archived in a static library as if they were specified individually on the linker command line.
The /WHOLEARCHIVE option can be used to re-export all the symbols from a static library. This allows you to make sure that all of your library code, resources, and metadata are included when you create a component from more than one static library. If you see warning LNK4264 when you create a static library that contains Windows Runtime components for export, use the /WHOLEARCHIVE option when linking that library into another component or app.
The /WHOLEARCHIVE option was introduced in Visual Studio 2015 Update 2.
By default, strings and char’s are transmitted (not coded) as 7-bit ASCII where all characters above 127 are illegal and will be replaced with “?” (code 63) – even though you have defined 8 data bits! Therefore, you cannot use a string or char related method to send or read binary information (0-255) unless you change the encoding to something, which include all values up to 255 like:
YourSerialPort.Encoding = System.Text.Encoding.GetEncoding(28591) ' or
YourSerialPort.Encoding = System.Text.Encoding.GetEncoding(1252)
## Tool entrance method
#
# This method mainly dispatch specific methods per the command line options.
# If no error found, return zero value so the caller of this tool can know
# if it's executed successfully or not.
#
# @retval 0 Tool was successful
# @retval 1 Tool failed
#
def Main():
测试结果:
这里证明了上述代码就是程序入口
代码中MyBuild.Launch()是具体执行 build 动作的地方:
MyBuild = Build(Target, Workspace, Option)
GlobalData.gCommandLineDefines['ARCH'] = ' '.join(MyBuild.ArchList)
if not (MyBuild.LaunchPrebuildFlag and os.path.exists(MyBuild.PlatformBuildPath)):
MyBuild.Launch()
实验确定对应代码:
## Launch the module or platform build
#
def Launch(self):
if not self.ModuleFile:
if not self.SpawnMode or self.Target not in ["", "all"]:
self.SpawnMode = False
self._BuildPlatform()
else:
self._MultiThreadBuildPlatform()
self.CreateGuidedSectionToolsFile()
else:
self.SpawnMode = False
self._BuildModule()
## Build a platform in multi-thread mode
#
def _MultiThreadBuildPlatform(self):
SaveFileOnChange(self.PlatformBuildPath, '# DO NOT EDIT \n# FILE auto-generated\n', False)
最近发现一个开源的 Windows 下查看 ACPI table 的工具 firmwaretables 在下面的链接可以下载到:
https://github.com/vurdalakov/firmwaretables
Lists, extracts and decodes system firmware tables.
Usage:
firmwaretables <-list | -all | -save | -decode <table type> <table id> [filename]> [-silent]
Commands:
-l – list available system firmware tables
-a – save all system firmware tables to files
-s – save specific system firmware table to file
-d – decode specific system firmware table
Options:
-silent – no error messages are shown; check exit code
Exit codes:
0 – operation succeeded
1 – operation failed
-1 – invalid command line syntax