@@ -46,6 +46,11 @@ struct MetaProtocolCodable: BuildToolPlugin {
4646 ) throws -> [ Command ] where Context: MetaProtocolCodablePluginContext {
4747 // Get config
4848 let tool = try context. tool ( named: " ProtocolGen " )
49+ #if swift(<6)
50+ let toolUrl = URL ( string: tool. path. string) !
51+ #else
52+ let toolUrl = tool. url
53+ #endif
4954 let config = try fetchConfig ( for: target)
5055 let ( allTargets, imports) = config. scanInput ( for: target, in: context)
5156
@@ -61,25 +66,28 @@ struct MetaProtocolCodable: BuildToolPlugin {
6166 return target. sourceFiles ( withSuffix: " swift " ) . map { file in
6267 let moduleName = target. moduleName
6368 #if swift(<6)
64- let fileName = URL ( string: file. path. string) !
69+ let fileUrl = URL ( string: file. path. string) !
6570 #else
66- let fileName = file. url. lastPathComponent
71+ let fileUrl = file. url
6772 #endif
73+ let fileName = fileUrl. deletingPathExtension ( ) . lastPathComponent
6874 let genFileName = " \( moduleName) - \( fileName) -gen.json "
6975 let genFile = genFolder. appending ( path: genFileName)
7076 intermFiles. append ( genFile)
77+
78+
7179 return Command . buildCommand (
7280 displayName: """
7381 Parse source file " \( fileName) " in module " \( moduleName) "
7482 """ ,
75- executable: tool . url ,
83+ executable: toolUrl ,
7684 arguments: [
7785 " parse " ,
78- file . url . absoluteString,
86+ fileUrl . absoluteString,
7987 " --output " ,
8088 genFile. absoluteString,
8189 ] ,
82- inputFiles: [ file . url ] ,
90+ inputFiles: [ fileUrl ] ,
8391 outputFiles: [ genFile]
8492 )
8593 }
@@ -88,7 +96,7 @@ struct MetaProtocolCodable: BuildToolPlugin {
8896 // Create syntax generation command
8997 let moduleName = target. moduleName
9098 let genFileName = " \( moduleName) +ProtocolHelperCoders.swift "
91- let genPath = genFolder. appending ( path: genFileName)
99+ let genPath = genFolder. appending ( path: genFileName)
92100 var genArgs = [ " generate " , " --output " , genPath. absoluteString]
93101 for `import` in imports {
94102 genArgs. append ( contentsOf: [ " --module " , `import`] )
@@ -101,7 +109,7 @@ struct MetaProtocolCodable: BuildToolPlugin {
101109 displayName: """
102110 Generate protocol decoding/encoding syntax for " \( moduleName) "
103111 """ ,
104- executable: tool . url ,
112+ executable: toolUrl ,
105113 arguments: genArgs,
106114 inputFiles: intermFiles,
107115 outputFiles: [ genPath]
0 commit comments