public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [edk2-devel] [edk2-libc Patch 0/1] Add BKM document to build Python UEFI using VS Tools
@ 2024-08-20 15:57 Jayaprakash, N
  2024-08-20 15:57 ` [edk2-devel] [edk2-libc Patch 1/1] edk2-libc: BKM document to build Python UEFI using Visual Studio Tools Jayaprakash, N
  0 siblings, 1 reply; 6+ messages in thread
From: Jayaprakash, N @ 2024-08-20 15:57 UTC (permalink / raw)
  To: devel; +Cc: Jayaprakash N

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 patch 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.

Jayaprakash N (1):
  edk2-libc: BKM document to build Python UEFI using Visual Studio Tools

 .../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

-- 
2.46.0.windows.1



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



^ permalink raw reply	[flat|nested] 6+ messages in thread

* [edk2-devel] [edk2-libc Patch 1/1] edk2-libc: BKM document to build Python UEFI using Visual Studio Tools
  2024-08-20 15:57 [edk2-devel] [edk2-libc Patch 0/1] Add BKM document to build Python UEFI using VS Tools Jayaprakash, N
@ 2024-08-20 15:57 ` Jayaprakash, N
  2024-08-20 16:13   ` Rebecca Cran
  0 siblings, 1 reply; 6+ messages in thread
From: Jayaprakash, N @ 2024-08-20 15:57 UTC (permalink / raw)
  To: devel; +Cc: Jayaprakash N, Rebecca Cran, Michael D Kinney

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  | 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 `<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/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]
-=-=-=-=-=-=-=-=-=-=-=-



^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [edk2-devel] [edk2-libc Patch 1/1] edk2-libc: BKM document to build Python UEFI using Visual Studio Tools
  2024-08-20 15:57 ` [edk2-devel] [edk2-libc Patch 1/1] edk2-libc: BKM document to build Python UEFI using Visual Studio Tools Jayaprakash, N
@ 2024-08-20 16:13   ` Rebecca Cran
  2024-08-20 16:24     ` Jayaprakash, N
  0 siblings, 1 reply; 6+ messages in thread
From: Rebecca Cran @ 2024-08-20 16:13 UTC (permalink / raw)
  To: devel, n.jayaprakash; +Cc: Michael D Kinney


On 8/20/24 9:57 AM, Jayaprakash, N wrote:
> +c. Run the below command to setup the tool chain environment variables and build the BaseTools:
> +```cmd
> +   edksetup.bat
> +   edksetup.bat Rebuild VS2022

Should we suggest people use Edk2ToolsBuild.py instead?


-- 
Rebecca



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#120377): https://edk2.groups.io/g/devel/message/120377
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]
-=-=-=-=-=-=-=-=-=-=-=-



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [edk2-devel] [edk2-libc Patch 1/1] edk2-libc: BKM document to build Python UEFI using Visual Studio Tools
  2024-08-20 16:13   ` Rebecca Cran
@ 2024-08-20 16:24     ` Jayaprakash, N
  2024-08-20 16:52       ` Rebecca Cran
  0 siblings, 1 reply; 6+ messages in thread
From: Jayaprakash, N @ 2024-08-20 16:24 UTC (permalink / raw)
  To: Rebecca Cran, devel@edk2.groups.io; +Cc: Kinney, Michael D

Hi Rebecca,

Thanks for your suggestion.

Would like to know if there are any advantages of calling this Python script over calling edksetup.bat directly. 

Regards,
JP
-----Original Message-----
From: Rebecca Cran <rebecca@bsdio.com> 
Sent: Tuesday, August 20, 2024 9:43 PM
To: devel@edk2.groups.io; Jayaprakash, N <n.jayaprakash@intel.com>
Cc: Kinney, Michael D <michael.d.kinney@intel.com>
Subject: Re: [edk2-devel] [edk2-libc Patch 1/1] edk2-libc: BKM document to build Python UEFI using Visual Studio Tools


On 8/20/24 9:57 AM, Jayaprakash, N wrote:
> +c. Run the below command to setup the tool chain environment variables and build the BaseTools:
> +```cmd
> +   edksetup.bat
> +   edksetup.bat Rebuild VS2022

Should we suggest people use Edk2ToolsBuild.py instead?


-- 
Rebecca



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#120378): https://edk2.groups.io/g/devel/message/120378
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]
-=-=-=-=-=-=-=-=-=-=-=-



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [edk2-devel] [edk2-libc Patch 1/1] edk2-libc: BKM document to build Python UEFI using Visual Studio Tools
  2024-08-20 16:24     ` Jayaprakash, N
@ 2024-08-20 16:52       ` Rebecca Cran
  2024-08-21  5:47         ` Jayaprakash, N
  0 siblings, 1 reply; 6+ messages in thread
From: Rebecca Cran @ 2024-08-20 16:52 UTC (permalink / raw)
  To: devel, n.jayaprakash; +Cc: Kinney, Michael D

Not that I know of, except that it's the 'new' way.


-- 

Rebecca


On 8/20/24 10:24 AM, Jayaprakash, N wrote:
> Hi Rebecca,
>
> Thanks for your suggestion.
>
> Would like to know if there are any advantages of calling this Python script over calling edksetup.bat directly.
>
> Regards,
> JP
> -----Original Message-----
> From: Rebecca Cran <rebecca@bsdio.com>
> Sent: Tuesday, August 20, 2024 9:43 PM
> To: devel@edk2.groups.io; Jayaprakash, N <n.jayaprakash@intel.com>
> Cc: Kinney, Michael D <michael.d.kinney@intel.com>
> Subject: Re: [edk2-devel] [edk2-libc Patch 1/1] edk2-libc: BKM document to build Python UEFI using Visual Studio Tools
>
>
> On 8/20/24 9:57 AM, Jayaprakash, N wrote:
>> +c. Run the below command to setup the tool chain environment variables and build the BaseTools:
>> +```cmd
>> +   edksetup.bat
>> +   edksetup.bat Rebuild VS2022
> Should we suggest people use Edk2ToolsBuild.py instead?
>
>


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#120379): https://edk2.groups.io/g/devel/message/120379
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]
-=-=-=-=-=-=-=-=-=-=-=-



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [edk2-devel] [edk2-libc Patch 1/1] edk2-libc: BKM document to build Python UEFI using Visual Studio Tools
  2024-08-20 16:52       ` Rebecca Cran
@ 2024-08-21  5:47         ` Jayaprakash, N
  0 siblings, 0 replies; 6+ messages in thread
From: Jayaprakash, N @ 2024-08-21  5:47 UTC (permalink / raw)
  To: devel@edk2.groups.io, rebecca@bsdio.com; +Cc: Kinney, Michael D

I have addressed your comment and sent an updated version of the patch V2 for the review.
Please do the needful.

Regards,
JP

-----Original Message-----
From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Rebecca Cran
Sent: Tuesday, August 20, 2024 10:22 PM
To: devel@edk2.groups.io; Jayaprakash, N <n.jayaprakash@intel.com>
Cc: Kinney, Michael D <michael.d.kinney@intel.com>
Subject: Re: [edk2-devel] [edk2-libc Patch 1/1] edk2-libc: BKM document to build Python UEFI using Visual Studio Tools

Not that I know of, except that it's the 'new' way.


-- 

Rebecca


On 8/20/24 10:24 AM, Jayaprakash, N wrote:
> Hi Rebecca,
>
> Thanks for your suggestion.
>
> Would like to know if there are any advantages of calling this Python script over calling edksetup.bat directly.
>
> Regards,
> JP
> -----Original Message-----
> From: Rebecca Cran <rebecca@bsdio.com>
> Sent: Tuesday, August 20, 2024 9:43 PM
> To: devel@edk2.groups.io; Jayaprakash, N <n.jayaprakash@intel.com>
> Cc: Kinney, Michael D <michael.d.kinney@intel.com>
> Subject: Re: [edk2-devel] [edk2-libc Patch 1/1] edk2-libc: BKM document to build Python UEFI using Visual Studio Tools
>
>
> On 8/20/24 9:57 AM, Jayaprakash, N wrote:
>> +c. Run the below command to setup the tool chain environment variables and build the BaseTools:
>> +```cmd
>> +   edksetup.bat
>> +   edksetup.bat Rebuild VS2022
> Should we suggest people use Edk2ToolsBuild.py instead?
>
>







-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#120385): https://edk2.groups.io/g/devel/message/120385
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]
-=-=-=-=-=-=-=-=-=-=-=-



^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2024-08-21  5:47 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-08-20 15:57 [edk2-devel] [edk2-libc Patch 0/1] Add BKM document to build Python UEFI using VS Tools Jayaprakash, N
2024-08-20 15:57 ` [edk2-devel] [edk2-libc Patch 1/1] edk2-libc: BKM document to build Python UEFI using Visual Studio Tools Jayaprakash, N
2024-08-20 16:13   ` Rebecca Cran
2024-08-20 16:24     ` Jayaprakash, N
2024-08-20 16:52       ` Rebecca Cran
2024-08-21  5:47         ` Jayaprakash, N

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox