EDKII Build Process:EDKII项目源码的配置、编译流程[三]

简介: <p style="margin-top: 0px; margin-bottom: 0px; padding-top: 0px; padding-bottom: 0px; font-family: Tahoma; line-height: 24px; font-size: 12.381px;"><span style="margin: 0px; padding: 0px; list-style

《EDKII Build ProcessEDKII项目源码的配置、编译流程[3]》博文目录:

3. EDKII Build ProcessEDKII项目源码的配置、编译流程)

      ->3.1 The General Process Of EDKII BuildEDKII项目源码的配置、编译一般流程)

            ->3.1.1 Tool chain:BaseTools

            ->3.1.2 Setup build shell environment

            ->3.1.3 Modify Conf Files

            ->3.1.4 Build

      ->3.2 The Process Of EDKII Build on WindowsWindows环境下EDKII项目源码的配置、编译流程)

            ->3.1.1 Tool chain:BaseTools

            ->3.2.2 Setup build shell environment

            ->3.2.3 Modify Conf Files

            ->3.2.4 Build Hello World! (and the rest of MdeModulePkg) 

      ->3.2.4 Build Hello World! (and the rest of MdeModulePkg)

            ->3.3 The Process Of EDKII Build on LinuxLinux环境下EDKII项目源码的配置、编译流程)

            ->3.3.1 Tool chain: Build the EDK II BaseTools

            ->3.3.2 Setup build shell environment

            ->3.3.3 Modify Conf Files

            ->3.3.4 Build Hello World! (and the rest of MdeModulePkg) 

3.1 The General Process Of EDKII BuildEDKII项目源码的配置、编译一般流程)

3.1.1 Tool chain:BaseTools

EDKII_UserManual_0_7》手册第一章《EDKII Introductionoverview中在列举EDKII优势(The features introduced by EDKII include:)最后一条:

更为强大的编译系统(Enhanced build system.):

编译系统是基于跨操作系统平台的python语言。它是用户可以通过修改几个配置文件来选择不同的工具链、编译规则、编译目标对象。(Its infrastructure is based on Python that is independent of the operating system. It exposes several configuration files that a user can utilize to choose the various tool-chains, even the build rule or generated target. )

EDKII工具链包括buildGenFVGenFW等,工具链位于BaseTools目录下,Windows平台下可执行工具位于\edk2\BaseTools\Bin\Win32目录下,Linux平台下可执行工具位于edk2/BaseTools/BinWrappers/PosixLike目录下。如果相应目录下没有这些工具就需要编译BaseTools来获得这些工具。

3.1.2 Setup build shell environment

在工作目录下在命令行下运行环境设置脚本(Run edksetup script from the command line prompt at the Work Space directory)

Windows Comand Prompt: 

D:\edk2> edksetup.bat
Linux like: 

bash$ . edksetup.sh BaseTools

3.1.3 Modify Conf Files 修改配置文件

我们可以通过配置Conf/target.txttools_def.txt文件来指定工具链将指定的包或模块编译成目标平台代码。

3.1.3.1 配置Conf/target.txt文件:

ACTIVE_PLATFORM       = MdeModulePkg/MdeModulePkg.dsc
TOOL_CHAIN_TAG        = GCC46
TARGET_ARCH           = IA32
这样我们可以只在命令行中运行“ build ”命令即可,会读取 Conf/target.txt 文件下这些变量的作为默认编译参数。 [ 这种方式一定程度上简化了编译过程,不必每次都指定当前要编译的模块和目标平台代码,但可能也会缺少下面第二种方式的灵活性 ]

3.1.3.2 检查/修改tools_def.txt确保编译器路径正确Check/Modify tools_def Information

检查相应工具链VS/Gcciasl路径是否正确。

 3.1.4 Build

我们可以通过两种方式来指定工具链将指定的包或模块编译成目标平台代码。

一种方式是配置Conf/target.txt文件,运行“build”命令会解析target.txt读取默认配置参数。

另一种方式是通过“build”命令行指定:

Build命令是编译UEFI工程常用的命令。Build命令有三个常用参数:-a-p-m

*-a(Architecture):用来选择目标平台架构。可供选择的平台架构:IA32(32位X86 CPU)、X64(64位X86_64 CPU)、IPF(Itanium Processor Family)、ARM和EBC(EFI Byte Code);默认的参数在Conf/target.txt中设置。
*-p(Package/Platform):用来指定要编译的package或platform。-p的参数是这个package或platform的.dsc文件;默认的参数在Conf/target.txt中设置。
*-m(Module):用来指定要编译模块。如果不指定-m选项,build将编译.dsc文件指定的所有模块。

Build命令的其他参数:(build -h  查看)

--version                     show program's version number and exit
  -h, --help                  show this help message and exit显示帮助信息。
  -a TARGETARCH,--arch=TARGETARCH
                              选择目标平台架构,该选项被指定会取代Conf/target.txt中的TARGET_ARCH。
  -p PLATFORMFILE,--platform=PLATFORMFILE
                              通过指定.dsc文件指定要编译的package,该选项将会Conf/target.txt文件ACTIVE_PLATFORM。
  -m MODULEFILE, --module=MODULEFILE
                              Build the module specified by the INF file name argument.
  -b BUILDTARGET, --buildtarget=BUILDTARGET
                              选择编译成DEBUG还是RELEASE。指定该选项后会取代target.txt文件中TARGET。
  -t TOOLCHAIN, --tagname=TOOLCHAIN
                              选择tools_def.txt中定义的编译工具,例如VS2012:-t vs2012
  -n THREADNUMBER             编译器使用的线程数量,指定后取代target.txt文件中MAX_CONCURRENT_THREAD_NUMBER指定的线程数量.            
                              Less than 2 will disable multi-thread builds.小于2就禁止多线程编译。
  -u, --skip-autogen          Skip AutoGen step.跳过AutoGen这一步。
  -c, --case-insensitive      Don't check case of file name.文件名不区分大小写。
  -w, --warning-as-error      Treat warning in tools as error.将警告做错误处理。
  -j LOGFILE, --log=LOGFILE
                              Put log in specified file as well as on console.将编译信息输出到文件。
  -s, --silent                Make use of silent mode of (n)make.使用沉默模式执行make或nmake。
  -q, --quiet                 Disable all messages except FATAL ERRORS.编译过程中只显示严重错误信息。
  -d DEBUG, --debug=DEBUG     Enable debug messages at specified level.在指定的级别启用调试消息。
  -D MACROS, --define=MACROS  Macro: "Name [= Value]".定义宏。

3.2 The Process Of EDKII Build on WindowsWindows环境下EDKII项目源码的配置、编译流程)

3.2.1 Tool chain:BaseTools

配置Windows开发环境时,我们没有编译EDKII工具链,因为EDKII源码包中包含了Windows下的EDKII工具链可执行文件。

 

3.2.2 Setup build shell environment

D:\> cd edk2
D:\edk2> edksetup.bat


3.2.3 Modify Conf files

3.2.3.1 Set Build Target Information:配置target.txt文件

通过记事本修改配置目录Conf/下的target.txt filestools_def.txt文件,来配置我们当前要编译的包和使用的相应工具链VS2013(You will need to edit the Conf/tools_def.txt and Conf/target.txt files. These changes will enable the MdeModulePkg to be built using the VS2013.)

You will need to edit the Conf\target.txt file. First, change the ACTIVE_PLATFORM to the MdeModulePkg:

D:\edk2> notepad Conf\target.txt
ACTIVE_PLATFORM should look like this in Conf\target.txt:

ACTIVE_PLATFORM       = MdeModulePkg/MdeModulePkg.dsc
Modify TOOL_CHAIN_TAG in target.txt for the toolchain installed on your system. There are many options, so review the tools_def.txt to find the appropriate toolchain for your system. Search for 'Supported Tool Chains' in tools_def.txt to see the valid options for TOOL_CHAIN_TAG.

TOOL_CHAIN_TAG        = VS2013x86

3.2.3.2 Check/Modify tools_def Information:检查tools_def.txt确保编译器路径正确

检查相应工具链VS2013iasl路径是否正确。

DEFINE VS2013x86_BIN    = C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin
DEFINE VS2013x86_DLL    = C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7 \IDE;DEF(VS2013x86_BIN)
DEFINE VS2013x86_BINX64 = DEF(VS2013x86_BIN)\x86_amd64
 ......
DEFINE WIN_ASL_BIN_DIR         = C:\ASL
DEFINE WIN_IASL_BIN            = DEF(WIN_ASL_BIN_DIR)\iasl.exe
DEFINE WIN_ASL_BIN             = DEF(WIN_ASL_BIN_DIR)\asl.exe

3.2.4 Build Hello World! (and the rest of MdeModulePkg)

Now you should be able to simply run the build command to compile the MdeModulePkg.

D:\edk2> build

As a tangible result of the build, you should have the HelloWorld UEFI application. If you have a UEFI system available to you which matches the processor architecture that you built, then this application should be able to run successfully under the shell.

D:\edk2> dir /s Build\MdeModule\HelloWorld.efi

[注:dir /s   specified directory显示指定目录和所有子目录中的文件]

 

3.3 The Process Of EDKII Build on LinuxLinux环境下EDKII项目源码的配置、编译流程)

3.3.1 Build the EDK II BaseTools

在配置Windows开发环境时,我们没有编译EDKII工具链,因为EDKII源码包中包含了Windows下的EDKII工具链可执行文件。但是由于Linux发行版本众多,EDKII源码包中没有包含EDKII工具链可执行文件,需要我们用makegcc等编译工具编译BaseTools生成Linux环境下可执行文件。

linux@ubuntu:~/src/edk2$ make -C BaseTools

[注:-CChange directory ;]


编译后,edk2/BaseTools/BinWrappers/PosixLike/目录下文件:

 

3.3.2 Setup build shell environment

linux@ubuntu:~$ cd ~/src/edk2
linux@ubuntu:~/src/edk2$ export EDK_TOOLS_PATH=$HOME/src/edk2/BaseTools
linux@ubuntu:~/src/edk2$ . edksetup.sh BaseTools


注意这里环境变量加载命令“. edksetup.sh BaseTools”而非“./edksetup.sh BaseTools

. edksetup.sh BaseTools”等同于“source edksetup.sh BaseTools”。“source edksetup.sh BaseTools”会将脚本“edksetup.sh BaseTools”中的命令读入当前shell环境变量中,并在当前环境变量中执行,而“./edksetup.sh BaseTools”仅仅是在当前shell下执行脚本。

所以要是执行“./edksetup.sh BaseTools”命令会出现“No command 'build' found”错误提示。

正确加载shell环境变量:

 

运行脚本“./edksetup.sh BaseTools”,未加载环境变量情况:

 

3.3.3 Modify Conf Files

通过vi修改配置目录Conf/下的target.txt filestools_def.txt文件,来配置我们当前要编译的包和使用的相应工具链Gcc4.6(You will need to edit the Conf/tools_def.txt and Conf/target.txt files. These changes will enable the MdeModulePkg to be built using the GCC 4.6 compiler.)

3.3.3.1 Set Build Target Information:配置target.txt文件

For the Conf/target.txt file, find the following lines:(Conf/target.txt文件中要编译的当前包、工具链变量)

ACTIVE_PLATFORM       = Nt32Pkg/Nt32Pkg.dsc
TOOL_CHAIN_TAG        = MYTOOLS

And change the corresponding lines to match these:(修改为如下:要编译的当前包MdeModulePkg,工具链是本博文Ubuntu12.0VMware中已安装的Gcc4.6)


ACTIVE_PLATFORM       = MdeModulePkg/MdeModulePkg.dsc
TOOL_CHAIN_TAG        = GCC46

注意:通过“gcc --version”命令可以查看当前环境下Gcc版本,gcc4.5.*这里工具链配置为GCC45,同理gcc4.6.*这里工具链配置为GCC46(Note: The 'gcc --version' command can be used to find out your GCC version. Use theGCC45 toolchain for gcc 4.5.* and the GCC46 toolchain for gcc 4.6.*.)

Optionally, you may consider finding:(修改源码要生成的目标平台架构)

TARGET_ARCH           = IA32

...and changing it if your GCC 4.6 installation supports 64-bit builds. You can change it to either 'X64', or even 'IA32 X64' which will build both architectures.

3.3.3.2 Check/Modify  tools_def Information:检查/修改tools_def.txt确保编译器路径正确

检查相应工具链Gcc4.6iasl路径是否正确。

 

DEFINE GCC46_IA32_PREFIX       = /usr/bin/
DEFINE GCC46_X64_PREFIX        = /usr/bin/

3.3.4 Build Hello World! (and the rest of MdeModulePkg)

现在可以运行简单的编译命令“build”来编译MdeModulePkg包。(Now you should be able to simply run the build command to compile the MdeModulePkg.)

linux@ubuntu:~/src/edk2$ build



可以通过ls命令One result of the build is that you should have the HelloWorld UEFI application:

linux@ubuntu: ls Build/MdeModule/DEBUG_*/*/HelloWorld.efi

 

相关文章
|
传感器 安全 API
SCP Firmware入门一篇就够啦
SCP Firmware入门一篇就够啦
1919 0
|
Shell 网络安全 开发工具
手把手教你配置Git客户端上传代码至Gitlab仓库
手把手教你配置Git客户端上传代码至Gitlab仓库
868 1
手把手教你配置Git客户端上传代码至Gitlab仓库
|
缓存 开发工具 git
【git】解决:remote: Permission to xxxx/xxxx.git denied to xxxx
【git】解决:remote: Permission to xxxx/xxxx.git denied to xxxx
1563 0
|
Web App开发 人工智能 JSON
深度测评:DeepSeek 对话导出工具 Top 3,公式不乱码、排版零折损的终极方案
本文为AI技术博主推荐三款高效导出DeepSeek对话的工具:专为iOS/macOS设计的App,支持多格式且完美保留代码高亮与公式;,适用于Chrome等主流浏览器;以及内置在QQ浏览器中的导出功能,无需额外安装,适合日常快速存档。结合官方导出方式与使用建议,帮助用户根据设备与需求选择最佳方案,同时提醒注意数据隐私与兼容性问题。
2433 0
深度测评:DeepSeek 对话导出工具 Top 3,公式不乱码、排版零折损的终极方案
|
9月前
|
人工智能 运维 定位技术
【微笑讲堂】AI时代的Geo优化:掌握这些技能,让你的内容被智能引擎“偏爱”
大家好,我是微笑老师!本期讲解“Geo都需要掌握哪些技能”。随着AI搜索兴起,GEO(生成式引擎优化)正取代传统SEO,核心在于让内容被AI“读懂、信任、引用”。需掌握四大技能:结构化数据工程、多模态语义对齐、动态知识图谱运维、权威信源建设。从“被找到”到“被引用”,GEO与SEO融合进化,助力内容在AI时代脱颖而出。未来已来,你准备好了吗?
1268 8
|
10月前
|
移动开发 程序员
您是否已经为DMN规则平台做好了准备?
DMN标准旨在让业务用户无需编程即可实现决策逻辑,通过DRD图表、决策表和FEEL语言简化决策建模。本文介绍了DMN的核心概念,并通过测试题帮助读者评估自身是否适合学习DMN。
|
NoSQL Linux 编译器
GDB符号表概念和在Linux下获取符号表的方法
通过掌握这些关于GDB符号表的知识,你可以更好地管理和理解你的程序,希望这些知识可以帮助你更有效地进行调试工作。
582 16
|
安全 Java 测试技术
单元测试一篇汇总
本文详细介绍了软件开发中的单元测试,包括其重要性和好处。单元测试主要用于确保程序模块代码的正确性,常使用的测试框架有JUnit和TestNG。文章重点讲解了JUnit框架,包括其注解、断言方法及JUnit 3.x和4.x的区别。此外,还列举了八大常用的单元测试框架,如Arquillian、JTest、The Grinder、TestNG、JUnit、JWalk、Mockito和PowerMock,帮助读者更好地理解和应用单元测试。
单元测试一篇汇总
|
安全 Ubuntu 测试技术
l4re Getting started
l4re Getting started
943 0
|
uml
UML类图的 绘制标准 及 绘制工具
讲解绘制类图的标准,以及如何使用ProcessOn(在线工具 无需下载)轻松绘制类图
948 0