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 C507AD802EC for ; Wed, 21 Aug 2024 05:46:33 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=+7HTGhCcJrM5YhlEvIbC+rGHk5o49RkgaHza4beKVeI=; 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=1724219193; v=1; b=wyoepC1Q0GM5pwnIhIstH7M28h9xfPrnnu9f8SNbjkpihezYypMpMGIRce+frKapx9rLEM1y j3SFPvPwUFEBj72ln4sYPRmGd2nB2/hwDRjpuOclvvt9IvoObypVvzlUTkZTjY2rk3XHDs3thFj gd+/ZjFQiFeKezCTYhIkdOuBdL2u5Z0e5jCG4BDjuXR7RPARVTEKc6TUu7qgfBzsg2PASWln47o z6JmWRyHa7OJqAU29AHcycxF7yo3V3QYWNYXCYF+yONv6pqWnG9E+J40mYWOqjJNq6IMZ7zniva UalI3U949YcgBBfR5HW6C94g8SB0Qy5+Xpf1GbvEDZ0RA== X-Received: by 127.0.0.2 with SMTP id hRJWYY7687511xJjY9z2qhmY; Tue, 20 Aug 2024 22:46:32 -0700 X-Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.10]) by mx.groups.io with SMTP id smtpd.web10.13359.1724219190501666665 for ; Tue, 20 Aug 2024 22:46:31 -0700 X-CSE-ConnectionGUID: WYg7hMMGQd66k0cf6j9pgw== X-CSE-MsgGUID: B9S8XT+USEemo4cltNjErg== X-IronPort-AV: E=McAfee;i="6700,10204,11170"; a="40015743" X-IronPort-AV: E=Sophos;i="6.10,164,1719903600"; d="scan'208";a="40015743" X-Received: from fmviesa010.fm.intel.com ([10.60.135.150]) by orvoesa102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Aug 2024 22:46:31 -0700 X-CSE-ConnectionGUID: JiyDGXadQNa9uoywYcHK0w== X-CSE-MsgGUID: iuhSNg0zS86vSAIRlG/WRw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.10,164,1719903600"; d="scan'208";a="61125435" X-Received: from njayapra-mobl.gar.corp.intel.com ([10.247.182.253]) by fmviesa010-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Aug 2024 22:46:30 -0700 From: "Jayaprakash, N" To: devel@edk2.groups.io Cc: Jayaprakash N , Rebecca Cran , Michael D Kinney Subject: [edk2-devel] [edk2-libc Patch v2 1/1] edk2-libc: BKM document to build Python UEFI using Visual Studio Tools Date: Wed, 21 Aug 2024 11:12:23 +0530 Message-ID: <20240821054623.517-2-n.jayaprakash@intel.com> In-Reply-To: <20240821054623.517-1-n.jayaprakash@intel.com> References: <20240821054623.517-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 22:46:31 -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: Vs7efywjgE8cZfAs6K1vKUB0x7686176AA= 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=wyoepC1Q; spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 45.79.224.7 as permitted sender) smtp.mailfrom=bounce@groups.io; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=intel.com (policy=none) 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 | 126 ++++++++++++++++++ 1 file changed, 126 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..87a5d7a --- /dev/null +++ b/AppPkg/Applications/Python/Python-3.6.8/VSCompilationBKMs.md @@ -0,0 +1,126 @@ +# 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 build the BaseTools: +```cmd + python -m pip install -r pip-requirements.txt --upgrade + python BaseTools\Edk2ToolsBuild.py -t 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 + edksetup.bat + cd .. + cd edk2-libc\AppPkg\Applications\Python\Python-3.6.8\ + python srcprep.py + cd ..\..\..\..\..\edk2 +``` + +Use one of the below command to build Python UEFI interpreter +```cmd + build -t VS2022 -a X64 -p ../edk2-libc/AppPkg/AppPkg.dsc -m ../edk2-libc/AppPkg/Applications/Python/Python-3.6.8/Python368.inf -b RELEASE -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 (#120384): https://edk2.groups.io/g/devel/message/120384 Mute This Topic: https://groups.io/mt/108014909/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=-=-=-=-=-=-=-=-=-=-=-