mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-08 01:00:05 +00:00
Meta: Create python version of invoke_generator
This allows for the C++ and Python generators to share the same core implementation, which will simplify the generator migration process
This commit is contained in:
parent
92b69e7885
commit
3836d0e219
Notes:
github-actions[bot]
2025-06-26 13:59:18 +00:00
Author: https://github.com/ayeteadoe
Commit: 3836d0e219
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/5027
Reviewed-by: https://github.com/ADKaster ✅
Reviewed-by: https://github.com/R-Goc
Reviewed-by: https://github.com/jdahlin
4 changed files with 45 additions and 19 deletions
|
@ -951,7 +951,7 @@ set(SOURCES
|
|||
compile_ipc(Worker/WebWorkerClient.ipc Worker/WebWorkerClientEndpoint.h)
|
||||
compile_ipc(Worker/WebWorkerServer.ipc Worker/WebWorkerServerEndpoint.h)
|
||||
|
||||
invoke_generator(
|
||||
invoke_cpp_generator(
|
||||
"AriaRoles.cpp"
|
||||
Lagom::GenerateAriaRoles
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/ARIA/AriaRoles.json"
|
||||
|
@ -964,7 +964,7 @@ generate_css_implementation()
|
|||
|
||||
generate_html_implementation()
|
||||
|
||||
invoke_generator(
|
||||
invoke_cpp_generator(
|
||||
"WebGLRenderingContextImpl.cpp"
|
||||
Lagom::GenerateWebGLRenderingContext
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/WebGL/WebGLRenderingContextBase.idl"
|
||||
|
@ -976,7 +976,7 @@ invoke_generator(
|
|||
dependencies WebGL/WebGLRenderingContextBase.idl WebGL/WebGLRenderingContextOverloads.idl CSS/GeneratedCSSStyleProperties.idl
|
||||
)
|
||||
|
||||
invoke_generator(
|
||||
invoke_cpp_generator(
|
||||
"WebGL2RenderingContextImpl.cpp"
|
||||
Lagom::GenerateWebGLRenderingContext
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/WebGL/WebGL2RenderingContextBase.idl"
|
||||
|
|
|
@ -2,7 +2,7 @@ function (generate_css_implementation)
|
|||
set(LIBWEB_INPUT_FOLDER "${CMAKE_CURRENT_SOURCE_DIR}")
|
||||
|
||||
|
||||
invoke_generator(
|
||||
invoke_cpp_generator(
|
||||
"DescriptorID.cpp"
|
||||
Lagom::GenerateCSSDescriptors
|
||||
"${LIBWEB_INPUT_FOLDER}/CSS/Descriptors.json"
|
||||
|
@ -11,7 +11,7 @@ function (generate_css_implementation)
|
|||
arguments -j "${LIBWEB_INPUT_FOLDER}/CSS/Descriptors.json"
|
||||
)
|
||||
|
||||
invoke_generator(
|
||||
invoke_cpp_generator(
|
||||
"Enums.cpp"
|
||||
Lagom::GenerateCSSEnums
|
||||
"${LIBWEB_INPUT_FOLDER}/CSS/Enums.json"
|
||||
|
@ -20,7 +20,7 @@ function (generate_css_implementation)
|
|||
arguments -j "${LIBWEB_INPUT_FOLDER}/CSS/Enums.json"
|
||||
)
|
||||
|
||||
invoke_generator(
|
||||
invoke_cpp_generator(
|
||||
"MathFunctions.cpp"
|
||||
Lagom::GenerateCSSMathFunctions
|
||||
"${LIBWEB_INPUT_FOLDER}/CSS/MathFunctions.json"
|
||||
|
@ -29,7 +29,7 @@ function (generate_css_implementation)
|
|||
arguments -j "${LIBWEB_INPUT_FOLDER}/CSS/MathFunctions.json"
|
||||
)
|
||||
|
||||
invoke_generator(
|
||||
invoke_cpp_generator(
|
||||
"MediaFeatureID.cpp"
|
||||
Lagom::GenerateCSSMediaFeatureID
|
||||
"${LIBWEB_INPUT_FOLDER}/CSS/MediaFeatures.json"
|
||||
|
@ -38,7 +38,7 @@ function (generate_css_implementation)
|
|||
arguments -j "${LIBWEB_INPUT_FOLDER}/CSS/MediaFeatures.json"
|
||||
)
|
||||
|
||||
invoke_generator(
|
||||
invoke_cpp_generator(
|
||||
"PropertyID.cpp"
|
||||
Lagom::GenerateCSSPropertyID
|
||||
"${LIBWEB_INPUT_FOLDER}/CSS/Properties.json"
|
||||
|
@ -47,7 +47,7 @@ function (generate_css_implementation)
|
|||
arguments -j "${LIBWEB_INPUT_FOLDER}/CSS/Properties.json"
|
||||
)
|
||||
|
||||
invoke_generator(
|
||||
invoke_cpp_generator(
|
||||
"PseudoClass.cpp"
|
||||
Lagom::GenerateCSSPseudoClass
|
||||
"${LIBWEB_INPUT_FOLDER}/CSS/PseudoClasses.json"
|
||||
|
@ -56,7 +56,7 @@ function (generate_css_implementation)
|
|||
arguments -j "${LIBWEB_INPUT_FOLDER}/CSS/PseudoClasses.json"
|
||||
)
|
||||
|
||||
invoke_generator(
|
||||
invoke_cpp_generator(
|
||||
"PseudoElement.cpp"
|
||||
Lagom::GenerateCSSPseudoElement
|
||||
"${LIBWEB_INPUT_FOLDER}/CSS/PseudoElements.json"
|
||||
|
@ -65,7 +65,7 @@ function (generate_css_implementation)
|
|||
arguments -j "${LIBWEB_INPUT_FOLDER}/CSS/PseudoElements.json"
|
||||
)
|
||||
|
||||
invoke_generator(
|
||||
invoke_cpp_generator(
|
||||
"TransformFunctions.cpp"
|
||||
Lagom::GenerateCSSTransformFunctions
|
||||
"${LIBWEB_INPUT_FOLDER}/CSS/TransformFunctions.json"
|
||||
|
@ -74,7 +74,7 @@ function (generate_css_implementation)
|
|||
arguments -j "${LIBWEB_INPUT_FOLDER}/CSS/TransformFunctions.json"
|
||||
)
|
||||
|
||||
invoke_generator(
|
||||
invoke_cpp_generator(
|
||||
"Keyword.cpp"
|
||||
Lagom::GenerateCSSKeyword
|
||||
"${LIBWEB_INPUT_FOLDER}/CSS/Keywords.json"
|
||||
|
@ -154,7 +154,7 @@ endfunction()
|
|||
function (generate_html_implementation)
|
||||
set(LIBWEB_INPUT_FOLDER "${CMAKE_CURRENT_SOURCE_DIR}")
|
||||
|
||||
invoke_generator(
|
||||
invoke_cpp_generator(
|
||||
"NamedCharacterReferences.cpp"
|
||||
Lagom::GenerateNamedCharacterReferences
|
||||
"${LIBWEB_INPUT_FOLDER}/HTML/Parser/Entities.json"
|
||||
|
|
|
@ -13,7 +13,7 @@ if (ENABLE_PUBLIC_SUFFIX_DOWNLOAD)
|
|||
else()
|
||||
message(STATUS "Skipping download of ${PUBLIC_SUFFIX_DATA_URL}, expecting it to be in ${PUBLIC_SUFFIX_DATA_PATH}")
|
||||
endif()
|
||||
invoke_generator(
|
||||
invoke_cpp_generator(
|
||||
"PublicSuffixData"
|
||||
Lagom::GeneratePublicSuffixData
|
||||
"${PUBLIC_SUFFIX_PATH}/"
|
||||
|
|
|
@ -40,17 +40,16 @@ function(remove_path_if_version_changed version version_file cache_path)
|
|||
endif()
|
||||
endfunction()
|
||||
|
||||
function(invoke_generator name generator primary_source header implementation)
|
||||
cmake_parse_arguments(invoke_generator "" "" "arguments;dependencies" ${ARGN})
|
||||
|
||||
function(invoke_generator_impl name generator primary_source header implementation)
|
||||
cmake_parse_arguments(invoke_generator_impl "" "" "command;arguments;dependencies" ${ARGN})
|
||||
add_custom_command(
|
||||
OUTPUT "${header}" "${implementation}"
|
||||
COMMAND $<TARGET_FILE:${generator}> -h "${header}.tmp" -c "${implementation}.tmp" ${invoke_generator_arguments}
|
||||
COMMAND ${invoke_generator_impl_command} ${generator} -h "${header}.tmp" -c "${implementation}.tmp" ${invoke_generator_impl_arguments}
|
||||
COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${header}.tmp" "${header}"
|
||||
COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${implementation}.tmp" "${implementation}"
|
||||
COMMAND "${CMAKE_COMMAND}" -E remove "${header}.tmp" "${implementation}.tmp"
|
||||
VERBATIM
|
||||
DEPENDS ${generator} ${invoke_generator_dependencies} "${primary_source}"
|
||||
DEPENDS ${generator} ${invoke_generator_impl_dependencies} "${primary_source}"
|
||||
)
|
||||
|
||||
add_custom_target("generate_${name}" DEPENDS "${header}" "${implementation}")
|
||||
|
@ -59,6 +58,33 @@ function(invoke_generator name generator primary_source header implementation)
|
|||
set(CURRENT_LIB_GENERATED ${CURRENT_LIB_GENERATED} PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
function(invoke_cpp_generator name generator primary_source header implementation)
|
||||
cmake_parse_arguments(invoke_cpp_generator "" "" "arguments;dependencies" ${ARGN})
|
||||
invoke_generator_impl(
|
||||
${name}
|
||||
$<TARGET_FILE:${generator}>
|
||||
${primary_source}
|
||||
${header}
|
||||
${implementation}
|
||||
arguments ${invoke_cpp_generator_arguments}
|
||||
dependencies ${invoke_cpp_generator_dependencies}
|
||||
)
|
||||
endfunction()
|
||||
|
||||
function(invoke_py_generator name script primary_source header implementation)
|
||||
cmake_parse_arguments(invoke_py_generator "" "" "arguments" ${ARGN})
|
||||
find_package(Python3 REQUIRED COMPONENTS Interpreter)
|
||||
invoke_generator_impl(
|
||||
${name}
|
||||
"${SerenityOS_SOURCE_DIR}/Meta/${script}"
|
||||
${primary_source}
|
||||
${header}
|
||||
${implementation}
|
||||
command ${Python3_EXECUTABLE}
|
||||
arguments ${invoke_py_generator_arguments}
|
||||
)
|
||||
endfunction()
|
||||
|
||||
function(invoke_idl_generator cpp_name idl_name generator primary_source header implementation idl)
|
||||
cmake_parse_arguments(invoke_idl_generator "" "" "arguments;dependencies" ${ARGN})
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue