partitionLinkFlags function
Splits a rustc native-static-libs: flag list into -framework names,
-l library names, and everything else (passed to the driver verbatim).
Order and duplication are preserved — rustc says both can matter.
Implementation
LinkFlagGroups partitionLinkFlags(List<String> flags) {
final frameworks = <String>[];
final libraries = <String>[];
final other = <String>[];
for (var i = 0; i < flags.length; i++) {
final f = flags[i];
if (f == '-framework' && i + 1 < flags.length) {
frameworks.add(flags[++i]);
} else if (f.startsWith('-l') && f.length > 2) {
libraries.add(f.substring(2));
} else {
other.add(f);
}
}
return (frameworks: frameworks, libraries: libraries, other: other);
}