Allow data generator to be run directly from Bazel

When run from Bazel without additional arguments, it will write data
files directly to the source directory.
This commit is contained in:
Dietrich Epp 2022-03-23 12:00:18 -04:00
parent 7e7a6a9da2
commit 491950e57d

View File

@ -26,6 +26,10 @@ func getSrcdir() (string, error) {
if flagSrc != "" { if flagSrc != "" {
return flagSrc, nil return flagSrc, nil
} }
workspace := os.Getenv("BUILD_WORKSPACE_DIRECTORY")
if workspace != "" {
return workspace, nil
}
exe, err := os.Executable() exe, err := os.Executable()
if err != nil { if err != nil {
return "", err return "", err