mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-01-07 19:57:45 +03:00
Lagom+CMake: Propagate dependencies for generated custom targets
We have logic for serenity_generated_sources which works well for source files that are specified in GENERATED_SOURCES prior to calling serenity_lib or serenity_bin. However, code generated with invoke_generator, and the LibWeb generators do not always follow the pattern of the IDL and GML files. For the LibWeb generators, we can just add_dependencies to LibWeb at the time we declare the generate_Foo custom target. However for LibLocale, LibTimeZone, and LibUnicode, we don't have the name of the target available, so export the name in a variable to set into GENERATED_SOURCES. To make this work for Lagom, we need to make sure that lagom_lib and serenity_bin in Lagom/CMakeLists.txt call serenity_generated_sources on the target. This enables the Xcode generator on macOS hosts, at least for Lagom.
This commit is contained in:
parent
8160b53228
commit
b8e51425e9
Notes:
sideshowbarker
2024-07-17 05:26:08 +09:00
Author: https://github.com/ADKaster Commit: https://github.com/SerenityOS/serenity/commit/b8e51425e9 Pull-request: https://github.com/SerenityOS/serenity/pull/15659 Reviewed-by: https://github.com/linusg ✅
@ -121,14 +121,13 @@ function (generate_js_bindings target)
|
|||||||
MAIN_DEPENDENCY ${class}.idl
|
MAIN_DEPENDENCY ${class}.idl
|
||||||
)
|
)
|
||||||
endforeach()
|
endforeach()
|
||||||
add_custom_target(generate_${basename}Constructor.h DEPENDS Bindings/${basename}Constructor.h)
|
|
||||||
add_dependencies(all_generated generate_${basename}Constructor.h)
|
foreach(generated_file IN LISTS BINDINGS_SOURCES)
|
||||||
add_custom_target(generate_${basename}Constructor.cpp DEPENDS Bindings/${basename}Constructor.cpp)
|
get_filename_component(generated_name ${generated_file} NAME)
|
||||||
add_dependencies(all_generated generate_${basename}Constructor.cpp)
|
add_custom_target(generate_${generated_name} DEPENDS ${generated_file})
|
||||||
add_custom_target(generate_${basename}Prototype.h DEPENDS Bindings/${basename}Prototype.h)
|
add_dependencies(all_generated generate_${generated_name})
|
||||||
add_dependencies(all_generated generate_${basename}Prototype.h)
|
add_dependencies(${target} generate_${generated_name})
|
||||||
add_custom_target(generate_${basename}Prototype.cpp DEPENDS Bindings/${basename}Prototype.cpp)
|
endforeach()
|
||||||
add_dependencies(all_generated generate_${basename}Prototype.cpp)
|
|
||||||
|
|
||||||
list(APPEND LIBWEB_ALL_IDL_FILES "${LIBWEB_INPUT_FOLDER}/${class}.idl")
|
list(APPEND LIBWEB_ALL_IDL_FILES "${LIBWEB_INPUT_FOLDER}/${class}.idl")
|
||||||
set(LIBWEB_ALL_IDL_FILES ${LIBWEB_ALL_IDL_FILES} PARENT_SCOPE)
|
set(LIBWEB_ALL_IDL_FILES ${LIBWEB_ALL_IDL_FILES} PARENT_SCOPE)
|
||||||
@ -154,8 +153,9 @@ function (generate_js_bindings target)
|
|||||||
DEPENDS Lagom::GenerateWindowOrWorkerInterfaces ${LIBWEB_ALL_IDL_FILES}
|
DEPENDS Lagom::GenerateWindowOrWorkerInterfaces ${LIBWEB_ALL_IDL_FILES}
|
||||||
)
|
)
|
||||||
target_sources(${target} PRIVATE ${exposed_interface_sources})
|
target_sources(${target} PRIVATE ${exposed_interface_sources})
|
||||||
add_custom_target("generate_exposed_interfaces" DEPENDS ${exposed_interface_sources})
|
add_custom_target(generate_exposed_interfaces DEPENDS ${exposed_interface_sources})
|
||||||
add_dependencies(all_generated "generate_exposed_interfaces")
|
add_dependencies(all_generated generate_exposed_interfaces)
|
||||||
|
add_dependencies(${target} generate_exposed_interfaces)
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
include("idl_files.cmake")
|
include("idl_files.cmake")
|
||||||
|
@ -192,6 +192,8 @@ function(invoke_generator name generator version_file header implementation)
|
|||||||
|
|
||||||
add_custom_target("generate_${name}" DEPENDS "${header}" "${implementation}")
|
add_custom_target("generate_${name}" DEPENDS "${header}" "${implementation}")
|
||||||
add_dependencies(all_generated "generate_${name}")
|
add_dependencies(all_generated "generate_${name}")
|
||||||
|
list(APPEND CURRENT_LIB_GENERATED "${name}")
|
||||||
|
set(CURRENT_LIB_GENERATED ${CURRENT_LIB_GENERATED} PARENT_SCOPE)
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
function(download_file url path)
|
function(download_file url path)
|
||||||
|
@ -224,6 +224,7 @@ function(lagom_lib target_name fs_name)
|
|||||||
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
|
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
|
||||||
FILES_MATCHING PATTERN "*.h"
|
FILES_MATCHING PATTERN "*.h"
|
||||||
)
|
)
|
||||||
|
serenity_generated_sources(${target_name})
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
function(lagom_test source)
|
function(lagom_test source)
|
||||||
@ -254,6 +255,7 @@ function(serenity_bin name)
|
|||||||
INCLUDES #
|
INCLUDES #
|
||||||
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
|
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
|
||||||
)
|
)
|
||||||
|
serenity_generated_sources(${name})
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
function(serenity_lib name fs_name)
|
function(serenity_lib name fs_name)
|
||||||
@ -372,9 +374,11 @@ if (BUILD_LAGOM)
|
|||||||
list(APPEND LIBWEBVIEW_GENERATED_SOURCES WebContent/WebContentClientEndpoint.h)
|
list(APPEND LIBWEBVIEW_GENERATED_SOURCES WebContent/WebContentClientEndpoint.h)
|
||||||
list(APPEND LIBWEBVIEW_GENERATED_SOURCES WebContent/WebContentServerEndpoint.h)
|
list(APPEND LIBWEBVIEW_GENERATED_SOURCES WebContent/WebContentServerEndpoint.h)
|
||||||
|
|
||||||
|
set(GENERATED_SOURCES ${LIBWEBVIEW_GENERATED_SOURCES})
|
||||||
lagom_lib(LibWebView webview
|
lagom_lib(LibWebView webview
|
||||||
SOURCES ${LIBWEBVIEW_SOURCES} ${LIBWEBVIEW_GENERATED_SOURCES}
|
SOURCES ${LIBWEBVIEW_SOURCES} ${LIBWEBVIEW_GENERATED_SOURCES}
|
||||||
LIBS LibGUI LibWeb)
|
LIBS LibGUI LibWeb)
|
||||||
|
unset(GENERATED_SOURCES)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# FIXME: Excluding arm64 is a temporary hack to circumvent a build problem
|
# FIXME: Excluding arm64 is a temporary hack to circumvent a build problem
|
||||||
|
@ -2,13 +2,16 @@ include(${SerenityOS_SOURCE_DIR}/Meta/CMake/locale_data.cmake)
|
|||||||
|
|
||||||
if (DEFINED LOCALE_DATA_SOURCES)
|
if (DEFINED LOCALE_DATA_SOURCES)
|
||||||
set(SOURCES ${LOCALE_DATA_SOURCES})
|
set(SOURCES ${LOCALE_DATA_SOURCES})
|
||||||
|
set(GENERATED_SOURCES ${CURRENT_LIB_GENERATED})
|
||||||
if (SERENITYOS)
|
if (SERENITYOS)
|
||||||
serenity_lib(LibLocaleData localedata)
|
serenity_lib(LibLocaleData localedata)
|
||||||
else()
|
else()
|
||||||
add_library(LibLocaleData OBJECT ${SOURCES})
|
add_library(LibLocaleData OBJECT ${SOURCES})
|
||||||
|
serenity_generated_sources(LibLocaleData)
|
||||||
endif()
|
endif()
|
||||||
target_compile_options(LibLocaleData PRIVATE -g0 -Os -Wno-parentheses-equality)
|
target_compile_options(LibLocaleData PRIVATE -g0 -Os -Wno-parentheses-equality)
|
||||||
target_link_libraries(LibLocaleData LibCore LibTimeZone)
|
target_link_libraries(LibLocaleData LibCore LibTimeZone)
|
||||||
|
unset(GENERATED_SOURCES)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
set(SOURCES
|
set(SOURCES
|
||||||
|
@ -4,8 +4,10 @@ set(SOURCES
|
|||||||
TimeZone.cpp
|
TimeZone.cpp
|
||||||
${TIME_ZONE_DATA_SOURCES}
|
${TIME_ZONE_DATA_SOURCES}
|
||||||
)
|
)
|
||||||
|
set(GENERATED_SOURCES ${CURRENT_LIB_GENERATED})
|
||||||
|
|
||||||
add_library(LibTimeZone OBJECT ${SOURCES})
|
add_library(LibTimeZone OBJECT ${SOURCES})
|
||||||
|
serenity_generated_sources(LibTimeZone)
|
||||||
target_compile_definitions(LibTimeZone PRIVATE ENABLE_TIME_ZONE_DATA=$<BOOL:${ENABLE_TIME_ZONE_DATABASE_DOWNLOAD}>)
|
target_compile_definitions(LibTimeZone PRIVATE ENABLE_TIME_ZONE_DATA=$<BOOL:${ENABLE_TIME_ZONE_DATABASE_DOWNLOAD}>)
|
||||||
|
|
||||||
# NOTE: These objects are used by the DynamicLoader, which is always built without coverage instrumentation.
|
# NOTE: These objects are used by the DynamicLoader, which is always built without coverage instrumentation.
|
||||||
|
@ -7,6 +7,7 @@ set(SOURCES
|
|||||||
Normalize.cpp
|
Normalize.cpp
|
||||||
${UNICODE_DATA_SOURCES}
|
${UNICODE_DATA_SOURCES}
|
||||||
)
|
)
|
||||||
|
set(GENERATED_SOURCES ${CURRENT_LIB_GENERATED})
|
||||||
|
|
||||||
serenity_lib(LibUnicode unicode)
|
serenity_lib(LibUnicode unicode)
|
||||||
target_link_libraries(LibUnicode LibCore)
|
target_link_libraries(LibUnicode LibCore)
|
||||||
|
Loading…
Reference in New Issue
Block a user