public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Yuwei Chen" <yuwei.chen@intel.com>
To: "Yang, Yuting2" <yuting2.yang@intel.com>,
	"devel@edk2.groups.io" <devel@edk2.groups.io>
Cc: Rebecca Cran <rebecca@bsdio.com>,
	Liming Gao <gaoliming@byosoft.com.cn>,
	"Feng, Bob C" <bob.c.feng@intel.com>
Subject: Re: [edk2-devel] [Patch V2] [edk2-staging] BaseTools: Update ReadMe in Python VfrCompiler Tool
Date: Wed, 27 Mar 2024 08:45:50 +0000	[thread overview]
Message-ID: <MW5PR11MB590616C8F7A072E25554085A96342@MW5PR11MB5906.namprd11.prod.outlook.com> (raw)
In-Reply-To: <20240327084254.307-1-yuting2.yang@intel.com>

Reviewed-by: Yuwei Chen <yuwei.chen@intel.com>

> -----Original Message-----
> From: Yang, Yuting2 <yuting2.yang@intel.com>
> Sent: Wednesday, March 27, 2024 4:43 PM
> To: devel@edk2.groups.io
> Cc: Rebecca Cran <rebecca@bsdio.com>; Liming Gao
> <gaoliming@byosoft.com.cn>; Feng, Bob C <bob.c.feng@intel.com>; Chen,
> Christine <yuwei.chen@intel.com>
> Subject: [Patch V2] [edk2-staging] BaseTools: Update ReadMe in Python
> VfrCompiler Tool
> 
> Cc: Rebecca Cran <rebecca@bsdio.com>
> 
> Cc: Liming Gao <gaoliming@byosoft.com.cn>
> 
> Cc: Bob Feng <bob.c.feng@intel.com>
> 
> Cc: Yuwei Chen <yuwei.chen@intel.com>
> 
> Signed-off-by: Yuting Yang <yuting2.yang@intel.com>
> ---
>  BaseTools/BinWrappers/PosixLike/PyVfrCompile  | 22 +++++++++++-----------
>  BaseTools/Conf/build_rule.template            |  2 --
>  BaseTools/Source/Python/VfrCompiler/README.md | 27
> +++++++++++++++++----------
>  3 files changed, 28 insertions(+), 23 deletions(-)
> 
> diff --git a/BaseTools/BinWrappers/PosixLike/PyVfrCompile
> b/BaseTools/BinWrappers/PosixLike/PyVfrCompile
> old mode 100644
> new mode 100755
> index 1f241482d4..53a32733fa
> --- a/BaseTools/BinWrappers/PosixLike/PyVfrCompile
> +++ b/BaseTools/BinWrappers/PosixLike/PyVfrCompile
> @@ -1,13 +1,13 @@
> -    #!/usr/bin/env bash
> 
> -    #python `dirname $0`/RunToolFromSource.py `basename $0` $*
> 
> +#!/usr/bin/env bash
> 
> +#python `dirname $0`/RunToolFromSource.py `basename $0` $*
> 
> 
> 
> -    # If a ${PYTHON_COMMAND} command is available, use it in preference to
> python
> 
> -    if command -v ${PYTHON_COMMAND} >/dev/null 2>&1; then
> 
> -        python_exe=${PYTHON_COMMAND}
> 
> -    fi
> 
> -    full_cmd=${BASH_SOURCE:-$0} # see
> http://mywiki.wooledge.org/BashFAQ/028 for a discussion of why $0 is not a
> good choice here
> 
> -    dir=$(dirname "$full_cmd")
> 
> -    cmd=${full_cmd##*/}
> 
> +# If a ${PYTHON_COMMAND} command is available, use it in preference to
> python
> 
> +if command -v ${PYTHON_COMMAND} >/dev/null 2>&1; then
> 
> +    python_exe=${PYTHON_COMMAND}
> 
> +fi
> 
> +full_cmd=${BASH_SOURCE:-$0} # see
> http://mywiki.wooledge.org/BashFAQ/028 for a discussion of why $0 is not a
> good choice here
> 
> +dir=$(dirname "$full_cmd")
> 
> +cmd=${full_cmd##*/}
> 
> 
> 
> -    export
> PYTHONPATH="$dir/../../Source/Python:$dir/../../Source/Python/VfrCompiler
> :$dir/../../Source/Python${PYTHONPATH:+:"$PYTHONPATH"}"
> 
> -    exec "${python_exe:-python}" -m IfrCompiler "$@"
> 
> \ No newline at end of file
> +export
> PYTHONPATH="$dir/../../Source/Python:$dir/../../Source/Python/VfrCompiler
> :$dir/../../Source/Python${PYTHONPATH:+:"$PYTHONPATH"}"
> 
> +exec "${python_exe:-python}" -m IfrCompiler "$@"
> 
> \ No newline at end of file
> diff --git a/BaseTools/Conf/build_rule.template
> b/BaseTools/Conf/build_rule.template
> index 0e19133589..b2fa2032e3 100755
> --- a/BaseTools/Conf/build_rule.template
> +++ b/BaseTools/Conf/build_rule.template
> @@ -257,7 +257,6 @@
>      <Command>
> 
>          "$(VFRPP)" $(DEPS_FLAGS) $(VFRPP_FLAGS) $(INC) ${src} >
> $(OUTPUT_DIR)(+)${s_base}.i
> 
>          "$(VFR)" $(VFR_FLAGS) --string-db
> $(OUTPUT_DIR)(+)$(MODULE_NAME)StrDefs.hpk --output-directory
> ${d_path} $(OUTPUT_DIR)(+)${s_base}.i
> 
> -        "$(PYVFR)" ${src} --string-db
> $(OUTPUT_DIR)(+)$(MODULE_NAME)StrDefs.hpk -w $(WORKSPACE) -m
> $(MODULE_NAME) -o $(OUTPUT_DIR) --vfr
> 
> 
> 
>  [Object-File]
> 
>      <InputFile>
> 
> @@ -629,7 +628,6 @@
>      <Command>
> 
>          "$(VFRPP)" $(DEPS_FLAGS) $(VFRPP_FLAGS) $(INC) ${src} >
> $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.i
> 
>          "$(VFR)" $(VFR_FLAGS) --create-ifr-package --string-db
> $(OUTPUT_DIR)(+)$(MODULE_NAME)StrDefs.hpk --output-directory
> $(OUTPUT_DIR)(+)${s_dir} $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.i
> 
> -        "$(PYVFR)" ${src} --string-db
> $(OUTPUT_DIR)(+)$(MODULE_NAME)StrDefs.hpk -w $(WORKSPACE) -m
> $(MODULE_NAME) -o $(OUTPUT_DIR) --vfr
> 
> 
> 
>  [Hii-Binary-Package.UEFI_HII]
> 
>      <InputFile>
> 
> diff --git a/BaseTools/Source/Python/VfrCompiler/README.md
> b/BaseTools/Source/Python/VfrCompiler/README.md
> index 7bdc85023a..473482f936 100644
> --- a/BaseTools/Source/Python/VfrCompiler/README.md
> +++ b/BaseTools/Source/Python/VfrCompiler/README.md
> @@ -29,12 +29,10 @@ The core function of the original C VfrCompiler tool is
> to convert VFR files int
>  - Future extension
> 
>    - The tool will extend new functions, which is able to compile yaml files.
> This feature will be added in future update.
> 
> 
> 
> -### Use with Build System
> 
> -To use the VfrCompiler Python Tool with Build System,  please do the
> following steps in the build command.
> 
> +### Implementation method
> 
> +
> 
> +To apply the VfrCompiler python tool with Build System, the code modifies
> the following steps in the build command.
> 
>  1. Locate the **VfrCompiler** folder to path
> **'\edk2\BaseTools\Source\Python'.**
> 
> -1. Open  **'build_rule.template'**  file  in path
> **'\edk2\BaseTools\Conf\'.**
> 
> -  - Find the C VFR command line `$(VFR)" $(VFR_FLAGS) --string-db
> $(OUTPUT_DIR)(+)$(MODULE_NAME)StrDefs.hpk --output-directory
> ${d_path} $(OUTPUT_DIR)(+)${s_base}.i` in **build_rule.template** file.
> There are two C VFR commands in it.
> 
> -  - Add new command line `"$(PYVFR)" ${src} --string-db
> $(OUTPUT_DIR)(+)$(MODULE_NAME)StrDefs.hpk -w $(WORKSPACE) -m
> $(MODULE_NAME) -o $(OUTPUT_DIR) --vfr` after each VFR command lines.
> 
>  2. Open  **'tools_def.template'**  file  in path **'\edk2\BaseTools\Conf\'.**
> 
>    - Find the C VFR_PATH command line `*_*_*_VFR_PATH                      =
> VfrCompile` in **tools_def.template** file.
> 
>    - Add new command line `*_*_*_PYVFR_PATH                    = PyVfrCompile`
> after the VFR_PATH command line.
> 
> @@ -51,7 +49,7 @@ To use the VfrCompiler Python Tool with Build System,
> please do the following s
>      ```
> 
>      #!/usr/bin/env bash
> 
>      #python `dirname $0`/RunToolFromSource.py `basename $0` $*
> 
> -
> 
> +
> 
>      # If a ${PYTHON_COMMAND} command is available, use it in preference to
> python
> 
>      if command -v ${PYTHON_COMMAND} >/dev/null 2>&1; then
> 
>          python_exe=${PYTHON_COMMAND}
> 
> @@ -59,10 +57,19 @@ To use the VfrCompiler Python Tool with Build
> System,  please do the following s
>      full_cmd=${BASH_SOURCE:-$0} # see
> http://mywiki.wooledge.org/BashFAQ/028 for a discussion of why $0 is not a
> good choice here
> 
>      dir=$(dirname "$full_cmd")
> 
>      cmd=${full_cmd##*/}
> 
> -
> 
> +
> 
>      export
> PYTHONPATH="$dir/../../Source/Python:$dir/../../Source/Python/VfrCompiler
> :$dir/../../Source/Python${PYTHONPATH:+:"$PYTHONPATH"}"
> 
>      exec "${python_exe:-python}" -m IfrCompiler "$@"
> 
>      ```
> 
> -5. Add Env: run `pip install antlr4-python3-runtime==4.7.1` based on the
> original build environment.
> 
> -6. Run Build Command: `build -p OvmfPkg\OvmfPkgIa32X64.dsc -a IA32 -a
> X64 -j build.log`
> 
> -`
> 
> +### How to use
> 
> +
> 
> +1. Add Env: run `pip install antlr4-python3-runtime==4.7.1` based on the
> original build environment.
> 
> +2. Open  **'build_rule.template'**  file  in path
> **'\edk2\BaseTools\Conf\'.**
> 
> +   - Find the C VFR command line `$(VFR)" $(VFR_FLAGS) --string-db
> $(OUTPUT_DIR)(+)$(MODULE_NAME)StrDefs.hpk --output-directory
> ${d_path} $(OUTPUT_DIR)(+)${s_base}.i` in **build_rule.template** file.
> There are two C VFR commands in it.
> 
> +   - Add new command line `"$(PYVFR)" ${src} --string-db
> $(OUTPUT_DIR)(+)$(MODULE_NAME)StrDefs.hpk -w $(WORKSPACE) -m
> $(MODULE_NAME) -o $(OUTPUT_DIR) --vfr` after each VFR command lines.
> 
> +3. Run Build Command: `build -p OvmfPkg\OvmfPkgIa32X64.dsc -a IA32 -a
> X64 -j build.log` to have a try.
> 
> +
> 
> +### Tips
> 
> +
> 
> +1. The output of the python tool will not override the output of the original
> C tool. Instead, it will be prefixed with "PyVfr".
> 
> +2. If you want to activate/deactivate the python tool, please locate and
> add/delete all `"$(PYVFR)" ${src} --string-db
> $(OUTPUT_DIR)(+)$(MODULE_NAME)StrDefs.hpk -w $(WORKSPACE) -m
> $(MODULE_NAME) -o $(OUTPUT_DIR) --vfr` command lines in
> **'build_rule.template'**.
> 
> --
> 2.26.2.windows.1



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



      reply	other threads:[~2024-03-27  8:45 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-27  8:42 [edk2-devel] [Patch V2] [edk2-staging] BaseTools: Update ReadMe in Python VfrCompiler Tool Yuting Yang
2024-03-27  8:45 ` Yuwei Chen [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=MW5PR11MB590616C8F7A072E25554085A96342@MW5PR11MB5906.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