FindBuildTool find build tool with tool name.
(ctx context.Context, nameVersion string)
| 321 | |
| 322 | // FindBuildTool find build tool with tool name. |
| 323 | func FindBuildTool(ctx context.Context, nameVersion string) (*BuildTool, error) { |
| 324 | // Determine current architecture |
| 325 | arch := runtime.GOARCH |
| 326 | switch arch { |
| 327 | case "amd64", "x86_64": |
| 328 | arch = "x86_64" |
| 329 | case "arm64": |
| 330 | arch = "aarch64" |
| 331 | } |
| 332 | |
| 333 | // Read the static TOML file for the current platform |
| 334 | staticFile := fmt.Sprintf("static/%s-%s.toml", arch, runtime.GOOS) |
| 335 | bytes, err := static.ReadFile(staticFile) |
| 336 | if err != nil { |
| 337 | return nil, fmt.Errorf("failed to read TOML config %s -> %w", staticFile, err) |
| 338 | } |
| 339 | |
| 340 | var buildTools BuildTools |
| 341 | if err := toml.Unmarshal(bytes, &buildTools); err != nil { |
| 342 | return nil, fmt.Errorf("failed to parse TOML config %s -> %w", staticFile, err) |
| 343 | } |
| 344 | |
| 345 | // Find the tool entry. |
| 346 | condaTool, err := buildTools.findTool(ctx, nameVersion) |
| 347 | if err != nil { |
| 348 | return nil, fmt.Errorf("failed to find matched tool %s -> %w", nameVersion, err) |
| 349 | } |
| 350 | |
| 351 | return condaTool, nil |
| 352 | } |
no test coverage detected