@@ -79,6 +79,10 @@ static llvm::cl::opt<std::string>
79
79
OutputFile (" o" , llvm::cl::desc(" Output file" ),
80
80
llvm::cl::cat(Category));
81
81
82
+ static llvm::cl::opt<std::string>
83
+ OutputDir (" output-dir" , llvm::cl::desc(" Directory path to where we dump the generated Json files" ),
84
+ llvm::cl::cat(Category));
85
+
82
86
static llvm::cl::opt<std::string>
83
87
SDK (" sdk" , llvm::cl::desc(" path to the SDK to build against" ),
84
88
llvm::cl::cat(Category));
@@ -2713,8 +2717,10 @@ static std::string getDefaultBaselinePath(const char *Main, StringRef Module,
2713
2717
return BaselinePath.str ();
2714
2718
}
2715
2719
2716
- static std::string getCustomBaselinePath (llvm::Triple Triple) {
2720
+ static std::string getCustomBaselinePath (llvm::Triple Triple, bool ABI ) {
2717
2721
llvm::SmallString<128 > BaselinePath (options::BaselineDirPath);
2722
+ // Look for ABI or API baseline
2723
+ llvm::sys::path::append (BaselinePath, ABI? " ABI" : " API" );
2718
2724
llvm::sys::path::append (BaselinePath, getBaselineFilename (Triple));
2719
2725
return BaselinePath.str ();
2720
2726
}
@@ -2736,7 +2742,8 @@ static SDKNodeRoot *getBaselineFromJson(const char *Main, SDKContext &Ctx) {
2736
2742
" Cannot find builtin baseline for more than one module" );
2737
2743
std::string Path;
2738
2744
if (!options::BaselineDirPath.empty ()) {
2739
- Path = getCustomBaselinePath (Invok.getLangOptions ().Target );
2745
+ Path = getCustomBaselinePath (Invok.getLangOptions ().Target ,
2746
+ Ctx.checkingABI ());
2740
2747
} else if (options::UseEmptyBaseline) {
2741
2748
Path = getEmptyBaselinePath (Main);
2742
2749
} else {
@@ -2755,6 +2762,24 @@ static SDKNodeRoot *getBaselineFromJson(const char *Main, SDKContext &Ctx) {
2755
2762
return Collector.getSDKRoot ();
2756
2763
}
2757
2764
2765
+ static std::string getJsonOutputFilePath (llvm::Triple Triple, bool ABI) {
2766
+ if (!options::OutputFile.empty ())
2767
+ return options::OutputFile;
2768
+ if (!options::OutputDir.empty ()) {
2769
+ llvm::SmallString<128 > OutputPath (options::OutputDir);
2770
+ llvm::sys::path::append (OutputPath, ABI? " ABI" : " API" );
2771
+ if (!llvm::sys::fs::exists (OutputPath.str ())) {
2772
+ llvm::errs () << " Baseline directory " << OutputPath.str ()
2773
+ << " doesn't exist\n " ;
2774
+ exit (1 );
2775
+ }
2776
+ llvm::sys::path::append (OutputPath, getBaselineFilename (Triple));
2777
+ return OutputPath.str ();
2778
+ }
2779
+ llvm::errs () << " Unable to decide output file path\n " ;
2780
+ exit (1 );
2781
+ }
2782
+
2758
2783
int main (int argc, char *argv[]) {
2759
2784
PROGRAM_START (argc, argv);
2760
2785
INITIALIZE_LLVM ();
@@ -2773,7 +2798,9 @@ int main(int argc, char *argv[]) {
2773
2798
switch (options::Action) {
2774
2799
case ActionType::DumpSDK:
2775
2800
return (prepareForDump (argv[0 ], InitInvok, Modules)) ? 1 :
2776
- dumpSDKContent (InitInvok, Modules, options::OutputFile, Opts);
2801
+ dumpSDKContent (InitInvok, Modules,
2802
+ getJsonOutputFilePath (InitInvok.getLangOptions ().Target , Opts.ABI ),
2803
+ Opts);
2777
2804
case ActionType::MigratorGen:
2778
2805
case ActionType::DiagnoseSDKs: {
2779
2806
ComparisonInputMode Mode = checkComparisonInputMode ();
0 commit comments