From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail05.groups.io (mail05.groups.io [45.79.224.7]) by spool.mail.gandi.net (Postfix) with ESMTPS id F2141941635 for ; Tue, 20 Aug 2024 15:58:14 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=yuvFWGgBBWLcBZbRi5/3m867//b0ah8tB1bSHrgDvw4=; c=relaxed/simple; d=groups.io; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References:MIME-Version:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Resent-Date:Resent-From:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Transfer-Encoding; s=20240206; t=1724169494; v=1; b=xk55ORrpWDYitl1U9jhJ3aw5fEgFz9sGkuXUVczNf3lUaYcHuxGDNZgS6dHbfu43tjcKhVRh CIT2O+w6PFkCyV7rvQjltd7G9p5097wzdkqBS+DpbGn9eG1QoZ6J2u+yChCqVLDk0MeKhxbB8wc tAcJSh/UltNgEDxpptcpjcmFJgGg4SVR9XloCYYLBrSPJ6TGHTzup79FyNUryiIfsHReqqOWRek h0pqomn6t15ZPgMMtMBakDczNJ7A5Nd+LYHY2CPeiKuDVfqbSF5Pu+Dxt4eRP/fsdXGykWYHNb6 QNkFe2ZdSbiykUS7ubgHQ4clF0hRTBmgOJSZI6Nq0liXg== X-Received: by 127.0.0.2 with SMTP id s80tYY7687511xJPJlP9q9Bs; Tue, 20 Aug 2024 08:58:13 -0700 X-Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.19]) by mx.groups.io with SMTP id smtpd.web11.23120.1724169491341393335 for ; Tue, 20 Aug 2024 08:58:12 -0700 X-CSE-ConnectionGUID: nRMOrwvoRlmdKPJiXN2NxQ== X-CSE-MsgGUID: pbiYkhOCRi6psd8N5NRRnQ== X-IronPort-AV: E=McAfee;i="6700,10204,11170"; a="22102423" X-IronPort-AV: E=Sophos;i="6.10,162,1719903600"; d="scan'208";a="22102423" X-Received: from orviesa005.jf.intel.com ([10.64.159.145]) by fmvoesa113.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Aug 2024 08:58:13 -0700 X-CSE-ConnectionGUID: gFrBWJ5HSq+ocKiWfL6Vhw== X-CSE-MsgGUID: Ld7DTpo3Q2azDyuXb7aE7Q== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.10,162,1719903600"; d="scan'208";a="65644979" X-Received: from njayapra-mobl.gar.corp.intel.com ([10.247.182.253]) by orviesa005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Aug 2024 08:58:11 -0700 From: "Jayaprakash, N" To: devel@edk2.groups.io Cc: Jayaprakash N , Rebecca Cran , Michael D Kinney Subject: [edk2-devel] [edk2-libc Patch 1/1] edk2-libc: BKM document to build Python UEFI using Visual Studio Tools Date: Tue, 20 Aug 2024 21:27:14 +0530 Message-ID: <20240820155803.1804-2-n.jayaprakash@intel.com> In-Reply-To: <20240820155803.1804-1-n.jayaprakash@intel.com> References: <20240820155803.1804-1-n.jayaprakash@intel.com> MIME-Version: 1.0 Precedence: Bulk List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Resent-Date: Tue, 20 Aug 2024 08:58:13 -0700 Resent-From: n.jayaprakash@intel.com Reply-To: devel@edk2.groups.io,n.jayaprakash@intel.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: rt0CNpiWNhk39GaYastAj9s0x7686176AA= Content-Transfer-Encoding: 8bit X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20240206 header.b=xk55ORrp; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=intel.com (policy=none); spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 45.79.224.7 as permitted sender) smtp.mailfrom=bounce@groups.io REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4810 There is a BKM document which provides detailed step by step instructions to build Python UEFI interpreter using GCC tool chain from Ubuntu Linux OS. But there is no complete BKM document providing the similar details to build on Windows using VS2019/VS2022 tool chains. This commit adds a new BKM document providing the step by step instructions to build Python UEFI interpreter using Visual Studio tool chains such as VS2019/VS2022. Cc: Rebecca Cran Cc: Michael D Kinney Cc: Jayaprakash N Signed-off-by: Jayaprakash N --- .../Python/Python-3.6.8/VSCompilationBKMs.md | 120 ++++++++++++++++++ 1 file changed, 120 insertions(+) create mode 100644 AppPkg/Applications/Python/Python-3.6.8/VSCompilationBKMs.md diff --git a/AppPkg/Applications/Python/Python-3.6.8/VSCompilationBKMs.md b/AppPkg/Applications/Python/Python-3.6.8/VSCompilationBKMs.md new file mode 100644 index 0000000..aaf689a --- /dev/null +++ b/AppPkg/Applications/Python/Python-3.6.8/VSCompilationBKMs.md @@ -0,0 +1,120 @@ +# Building Python UEFI Interpreter uisng Visual Studio Tool Chain(s) + +## 1. Introduction +This is a Best-Known Methods document capturing the details of build environment setup for compiling the Python UEFI interpreter version 3.6.8 using Microsoft Visual Studio Tool chains on Windows 11 systems. These BKMs have been tested on Windows 11 with VS2019 and VS2022 tool chains. + +## 2. Pre-requisites +a. Install the Microsoft Visual Studio tool chain VS2022 community version by downloading it from [here](https://visualstudio.microsoft.com/downloads/). You could also use VS2019 for building Python UEFI interpreter. + +b. Install the latest version of NASM assembler for X64 bit platforms by downloading it from [here](https://www.nasm.us/pub/nasm/releasebuilds/2.16.03/win64/nasm-2.16.03-installer-x64.exe). + +c. Install the ASL tools by downloading it from [Intel's website](https://www.intel.com/content/www/us/en/download/774881/acpi-component-architecture-downloads-windows-binary-tools.html). Unzip the iasl-win-*.zip folder, create a folder with name ASL in `C:\` drive as `C:\ASL\`, then copy all the contents from the unzipped folder to `C:\ASL\`. + +d. Install the latest version of Python by downloading it from [here](https://www.python.org/ftp/python/3.12.5/python-3.12.5-amd64.exe). While installing Python, click on customize installation, click next, check the Add Python to environment variables, modify the installation path to `c:\python312\`, then click install. + +e. Install git bash or any other git source code management tools you are comfortable with. You may download the git bash for windows from [this website](https://github.com/git-for-windows/git/releases/download/v2.46.0.windows.1/Git-2.46.0-64-bit.exe). + +## 3. Setup Edk2 Build Environment +a. Open a windows command prompt (not PowerShell) and create a folder with name `src` and change your working folder to the newly created folder using the commands provided below: +```cmd + mkdir src + cd src +``` + +b. Clone the `edk2` repo and initialize all the submodule within it using the commands provided below: +```cmd + git clone https://github.com/tianocore/edk2.git + cd edk2 + git submodule update --init +``` + +c. Run the below command to setup the tool chain environment variables and build the BaseTools: +```cmd + edksetup.bat + edksetup.bat Rebuild VS2022 +``` + +## 4. Setup Build Environment to Build Python UEFI Interpreter +a. Change your working directory to `src` folder using the following command: +```cmd + cd .. +``` + +b. Clone `edk2-libc` repo using the following command: +```cmd + git clone https://github.com/tianocore/edk2-libc.git +``` + +c. Set the PACKAGES_PATH and EDK2_LIBC_PATH using the commands below: +```cmd + set PACKAGES_PATH=%cd%\edk2;%cd%\edk2-libc + set EDK2_LIBC_PATH=%cd%\edk2-libc +``` + + +## 5. Build Python UEFI Interpreter with VS2022 compiler +You may use the commands provided below to build the Python UEFI interpreter using Visual Studio 2022 compiler tool chain. +```cmd + cd edk2-libc\AppPkg\Applications\Python\Python-3.6.8\ + python srcprep.py + cd ..\..\..\..\..\edk2 +``` +```cmd + build -t VS2022 -a X64 -b RELEASE -p ../edk2-libc/AppPkg/AppPkg.dsc \ + -m ../edk2-libc/AppPkg/Applications/Python/Python-3.6.8/Python368.inf -D BUILD_PYTHON368 +``` + or +```cmd + build -t VS2022 -a X64 -b RELEASE -p ../edk2-libc/AppPkg/AppPkg.dsc -D BUILD_PYTHON368 +``` + + +## 6. Create a Deployable Python UEFI package +To create a usable Python UEFI package with all the dependencies from the build environment, you can use the batch (.bat) create_python_pkg.bat script available under edk2-libc/AppPkg/Applications/Python/Python-3.6.8 folder. + +Ensure that EDK2_LIBC_PATH environment variable set to edk2-libc folder path using the below command: + +```cmd + echo %EDK2_LIBC_PATH% +``` + +Then use the commands provided below to create a Python UEFI package: +```cmd + cd ..\edk2-libc\AppPkg\Applications\Python\Python-3.6.8 + create_python_pkg.bat VS2022 RELEASE X64 myPyUEFI +``` + +This creates a Python UEFI package at src\edk2\myPyUEFI\. + +In the above command: +- `VS2022` refers to the tool chain. +- `RELEASE` refers to the build type. +- `X64` refers to the architecture. +- `myPyUEFI` refers to the name of the folder for the Python UEFI package. + +When you run the create_python_pkg.bat without any parameters, it lists the help information as shown below: + +Batch Script to create Python EFI Package. + +Usage: ./create_python_pkg.sh + +Where +- `ToolChain` : name of the tool chain such as VS2019 / VS2022 +- `Target` : build type such as RELEASE, DEBUG +- `Architecture` : Architecture such as X64 +- `OutFolder` : Output directory for creating the package + + +## 7. Usage of Python UEFI package from UEFI shell +1. Connect a USB thumb drive to your development system and format it with FAT32 file system. +2. Copy the EFI `` (Ex: `myPyUEFI`) folder to a USB thumb drive, ensure that EFI folder is available at the root of the thumb drive. +3. Eject the thumb drive from your development system and connect/insert the thumb drive to a system under test (SUT) and boot the SUT to UEFI shell. +4. Switch to the right file system such as `FS0:` or `FS1:` and so on depending on how your USB thumb drive has been enumerated by the shell. +5. Start using the Python interpreter from UEFI shell by executing the `Python` command from shell to get into interactive interpreter mode of Python, or execute `Python ` to execute the Python script from UEFI shell. + +Alternatively, you could create a FAT32 partition on your system and copy the contents of the EFI folder from the above package to this partition. This partition will be visible to the UEFI shell as a file system such as FS1/FS2 depending on how the UEFI environment enumerates. + +## 8. Pre-build Python UEFI interpreter package from edk2-libc repo +The pre-built Python UEFI interpreter packages are available at: +- Artifacts built using VS2019 tool chain: [VS2019 Artifacts](https://github.com/tianocore/edk2-libc/actions/runs/9788764204/artifacts/1666612053) +- Artifacts built using GCC tool chain: [GCC Artifacts](https://github.com/tianocore/edk2-libc/actions/runs/9788764199/artifacts/1666613814) -- 2.46.0.windows.1 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#120376): https://edk2.groups.io/g/devel/message/120376 Mute This Topic: https://groups.io/mt/108003139/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=-=-=-=-=-=-=-=-=-=-=-