Skip to content

Commit d9b7994

Browse files
authored
Merge pull request #75494 from hyp/eng/posix_filesystem_fix
[android] fix path and cmake local build target tracking for posix_fi…
2 parents 534ea14 + c036270 commit d9b7994

File tree

2 files changed

+16
-30
lines changed

2 files changed

+16
-30
lines changed

lib/ClangImporter/ClangIncludePaths.cpp

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -418,29 +418,6 @@ GetPlatformAuxiliaryFile(StringRef Platform, StringRef File,
418418
return "";
419419
}
420420

421-
SmallVector<std::pair<std::string, std::string>, 2>
422-
GetAndroidFileMappings(
423-
ASTContext &Context, const std::string &sysroot,
424-
const llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> &VFS) {
425-
const llvm::Triple &Triple = Context.LangOpts.Target;
426-
const SearchPathOptions &SearchPathOpts = Context.SearchPathOpts;
427-
SmallVector<std::pair<std::string, std::string>, 2> Mappings;
428-
std::string AuxiliaryFile;
429-
430-
if (!Triple.isAndroid()) return Mappings;
431-
432-
llvm::SmallString<261> NDKInjection{sysroot};
433-
llvm::sys::path::append(NDKInjection, "posix_filesystem.apinotes");
434-
435-
AuxiliaryFile =
436-
GetPlatformAuxiliaryFile("android", "posix_filesystem.apinotes",
437-
SearchPathOpts);
438-
if (!AuxiliaryFile.empty())
439-
Mappings.emplace_back(std::string(NDKInjection), AuxiliaryFile);
440-
441-
return Mappings;
442-
}
443-
444421
SmallVector<std::pair<std::string, std::string>, 2> GetWindowsFileMappings(
445422
ASTContext &Context,
446423
const llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> &driverVFS,
@@ -612,9 +589,5 @@ ClangInvocationFileMapping swift::getClangInvocationFileMapping(
612589

613590
result.redirectedFiles.append(GetWindowsFileMappings(
614591
ctx, vfs, result.requiresBuiltinHeadersInSystemModules));
615-
616-
result.redirectedFiles.append(GetAndroidFileMappings(ctx, sysroot.str().str(),
617-
vfs));
618-
619592
return result;
620593
}

stdlib/public/Platform/CMakeLists.txt

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -474,10 +474,23 @@ if("ANDROID" IN_LIST SWIFT_SDKS)
474474
endif()
475475
endforeach()
476476

477+
set(android_posix_filesystem_apinotes_source "posix_filesystem.apinotes")
478+
set(apinotes_subdir "${SWIFTLIB_DIR}/apinotes")
479+
add_custom_command_target(
480+
copy_android_posix_filesystem_apinotes_resource
481+
COMMAND
482+
"${CMAKE_COMMAND}" "-E" "make_directory" ${apinotes_subdir}
483+
COMMAND
484+
"${CMAKE_COMMAND}" "-E" "copy_if_different"
485+
"${CMAKE_CURRENT_SOURCE_DIR}/${android_posix_filesystem_apinotes_source}" ${apinotes_subdir}
486+
OUTPUT ${apinotes_subdir}/${android_posix_filesystem_apinotes_source}
487+
COMMENT "Copying Android posix_filesystem API notes to resource directories")
488+
add_dependencies(sdk-overlay ${copy_android_posix_filesystem_apinotes_resource})
489+
list(APPEND android_modulemap_target_list ${copy_android_posix_filesystem_apinotes_resource})
477490
swift_install_in_component(FILES
478-
posix_filesystem.apinotes
479-
DESTINATION "share"
480-
COMPONENT sdk-overlay)
491+
"${android_posix_filesystem_apinotes_source}"
492+
DESTINATION "lib/swift/apinotes"
493+
COMPONENT sdk-overlay)
481494
endif()
482495
add_custom_target(android_modulemap DEPENDS ${android_modulemap_target_list})
483496
set_property(TARGET android_modulemap PROPERTY FOLDER "Miscellaneous")

0 commit comments

Comments
 (0)