(p: Plugin, sourceFiles: any[])
| 197 | } |
| 198 | |
| 199 | function buildCSettingsText(p: Plugin, sourceFiles: any[]): string { |
| 200 | const pluginId = p.id; |
| 201 | const allFlags = new Set<string>(); |
| 202 | for (const sourceFile of sourceFiles) { |
| 203 | const flags = sourceFile.$?.['compiler-flags']; |
| 204 | if (flags) { |
| 205 | flags |
| 206 | .split(/\s+/) |
| 207 | .map((f: string) => f.trim()) |
| 208 | .filter((f: string) => f.length > 0) |
| 209 | .forEach((f: string) => allFlags.add(f)); |
| 210 | } |
| 211 | } |
| 212 | |
| 213 | if (allFlags.size === 0) { |
| 214 | return ''; |
| 215 | } |
| 216 | |
| 217 | const entries: string[] = []; |
| 218 | const unsupportedFlags: string[] = []; |
| 219 | |
| 220 | for (const flag of allFlags) { |
| 221 | if (flag.startsWith('-D')) { |
| 222 | const definition = flag.slice(2); |
| 223 | const eqIndex = definition.indexOf('='); |
| 224 | if (eqIndex !== -1) { |
| 225 | const name = definition.slice(0, eqIndex); |
| 226 | const value = definition.slice(eqIndex + 1); |
| 227 | entries.push(` .define("${name}", to: "${value}")`); |
| 228 | } else { |
| 229 | entries.push(` .define("${definition}")`); |
| 230 | } |
| 231 | } else { |
| 232 | unsupportedFlags.push(flag); |
| 233 | } |
| 234 | } |
| 235 | |
| 236 | if (unsupportedFlags.length > 0) { |
| 237 | logger.warn( |
| 238 | `${pluginId}: the following compiler flags are not supported in SPM and were ignored: ${unsupportedFlags.join(', ')}. ` + |
| 239 | `This might cause the plugin to fail to compile.`, |
| 240 | ); |
| 241 | } |
| 242 | |
| 243 | if (entries.length === 0) { |
| 244 | return ''; |
| 245 | } |
| 246 | |
| 247 | return `, |
| 248 | cSettings: [ |
| 249 | ${entries.join(',\n')} |
| 250 | ]`; |
| 251 | } |
| 252 | |
| 253 | async function writeGeneratedPackageSwift(p: Plugin, config: Config, iosPlatformVersion: string) { |
| 254 | const iosVersion = getMajoriOSVersion(config); |
no test coverage detected