summaryrefslogtreecommitdiff
path: root/Meta/CMake/libweb_generators.cmake
diff options
context:
space:
mode:
authorAndrew Kaster <akaster@serenityos.org>2022-10-08 16:58:55 -0600
committerAndreas Kling <kling@serenityos.org>2022-10-09 10:14:57 +0200
commit2acff8d853c7c3859467104151997d9949027cfe (patch)
tree9957fb737b4e7b477876865bc736ac80eb38df1d /Meta/CMake/libweb_generators.cmake
parent067a53b7e7984d193abb0d0b69aad9ddfbd2745a (diff)
downloadserenity-2acff8d853c7c3859467104151997d9949027cfe.zip
LibWeb: Add new code generator for creating exposed interface helpers
This new code generator takes all the .idl files in LibWeb, looks for each top level interface in there with an [Exposed=Foo] attribute, and adds code to add the constructor and prototype for each of those exposed interfaces to the realm of the relevant global object we're initialzing. It will soon replace WindowObjectHelper as the way that web interfaces are added to the Window object, and will be used in the future for creating proper WorkerGlobalScope objects for dedicated and shared workers.
Diffstat (limited to 'Meta/CMake/libweb_generators.cmake')
-rw-r--r--Meta/CMake/libweb_generators.cmake28
1 files changed, 28 insertions, 0 deletions
diff --git a/Meta/CMake/libweb_generators.cmake b/Meta/CMake/libweb_generators.cmake
index d4c0fec9cf..cce8ce7c33 100644
--- a/Meta/CMake/libweb_generators.cmake
+++ b/Meta/CMake/libweb_generators.cmake
@@ -158,8 +158,36 @@ function (generate_js_bindings target)
add_dependencies(all_generated generate_${basename}Prototype.h)
add_custom_target(generate_${basename}Prototype.cpp DEPENDS ${LIBWEB_OUTPUT_FOLDER}Bindings/${basename}Prototype.cpp)
add_dependencies(all_generated generate_${basename}Prototype.cpp)
+
+ list(APPEND LIBWEB_ALL_IDL_FILES "${LIBWEB_INPUT_FOLDER}/${class}.idl")
+ set(LIBWEB_ALL_IDL_FILES ${LIBWEB_ALL_IDL_FILES} PARENT_SCOPE)
+ endfunction()
+
+ function(generate_exposed_interface_files)
+ set(exposed_interface_sources DedicatedWorkerExposedInterfaces.cpp DedicatedWorkerExposedInterfaces.h
+ SharedWorkerExposedInterfaces.cpp SharedWorkerExposedInterfaces.h
+ WindowExposedInterfaces.cpp WindowExposedInterfaces.h)
+ list(TRANSFORM exposed_interface_sources PREPEND "${LIBWEB_OUTPUT_FOLDER}Bindings/")
+ add_custom_command(
+ OUTPUT ${exposed_interface_sources}
+ COMMAND "${CMAKE_COMMAND}" -E make_directory "tmp"
+ COMMAND $<TARGET_FILE:Lagom::GenerateWindowOrWorkerInterfaces> -o "${CMAKE_CURRENT_BINARY_DIR}/tmp" -b "${LIBWEB_INPUT_FOLDER}" ${LIBWEB_ALL_IDL_FILES}
+ COMMAND "${CMAKE_COMMAND}" -E copy_if_different tmp/DedicatedWorkerExposedInterfaces.h "${LIBWEB_OUTPUT_FOLDER}Bindings/DedicatedWorkerExposedInterfaces.h"
+ COMMAND "${CMAKE_COMMAND}" -E copy_if_different tmp/DedicatedWorkerExposedInterfaces.cpp "${LIBWEB_OUTPUT_FOLDER}Bindings/DedicatedWorkerExposedInterfaces.cpp"
+ COMMAND "${CMAKE_COMMAND}" -E copy_if_different tmp/SharedWorkerExposedInterfaces.h "${LIBWEB_OUTPUT_FOLDER}Bindings/SharedWorkerExposedInterfaces.h"
+ COMMAND "${CMAKE_COMMAND}" -E copy_if_different tmp/SharedWorkerExposedInterfaces.cpp "${LIBWEB_OUTPUT_FOLDER}Bindings/SharedWorkerExposedInterfaces.cpp"
+ COMMAND "${CMAKE_COMMAND}" -E copy_if_different tmp/WindowExposedInterfaces.h "${LIBWEB_OUTPUT_FOLDER}Bindings/WindowExposedInterfaces.h"
+ COMMAND "${CMAKE_COMMAND}" -E copy_if_different tmp/WindowExposedInterfaces.cpp "${LIBWEB_OUTPUT_FOLDER}Bindings/WindowExposedInterfaces.cpp"
+ COMMAND "${CMAKE_COMMAND}" -E remove_directory "${CMAKE_CURRENT_BINARY_DIR}/tmp"
+ VERBATIM
+ DEPENDS Lagom::GenerateWindowOrWorkerInterfaces ${LIBWEB_ALL_IDL_FILES}
+ )
+ target_sources(${target} PRIVATE ${exposed_interface_sources})
+ add_custom_target("generate_${LIBWEB_META_PREFIX}exposed_interfaces" DEPENDS ${exposed_interface_sources})
+ add_dependencies(all_generated "generate_${LIBWEB_META_PREFIX}exposed_interfaces")
endfunction()
include("${LIBWEB_INPUT_FOLDER}/idl_files.cmake")
+ generate_exposed_interface_files()
endfunction()