@@ -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 }
0 commit comments