aboutsummaryrefslogtreecommitdiff
path: root/android
diff options
context:
space:
mode:
authorSteven Moreland <smoreland@google.com>2023-04-12 03:18:16 +0000
committerAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>2023-04-12 03:18:16 +0000
commitf4353c53551f89fd97bd3e1fa34bc80a1c089b80 (patch)
tree442f2a6fadc3a3b5e9a8d22b7edaba10eadebf4a /android
parent76c22a0b1c4831a2ef00c0c80f28b70ebf9bf182 (diff)
parent9da29c4ad930ecd9ed2319b73fdd9f1fa28c7e2a (diff)
downloadsoong-f4353c53551f89fd97bd3e1fa34bc80a1c089b80.tar.gz
Merge "Add name hint to Soong." am: a80b113f55 am: 4365189ed3 am: 9da29c4ad9
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/2518037 Change-Id: Iff87fa4a1e228cbb0cbbf0e343a39abba0dfdcb6 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
Diffstat (limited to 'android')
-rw-r--r--android/namespace.go11
-rw-r--r--android/namespace_test.go15
2 files changed, 17 insertions, 9 deletions
diff --git a/android/namespace.go b/android/namespace.go
index c47a1c593..ebf85a1fd 100644
--- a/android/namespace.go
+++ b/android/namespace.go
@@ -325,8 +325,8 @@ func (r *NameResolver) chooseId(namespace *Namespace) {
namespace.id = strconv.Itoa(id)
}
-func (r *NameResolver) MissingDependencyError(depender string, dependerNamespace blueprint.Namespace, depName string) (err error) {
- text := fmt.Sprintf("%q depends on undefined module %q", depender, depName)
+func (r *NameResolver) MissingDependencyError(depender string, dependerNamespace blueprint.Namespace, depName string, guess []string) (err error) {
+ text := fmt.Sprintf("%q depends on undefined module %q.", depender, depName)
_, _, isAbs := r.parseFullyQualifiedName(depName)
if isAbs {
@@ -345,9 +345,10 @@ func (r *NameResolver) MissingDependencyError(depender string, dependerNamespace
}
_, skipped := namespace.moduleContainer.SkippedModuleFromName(depName, nil)
if skipped {
- skippedDepErrors = append(skippedDepErrors, namespace.moduleContainer.MissingDependencyError(depender, dependerNamespace, depName))
+ skippedDepErrors = append(skippedDepErrors, namespace.moduleContainer.MissingDependencyError(depender, dependerNamespace, depName, nil))
}
}
+
if len(foundInNamespaces) > 0 {
// determine which namespaces are visible to dependerNamespace
dependerNs := dependerNamespace.(*Namespace)
@@ -363,6 +364,10 @@ func (r *NameResolver) MissingDependencyError(depender string, dependerNamespace
text += fmt.Sprintf("\n%s", err.Error())
}
+ if len(guess) > 0 {
+ text += fmt.Sprintf("\nOr did you mean %q?", guess)
+ }
+
return fmt.Errorf(text)
}
diff --git a/android/namespace_test.go b/android/namespace_test.go
index 7a387a0bd..ea51c6eae 100644
--- a/android/namespace_test.go
+++ b/android/namespace_test.go
@@ -174,9 +174,10 @@ func TestDependingOnModuleInNonImportedNamespace(t *testing.T) {
`,
}),
).
- ExtendWithErrorHandler(FixtureExpectsOneErrorPattern(`\Qdir3/Android.bp:4:5: "b" depends on undefined module "a"
+ ExtendWithErrorHandler(FixtureExpectsOneErrorPattern(`\Qdir3/Android.bp:4:5: "b" depends on undefined module "a".
Module "b" is defined in namespace "dir3" which can read these 2 namespaces: ["dir3" "."]
-Module "a" can be found in these namespaces: ["dir1" "dir2"]\E`)).
+Module "a" can be found in these namespaces: ["dir1" "dir2"]\E
+Or did you mean ["soong_namespace"]?`)).
RunTest(t)
}
@@ -421,9 +422,10 @@ func TestNamespacesDontInheritParentNamespaces(t *testing.T) {
`,
}),
).
- ExtendWithErrorHandler(FixtureExpectsOneErrorPattern(`\Qdir1/subdir1/Android.bp:4:5: "b" depends on undefined module "a"
+ ExtendWithErrorHandler(FixtureExpectsOneErrorPattern(`\Qdir1/subdir1/Android.bp:4:5: "b" depends on undefined module "a".
Module "b" is defined in namespace "dir1/subdir1" which can read these 2 namespaces: ["dir1/subdir1" "."]
-Module "a" can be found in these namespaces: ["dir1"]\E`)).
+Module "a" can be found in these namespaces: ["dir1"]\E
+Or did you mean ["soong_namespace"]?`)).
RunTest(t)
}
@@ -481,9 +483,10 @@ func TestNamespaceImportsNotTransitive(t *testing.T) {
`,
}),
).
- ExtendWithErrorHandler(FixtureExpectsOneErrorPattern(`\Qdir3/Android.bp:5:5: "c" depends on undefined module "a"
+ ExtendWithErrorHandler(FixtureExpectsOneErrorPattern(`\Qdir3/Android.bp:5:5: "c" depends on undefined module "a".
Module "c" is defined in namespace "dir3" which can read these 3 namespaces: ["dir3" "dir2" "."]
-Module "a" can be found in these namespaces: ["dir1"]\E`)).
+Module "a" can be found in these namespaces: ["dir1"]\E
+Or did you mean ["b"]?`)).
RunTest(t)
}