Improve messages for VNDK dependency errors.
Test: build_test.bash
Change-Id: I8a52664d7bbb05232bc01b32580f926aae98056d
diff --git a/cc/vndk.go b/cc/vndk.go
index 5a24a98..1a9b77a 100644
--- a/cc/vndk.go
+++ b/cc/vndk.go
@@ -15,6 +15,7 @@
package cc
import (
+ "errors"
"sort"
"strings"
"sync"
@@ -151,38 +152,42 @@
}
// Check the dependencies of VNDK shared libraries.
- if !vndkIsVndkDepAllowed(vndk, to.vndkdep) {
- ctx.ModuleErrorf("(%s) should not link to %q (%s)",
- vndk.typeName(), to.Name(), to.vndkdep.typeName())
+ if err := vndkIsVndkDepAllowed(vndk, to.vndkdep); err != nil {
+ ctx.ModuleErrorf("(%s) should not link to %q (%s): %v",
+ vndk.typeName(), to.Name(), to.vndkdep.typeName(), err)
return
}
}
-func vndkIsVndkDepAllowed(from *vndkdep, to *vndkdep) bool {
+func vndkIsVndkDepAllowed(from *vndkdep, to *vndkdep) error {
// Check the dependencies of VNDK, VNDK-Ext, VNDK-SP, VNDK-SP-Ext and vendor modules.
if from.isVndkExt() {
if from.isVndkSp() {
- // VNDK-SP-Ext may depend on VNDK-SP, VNDK-SP-Ext, or vendor libs (excluding
- // VNDK and VNDK-Ext).
- return to.isVndkSp() || !to.isVndk()
+ if to.isVndk() && !to.isVndkSp() {
+ return errors.New("VNDK-SP extensions must not depend on VNDK or VNDK extensions")
+ }
+ return nil
}
// VNDK-Ext may depend on VNDK, VNDK-Ext, VNDK-SP, VNDK-SP-Ext, or vendor libs.
- return true
+ return nil
}
if from.isVndk() {
if to.isVndkExt() {
- // VNDK-core and VNDK-SP must not depend on VNDK extensions.
- return false
+ return errors.New("VNDK-core and VNDK-SP must not depend on VNDK extensions")
}
if from.isVndkSp() {
- // VNDK-SP must only depend on VNDK-SP.
- return to.isVndkSp()
+ if !to.isVndkSp() {
+ return errors.New("VNDK-SP must only depend on VNDK-SP")
+ }
+ return nil
}
- // VNDK-core may depend on VNDK-core or VNDK-SP.
- return to.isVndk()
+ if !to.isVndk() {
+ return errors.New("VNDK-core must only depend on VNDK-core or VNDK-SP")
+ }
+ return nil
}
// Vendor modules may depend on VNDK, VNDK-Ext, VNDK-SP, VNDK-SP-Ext, or vendor libs.
- return true
+ return nil
}
var (