public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Jayaprakash, N" <n.jayaprakash@intel.com>
To: devel@edk2.groups.io
Cc: Jayaprakash N <n.jayaprakash@intel.com>,
	Rebecca Cran <rebecca@bsdio.com>,
	Michael D Kinney <michael.d.kinney@intel.com>
Subject: [edk2-devel] [edk2-libc Patch 1/1] edk2-libc : update build and packaging scripts to take EDK2_LIBC_PATH
Date: Wed, 19 Jun 2024 13:22:43 +0530	[thread overview]
Message-ID: <20240619075421.1345-2-n.jayaprakash@intel.com> (raw)
In-Reply-To: <20240619075421.1345-1-n.jayaprakash@intel.com>

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4791

This commit adds necessary changes to build and packaging scripts
to take path to edk2-libc through an environment variable.
It also updates the build and packaging instructions in
GCCCompilationBKMs.rst file and Py368ReadMe.txt files.
The Python368.inf file is also updated to take EDK2_LIBC_PATH
instead of the current WORKSPACE path in the CC flags.

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-3.6.8/GCCCompilationBKMs.rst       | 21 +++++++++++------
 .../Python/Python-3.6.8/Py368ReadMe.txt       | 22 ++++++++++++++++--
 .../Python/Python-3.6.8/Python368.inf         |  6 ++---
 .../Python/Python-3.6.8/create_python_pkg.bat | 21 ++++++++++++++---
 .../Python/Python-3.6.8/create_python_pkg.sh  | 23 ++++++++++++++++---
 5 files changed, 75 insertions(+), 18 deletions(-)

diff --git a/AppPkg/Applications/Python/Python-3.6.8/GCCCompilationBKMs.rst b/AppPkg/Applications/Python/Python-3.6.8/GCCCompilationBKMs.rst
index 0574977..667b408 100644
--- a/AppPkg/Applications/Python/Python-3.6.8/GCCCompilationBKMs.rst
+++ b/AppPkg/Applications/Python/Python-3.6.8/GCCCompilationBKMs.rst
@@ -136,17 +136,17 @@ Now clone the edk2-libc git repo by following / executing the below commands::
 
         bash$ cd ~/src
         bash$ git clone https://github.com/tianocore/edk2-libc.git
-        bash$ export PACKAGES_PATH=$HOME/src/edk2:$HOME/src/edk2-libc
 
+Set the PACKAGES_PATH and EDK2_LIBC_PATH using the commands below::
+
+        bash$ export PACKAGES_PATH=$HOME/src/edk2:$HOME/src/edk2-libc
+        bash$ export EDK2_LIBC_PATH=$HOME/src/edk2-libc
 
 Verify that you can build the hello world application from AppPkg under edk2-libc by running the following commands
 Build hello.inf from edk2-libc applications::
 
-        $bash build -p AppPkg/AppPkg.dsc -m AppPkg/Applications/Hello/Hello.inf
-
-Copy the contents of edk2-libc to edk2 folder::
+        $bash build -p ../edk2-libc/AppPkg/AppPkg.dsc -m ../edk2-libc/AppPkg/Applications/Hello/Hello.inf
 
-        bash$ cp -rf ~/src/edk2-libc/* ~/src/edk2/
 
 2.5.  Build Python Interpreter using GCC
 ----------------------------------------
@@ -156,7 +156,8 @@ Execute the below command to build the X64 version of the Python 3.6.8 interpret
         bash$ cd AppPkg/Applications/Python/Python-3.6.8/
         bash$ python srcprep.py
         bash$ cd ~/src/edk2
-        bash$ build -a X64 -b RELEASE -p AppPkg/AppPkg.dsc -m AppPkg/Applications/Python/Python-3.6.8/Python368.inf -D BUILD_PYTHON368
+        bash$ build -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
         bash$ build -a X64 -b RELEASE -p AppPkg/AppPkg.dsc -D BUILD_PYTHON368
 
@@ -166,7 +167,13 @@ Execute the below command to build the X64 version of the Python 3.6.8 interpret
 
 To create an usable Python UEFI package with all the dependencies from the build environment,
 you can use the bash shell script create_python_pkg.sh available under /AppPkg/Applications/Python/Python-3.6.8
-folder.
+folder. Ensure that EDK2_LIBC_PATH environment variable to edk2-libc folder path.
+
+Ensure that EDK2_LIBC_PATH environment variable to edk2-libc folder path::
+
+        bash$ echo $EDK2_LIBC_PATH
+
+The environment variable should be set to the folder path for the edk2-libc cloned repo.
 
 Use the following commands to create Python UEFI package::
 
diff --git a/AppPkg/Applications/Python/Python-3.6.8/Py368ReadMe.txt b/AppPkg/Applications/Python/Python-3.6.8/Py368ReadMe.txt
index 91f4c24..8a0b3fe 100644
--- a/AppPkg/Applications/Python/Python-3.6.8/Py368ReadMe.txt
+++ b/AppPkg/Applications/Python/Python-3.6.8/Py368ReadMe.txt
@@ -68,7 +68,24 @@ and that you can successfully build packages within that distribution.
         gc          itertools       math          _operator
         time
 
-  C.  Build AppPkg using the standard "build" command:
+  C.  Set the PACKAGES_PATH and EDK2_LIBC_PATH environment variables to
+    the right values. PACKAGES_PATH should be set to the folder path of
+    edk2 and edk2-libc folders. EDK2_LIBC_PATH should be set to the
+    folder path of edk2-libc.
+    Use the below provided commands as reference to set the environment
+    variables to the corresponding values
+
+                set PACKAGES_PATH=<path_to_edk2>;<path_to_edk2_libc>;
+		set EDK2_LIBC_PATH=<path_to_edk2_libc>
+
+    where,
+        <path_to_edk2> should be replaced with the absolute path to
+                       edk2 folder on your development system.
+
+        <path_to_edk2_libc> should be replaced with the absolute path
+                       to edk2-libc folder on your development system.
+
+  D.  Build AppPkg using the standard "build" command:
     For example, to build Python for an X64 CPU architecture:
                     build -a X64 -p AppPkg\AppPkg.dsc -D BUILD_PYTHON368
 
@@ -115,7 +132,8 @@ system as follows:
   A script, create_python_pkg.bat , is provided which facilitates the population
   of the target EFI package.  Execute this script from within the
   AppPkg/Applications/Python/Python-3.6.8 directory, providing the Tool Chain, Target
-  Build and destination directory which is the path to the destination directory.  
+  Build and destination directory which is the path to the destination directory.
+  Ensure that EDK2_LIBC_PATH environment variable has been set to edk2-libc folder path.
   The appropriate contents of the AppPkg/Applications/Python/Python-3.6.8/Lib and
   Python.efi Application from Build/AppPkg/RELEASE_VS2017/X64/ will be
                                               ^^^^^^^^^^^^^^   
diff --git a/AppPkg/Applications/Python/Python-3.6.8/Python368.inf b/AppPkg/Applications/Python/Python-3.6.8/Python368.inf
index fe42fb4..ffd802c 100644
--- a/AppPkg/Applications/Python/Python-3.6.8/Python368.inf
+++ b/AppPkg/Applications/Python/Python-3.6.8/Python368.inf
@@ -1,7 +1,7 @@
 ## @file
 # Python368.inf
 #
-#  Copyright (c) 2011-2021, Intel Corporation. All rights reserved.<BR>
+#  Copyright (c) 2011-2024, Intel Corporation. All rights reserved.<BR>
 #  This program and the accompanying materials
 #  are licensed and made available under the terms and conditions of the BSD License
 #  which accompanies this distribution. The full text of the license may be found at
@@ -275,8 +275,8 @@ Modules/zlib
   PyMod-$(PYTHON_VERSION)/Modules/cpu_gcc.s  | GCC #
 
 [BuildOptions]
-  MSFT:*_*_*_CC_FLAGS = /GL- /Oi- /wd4018 /wd4054 /wd4055 /wd4101 /wd4131 /wd4152 /wd4204 /wd4210 /wd4244 /wd4267 /wd4305 /wd4310 /wd4389 /wd4701 /wd4702 /wd4706 /wd4456 /wd4312 /wd4457 /wd4459 /wd4474 /wd4476 /I$(WORKSPACE)\AppPkg\Applications\Python\Python-3.6.8\Include /DHAVE_MEMMOVE /DUSE_PYEXPAT_CAPI /DXML_STATIC -D UEFI /WX- /DXML_POOR_ENTROPY /DUEFI_C_SOURCE
-  GCC:*_*_*_CC_FLAGS = -Wno-unused-function -Wno-format -Wno-error -fno-strict-aliasing -I$(WORKSPACE)/AppPkg/Applications/Python/Python-3.6.8/Include -DHAVE_MEMMOVE -DUSE_PYEXPAT_CAPI -DXML_STATIC -DXML_POOR_ENTROPY
+  MSFT:*_*_*_CC_FLAGS = /GL- /Oi- /wd4018 /wd4054 /wd4055 /wd4101 /wd4131 /wd4152 /wd4204 /wd4210 /wd4244 /wd4267 /wd4305 /wd4310 /wd4389 /wd4701 /wd4702 /wd4706 /wd4456 /wd4312 /wd4457 /wd4459 /wd4474 /wd4476 /I$(EDK2_LIBC_PATH)\AppPkg\Applications\Python\Python-3.6.8\Include /DHAVE_MEMMOVE /DUSE_PYEXPAT_CAPI /DXML_STATIC -D UEFI /WX- /DXML_POOR_ENTROPY /DUEFI_C_SOURCE
+  GCC:*_*_*_CC_FLAGS = -Wno-unused-function -Wno-format -Wno-error -fno-strict-aliasing -I$(EDK2_LIBC_PATH)/AppPkg/Applications/Python/Python-3.6.8/Include -DHAVE_MEMMOVE -DUSE_PYEXPAT_CAPI -DXML_STATIC -DXML_POOR_ENTROPY
 
 [BuildOptions.IA32]
   MSFT:*_*_*_CC_FLAGS = /DUEFI_MSVC_32
diff --git a/AppPkg/Applications/Python/Python-3.6.8/create_python_pkg.bat b/AppPkg/Applications/Python/Python-3.6.8/create_python_pkg.bat
index 32044d2..2682ac6 100644
--- a/AppPkg/Applications/Python/Python-3.6.8/create_python_pkg.bat
+++ b/AppPkg/Applications/Python/Python-3.6.8/create_python_pkg.bat
@@ -27,7 +27,22 @@ echo.
 goto :eof
 
 :continue
-cd ..\..\..\..\
+echo current working directory %CD%
+echo changing working directory to workspace %WORKSPACE%
+cd %WORKSPACE%
+dir
+
+if "%EDK2_LIBC_PATH%" == "" (
+    echo Warning: EDK2_LIBC_PATH environment variable is not set
+    echo It should be set to edk2-libc folder path.
+    echo.
+    echo Assuming that edk2-libc contents are copied to edk2 folder
+    echo at compilation time, setting this variable to edk2 path.
+    set EDK2_LIBC_PATH=%WORKSPACE%
+)
+
+echo edk2 libc path %EDK2_LIBC_PATH%
+
 if not exist Build\AppPkg\%TARGET%_%TOOL_CHAIN_TAG%\%ARCH%\Python.efi (
     goto error
 )
@@ -43,8 +58,8 @@ if not exist %OUT_FOLDER%\EFI\StdLib\lib\python36.8 (
 if not exist %OUT_FOLDER%\EFI\StdLib\etc (
    mkdir %OUT_FOLDER%\EFI\StdLib\etc
 )
-xcopy AppPkg\Applications\Python\Python-3.6.8\Lib\*  %OUT_FOLDER%\EFI\StdLib\lib\python36.8\    /Y /S /I
-xcopy StdLib\Efi\StdLib\etc\*  %OUT_FOLDER%\EFI\StdLib\etc\  /Y /S /I
+xcopy %EDK2_LIBC_PATH%\AppPkg\Applications\Python\Python-3.6.8\Lib\*  %OUT_FOLDER%\EFI\StdLib\lib\python36.8\    /Y /S /I
+xcopy %EDK2_LIBC_PATH%\StdLib\Efi\StdLib\etc\*  %OUT_FOLDER%\EFI\StdLib\etc\  /Y /S /I
 echo.
 
 if not x%OUT_FOLDER::=%==x%OUT_FOLDER% (
diff --git a/AppPkg/Applications/Python/Python-3.6.8/create_python_pkg.sh b/AppPkg/Applications/Python/Python-3.6.8/create_python_pkg.sh
index 4a3a1e5..323d846 100644
--- a/AppPkg/Applications/Python/Python-3.6.8/create_python_pkg.sh
+++ b/AppPkg/Applications/Python/Python-3.6.8/create_python_pkg.sh
@@ -59,7 +59,24 @@ then
    exit
 fi
 
-cd ../../../../
+echo current working directory `pwd`
+echo changing working directory to $WORKSPACE
+cd $WORKSPACE
+ls
+
+# check if the EDK2_LIBC_PATH environment variable set or not
+if [ -z $EDK2_LIBC_PATH ]
+then
+    echo Warning: EDK2_LIBC_PATH environment variable is not set
+    echo It should be set to edk2-libc folder path.
+    echo.
+    echo Assuming that edk2-libc contents are copied to edk2 folder
+    echo at compilation time, setting this variable to edk2 path.
+    export EDK2_LIBC_PATH=$WORKSPACE
+fi
+
+echo edk2 libc path $EDK2_LIBC_PATH
+
 PYTHON_BIN="Build/AppPkg/$TARGET"_"$TOOL_CHAIN_TAG/$ARCH/Python.efi"
 if [ ! -f $PYTHON_BIN ]
 then
@@ -86,8 +103,8 @@ then
     mkdir -p $OUT_FOLDER/EFI/StdLib/etc
 fi
 
-cp -rf AppPkg/Applications/Python/Python-3.6.8/Lib/*  $OUT_FOLDER/EFI/StdLib/lib/python36.8/
-cp -rf StdLib/Efi/StdLib/etc/*  $OUT_FOLDER/EFI/StdLib/etc/
+cp -rf $EDK2_LIBC_PATH/AppPkg/Applications/Python/Python-3.6.8/Lib/*  $OUT_FOLDER/EFI/StdLib/lib/python36.8/
+cp -rf $EDK2_LIBC_PATH/StdLib/Efi/StdLib/etc/*  $OUT_FOLDER/EFI/StdLib/etc/
 
 if [ ${OUT_FOLDER:0:1} == "/" ]
 then
-- 
2.45.1.windows.1



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



  reply	other threads:[~2024-06-19  7:54 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-19  7:52 [edk2-devel] [edk2-libc Patch 0/1] update build and packaging scripts to take EDK2_LIBC_PATH Jayaprakash, N
2024-06-19  7:52 ` Jayaprakash, N [this message]
2024-06-19 23:28   ` [edk2-devel] [edk2-libc Patch 1/1] edk2-libc : " Michael D Kinney

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=20240619075421.1345-2-n.jayaprakash@intel.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