detectPlatformTriple dynamically detects the platform triple subdirectory in LLVM's include and lib directories. This avoids hardcoding platform-specific paths like "x86_64-unknown-linux-gnu".
(toolchainRoot string)
| 363 | // in LLVM's include and lib directories. This avoids hardcoding platform-specific |
| 364 | // paths like "x86_64-unknown-linux-gnu". |
| 365 | func (b b2) detectPlatformTriple(toolchainRoot string) (string, error) { |
| 366 | // Look for platform-specific subdirectories in include/ |
| 367 | includePath := filepath.Join(toolchainRoot, "include") |
| 368 | entries, err := os.ReadDir(includePath) |
| 369 | if err != nil { |
| 370 | return "", fmt.Errorf("failed to read include directory: %w", err) |
| 371 | } |
| 372 | |
| 373 | // Find the first subdirectory that contains c++/v1/__config_site |
| 374 | for _, entry := range entries { |
| 375 | if entry.IsDir() && entry.Name() != "c++" { |
| 376 | configSite := filepath.Join(includePath, entry.Name(), "c++", "v1", "__config_site") |
| 377 | if fileio.PathExists(configSite) { |
| 378 | return entry.Name(), nil |
| 379 | } |
| 380 | } |
| 381 | } |
| 382 | |
| 383 | return "", fmt.Errorf("could not find platform-specific subdirectory with __config_site") |
| 384 | } |
| 385 | |
| 386 | func (b b2) formatUsingToolset(toolset, version, cxx string) string { |
| 387 | var compilerCmd string |
no test coverage detected