mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-06 16:19:23 +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/WebWorkerClient.ipc Worker/WebWorkerClientEndpoint.h)
|
||||||
compile_ipc(Worker/WebWorkerServer.ipc Worker/WebWorkerServerEndpoint.h)
|
compile_ipc(Worker/WebWorkerServer.ipc Worker/WebWorkerServerEndpoint.h)
|
||||||
|
|
||||||
invoke_generator(
|
invoke_cpp_generator(
|
||||||
"AriaRoles.cpp"
|
"AriaRoles.cpp"
|
||||||
Lagom::GenerateAriaRoles
|
Lagom::GenerateAriaRoles
|
||||||
"${CMAKE_CURRENT_SOURCE_DIR}/ARIA/AriaRoles.json"
|
"${CMAKE_CURRENT_SOURCE_DIR}/ARIA/AriaRoles.json"
|
||||||
|
@ -964,7 +964,7 @@ generate_css_implementation()
|
||||||
|
|
||||||
generate_html_implementation()
|
generate_html_implementation()
|
||||||
|
|
||||||
invoke_generator(
|
invoke_cpp_generator(
|
||||||
"WebGLRenderingContextImpl.cpp"
|
"WebGLRenderingContextImpl.cpp"
|
||||||
Lagom::GenerateWebGLRenderingContext
|
Lagom::GenerateWebGLRenderingContext
|
||||||
"${CMAKE_CURRENT_SOURCE_DIR}/WebGL/WebGLRenderingContextBase.idl"
|
"${CMAKE_CURRENT_SOURCE_DIR}/WebGL/WebGLRenderingContextBase.idl"
|
||||||
|
@ -976,7 +976,7 @@ invoke_generator(
|
||||||
dependencies WebGL/WebGLRenderingContextBase.idl WebGL/WebGLRenderingContextOverloads.idl CSS/GeneratedCSSStyleProperties.idl
|
dependencies WebGL/WebGLRenderingContextBase.idl WebGL/WebGLRenderingContextOverloads.idl CSS/GeneratedCSSStyleProperties.idl
|
||||||
)
|
)
|
||||||
|
|
||||||
invoke_generator(
|
invoke_cpp_generator(
|
||||||
"WebGL2RenderingContextImpl.cpp"
|
"WebGL2RenderingContextImpl.cpp"
|
||||||
Lagom::GenerateWebGLRenderingContext
|
Lagom::GenerateWebGLRenderingContext
|
||||||
"${CMAKE_CURRENT_SOURCE_DIR}/WebGL/WebGL2RenderingContextBase.idl"
|
"${CMAKE_CURRENT_SOURCE_DIR}/WebGL/WebGL2RenderingContextBase.idl"
|
||||||
|
|
|
@ -2,7 +2,7 @@ function (generate_css_implementation)
|
||||||
set(LIBWEB_INPUT_FOLDER "${CMAKE_CURRENT_SOURCE_DIR}")
|
set(LIBWEB_INPUT_FOLDER "${CMAKE_CURRENT_SOURCE_DIR}")
|
||||||
|
|
||||||
|
|
||||||
invoke_generator(
|
invoke_cpp_generator(
|
||||||
"DescriptorID.cpp"
|
"DescriptorID.cpp"
|
||||||
Lagom::GenerateCSSDescriptors
|
Lagom::GenerateCSSDescriptors
|
||||||
"${LIBWEB_INPUT_FOLDER}/CSS/Descriptors.json"
|
"${LIBWEB_INPUT_FOLDER}/CSS/Descriptors.json"
|
||||||
|
@ -11,7 +11,7 @@ function (generate_css_implementation)
|
||||||
arguments -j "${LIBWEB_INPUT_FOLDER}/CSS/Descriptors.json"
|
arguments -j "${LIBWEB_INPUT_FOLDER}/CSS/Descriptors.json"
|
||||||
)
|
)
|
||||||
|
|
||||||
invoke_generator(
|
invoke_cpp_generator(
|
||||||
"Enums.cpp"
|
"Enums.cpp"
|
||||||
Lagom::GenerateCSSEnums
|
Lagom::GenerateCSSEnums
|
||||||
"${LIBWEB_INPUT_FOLDER}/CSS/Enums.json"
|
"${LIBWEB_INPUT_FOLDER}/CSS/Enums.json"
|
||||||
|
@ -20,7 +20,7 @@ function (generate_css_implementation)
|
||||||
arguments -j "${LIBWEB_INPUT_FOLDER}/CSS/Enums.json"
|
arguments -j "${LIBWEB_INPUT_FOLDER}/CSS/Enums.json"
|
||||||
)
|
)
|
||||||
|
|
||||||
invoke_generator(
|
invoke_cpp_generator(
|
||||||
"MathFunctions.cpp"
|
"MathFunctions.cpp"
|
||||||
Lagom::GenerateCSSMathFunctions
|
Lagom::GenerateCSSMathFunctions
|
||||||
"${LIBWEB_INPUT_FOLDER}/CSS/MathFunctions.json"
|
"${LIBWEB_INPUT_FOLDER}/CSS/MathFunctions.json"
|
||||||
|
@ -29,7 +29,7 @@ function (generate_css_implementation)
|
||||||
arguments -j "${LIBWEB_INPUT_FOLDER}/CSS/MathFunctions.json"
|
arguments -j "${LIBWEB_INPUT_FOLDER}/CSS/MathFunctions.json"
|
||||||
)
|
)
|
||||||
|
|
||||||
invoke_generator(
|
invoke_cpp_generator(
|
||||||
"MediaFeatureID.cpp"
|
"MediaFeatureID.cpp"
|
||||||
Lagom::GenerateCSSMediaFeatureID
|
Lagom::GenerateCSSMediaFeatureID
|
||||||
"${LIBWEB_INPUT_FOLDER}/CSS/MediaFeatures.json"
|
"${LIBWEB_INPUT_FOLDER}/CSS/MediaFeatures.json"
|
||||||
|
@ -38,7 +38,7 @@ function (generate_css_implementation)
|
||||||
arguments -j "${LIBWEB_INPUT_FOLDER}/CSS/MediaFeatures.json"
|
arguments -j "${LIBWEB_INPUT_FOLDER}/CSS/MediaFeatures.json"
|
||||||
)
|
)
|
||||||
|
|
||||||
invoke_generator(
|
invoke_cpp_generator(
|
||||||
"PropertyID.cpp"
|
"PropertyID.cpp"
|
||||||
Lagom::GenerateCSSPropertyID
|
Lagom::GenerateCSSPropertyID
|
||||||
"${LIBWEB_INPUT_FOLDER}/CSS/Properties.json"
|
"${LIBWEB_INPUT_FOLDER}/CSS/Properties.json"
|
||||||
|
@ -47,7 +47,7 @@ function (generate_css_implementation)
|
||||||
arguments -j "${LIBWEB_INPUT_FOLDER}/CSS/Properties.json"
|
arguments -j "${LIBWEB_INPUT_FOLDER}/CSS/Properties.json"
|
||||||
)
|
)
|
||||||
|
|
||||||
invoke_generator(
|
invoke_cpp_generator(
|
||||||
"PseudoClass.cpp"
|
"PseudoClass.cpp"
|
||||||
Lagom::GenerateCSSPseudoClass
|
Lagom::GenerateCSSPseudoClass
|
||||||
"${LIBWEB_INPUT_FOLDER}/CSS/PseudoClasses.json"
|
"${LIBWEB_INPUT_FOLDER}/CSS/PseudoClasses.json"
|
||||||
|
@ -56,7 +56,7 @@ function (generate_css_implementation)
|
||||||
arguments -j "${LIBWEB_INPUT_FOLDER}/CSS/PseudoClasses.json"
|
arguments -j "${LIBWEB_INPUT_FOLDER}/CSS/PseudoClasses.json"
|
||||||
)
|
)
|
||||||
|
|
||||||
invoke_generator(
|
invoke_cpp_generator(
|
||||||
"PseudoElement.cpp"
|
"PseudoElement.cpp"
|
||||||
Lagom::GenerateCSSPseudoElement
|
Lagom::GenerateCSSPseudoElement
|
||||||
"${LIBWEB_INPUT_FOLDER}/CSS/PseudoElements.json"
|
"${LIBWEB_INPUT_FOLDER}/CSS/PseudoElements.json"
|
||||||
|
@ -65,7 +65,7 @@ function (generate_css_implementation)
|
||||||
arguments -j "${LIBWEB_INPUT_FOLDER}/CSS/PseudoElements.json"
|
arguments -j "${LIBWEB_INPUT_FOLDER}/CSS/PseudoElements.json"
|
||||||
)
|
)
|
||||||
|
|
||||||
invoke_generator(
|
invoke_cpp_generator(
|
||||||
"TransformFunctions.cpp"
|
"TransformFunctions.cpp"
|
||||||
Lagom::GenerateCSSTransformFunctions
|
Lagom::GenerateCSSTransformFunctions
|
||||||
"${LIBWEB_INPUT_FOLDER}/CSS/TransformFunctions.json"
|
"${LIBWEB_INPUT_FOLDER}/CSS/TransformFunctions.json"
|
||||||
|
@ -74,7 +74,7 @@ function (generate_css_implementation)
|
||||||
arguments -j "${LIBWEB_INPUT_FOLDER}/CSS/TransformFunctions.json"
|
arguments -j "${LIBWEB_INPUT_FOLDER}/CSS/TransformFunctions.json"
|
||||||
)
|
)
|
||||||
|
|
||||||
invoke_generator(
|
invoke_cpp_generator(
|
||||||
"Keyword.cpp"
|
"Keyword.cpp"
|
||||||
Lagom::GenerateCSSKeyword
|
Lagom::GenerateCSSKeyword
|
||||||
"${LIBWEB_INPUT_FOLDER}/CSS/Keywords.json"
|
"${LIBWEB_INPUT_FOLDER}/CSS/Keywords.json"
|
||||||
|
@ -154,7 +154,7 @@ endfunction()
|
||||||
function (generate_html_implementation)
|
function (generate_html_implementation)
|
||||||
set(LIBWEB_INPUT_FOLDER "${CMAKE_CURRENT_SOURCE_DIR}")
|
set(LIBWEB_INPUT_FOLDER "${CMAKE_CURRENT_SOURCE_DIR}")
|
||||||
|
|
||||||
invoke_generator(
|
invoke_cpp_generator(
|
||||||
"NamedCharacterReferences.cpp"
|
"NamedCharacterReferences.cpp"
|
||||||
Lagom::GenerateNamedCharacterReferences
|
Lagom::GenerateNamedCharacterReferences
|
||||||
"${LIBWEB_INPUT_FOLDER}/HTML/Parser/Entities.json"
|
"${LIBWEB_INPUT_FOLDER}/HTML/Parser/Entities.json"
|
||||||
|
|
|
@ -13,7 +13,7 @@ if (ENABLE_PUBLIC_SUFFIX_DOWNLOAD)
|
||||||
else()
|
else()
|
||||||
message(STATUS "Skipping download of ${PUBLIC_SUFFIX_DATA_URL}, expecting it to be in ${PUBLIC_SUFFIX_DATA_PATH}")
|
message(STATUS "Skipping download of ${PUBLIC_SUFFIX_DATA_URL}, expecting it to be in ${PUBLIC_SUFFIX_DATA_PATH}")
|
||||||
endif()
|
endif()
|
||||||
invoke_generator(
|
invoke_cpp_generator(
|
||||||
"PublicSuffixData"
|
"PublicSuffixData"
|
||||||
Lagom::GeneratePublicSuffixData
|
Lagom::GeneratePublicSuffixData
|
||||||
"${PUBLIC_SUFFIX_PATH}/"
|
"${PUBLIC_SUFFIX_PATH}/"
|
||||||
|
|
|
@ -40,17 +40,16 @@ function(remove_path_if_version_changed version version_file cache_path)
|
||||||
endif()
|
endif()
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
function(invoke_generator name generator primary_source header implementation)
|
function(invoke_generator_impl name generator primary_source header implementation)
|
||||||
cmake_parse_arguments(invoke_generator "" "" "arguments;dependencies" ${ARGN})
|
cmake_parse_arguments(invoke_generator_impl "" "" "command;arguments;dependencies" ${ARGN})
|
||||||
|
|
||||||
add_custom_command(
|
add_custom_command(
|
||||||
OUTPUT "${header}" "${implementation}"
|
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 "${header}.tmp" "${header}"
|
||||||
COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${implementation}.tmp" "${implementation}"
|
COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${implementation}.tmp" "${implementation}"
|
||||||
COMMAND "${CMAKE_COMMAND}" -E remove "${header}.tmp" "${implementation}.tmp"
|
COMMAND "${CMAKE_COMMAND}" -E remove "${header}.tmp" "${implementation}.tmp"
|
||||||
VERBATIM
|
VERBATIM
|
||||||
DEPENDS ${generator} ${invoke_generator_dependencies} "${primary_source}"
|
DEPENDS ${generator} ${invoke_generator_impl_dependencies} "${primary_source}"
|
||||||
)
|
)
|
||||||
|
|
||||||
add_custom_target("generate_${name}" DEPENDS "${header}" "${implementation}")
|
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)
|
set(CURRENT_LIB_GENERATED ${CURRENT_LIB_GENERATED} PARENT_SCOPE)
|
||||||
endfunction()
|
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)
|
function(invoke_idl_generator cpp_name idl_name generator primary_source header implementation idl)
|
||||||
cmake_parse_arguments(invoke_idl_generator "" "" "arguments;dependencies" ${ARGN})
|
cmake_parse_arguments(invoke_idl_generator "" "" "arguments;dependencies" ${ARGN})
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue