@@ -46,6 +46,11 @@ struct MetaProtocolCodable: BuildToolPlugin {
46
46
) throws -> [ Command ] where Context: MetaProtocolCodablePluginContext {
47
47
// Get config
48
48
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
49
54
let config = try fetchConfig ( for: target)
50
55
let ( allTargets, imports) = config. scanInput ( for: target, in: context)
51
56
@@ -61,25 +66,28 @@ struct MetaProtocolCodable: BuildToolPlugin {
61
66
return target. sourceFiles ( withSuffix: " swift " ) . map { file in
62
67
let moduleName = target. moduleName
63
68
#if swift(<6)
64
- let fileName = URL ( string: file. path. string) !
69
+ let fileUrl = URL ( string: file. path. string) !
65
70
#else
66
- let fileName = file. url. lastPathComponent
71
+ let fileUrl = file. url
67
72
#endif
73
+ let fileName = fileUrl. deletingPathExtension ( ) . lastPathComponent
68
74
let genFileName = " \( moduleName) - \( fileName) -gen.json "
69
75
let genFile = genFolder. appending ( path: genFileName)
70
76
intermFiles. append ( genFile)
77
+
78
+
71
79
return Command . buildCommand (
72
80
displayName: """
73
81
Parse source file " \( fileName) " in module " \( moduleName) "
74
82
""" ,
75
- executable: tool . url ,
83
+ executable: toolUrl ,
76
84
arguments: [
77
85
" parse " ,
78
- file . url . absoluteString,
86
+ fileUrl . absoluteString,
79
87
" --output " ,
80
88
genFile. absoluteString,
81
89
] ,
82
- inputFiles: [ file . url ] ,
90
+ inputFiles: [ fileUrl ] ,
83
91
outputFiles: [ genFile]
84
92
)
85
93
}
@@ -88,7 +96,7 @@ struct MetaProtocolCodable: BuildToolPlugin {
88
96
// Create syntax generation command
89
97
let moduleName = target. moduleName
90
98
let genFileName = " \( moduleName) +ProtocolHelperCoders.swift "
91
- let genPath = genFolder. appending ( path: genFileName)
99
+ let genPath = genFolder. appending ( path: genFileName)
92
100
var genArgs = [ " generate " , " --output " , genPath. absoluteString]
93
101
for `import` in imports {
94
102
genArgs. append ( contentsOf: [ " --module " , `import`] )
@@ -101,7 +109,7 @@ struct MetaProtocolCodable: BuildToolPlugin {
101
109
displayName: """
102
110
Generate protocol decoding/encoding syntax for " \( moduleName) "
103
111
""" ,
104
- executable: tool . url ,
112
+ executable: toolUrl ,
105
113
arguments: genArgs,
106
114
inputFiles: intermFiles,
107
115
outputFiles: [ genPath]
0 commit comments