Add name hint to Soong.
Bug: N/A
Test: updated, also manual:
error: system/tools/aidl/Android.bp:431:1: "aidl_test_client_ndk" depends on undefined module "aidl-test-versioned-interface-ndk". Did you m
ean ["aidl-test-versioned-interface-V1-ndk" "aidl-test-versioned-interface-V2-ndk" "aidl-test-versioned-interface-V3-ndk" "aidl-test-version
ed-interface-api"]?
Change-Id: I62f679d1f2152b42cdc336b6e3e7814cd2594c92
diff --git a/android/namespace.go b/android/namespace.go
index c47a1c5..ebf85a1 100644
--- a/android/namespace.go
+++ b/android/namespace.go
@@ -325,8 +325,8 @@
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 @@
}
_, 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 @@
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 7a387a0..ea51c6e 100644
--- a/android/namespace_test.go
+++ b/android/namespace_test.go
@@ -174,9 +174,10 @@
`,
}),
).
- 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 @@
`,
}),
).
- 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 @@
`,
}),
).
- 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)
}