Skip to content

Commit 2b2bc45

Browse files
committed
Replace the swift-dependency-tool binary with a symlink to swift-frontend
rdar://76551283
1 parent 8ce6038 commit 2b2bc45

File tree

9 files changed

+40
-45
lines changed

9 files changed

+40
-45
lines changed

include/swift/Driver/Driver.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,7 @@ class Driver {
171171
SILNM, // sil-nm
172172
SILLLVMGen, // sil-llvm-gen
173173
SILPassPipelineDumper, // sil-passpipeline-dumper
174+
SwiftDependencyTool, // swift-dependency-tool
174175
AutolinkExtract, // swift-autolink-extract
175176
SwiftIndent, // swift-indent
176177
SymbolGraph, // swift-symbolgraph

lib/Driver/Driver.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ void Driver::parseDriverKind(ArrayRef<const char *> Args) {
104104
.Case("sil-nm", DriverKind::SILNM)
105105
.Case("sil-llvm-gen", DriverKind::SILLLVMGen)
106106
.Case("sil-passpipeline-dumper", DriverKind::SILPassPipelineDumper)
107+
.Case("swift-dependency-tool", DriverKind::SwiftDependencyTool)
107108
.Case("swift-autolink-extract", DriverKind::AutolinkExtract)
108109
.Case("swift-indent", DriverKind::SwiftIndent)
109110
.Case("swift-symbolgraph-extract", DriverKind::SymbolGraph)
@@ -3565,6 +3566,7 @@ void Driver::printHelp(bool ShowHidden) const {
35653566
case DriverKind::SILNM:
35663567
case DriverKind::SILLLVMGen:
35673568
case DriverKind::SILPassPipelineDumper:
3569+
case DriverKind::SwiftDependencyTool:
35683570
case DriverKind::AutolinkExtract:
35693571
case DriverKind::SwiftIndent:
35703572
case DriverKind::SymbolGraph:

lib/DriverTool/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ set(driver_sources_and_options
55
sil_nm_main.cpp
66
sil_llvm_gen_main.cpp
77
sil_passpipeline_dumper_main.cpp
8+
swift_dependency_tool_main.cpp
89
autolink_extract_main.cpp
910
modulewrap_main.cpp
1011
swift_api_digester_main.cpp

lib/DriverTool/driver.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,9 @@ extern int sil_llvm_gen_main(ArrayRef<const char *> argv, void *MainAddr);
7878
/// Run 'sil-passpipeline-dumper'
7979
extern int sil_passpipeline_dumper_main(ArrayRef<const char *> argv, void *MainAddr);
8080

81+
/// Run 'swift-dependency-tool'
82+
extern int swift_dependency_tool_main(ArrayRef<const char *> argv, void *MainAddr);
83+
8184
/// Run 'swift-autolink-extract'.
8285
extern int autolink_extract_main(ArrayRef<const char *> Args, const char *Argv0,
8386
void *MainAddr);
@@ -306,6 +309,8 @@ static int run_driver(StringRef ExecName,
306309
return sil_llvm_gen_main(argv, (void *)(intptr_t)getExecutablePath);
307310
case Driver::DriverKind::SILPassPipelineDumper:
308311
return sil_passpipeline_dumper_main(argv, (void *)(intptr_t)getExecutablePath);
312+
case Driver::DriverKind::SwiftDependencyTool:
313+
return swift_dependency_tool_main(argv, (void *)(intptr_t)getExecutablePath);
309314
case Driver::DriverKind::AutolinkExtract:
310315
return autolink_extract_main(
311316
TheDriver.getArgsWithoutProgramNameAndDriverMode(argv),

tools/swift-dependency-tool/swift-dependency-tool.cpp renamed to lib/DriverTool/swift_dependency_tool_main.cpp

Lines changed: 26 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -175,58 +175,53 @@ enum class ActionType : unsigned {
175175
YAMLToBinary
176176
};
177177

178-
namespace options {
179-
180-
static llvm::cl::OptionCategory Category("swift-dependency-tool Options");
178+
int swift_dependency_tool_main(ArrayRef<const char *> argv, void *MainAddr) {
179+
INITIALIZE_LLVM();
181180

182-
static llvm::cl::opt<std::string>
183-
InputFilename("input-filename",
184-
llvm::cl::desc("Name of the input file"),
185-
llvm::cl::cat(Category));
181+
llvm::cl::OptionCategory Category("swift-dependency-tool Options");
186182

187-
static llvm::cl::opt<std::string>
188-
OutputFilename("output-filename",
189-
llvm::cl::desc("Name of the output file"),
190-
llvm::cl::cat(Category));
183+
llvm::cl::opt<std::string>
184+
InputFilename("input-filename",
185+
llvm::cl::desc("Name of the input file"),
186+
llvm::cl::cat(Category));
191187

192-
static llvm::cl::opt<ActionType>
193-
Action(llvm::cl::desc("Mode:"), llvm::cl::init(ActionType::None),
194-
llvm::cl::cat(Category),
195-
llvm::cl::values(
196-
clEnumValN(ActionType::BinaryToYAML,
197-
"to-yaml", "Convert new binary .swiftdeps format to YAML"),
198-
clEnumValN(ActionType::YAMLToBinary,
199-
"from-yaml", "Convert YAML to new binary .swiftdeps format")));
188+
llvm::cl::opt<std::string>
189+
OutputFilename("output-filename",
190+
llvm::cl::desc("Name of the output file"),
191+
llvm::cl::cat(Category));
200192

201-
}
202-
203-
int main(int argc, char *argv[]) {
204-
PROGRAM_START(argc, argv);
205-
INITIALIZE_LLVM();
193+
llvm::cl::opt<ActionType>
194+
Action(llvm::cl::desc("Mode:"), llvm::cl::init(ActionType::None),
195+
llvm::cl::cat(Category),
196+
llvm::cl::values(
197+
clEnumValN(ActionType::BinaryToYAML,
198+
"to-yaml", "Convert new binary .swiftdeps format to YAML"),
199+
clEnumValN(ActionType::YAMLToBinary,
200+
"from-yaml", "Convert YAML to new binary .swiftdeps format")));
206201

207-
llvm::cl::HideUnrelatedOptions(options::Category);
208-
llvm::cl::ParseCommandLineOptions(argc, argv, "Swift Dependency Tool\n");
202+
llvm::cl::HideUnrelatedOptions(Category);
203+
llvm::cl::ParseCommandLineOptions(argv.size(), argv.data(), "Swift Dependency Tool\n");
209204

210205
SourceManager sourceMgr;
211206
DiagnosticEngine diags(sourceMgr);
212207
llvm::vfs::OnDiskOutputBackend outputBackend;
213208

214-
switch (options::Action) {
209+
switch (Action) {
215210
case ActionType::None: {
216211
llvm::errs() << "action required\n";
217212
llvm::cl::PrintHelpMessage();
218213
return 1;
219214
}
220215

221216
case ActionType::BinaryToYAML: {
222-
auto fg = SourceFileDepGraph::loadFromPath(options::InputFilename, true);
217+
auto fg = SourceFileDepGraph::loadFromPath(InputFilename, true);
223218
if (!fg) {
224219
llvm::errs() << "Failed to read dependency file\n";
225220
return 1;
226221
}
227222

228223
bool hadError =
229-
withOutputPath(diags, outputBackend, options::OutputFilename,
224+
withOutputPath(diags, outputBackend, OutputFilename,
230225
[&](llvm::raw_pwrite_stream &out) {
231226
out << "# Fine-grained v0\n";
232227
llvm::yaml::Output yamlWriter(out);
@@ -241,7 +236,7 @@ int main(int argc, char *argv[]) {
241236
}
242237

243238
case ActionType::YAMLToBinary: {
244-
auto bufferOrError = llvm::MemoryBuffer::getFile(options::InputFilename);
239+
auto bufferOrError = llvm::MemoryBuffer::getFile(InputFilename);
245240
if (!bufferOrError) {
246241
llvm::errs() << "Failed to read dependency file\n";
247242
return 1;
@@ -258,7 +253,7 @@ int main(int argc, char *argv[]) {
258253
}
259254

260255
if (writeFineGrainedDependencyGraphToPath(
261-
diags, outputBackend, options::OutputFilename, fg)) {
256+
diags, outputBackend, OutputFilename, fg)) {
262257
llvm::errs() << "Failed to write binary swiftdeps\n";
263258
return 1;
264259
}

test/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ function(get_test_dependencies SDK result_var_name)
5555
swift-frontend
5656
swift-demangle
5757
swift-demangle-yamldump
58-
swift-dependency-tool
5958
swift-ide-test
6059
swift-llvm-opt
6160
swift-refactor

tools/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ endif()
1818

1919
add_swift_tool_subdirectory(driver)
2020
add_swift_tool_subdirectory(swift-compatibility-symbols)
21-
add_swift_tool_subdirectory(swift-dependency-tool)
2221
add_swift_tool_subdirectory(swift-demangle)
2322
add_swift_tool_subdirectory(swift-demangle-yamldump)
2423
add_swift_tool_subdirectory(swift-def-to-strings-converter)

tools/driver/CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,11 @@ swift_create_post_build_symlink(swift-frontend
114114
DESTINATION "sil-passpipeline-dumper${CMAKE_EXECUTABLE_SUFFIX}"
115115
WORKING_DIRECTORY "${SWIFT_RUNTIME_OUTPUT_INTDIR}")
116116

117+
swift_create_post_build_symlink(swift-frontend
118+
SOURCE "swift-frontend${CMAKE_EXECUTABLE_SUFFIX}"
119+
DESTINATION "swift-dependency-tool${CMAKE_EXECUTABLE_SUFFIX}"
120+
WORKING_DIRECTORY "${SWIFT_RUNTIME_OUTPUT_INTDIR}")
121+
117122
swift_create_post_build_symlink(swift-frontend
118123
SOURCE "swift-frontend${CMAKE_EXECUTABLE_SUFFIX}"
119124
DESTINATION "swift-indent${CMAKE_EXECUTABLE_SUFFIX}"

tools/swift-dependency-tool/CMakeLists.txt

Lines changed: 0 additions & 12 deletions
This file was deleted.

0 commit comments

Comments
 (0)