mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[Migrator] Add stubs for API change data files. (#8844)
These data files are installed into runtime resource directory so that migrator can pick them automatically according to specific platforms. To support testing, a front-end option -api-diff-data-file can be used to specify the data file to use and it will overwrite the default ones from resource directory.
This commit is contained in:
@@ -1544,7 +1544,8 @@ static bool ParseIRGenArgs(IRGenOptions &Opts, ArgList &Args,
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ParseMigratorArgs(MigratorOptions &Opts, ArgList &Args,
|
||||
bool ParseMigratorArgs(MigratorOptions &Opts, llvm::Triple &Triple,
|
||||
StringRef ResourcePath, ArgList &Args,
|
||||
DiagnosticEngine &Diags) {
|
||||
using namespace options;
|
||||
|
||||
@@ -1562,6 +1563,25 @@ bool ParseMigratorArgs(MigratorOptions &Opts, ArgList &Args,
|
||||
Opts.DumpMigrationStatesDir = Dumpster->getValue();
|
||||
}
|
||||
|
||||
if (auto DataPath = Args.getLastArg(OPT_api_diff_data_file)) {
|
||||
Opts.APIDigesterDataStorePath = DataPath->getValue();
|
||||
} else {
|
||||
bool Supported = true;
|
||||
llvm::SmallString<128> dataPath(ResourcePath);
|
||||
llvm::sys::path::append(dataPath, "migrator");
|
||||
if (Triple.isMacOSX())
|
||||
llvm::sys::path::append(dataPath, "macos.json");
|
||||
else if (Triple.isiOS())
|
||||
llvm::sys::path::append(dataPath, "ios.json");
|
||||
else if (Triple.isTvOS())
|
||||
llvm::sys::path::append(dataPath, "tvos.json");
|
||||
else if (Triple.isWatchOS())
|
||||
llvm::sys::path::append(dataPath, "watchos.json");
|
||||
else
|
||||
Supported = false;
|
||||
if (Supported)
|
||||
Opts.APIDigesterDataStorePath = dataPath.str();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1627,7 +1647,8 @@ bool CompilerInvocation::parseArgs(ArrayRef<const char *> Args,
|
||||
return true;
|
||||
}
|
||||
|
||||
if (ParseMigratorArgs(MigratorOpts, ParsedArgs, Diags)) {
|
||||
if (ParseMigratorArgs(MigratorOpts, LangOpts.Target,
|
||||
SearchPathOpts.RuntimeResourcePath, ParsedArgs, Diags)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user