Skip to content

api-digester: rename argument -compare-sdk to -generate-migration-script. SR-10489 #24871

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 17, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions test/api-digester/apinotes-migrator-gen.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// RUN: %empty-directory(%t.module-cache)
// RUN: %api-digester -dump-sdk -module APINotesTest -o %t.dump1.json -module-cache-path %t.module-cache %clang-importer-sdk-nosource -swift-version 5 -I %S/Inputs/APINotesLeft
// RUN: %api-digester -dump-sdk -module APINotesTest -o %t.dump2.json -module-cache-path %t.module-cache %clang-importer-sdk-nosource -swift-version 5 -I %S/Inputs/APINotesRight
// RUN: %api-digester -compare-sdk --input-paths %t.dump1.json -input-paths %t.dump2.json -o %t.result -json
// RUN: %api-digester -generate-migration-script --input-paths %t.dump1.json -input-paths %t.dump2.json -o %t.result -json
// RUN: diff -u %S/Outputs/apinotes-migrator-gen.json %t.result
// RUN: %api-digester -compare-sdk --input-paths %t.dump2.json -input-paths %t.dump1.json -o %t.result -json
// RUN: %api-digester -generate-migration-script --input-paths %t.dump2.json -input-paths %t.dump1.json -o %t.result -json
// RUN: diff -u %S/Outputs/apinotes-migrator-gen-revert.json %t.result
2 changes: 1 addition & 1 deletion test/api-digester/macro-gen-json.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
// RUN: %swift -emit-module -o %t.mod/macrogenright.swiftmodule %S/Inputs/macro-gen-right.swift -parse-as-library
// RUN: %api-digester -dump-sdk -module macrogenleft -o %t.dump1.json -module-cache-path %t.module-cache -sdk %t.sdk -I %t.mod
// RUN: %api-digester -dump-sdk -module macrogenright -o %t.dump2.json -module-cache-path %t.module-cache -sdk %t.sdk -I %t.mod
// RUN: %api-digester -compare-sdk --input-paths %t.dump1.json -input-paths %t.dump2.json -o %t.result -json
// RUN: %api-digester -generate-migration-script --input-paths %t.dump1.json -input-paths %t.dump2.json -o %t.result -json
// RUN: diff -u %S/Outputs/macro-gen.json %t.result
2 changes: 1 addition & 1 deletion test/api-digester/macro-gen.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
// RUN: %swift -emit-module -o %t.mod/macrogenright.swiftmodule %S/Inputs/macro-gen-right.swift -parse-as-library
// RUN: %api-digester -dump-sdk -module macrogenleft -o %t.dump1.json -module-cache-path %t.module-cache -sdk %t.sdk -swift-version 4 -I %t.mod
// RUN: %api-digester -dump-sdk -module macrogenright -o %t.dump2.json -module-cache-path %t.module-cache -sdk %t.sdk -swift-version 5 -I %t.mod
// RUN: %api-digester -compare-sdk --input-paths %t.dump1.json -input-paths %t.dump2.json -o %t.result
// RUN: %api-digester -generate-migration-script --input-paths %t.dump1.json -input-paths %t.dump2.json -o %t.result
// RUN: diff -u %S/Outputs/macro-gen.def %t.result
24 changes: 13 additions & 11 deletions tools/swift-api-digester/swift-api-digester.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ namespace {
None,
DumpSDK,
DumpSwiftModules,
CompareSDKs,
MigratorGen,
DiagnoseSDKs,
// The following two are for testing purposes
DeserializeDiffItems,
Expand Down Expand Up @@ -141,9 +141,9 @@ Action(llvm::cl::desc("Mode:"), llvm::cl::init(ActionType::None),
clEnumValN(ActionType::DumpSwiftModules,
"dump-swift",
"dump swift modules in SDK"),
clEnumValN(ActionType::CompareSDKs,
"compare-sdk",
"Compare SDK content in JSON file"),
clEnumValN(ActionType::MigratorGen,
"generate-migration-script",
"Compare SDK content in JSON file and generate migration script"),
clEnumValN(ActionType::DiagnoseSDKs,
"diagnose-sdk",
"Diagnose SDK content in JSON file"),
Expand Down Expand Up @@ -2128,9 +2128,10 @@ static void populateAliasChanges(NodeMap &AliasMap, DiffVector &AllItems,
}
}

static int compareSDKs(StringRef LeftPath, StringRef RightPath,
StringRef DiffPath,
llvm::StringSet<> &IgnoredRemoveUsrs, CheckerOptions Opts) {
static int generateMigrationScript(StringRef LeftPath, StringRef RightPath,
StringRef DiffPath,
llvm::StringSet<> &IgnoredRemoveUsrs,
CheckerOptions Opts) {
if (!fs::exists(LeftPath)) {
llvm::errs() << LeftPath << " does not exist\n";
return 1;
Expand Down Expand Up @@ -2395,7 +2396,7 @@ int main(int argc, char *argv[]) {
case ActionType::DumpSDK:
return (prepareForDump(argv[0], InitInvok, Modules)) ? 1 :
dumpSDKContent(InitInvok, Modules, options::OutputFile, Opts);
case ActionType::CompareSDKs:
case ActionType::MigratorGen:
case ActionType::DiagnoseSDKs: {
if (options::SDKJsonPaths.size() != 2) {
llvm::errs() << "Only two SDK versions can be compared\n";
Expand All @@ -2407,9 +2408,10 @@ int main(int argc, char *argv[]) {
if (readFileLineByLine(options::ProtReqWhiteList, protocolWhitelist))
return 1;
}
if (options::Action == ActionType::CompareSDKs)
return compareSDKs(options::SDKJsonPaths[0], options::SDKJsonPaths[1],
options::OutputFile, IgnoredUsrs, Opts);
if (options::Action == ActionType::MigratorGen)
return generateMigrationScript(options::SDKJsonPaths[0],
options::SDKJsonPaths[1],
options::OutputFile, IgnoredUsrs, Opts);
else
return diagnoseModuleChange(options::SDKJsonPaths[0],
options::SDKJsonPaths[1],
Expand Down