| 165 | * manifest's directory. |
| 166 | */ |
| 167 | export function parseTargetPaths(cargoToml: string): { lib?: string; bins: string[]; others: string[] } { |
| 168 | const out: { lib?: string; bins: string[]; others: string[] } = { bins: [], others: [] }; |
| 169 | let table: 'lib' | 'bin' | 'other' | null = null; |
| 170 | for (const raw of cargoToml.split(/\r?\n/)) { |
| 171 | const line = raw.replace(/#.*$/, '').trim(); |
| 172 | if (line.startsWith('[')) { |
| 173 | table = line === '[lib]' ? 'lib' : line === '[[bin]]' ? 'bin' : /^\[\[(?:example|test|bench)\]\]$/.test(line) ? 'other' : null; |
| 174 | continue; |
| 175 | } |
| 176 | const at = table && /^path\s*=\s*["']([^"'\n]+)["']/.exec(line)?.[1]?.replace(/\\/g, '/'); |
| 177 | if (!at) continue; |
| 178 | if (table === 'lib') out.lib = at; |
| 179 | else if (table === 'bin') out.bins.push(at); |
| 180 | else out.others.push(at); |
| 181 | } |
| 182 | return out; |
| 183 | } |
| 184 | |
| 185 | function addCrateAlias(map: Map<string, string>, crateName: string, memberPath: string): void { |
| 186 | const normalized = crateName.replace(/-/g, '_'); |