in core/core.go [352:371]
func linkLocalBazel(baseDirectory string, bazelPath string) (string, error) {
normalizedBazelPath := dirForURL(bazelPath)
destinationDir := filepath.Join(baseDirectory, normalizedBazelPath, "bin")
err := os.MkdirAll(destinationDir, 0755)
if err != nil {
return "", fmt.Errorf("could not create directory %s: %v", destinationDir, err)
}
destinationPath := filepath.Join(destinationDir, "bazel"+platforms.DetermineExecutableFilenameSuffix())
if _, err := os.Stat(destinationPath); err != nil {
err = os.Symlink(bazelPath, destinationPath)
// If can't create Symlink, fallback to copy
if err != nil {
err = copyFile(bazelPath, destinationPath, 0755)
if err != nil {
return "", fmt.Errorf("cound not copy file from %s to %s: %v", bazelPath, destinationPath, err)
}
}
}
return destinationPath, nil
}