[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:
Xi Ge
2017-04-18 15:20:57 -07:00
committed by GitHub
parent 60998cbb50
commit acf4f6e27e
10 changed files with 88 additions and 3 deletions

View File

@@ -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;
}