aboutsummaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
authorPatrice Arruda <patricearruda@google.com>2019-07-03 10:47:34 -0700
committerLuca Stefani <luca.stefani.ge1@gmail.com>2019-09-04 15:33:28 +0200
commitf60bb1bdd07a2590bd4843caeb4069f7a4df4a72 (patch)
tree85b7a5de29a80e07a0d7c50da387ceb46df7bfd7 /ui
parent346a749ccb348cc682845a33a84351d0455dc5f7 (diff)
downloadbuild_soong-f60bb1bdd07a2590bd4843caeb4069f7a4df4a72.tar.gz
build_soong-f60bb1bdd07a2590bd4843caeb4069f7a4df4a72.tar.bz2
build_soong-f60bb1bdd07a2590bd4843caeb4069f7a4df4a72.zip
soong_ui: Build under a path that contains a symbolic link.
The build directory passed in to soong_ui can contain a symbolic link. soong_ui was not evaluating the build directory to retrieve the true path, hence failing to execute the internal soong. Fixes: b/135995632 Test: Unit test case and executed the scenario in the bug description. Change-Id: I5779c6aa3f3183810437dbe2b2d4e40acbafb205
Diffstat (limited to 'ui')
-rw-r--r--ui/build/config.go4
-rw-r--r--ui/build/config_test.go56
2 files changed, 59 insertions, 1 deletions
diff --git a/ui/build/config.go b/ui/build/config.go
index 50412d59..7148c177 100644
--- a/ui/build/config.go
+++ b/ui/build/config.go
@@ -267,6 +267,10 @@ func getConfigArgs(action BuildAction, dir string, buildDependencies bool, ctx C
if err != nil {
ctx.Fatalf("Error retrieving top directory: %v", err)
}
+ dir, err = filepath.EvalSymlinks(dir)
+ if err != nil {
+ ctx.Fatalf("Unable to evaluate symlink of %s: %v", dir, err)
+ }
dir, err = filepath.Abs(dir)
if err != nil {
ctx.Fatalf("Unable to find absolute path %s: %v", dir, err)
diff --git a/ui/build/config_test.go b/ui/build/config_test.go
index 856af117..7a1ee170 100644
--- a/ui/build/config_test.go
+++ b/ui/build/config_test.go
@@ -690,6 +690,9 @@ type buildActionTestCase struct {
// Build files that exists in the source tree.
buildFiles []string
+ // Create root symlink that points to topDir.
+ rootSymlink bool
+
// ********* Action *********
// Arguments passed in to soong_ui.
args []string
@@ -738,6 +741,22 @@ func testGetConfigArgs(t *testing.T, tt buildActionTestCase, action BuildAction,
createDirectories(t, topDir, tt.dirsInTrees)
createBuildFiles(t, topDir, tt.buildFiles)
+ if tt.rootSymlink {
+ // Create a secondary root source tree which points to the true root source tree.
+ symlinkTopDir, err := ioutil.TempDir("", "")
+ if err != nil {
+ t.Fatalf("failed to create symlink temp dir: %v", err)
+ }
+ defer os.RemoveAll(symlinkTopDir)
+
+ symlinkTopDir = filepath.Join(symlinkTopDir, "root")
+ err = os.Symlink(topDir, symlinkTopDir)
+ if err != nil {
+ t.Fatalf("failed to create symlink: %v", err)
+ }
+ topDir = symlinkTopDir
+ }
+
r := setTop(t, topDir)
defer r()
@@ -796,7 +815,17 @@ func TestGetConfigArgsBuildModules(t *testing.T) {
dirsInTrees: []string{"0/1/2", "0/2", "0/3"},
buildFiles: []string{"0/1/2/Android.mk", "0/2/Android.bp"},
args: []string{},
- curDir: "1/2/3/4/5/6/7/8/9",
+ curDir: "0/2",
+ tidyOnly: "",
+ expectedArgs: []string{},
+ expectedEnvVars: []envVar{},
+ }, {
+ description: "normal execution in symlink root source tree, no args",
+ dirsInTrees: []string{"0/1/2", "0/2", "0/3"},
+ buildFiles: []string{"0/1/2/Android.mk", "0/2/Android.bp"},
+ rootSymlink: true,
+ args: []string{},
+ curDir: "0/2",
tidyOnly: "",
expectedArgs: []string{},
expectedEnvVars: []envVar{},
@@ -932,6 +961,17 @@ func TestGetConfigArgsBuildModulesInDirectory(t *testing.T) {
description: "build action executed at root directory",
dirsInTrees: []string{},
buildFiles: []string{},
+ rootSymlink: false,
+ args: []string{},
+ curDir: ".",
+ tidyOnly: "",
+ expectedArgs: []string{},
+ expectedEnvVars: []envVar{},
+ }, {
+ description: "build action executed at root directory in symlink",
+ dirsInTrees: []string{},
+ buildFiles: []string{},
+ rootSymlink: true,
args: []string{},
curDir: ".",
tidyOnly: "",
@@ -1080,6 +1120,20 @@ func TestGetConfigArgsBuildModulesInDirectories(t *testing.T) {
description: "normal execution from top dir directory",
dirsInTrees: []string{"0/1/2/3.1", "0/1/2/3.2", "0/1/3", "0/2"},
buildFiles: []string{"0/1/2/3.1/Android.bp", "0/1/2/3.2/Android.bp", "0/1/3/Android.bp", "0/2/Android.bp"},
+ rootSymlink: false,
+ args: []string{"0/1/2/3.1", "0/1/2/3.2", "0/1/3", "0/2"},
+ curDir: ".",
+ tidyOnly: "",
+ expectedArgs: []string{"MODULES-IN-0-1-2-3.1", "MODULES-IN-0-1-2-3.2", "MODULES-IN-0-1-3", "MODULES-IN-0-2"},
+ expectedEnvVars: []envVar{
+ envVar{
+ name: "ONE_SHOT_MAKEFILE",
+ value: ""}},
+ }, {
+ description: "normal execution from top dir directory in symlink",
+ dirsInTrees: []string{"0/1/2/3.1", "0/1/2/3.2", "0/1/3", "0/2"},
+ buildFiles: []string{"0/1/2/3.1/Android.bp", "0/1/2/3.2/Android.bp", "0/1/3/Android.bp", "0/2/Android.bp"},
+ rootSymlink: true,
args: []string{"0/1/2/3.1", "0/1/2/3.2", "0/1/3", "0/2"},
curDir: ".",
tidyOnly: "",