[cxx-interop][SwiftCompilerSources] Include Clang headers

This will allow using Swift headers that include Clang headers from SwiftCompilerSources.

For example, some headers in `swift/Basic` include headers from `clang/Basic`. Currently adding those Swift headers to the modulemap causes a build error.
This commit is contained in:
Egor Zhdan
2022-09-06 14:34:53 +01:00
parent 486dc27e1d
commit e515db9c48
2 changed files with 18 additions and 8 deletions

View File

@@ -160,6 +160,21 @@ function(add_swift_compiler_modules_library name)
if (add_to_syntaxparse) if (add_to_syntaxparse)
set(syntaxparse_obj_files ${syntaxparse_obj_files} ${module_obj_file}) set(syntaxparse_obj_files ${syntaxparse_obj_files} ${module_obj_file})
endif() endif()
set(c_include_paths
# LLVM modules and headers.
"${LLVM_MAIN_INCLUDE_DIR}"
# Generated LLVM headers.
"${LLVM_INCLUDE_DIR}"
# Clang modules and headers.
${CLANG_INCLUDE_DIRS}
# Bridging modules and headers.
"${SWIFT_MAIN_INCLUDE_DIR}"
# Generated C headers.
"${CMAKE_CURRENT_BINARY_DIR}/../include")
set(c_include_paths_args)
foreach(c_include_path ${c_include_paths})
list(APPEND c_include_paths_args "-Xcc" "-I" "-Xcc" "${c_include_path}")
endforeach()
# Compile the module into an object file # Compile the module into an object file
add_custom_command_target(dep_target OUTPUT ${module_obj_file} add_custom_command_target(dep_target OUTPUT ${module_obj_file}
@@ -173,14 +188,7 @@ function(add_swift_compiler_modules_library name)
"-emit-module-path" "${build_dir}/${module}.swiftmodule" "-emit-module-path" "${build_dir}/${module}.swiftmodule"
"-parse-as-library" ${sources} "-parse-as-library" ${sources}
"-wmo" ${swift_compile_options} "-wmo" ${swift_compile_options}
# LLVM modules and headers. ${c_include_paths_args}
"-Xcc" "-I" "-Xcc" "${LLVM_MAIN_INCLUDE_DIR}"
# Generated LLVM headers.
"-Xcc" "-I" "-Xcc" "${LLVM_INCLUDE_DIR}"
# Bridging modules and headers.
"-Xcc" "-I" "-Xcc" "${SWIFT_SOURCE_DIR}/include"
# Generated C headers.
"-Xcc" "-I" "-Xcc" "${CMAKE_CURRENT_BINARY_DIR}/../include"
# Generated swift modules. # Generated swift modules.
"-I" "${build_dir}" "-I" "${build_dir}"
COMMENT "Building swift module ${module}") COMMENT "Building swift module ${module}")

View File

@@ -22,6 +22,8 @@ private extension Target {
"-Xcc", "-I", "-Xcc", "../include", "-Xcc", "-I", "-Xcc", "../include",
// LLVM modules and headers // LLVM modules and headers
"-Xcc", "-I", "-Xcc", "../../llvm-project/llvm/include", "-Xcc", "-I", "-Xcc", "../../llvm-project/llvm/include",
// Clang modules and headers
"-Xcc", "-I", "-Xcc", "../../llvm-project/clang/include",
"-cross-module-optimization" "-cross-module-optimization"
]), ]),
] ]