mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[embedded] Include and use cxxshims in the embedded/ resource dir
This commit is contained in:
@@ -574,7 +574,7 @@ void importer::getNormalInvocationArguments(
|
||||
}
|
||||
|
||||
if (LangOpts.EnableCXXInterop) {
|
||||
if (auto path = getCxxShimModuleMapPath(searchPathOpts, triple)) {
|
||||
if (auto path = getCxxShimModuleMapPath(searchPathOpts, LangOpts, triple)) {
|
||||
invocationArgStrs.push_back((Twine("-fmodule-map-file=") + *path).str());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,14 +27,18 @@ using namespace swift;
|
||||
using Path = SmallString<128>;
|
||||
|
||||
static std::optional<Path> getActualModuleMapPath(
|
||||
StringRef name, SearchPathOptions &Opts, const llvm::Triple &triple,
|
||||
bool isArchSpecific,
|
||||
StringRef name, SearchPathOptions &Opts, const LangOptions &LangOpts,
|
||||
const llvm::Triple &triple, bool isArchSpecific,
|
||||
const llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> &vfs) {
|
||||
StringRef platform;
|
||||
if (swift::tripleIsMacCatalystEnvironment(triple))
|
||||
platform = "macosx";
|
||||
else
|
||||
platform = swift::getPlatformNameForTriple(triple);
|
||||
|
||||
if (LangOpts.hasFeature(Feature::Embedded))
|
||||
platform = "embedded";
|
||||
|
||||
StringRef arch = swift::getMajorArchitectureName(triple);
|
||||
|
||||
Path result;
|
||||
@@ -95,16 +99,18 @@ static std::optional<Path> getInjectedModuleMapPath(
|
||||
}
|
||||
|
||||
static std::optional<Path> getLibStdCxxModuleMapPath(
|
||||
SearchPathOptions &opts, const llvm::Triple &triple,
|
||||
SearchPathOptions &opts, const LangOptions &langOpts,
|
||||
const llvm::Triple &triple,
|
||||
const llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> &vfs) {
|
||||
return getActualModuleMapPath("libstdcxx.modulemap", opts, triple,
|
||||
return getActualModuleMapPath("libstdcxx.modulemap", opts, langOpts, triple,
|
||||
/*isArchSpecific*/ false, vfs);
|
||||
}
|
||||
|
||||
std::optional<SmallString<128>>
|
||||
swift::getCxxShimModuleMapPath(SearchPathOptions &opts,
|
||||
const LangOptions &langOpts,
|
||||
const llvm::Triple &triple) {
|
||||
return getActualModuleMapPath("libcxxshim.modulemap", opts, triple,
|
||||
return getActualModuleMapPath("libcxxshim.modulemap", opts, langOpts, triple,
|
||||
/*isArchSpecific*/ false,
|
||||
llvm::vfs::getRealFileSystem());
|
||||
}
|
||||
@@ -225,7 +231,8 @@ getLibcFileMapping(ASTContext &ctx, StringRef modulemapFileName,
|
||||
|
||||
Path actualModuleMapPath;
|
||||
if (auto path = getActualModuleMapPath(modulemapFileName, ctx.SearchPathOpts,
|
||||
triple, /*isArchSpecific*/ true, vfs))
|
||||
ctx.LangOpts, triple,
|
||||
/*isArchSpecific*/ true, vfs))
|
||||
actualModuleMapPath = path.value();
|
||||
else
|
||||
// FIXME: Emit a warning of some kind.
|
||||
@@ -305,7 +312,8 @@ static void getLibStdCxxFileMapping(
|
||||
}
|
||||
|
||||
Path actualModuleMapPath;
|
||||
if (auto path = getLibStdCxxModuleMapPath(ctx.SearchPathOpts, triple, vfs))
|
||||
if (auto path = getLibStdCxxModuleMapPath(ctx.SearchPathOpts, ctx.LangOpts,
|
||||
triple, vfs))
|
||||
actualModuleMapPath = path.value();
|
||||
else
|
||||
return;
|
||||
|
||||
@@ -18,7 +18,8 @@
|
||||
namespace swift {
|
||||
|
||||
std::optional<SmallString<128>>
|
||||
getCxxShimModuleMapPath(SearchPathOptions &opts, const llvm::Triple &triple);
|
||||
getCxxShimModuleMapPath(SearchPathOptions &opts, const LangOptions &langOpts,
|
||||
const llvm::Triple &triple);
|
||||
|
||||
} // namespace swift
|
||||
|
||||
|
||||
@@ -67,6 +67,27 @@ foreach(sdk ${SWIFT_SDKS})
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
if(SWIFT_SHOULD_BUILD_EMBEDDED_STDLIB)
|
||||
set(module_dir "${SWIFTLIB_DIR}/embedded")
|
||||
add_custom_command(OUTPUT ${module_dir}
|
||||
COMMAND ${CMAKE_COMMAND} "-E" "make_directory" "${module_dir}")
|
||||
set(outputs)
|
||||
foreach(source libcxxshim.modulemap libcxxshim.h libcxxstdlibshim.h)
|
||||
add_custom_command(OUTPUT ${module_dir}/${source}
|
||||
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${source}
|
||||
COMMAND ${CMAKE_COMMAND} "-E" "copy_if_different" "${CMAKE_CURRENT_SOURCE_DIR}/${source}" "${module_dir}/${source}"
|
||||
COMMENT "Copying ${source} to ${module_dir}")
|
||||
list(APPEND outputs "${module_dir}/${source}")
|
||||
endforeach()
|
||||
add_custom_target(cxxshim-embedded ALL
|
||||
DEPENDS ${outputs}
|
||||
COMMENT "Copying cxxshims to ${module_dir}")
|
||||
list(APPEND libcxxshim_modulemap_target_list cxxshim-embedded)
|
||||
swift_install_in_component(FILES libcxxshim.modulemap libcxxshim.h libcxxstdlibshim.h
|
||||
DESTINATION "lib/swift/embedded"
|
||||
COMPONENT compiler)
|
||||
endif()
|
||||
|
||||
add_custom_target(libcxxshim_modulemap DEPENDS ${libcxxshim_modulemap_target_list})
|
||||
set_property(TARGET libcxxshim_modulemap PROPERTY FOLDER "Miscellaneous")
|
||||
add_dependencies(sdk-overlay libcxxshim_modulemap)
|
||||
|
||||
Reference in New Issue
Block a user