Windows systems - Wayne777Chiu/Chinese_Practice_about_TianoCore GitHub Wiki

(2019/03/08)

本頁提供單步指示來建立一個在 Windows 系統上的 EDK II 建置環境。

內容表格

GitHub Help

GitHub (https://help.github.com/index.html) 提供了使用者註冊和 GitHub 支援的基本功能的單步指示。

Windows 系統上的 Git 圖形使用者介面

GitHub EDK II 專案倉儲

內容 - 沒有在一個開放源碼授權許可下的釋出發行內容可在此找到 https://github.com/tianocore/edk2-non-osi.
 
注意:以下步驟將從 edk2 master 分支拉取最新的的源碼。 要在穩定發行版下作業,請參考 UDK2017 Microsoft Windows 建置步驟: 如何建置 UDK2017 在 Windows 系統



網路代理

假如你的區域網路使用一個有網路代理的防火牆,那麼你可能需要去設定代理伺服資訊給各種的命令列應用程式去作業。 你能需要諮詢你的區域網路管理者去為代理伺服器的設定找出電腦名稱和連接埠來使用。以下是一般 Git Bash 如何藉著設定環境變數來設定你的代理伺服器組態組態的例子:

    $git config --global https.proxy <proxyname>.domain.com:<port>
    $git config --global thhp.proxy <proxyname>.domain.com:<port>

如何建置 EDK II 樹

注意: 以下的一些例子使用了多重工作區 (Multiple Workspace) 功能區去組態 EDK II BaseTools (基礎工具)。 更多資訊關於多重工作區功能能透過以下路徑。

下載

下載/查驗 EDK II 源碼樹透過 Github

使用網頁瀏覽器下載

  1. 下載 EDK II 專案
    1. 在瀏覽器上開啟網址 https://github.com/tianocore/edk2
    2. 點擊 Clone or Download 按紐 (右邊 綠色)
    3. 點擊 Download ZIP
    4. 解壓縮到 C 槽
    5. 更改 “edk2-master” 目錄名稱成 “edk2”
接續到 編譯工具

Windows 版 Git 應用程式

Git GUI

  1. 克隆 EDK II 專案倉儲
    1. 開啟 Git GUI
    2. 使用 Clone Exiting Repository 利用源碼所在 https://github.com/tianocore/edk2.git
    3. 選擇目標路徑到 C:/edk2
    4. 勾選 Recursively clone submodules too (也遞迴性克隆子模組)
    5. 點擊 Clone 按鈕
接續到 編譯工具 章節

Git CMD

假如你使用的是命令列版本,那麼你能容易地用以下 git 命令去查找 (checkout) edk2 到 C:\edk2 目錄: 主要倉儲: https://github.com/tianocore/edk2

    $git clone https://github.com/tianocore/edk2

接續到 編譯工具建置 章節。

編譯工具

對於利用 Windows 上源碼BaseTools的 EDK II 專案開發者
例如:
  • Inside Bit Bash
    $ git clone https://github.com/tianocore/edk2
編譯BaseTools

例如:

  • 開啟命令提示視窗和 進入(CD) C:\edk2
    C:\edk2> set PYTHON_HOME=C:\Python27
    C:\edk2> edksetup.bat Rebuild

建置

  • 設立 Nasm 開放源碼組譯器
  • 設立 ASL 編譯器
  • 在上方(提及)的 編譯工具
  • 開啟 Windows 命令提示視窗
  • 切換到 edk2 目錄
  • 運行 edksetup.bat 腳本檔
      C:\\Users\MySid> CD \edk2
      C:\edk2> edksetup

建置 MdeModulePkg

=修改 配置檔

你將需要編輯 Conf\target.txt 檔。 首先, 改變 ACTIVE_PLATFORM 成 MdeModulePkg:

C:\edk2> notepad Conf\target.txt

ACTIVE_PLATFORM 在 Conf\target.txt (檔案裡)應該像這樣:

ACTIVE_PLATFORM       = MdeModulePkg/MdeModulePkg.dsc 

在 target.txt 裡,修改 TOOL_CHAIN_TAG 成在你系統裡的安裝好的(那個)工具鏈。 有很多選項,因此檢視 tools_def.txt 去找出你系統裡適當的工具鏈。 在 tools_def.txt 檔裡搜尋 'Supported Tool Chains' 去看可用的選項給 TOOL_CHAIN_TAG。

TOOL_CHAIN_TAG       = VS2015x86

也可參照: Windows-systems-ToolChain-Matrix 看如何改變工具鏈標籤屬性 (Tool Chain Tag)。

當然,也可以藉由改變 在target.txt 檔裡的 TARGET_ARCH 的值來審思是否你要建構其他處理器架構。 請認知某些工具鏈只支援建構某些處理器架構。

建置 Hello World! (和 MdeModulePkg 的剩餘部分)

現在你應該能夠簡單運行建置命令來編譯 MdeModulePkg。

C:\edk2> build

當建置的明確結果出來,你應該會有一個 HelloWorld UEFI 應用程式。 假如你有一個 UEFI 系統符合你所建置的處理器架構,那麼這應用程式應該能夠正確地運行在 shell 下。

C:\edk2> dir /s Build\MdeModule\DEBUG_...\IA32\HelloWorld.efi

建置 OVMF (選項)

一旦你的建置環境被設定成功,你可能會有興趣去建置 OVMF 平台,這已包含在主 edk2 源碼樹中。 利用 OVMF 建置一個完整系統韌體映像檔,這對 UEFI 系統韌體開發者而言是有趣的。

也可參考





原文

This page provides step-by-step instructions or setting up a EDK II build environment on Windows systems.

Table of Contents

GitHub Help

GitHub (https://help.github.com/index.html) provides step-by-step instructions for user registration and basic features supported by GitHub.

Git GUI Interface for Windows OS

GitHub EDK II Project Repositories

Content that is not released under an accepted open source license can be found at https://github.com/tianocore/edk2-non-osi.
 
Note: the steps below will pull the latest code from edk2 master. To work from a stable release, please refer to the Microsoft Windows build steps for UDK2017: https://github.com/tianocore/tianocore.github.io/wiki/UDK2017-How-to-Build#how-to-build-windows-system

Internet proxies

If your network utilizes a firewall with a web proxy, then you may need to configure your proxy information for various command line applications to work. You may need to consult with your network administrator to find out the computer name and port to use for proxy setup. The following commands are common Git Bash examples of how you would configure your proxy by setting an environment variable:

    $ git config --global https.proxy <proxyname>.domain.com:<port>
    $ git config --global http.proxy <proxyname>.domain.com:<port>

How to Setup the EDK II Tree

Note: Some of the following examples use the Multiple Workspace feature to configure the EDK II BaseTools. More information on the Multiple Workspace feature can be found at the following location.

Download

Download/Checkout the EDK II source tree from Github

Download Using a Web browser

  1. Download EDK II Project
    1. Open https://github.com/tianocore/edk2 in web browser
    2. Click on the Clone or Download button (Right Green)
    3. Click on Download ZIP
    4. Unzip to C:/
    5. Rename directory “edk2-master” to “edk2”
Continue to Compile Tools

Using Git for Windows Application

Git GUI

  1. Clone the EDK II project repository
    1. Open Git GUI
    2. Use Clone Exiting Repository with Source location https://github.com/tianocore/edk2.git
    3. Select a Target directory C:/edk2
    4. Check Recursively clone submodules too
    5. click Clone button
Continue to Compile Tools section

Git CMD

If you use the command line version, then you can easily checkout the edk2 to the C:\edk2 directory with the following git command: Main repository: https://github.com/tianocore/edk2

    $git clone https://github.com/tianocore/edk2

Continue to Compile Tools and then BUILD sections

Compile Tools

For EDK II project developers on Windows with source BaseTools:
Example:
  • Inside Git Bash
     $ git clone https://github.com/tianocore/edk2
Compile BaseTools

Example:

  • Open Command prompt and CD C:\edk2:
     C:\edk2> set PYTHON_HOME=C:\Python27
     C:\edk2> edksetup.bat Rebuild

Build

  • Set up the Nasm open source assembly compiler
  • Set up the ASL Compiler
  • Compile Tools above
  • Open a Windows CMD prompt:
  • Change to the edk2 directory
  • Run the edksetup.bat script
      C:\Users\MySid> CD \edk2
      C:\edk2> edksetup

Build MdeModulePkg

Modify Conf files

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

C:\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        = VS2015x86

See also: Windows-systems-ToolChain-Matrix for how to change the Tool Chain Tag.

Also, consider if you want to build a different processor architecture by changing the TARGET_ARCH value in target.txt. Please consider that certain toolchains only support building certain processor architectures.

Build Hello World! (and the rest of MdeModulePkg)

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

C:\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.

C:\edk2> dir /s Build\MdeModule\DEBUG_...\IA32\HelloWorld.efi

Build OVMF (OPTIONAL)

Once your build environment is set up you might be interested in building the OVMF platform which is included in the main edk2 source tree. Since OVMF builds a full system firmware image this may be of interest to UEFI system firmware developers.

See Also

⚠️ **GitHub.com Fallback** ⚠️