Re: [edk2-devel] [edk2-libc Patch 1/1] edk2-libc : add github actions workflow to build PyUEFI using VS2019

2024-06-15 Thread Michael D Kinney



> -Original Message-
> From: Jayaprakash, N 
> Sent: Saturday, June 15, 2024 1:18 AM
> To: Kinney, Michael D ; devel@edk2.groups.io
> Cc: Rebecca Cran 
> Subject: RE: [edk2-libc Patch 1/1] edk2-libc : add github actions workflow to
> build PyUEFI using VS2019
> 
> Thanks Mike for your comments.
> Please find my responses inline.
> 
> Regards,
> JP
> 
> -Original Message-
> From: Kinney, Michael D 
> Sent: Saturday, June 15, 2024 7:12 AM
> To: Jayaprakash, N ; devel@edk2.groups.io
> Cc: Rebecca Cran ; Kinney, Michael D
> 
> Subject: RE: [edk2-libc Patch 1/1] edk2-libc : add github actions workflow to
> build PyUEFI using VS2019
> 
> Comments below.
> 
> Mike
> 
> > -Original Message-
> > From: Jayaprakash, N 
> > Sent: Friday, June 14, 2024 10:02 AM
> > To: devel@edk2.groups.io
> > Cc: Jayaprakash, N ; Rebecca Cran
> > ; Kinney, Michael D 
> > Subject: [edk2-libc Patch 1/1] edk2-libc : add github actions workflow
> > to build PyUEFI using VS2019
> >
> > REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4788
> >
> > This commit adds github actions workflow to build python uefi
> > interpreter with visual studio 2019 tool chain.
> > The build-python-uefi-vs.yaml file under .github/workflows implements
> > the build action for building the pyuefi interpreter with VS2019 tool
> > chain. There is also a supporting python script under .github/scripts
> > folder which is used to uncomment the python uefi related .inf file in
> > AppPkg.dsc file.
> >
> > Cc: Rebecca Cran 
> > Cc: Michael D Kinney 
> > Cc: Jayaprakash N 
> > Signed-off-by: Jayaprakash N 
> > ---
> >  .github/scripts/enable_pyuefi_apppkg.py | 31 
> >  .github/workflows/build-python-uefi-vs.yaml | 84
> > +
> >  2 files changed, 115 insertions(+)
> >  create mode 100644 .github/scripts/enable_pyuefi_apppkg.py
> >  create mode 100644 .github/workflows/build-python-uefi-vs.yaml
> >
> > diff --git a/.github/scripts/enable_pyuefi_apppkg.py
> > b/.github/scripts/enable_pyuefi_apppkg.py
> > new file mode 100644
> > index 000..37b9e0a
> > --- /dev/null
> > +++ b/.github/scripts/enable_pyuefi_apppkg.py
> > @@ -0,0 +1,31 @@
> > +'''Script to enable the build of python UEFI interpreter
> > +   in AppPkg.dsc file
> > +'''
> 
> Copyright and License missing
> <> Will add copyright and license
> 
> > +import os
> > +
> > +
> > +script_path = os.path.abspath(__file__) script_dir =
> > +os.path.dirname(script_path)
> > +
> > +# path to the AppPkg.dsc file
> > +path_to_AppPkg_dsc = os.path.join(script_dir, '..', '..', 'edk2',
> > +'AppPkg',
> > 'AppPkg.dsc')
> > +print('Path to AppPkg dsc file : ', path_to_AppPkg_dsc)
> > +
> > +# Check if the file exists
> > +if not os.path.isfile(path_to_AppPkg_dsc):
> > +print(f"The file {path_to_AppPkg_dsc} does not exist.")
> > +else:
> > +# Read the content of the file
> > +with open(path_to_AppPkg_dsc, 'r') as file:
> > +lines = file.readlines()
> > +
> > +# Uncomment the line containing "Python368.inf"
> > +with open(path_to_AppPkg_dsc, 'w') as file:
> > +for line in lines:
> > +if 'Python368.inf' in line and line.strip().startswith('#'):
> > +# Uncomment the line
> > +file.write(line.lstrip('#'))
> > +else:
> > +file.write(line)
> 
> This is complicated to edit a DSC file.  Can this INF be uncommented in this
> DSC file or add another DSC files that is only used for this workflow to
> build python that has this INF uncommented.  Then this extra python script
> can be removed.
> 
> <>
> The reason I chose this approach is because we cannot uncomment this file by
> default in DSC file as it needs few additional steps to be done before the
> compilation.
> Also adding another DSC file can lead to regular maintenance of the DSC file
> whenever there are changes to it, we need update in two files.
> This custom script makes the process is and it keeps the github actions
> specific things are completely isolated from the rest of the code base.
> Would like to continue with this script rather than having a duplicate DCS
> file specifically for github actions.

You can add a !if statement around this INF so by default it is not built
and you can add a -D flag to the build command to build the interpreter.

> 
> > +
> > +print(f"The file {path_to_AppPkg_dsc} has been updated.")
> > diff --git a/.github/workflows/build-python-uefi-vs.yaml
> > b/.github/workflows/build-python-uefi-vs.yaml
> > new file mode 100644
> > index 000..aa5c317
> > --- /dev/null
> > +++ b/.github/workflows/build-python-uefi-vs.yaml
> > @@ -0,0 +1,84 @@
> 
> Copyright and License missing
> 
> <> Will add and send updated patch for review.
> 
> > +name: Build Python Interpreter for UEFI using VS2019
> > +
> > +on: [push, pull_request]
> > +
> > +jobs:
> > +  build:
> > +runs-on: windows-2019
> > +env:
> > +  NASM_PREFIX: "C:\\Program Files\\NASM\\"
> > +defaults:
> > +  

Re: [edk2-devel] [edk2-libc Patch 1/1] edk2-libc : add github actions workflow to build PyUEFI using VS2019

2024-06-15 Thread Jayaprakash, N
Thanks Mike for your comments.
Please find my responses inline.

Regards,
JP

-Original Message-
From: Kinney, Michael D  
Sent: Saturday, June 15, 2024 7:12 AM
To: Jayaprakash, N ; devel@edk2.groups.io
Cc: Rebecca Cran ; Kinney, Michael D 

Subject: RE: [edk2-libc Patch 1/1] edk2-libc : add github actions workflow to 
build PyUEFI using VS2019

Comments below.

Mike

> -Original Message-
> From: Jayaprakash, N 
> Sent: Friday, June 14, 2024 10:02 AM
> To: devel@edk2.groups.io
> Cc: Jayaprakash, N ; Rebecca Cran 
> ; Kinney, Michael D 
> Subject: [edk2-libc Patch 1/1] edk2-libc : add github actions workflow 
> to build PyUEFI using VS2019
> 
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4788
> 
> This commit adds github actions workflow to build python uefi 
> interpreter with visual studio 2019 tool chain.
> The build-python-uefi-vs.yaml file under .github/workflows implements 
> the build action for building the pyuefi interpreter with VS2019 tool 
> chain. There is also a supporting python script under .github/scripts 
> folder which is used to uncomment the python uefi related .inf file in 
> AppPkg.dsc file.
> 
> Cc: Rebecca Cran 
> Cc: Michael D Kinney 
> Cc: Jayaprakash N 
> Signed-off-by: Jayaprakash N 
> ---
>  .github/scripts/enable_pyuefi_apppkg.py | 31 
>  .github/workflows/build-python-uefi-vs.yaml | 84 
> +
>  2 files changed, 115 insertions(+)
>  create mode 100644 .github/scripts/enable_pyuefi_apppkg.py
>  create mode 100644 .github/workflows/build-python-uefi-vs.yaml
> 
> diff --git a/.github/scripts/enable_pyuefi_apppkg.py
> b/.github/scripts/enable_pyuefi_apppkg.py
> new file mode 100644
> index 000..37b9e0a
> --- /dev/null
> +++ b/.github/scripts/enable_pyuefi_apppkg.py
> @@ -0,0 +1,31 @@
> +'''Script to enable the build of python UEFI interpreter
> +   in AppPkg.dsc file
> +'''

Copyright and License missing
<> Will add copyright and license

> +import os
> +
> +
> +script_path = os.path.abspath(__file__) script_dir = 
> +os.path.dirname(script_path)
> +
> +# path to the AppPkg.dsc file
> +path_to_AppPkg_dsc = os.path.join(script_dir, '..', '..', 'edk2', 
> +'AppPkg',
> 'AppPkg.dsc')
> +print('Path to AppPkg dsc file : ', path_to_AppPkg_dsc)
> +
> +# Check if the file exists
> +if not os.path.isfile(path_to_AppPkg_dsc):
> +print(f"The file {path_to_AppPkg_dsc} does not exist.")
> +else:
> +# Read the content of the file
> +with open(path_to_AppPkg_dsc, 'r') as file:
> +lines = file.readlines()
> +
> +# Uncomment the line containing "Python368.inf"
> +with open(path_to_AppPkg_dsc, 'w') as file:
> +for line in lines:
> +if 'Python368.inf' in line and line.strip().startswith('#'):
> +# Uncomment the line
> +file.write(line.lstrip('#'))
> +else:
> +file.write(line)

This is complicated to edit a DSC file.  Can this INF be uncommented in this 
DSC file or add another DSC files that is only used for this workflow to build 
python that has this INF uncommented.  Then this extra python script can be 
removed.

<> 
The reason I chose this approach is because we cannot uncomment this file by 
default in DSC file as it needs few additional steps to be done before the 
compilation.
Also adding another DSC file can lead to regular maintenance of the DSC file 
whenever there are changes to it, we need update in two files.
This custom script makes the process is and it keeps the github actions 
specific things are completely isolated from the rest of the code base. 
Would like to continue with this script rather than having a duplicate DCS file 
specifically for github actions. 

> +
> +print(f"The file {path_to_AppPkg_dsc} has been updated.")
> diff --git a/.github/workflows/build-python-uefi-vs.yaml
> b/.github/workflows/build-python-uefi-vs.yaml
> new file mode 100644
> index 000..aa5c317
> --- /dev/null
> +++ b/.github/workflows/build-python-uefi-vs.yaml
> @@ -0,0 +1,84 @@

Copyright and License missing

<> Will add and send updated patch for review.

> +name: Build Python Interpreter for UEFI using VS2019
> +
> +on: [push, pull_request]
> +
> +jobs:
> +  build:
> +runs-on: windows-2019
> +env:
> +  NASM_PREFIX: "C:\\Program Files\\NASM\\"
> +defaults:
> +  run:
> +shell: cmd
> +
> +steps:
> +- name: Checkout repository
> +  uses: actions/checkout@v4
> +
> +- name: Setup Python
> +  uses: actions/setup-python@v5
> +  with:
> +python-version: '3.10'
> +
> +- name: Install NASM
> +  run: choco install nasm
> +
> +- name: VSWhere
> +  run: |
> +"C:\Program Files (x86)\Microsoft Visual
> Studio\Installer\vswhere.exe"
> +
> +- name: Setup environment for Visual Studio 2019 Build Tools
> +  run: |
> +"C:\Program Files (x86)\Microsoft Visual
> Studio\2019\Professional\VC\Auxiliary\Build\vcvarsall.bat" x86
> +set
> +
> +-