@@ -2544,9 +2544,7 @@ Job *Driver::buildJobsForAction(Compilation &C, const JobAction *JA,
2544
2544
if (OI.ShouldGenerateModule &&
2545
2545
(isa<CompileJobAction>(JA) || isa<MergeModuleJobAction>(JA))) {
2546
2546
chooseSwiftModuleDocOutputPath (C, OutputMap, workingDirectory, Output.get ());
2547
- choosePrivateOutputFilePath (C, OutputMap, workingDirectory, Output.get (),
2548
- file_types::TY_SwiftSourceInfoFile,
2549
- options::OPT_emit_module_source_info_path);
2547
+ chooseSwiftSourceInfoOutputPath (C, OutputMap, workingDirectory, Output.get ());
2550
2548
}
2551
2549
2552
2550
if (C.getArgs ().hasArg (options::OPT_emit_module_interface,
@@ -2790,12 +2788,13 @@ void Driver::chooseSwiftModuleOutputPath(Compilation &C,
2790
2788
}
2791
2789
}
2792
2790
2793
- void Driver::choosePrivateOutputFilePath (Compilation &C,
2794
- const TypeToPathMap *OutputMap,
2795
- StringRef workingDirectory,
2796
- CommandOutput *Output,
2797
- file_types::ID fileID,
2798
- Optional<options::ID> optId) const {
2791
+ static void chooseModuleAuxiliaryOutputFilePath (Compilation &C,
2792
+ const TypeToPathMap *OutputMap,
2793
+ StringRef workingDirectory,
2794
+ CommandOutput *Output,
2795
+ file_types::ID fileID,
2796
+ bool isPrivate,
2797
+ Optional<options::ID> optId = llvm::None) {
2799
2798
if (hasExistingAdditionalOutput (*Output, fileID))
2800
2799
return ;
2801
2800
// Honor driver option for this path if it's given
@@ -2820,10 +2819,12 @@ void Driver::choosePrivateOutputFilePath(Compilation &C,
2820
2819
bool isTempFile = C.isTemporaryFile (ModulePath);
2821
2820
auto ModuleName = llvm::sys::path::filename (ModulePath);
2822
2821
llvm::SmallString<128 > Path (llvm::sys::path::parent_path (ModulePath));
2823
- llvm::sys::path::append (Path, " Private" );
2824
- // If the build system has created a Private dir for us to include the file, use it.
2825
- if (!llvm::sys::fs::exists (Path)) {
2826
- llvm::sys::path::remove_filename (Path);
2822
+ if (isPrivate) {
2823
+ llvm::sys::path::append (Path, " Private" );
2824
+ // If the build system has created a Private dir for us to include the file, use it.
2825
+ if (!llvm::sys::fs::exists (Path)) {
2826
+ llvm::sys::path::remove_filename (Path);
2827
+ }
2827
2828
}
2828
2829
llvm::sys::path::append (Path, ModuleName);
2829
2830
llvm::sys::path::replace_extension (Path, file_types::getExtension (fileID));
@@ -2833,35 +2834,21 @@ void Driver::choosePrivateOutputFilePath(Compilation &C,
2833
2834
}
2834
2835
}
2835
2836
2837
+ void Driver::chooseSwiftSourceInfoOutputPath (Compilation &C,
2838
+ const TypeToPathMap *OutputMap,
2839
+ StringRef workingDirectory,
2840
+ CommandOutput *Output) const {
2841
+ chooseModuleAuxiliaryOutputFilePath (C, OutputMap, workingDirectory, Output,
2842
+ file_types::TY_SwiftSourceInfoFile,
2843
+ /* isPrivate*/ true , options::OPT_emit_module_source_info_path);
2844
+ }
2845
+
2836
2846
void Driver::chooseSwiftModuleDocOutputPath (Compilation &C,
2837
2847
const TypeToPathMap *OutputMap,
2838
2848
StringRef workingDirectory,
2839
2849
CommandOutput *Output) const {
2840
-
2841
- if (hasExistingAdditionalOutput (*Output, file_types::TY_SwiftModuleDocFile))
2842
- return ;
2843
-
2844
- StringRef OFMModuleDocOutputPath;
2845
- if (OutputMap) {
2846
- auto iter = OutputMap->find (file_types::TY_SwiftModuleDocFile);
2847
- if (iter != OutputMap->end ())
2848
- OFMModuleDocOutputPath = iter->second ;
2849
- }
2850
- if (!OFMModuleDocOutputPath.empty ()) {
2851
- // Prefer a path from the OutputMap.
2852
- Output->setAdditionalOutputForType (file_types::TY_SwiftModuleDocFile,
2853
- OFMModuleDocOutputPath);
2854
- } else if (Output->getPrimaryOutputType () != file_types::TY_Nothing) {
2855
- // Otherwise, put it next to the swiftmodule file.
2856
- llvm::SmallString<128 > Path (
2857
- Output->getAnyOutputForType (file_types::TY_SwiftModuleFile));
2858
- bool isTempFile = C.isTemporaryFile (Path);
2859
- llvm::sys::path::replace_extension (
2860
- Path, file_types::getExtension (file_types::TY_SwiftModuleDocFile));
2861
- Output->setAdditionalOutputForType (file_types::TY_SwiftModuleDocFile, Path);
2862
- if (isTempFile)
2863
- C.addTemporaryFile (Path);
2864
- }
2850
+ chooseModuleAuxiliaryOutputFilePath (C, OutputMap, workingDirectory, Output,
2851
+ file_types::TY_SwiftModuleDocFile, /* isPrivate*/ false );
2865
2852
}
2866
2853
2867
2854
void Driver::chooseRemappingOutputPath (Compilation &C,
0 commit comments