From 534f15708f8335b3ec0547445ec71c408191986d Mon Sep 17 00:00:00 2001 From: Rupert Shuttleworth Date: Wed, 16 Dec 2020 23:07:06 +0000 Subject: [PATCH] Skip Bazel dist dir migration if not in dist mode or if Bazel dist dir does not exist. Test: DIST_DIR=/tmp/foo USE_BAZEL=1 m dist and DIST_DIR=/tmp/foo USE_BAZEL=1 m dist installclean Change-Id: Ibf576d2f3ba506e0f45c30a5dbea69de5c475c9a --- cmd/soong_ui/main.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/cmd/soong_ui/main.go b/cmd/soong_ui/main.go index bd1d4507b..74ede68b1 100644 --- a/cmd/soong_ui/main.go +++ b/cmd/soong_ui/main.go @@ -174,7 +174,7 @@ func main() { build.SetupOutDir(buildCtx, config) - if config.UseBazel() { + if config.UseBazel() && config.Dist() { defer populateExternalDistDir(buildCtx, config) } @@ -547,6 +547,12 @@ func populateExternalDistDir(ctx build.Context, config build.Config) { return } + // Make sure the internal DIST_DIR actually exists before trying to read from it + if _, err = os.Stat(internalDistDirPath); os.IsNotExist(err) { + ctx.Println("Skipping Bazel dist dir migration - nothing to do!") + return + } + // Make sure the external DIST_DIR actually exists before trying to write to it if err = os.MkdirAll(externalDistDirPath, 0755); err != nil { ctx.Fatalf("Unable to make directory %s: %s", externalDistDirPath, err)