build: remove pcpp dependency (#8090)

This commit is contained in:
André Costa
2025-04-14 19:51:58 +02:00
committed by GitHub
parent dce4a078d0
commit f0257a633f
5 changed files with 33 additions and 7 deletions
-1
View File
@@ -16,4 +16,3 @@ sphinx-rtd-dark-mode
typing-extensions typing-extensions
sphinx-reredirects sphinx-reredirects
dirsync dirsync
pcpp
+1
View File
@@ -81,6 +81,7 @@ execute_process(
--input ${LVGL_ROOT_DIR}/src/lv_conf_internal.h --input ${LVGL_ROOT_DIR}/src/lv_conf_internal.h
--tmp_file ${CMAKE_CURRENT_BINARY_DIR}/tmp.h --tmp_file ${CMAKE_CURRENT_BINARY_DIR}/tmp.h
--output ${CMAKE_CURRENT_BINARY_DIR}/lv_conf_expanded.h --output ${CMAKE_CURRENT_BINARY_DIR}/lv_conf_expanded.h
--workfolder ${CMAKE_CURRENT_BINARY_DIR}
${PCPP_ADDITIONAL_DEFS} ${PCPP_ADDITIONAL_DEFS}
--include ${LVGL_ROOT_DIR} ${LVGL_ROOT_DIR}/.. ${LVGL_ROOT_DIR}/src ${LV_CONF_DIR} --include ${LVGL_ROOT_DIR} ${LVGL_ROOT_DIR}/.. ${LVGL_ROOT_DIR}/src ${LV_CONF_DIR}
RESULT_VARIABLE ret RESULT_VARIABLE ret
+1 -1
View File
@@ -1,4 +1,4 @@
vcpkg install vcpkg-tool-ninja libpng freetype opengl glfw3 glew vcpkg install vcpkg-tool-ninja libpng freetype opengl glfw3 glew
if %errorlevel% neq 0 exit /b %errorlevel% if %errorlevel% neq 0 exit /b %errorlevel%
pip install pypng lz4 kconfiglib pcpp pip install pypng lz4 kconfiglib
if %errorlevel% neq 0 exit /b %errorlevel% if %errorlevel% neq 0 exit /b %errorlevel%
+1 -1
View File
@@ -14,4 +14,4 @@ sudo apt install gcc gcc-multilib g++-multilib ninja-build \
ruby-full gcovr cmake python3 libinput-dev libxkbcommon-dev \ ruby-full gcovr cmake python3 libinput-dev libxkbcommon-dev \
libdrm-dev pkg-config wayland-protocols libwayland-dev libwayland-bin \ libdrm-dev pkg-config wayland-protocols libwayland-dev libwayland-bin \
libwayland-dev:i386 libxkbcommon-dev:i386 libudev-dev libwayland-dev:i386 libxkbcommon-dev:i386 libudev-dev
pip3 install pypng lz4 kconfiglib pcpp pip3 install pypng lz4 kconfiglib
+30 -4
View File
@@ -8,6 +8,7 @@
# Author: David TRUAN (david.truan@edgemtech.ch) # Author: David TRUAN (david.truan@edgemtech.ch)
# #
import sys
import subprocess import subprocess
import os import os
import argparse import argparse
@@ -18,6 +19,7 @@ def get_args():
parser.add_argument("--input", help="Path to the input C header file", required=True) parser.add_argument("--input", help="Path to the input C header file", required=True)
parser.add_argument("--tmp_file", help="Path to save the preprocessed output", required=True) parser.add_argument("--tmp_file", help="Path to save the preprocessed output", required=True)
parser.add_argument("--output", help="Path to save the cleaned output with removed indentation", required=True) parser.add_argument("--output", help="Path to save the cleaned output with removed indentation", required=True)
parser.add_argument("--workfolder", help="Path used to create a python environnement", required=True)
parser.add_argument( parser.add_argument(
"--defs", "--defs",
@@ -36,11 +38,10 @@ def get_args():
return parser.parse_args() return parser.parse_args()
def preprocess_file(pcpp_exe, input_file, tmp_file, output_file, include_dirs, defs):
def preprocess_file(input_file, tmp_file, output_file, include_dirs, defs):
try: try:
pcpp_command = ["pcpp", "-o", tmp_file, "--passthru-defines", "--line-directive=", input_file] pcpp_command = [pcpp_exe, "-o", tmp_file, "--passthru-defines", "--line-directive=", input_file]
for include_path in include_dirs: for include_path in include_dirs:
pcpp_command.append(f"-I{include_path}") pcpp_command.append(f"-I{include_path}")
@@ -83,12 +84,37 @@ def remove_indentation(tmp_file, output_file):
print(f"Error during indentation removal: {e}") print(f"Error during indentation removal: {e}")
exit(1) exit(1)
def install_pcpp_in_venv(workfolder:str) -> str:
"""
Creates a virtual env named .venv inside `workfolder`
and installs every dependecy inside `dependencies`
Returns the path to pcpp
"""
venv_path = os.path.join(workfolder, ".venv")
try:
subprocess.check_call([sys.executable, "-m", "venv", venv_path])
if sys.platform == "win32":
venv_pip = os.path.join(venv_path, "Scripts", "pip.exe")
venv_pcpp = os.path.join(venv_path, "Scripts", "pcpp.exe")
else:
venv_pip = os.path.join(venv_path, "bin", "pip")
venv_pcpp = os.path.join(venv_path, "bin", "pcpp")
subprocess.check_call([venv_pip, "install", "pcpp"])
except subprocess.CalledProcessError as e:
print(f"Error setting up environnement: {e}")
sys.exit(1)
return venv_pcpp
def main(): def main():
args = get_args() args = get_args()
preprocess_file(args.input, args.tmp_file, args.output, args.include, args.defs) pcpp_exe = install_pcpp_in_venv(args.workfolder)
preprocess_file(pcpp_exe, args.input, args.tmp_file, args.output, args.include, args.defs)
remove_indentation(args.tmp_file, args.output) remove_indentation(args.tmp_file, args.output)