add_custom_target(diagnostic-translation-database)

add_custom_command(
  TARGET diagnostic-translation-database
  WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
  DEPENDS diagnostics
  COMMAND "${CMAKE_COMMAND}" -E copy_directory diagnostics/ "${SWIFT_BINARY_DIR}/share/swift/diagnostics/")

add_custom_command(
  TARGET diagnostic-translation-database
  WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
  COMMAND swift-serialize-diagnostics
    --input-file-path diagnostics/en.yaml
    --output-directory ${SWIFT_BINARY_DIR}/share/swift/diagnostics)

add_dependencies(swift-frontend diagnostic-translation-database)

swift_install_in_component(
  DIRECTORY diagnostics
  DESTINATION "share/swift"
  COMPONENT compiler)

add_custom_target(diagnostic-database)

add_custom_command(TARGET diagnostic-database
  COMMAND
    ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/diagnostics/ ${CMAKE_BINARY_DIR}/share/swift/diagnostics/
  COMMAND
    swift-serialize-diagnostics
      --input-file-path ${CMAKE_BINARY_DIR}/share/swift/diagnostics/en.yaml
      --output-directory ${CMAKE_BINARY_DIR}/share/swift/diagnostics/
)

add_dependencies(swift-frontend diagnostic-database)

swift_install_in_component(
  DIRECTORY ${CMAKE_BINARY_DIR}/share/swift/diagnostics/
  DESTINATION "share/swift/diagnostics"
  COMPONENT compiler)

Adjust cmake to include serialized diagnostics in toolchain
[Localization] Adjust cmake to include serialized diagnostics in toolchain

Building of the diagnostic database to be done in three steps:

- Copy YAMLs from <source>/localization/diagnostics to <build>/share/swift/diagnostics
- Serialize English into <build>/share/swift/diagnostics
- Install everything (YAML and `.db`) from <build>/share/swift/diagnostics
  to share/swift/diagnostics in toolchain
