public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Jayaprakash, N" <n.jayaprakash@intel.com>
To: "devel@edk2.groups.io" <devel@edk2.groups.io>,
	"Jayaprakash, N" <n.jayaprakash@intel.com>
Cc: Rebecca Cran <rebecca@bsdio.com>,
	"Kinney, Michael D" <michael.d.kinney@intel.com>
Subject: Re: [edk2-devel] [edk2-libc Patch v2 1/1] edk2-libc: BKM document to build Python UEFI using Visual Studio Tools
Date: Mon, 26 Aug 2024 04:41:11 +0000	[thread overview]
Message-ID: <PH7PR11MB59438827250912A5C762E87DEE8B2@PH7PR11MB5943.namprd11.prod.outlook.com> (raw)
In-Reply-To: <17EDA8382F57BDB4.11026@groups.io>

Hi Rebecca,

This address your comment. 
Please review and approve the same.

Regards,
JP

-----Original Message-----
From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Jayaprakash, N
Sent: Wednesday, August 21, 2024 11:12 AM
To: devel@edk2.groups.io
Cc: Jayaprakash, N <n.jayaprakash@intel.com>; Rebecca Cran <rebecca@bsdio.com>; Kinney, Michael D <michael.d.kinney@intel.com>
Subject: [edk2-devel] [edk2-libc Patch v2 1/1] edk2-libc: BKM document to build Python UEFI using Visual Studio Tools

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 <rebecca@bsdio.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Jayaprakash N <n.jayaprakash@intel.com>
Signed-off-by: Jayaprakash N <n.jayaprakash@intel.com>
---
 .../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 `<OutFolder>` (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 <NameOfPythonScript>` 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/97887642
+04/artifacts/1666612053)
+- Artifacts built using GCC tool chain: [GCC 
+Artifacts](https://github.com/tianocore/edk2-libc/actions/runs/97887641
+99/artifacts/1666613814)
--
2.46.0.windows.1








-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#120406): https://edk2.groups.io/g/devel/message/120406
Mute This Topic: https://groups.io/mt/108099092/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-



      parent reply	other threads:[~2024-08-26  4:41 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-21  5:42 [edk2-devel] [edk2-libc Patch v2 0/1] Add BKM document to build Python UEFI using VS Tools Jayaprakash, N
2024-08-21  5:42 ` [edk2-devel] [edk2-libc Patch v2 1/1] edk2-libc: BKM document to build Python UEFI using Visual Studio Tools Jayaprakash, N
     [not found] ` <17EDA8382F57BDB4.11026@groups.io>
2024-08-26  4:41   ` Jayaprakash, N [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=PH7PR11MB59438827250912A5C762E87DEE8B2@PH7PR11MB5943.namprd11.prod.outlook.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox