Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: de4a43034222f6c36eab63578c1617d9a295a923
      
https://github.com/WebKit/WebKit/commit/de4a43034222f6c36eab63578c1617d9a295a923
  Author: Adrian Taylor <[email protected]>
  Date:   2026-05-19 (Tue, 19 May 2026)

  Changed paths:
    M Source/WebKit/CMakeLists.txt
    M Source/cmake/WebKitMacros.cmake

  Log Message:
  -----------
  [Swift GTK] Track header dependencies for Swift compilation
https://bugs.webkit.org/show_bug.cgi?id=315044

Reviewed by Geoffrey Garen.

Swift compilation (both the main object-file step and the C++ header
emission step) can fail on a clean build if generated headers are not yet
on disk when swiftc runs. The root cause is that CMake needs explicit
ordering edges for generated files; the DEPFILE mechanism only helps for
incremental rebuilds.

Furthermore, we need to rebuild Swift when such a header changes.

The previous approach hard-coded WebKitLogDefinitions.h as an extra
dependency. That was incomplete in two ways: it only covered the header
emission add_custom_command (not the main Swift compilation), and it
required each generated header to be listed manually.

The fix:

* In WEBKIT_SETUP_SWIFT_AND_GENERATE_SWIFT_CPP_INTEROP_HEADER, create an
  empty placeholder custom target ${_target}_SwiftGeneratedDeps and list
  it in the add_custom_command DEPENDS. At macro-expansion time the
  generated-file set is not yet fully known, so the placeholder starts
  with no file dependencies.

* In _webkit_setup_swift_header_deps (called deferred at end-of-directory,
  so ${_target}_HEADERS and ${_target}_DERIVED_SOURCES are fully
  populated), scan those lists for files under CMAKE_BINARY_DIR. Any such
  file is a product of an add_custom_command and must exist before Swift
  can run. Create ${_target}_SwiftGenFileOrderDeps with those files as
  DEPENDS, chain it into the placeholder, and add an ordering dependency
  from the main target to the placeholder. This covers both the header-
  emission step (via the custom command's DEPENDS) and the main Swift
  compilation (via add_dependencies on the library target).

Additionally, add -track-system-dependencies since the modulemaps
contain [system] and otherwise header tracking does not spot changes.

Co-authored with Claude.

Canonical link: https://commits.webkit.org/313548@main



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications

Reply via email to