From: "Yuting Yang" <yuting2.yang@intel.com>
To: devel@edk2.groups.io
Cc: Rebecca Cran <rebecca@bsdio.com>,
Liming Gao <gaoliming@byosoft.com.cn>,
Bob Feng <bob.c.feng@intel.com>,
Yuwei Chen <yuwei.chen@intel.com>
Subject: [edk2-devel] [PATCH] [edk2-staging] BaseTools: Update ReadMe in Python VfrCompiler Tool
Date: Wed, 27 Mar 2024 01:21:46 -0700 [thread overview]
Message-ID: <20240327082146.9-1-yuting2.yang@intel.com> (raw)
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/Source/Python/VfrCompiler/README.md | 27 ++++++++++++-------
2 files changed, 28 insertions(+), 21 deletions(-)
mode change 100644 => 100755 BaseTools/BinWrappers/PosixLike/PyVfrCompile
diff --git a/BaseTools/BinWrappers/PosixLike/PyVfrCompile b/BaseTools/BinWrappers/PosixLike/PyVfrCompile
old mode 100644
new mode 100755
index 1f241482d4..18119fa2a9
--- 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/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 (#117159): https://edk2.groups.io/g/devel/message/117159
Mute This Topic: https://groups.io/mt/105173564/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:21 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20240327082146.9-1-yuting2.yang@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