This is an automated email from the ASF dual-hosted git repository.

ccollins pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-newt.git


The following commit(s) were added to refs/heads/master by this push:
     new e6229f4  Remember which packages satisfy API requirements
e6229f4 is described below

commit e6229f41b753f404fbecc18f8e2fdcdc53c145cc
Author: Christopher Collins <[email protected]>
AuthorDate: Thu Feb 28 10:40:57 2019 -0800

    Remember which packages satisfy API requirements
    
    This is a fix for an error reporting bug.  When any API requirement was
    unsatisfied, newt would report all APIs as unsatisfied.
    
    For example, mynewt-blinky at commit
    06536d2a86a4eaf8d619fe2bad75a4cdf9b77cc8 is broken.  The blinky app has
    an unsatisfied `log` dependency.  When I try building it, I get the
    following error:
    
        Error: Unsatisfied APIs detected:
            * console, required by: hw/mcu/native, kernel/os
            * log, required by: sys/log/modlog
    
    The `console` API is satisfied, so it should not be reported.
    
    This newt bug was introduced in
    a2573a97549cc05dd4949ffca3f87165b239f8aa.  Prior to that commit, each
    satisfied API dependency was tracked in two directions: the depender
    remembers which package satisfies its API requirement, and the dependee
    remembers who requires the API.  In the bad commit, the first of these
    was accidentally removed.
    
    The fix is to add the missing code back.  Now, the depender remembers
    which packages satisfy its API requirements again.
---
 newt/parse/expr.go      | 10 ++++++++++
 newt/resolve/resolve.go |  8 +++++++-
 2 files changed, 17 insertions(+), 1 deletion(-)

diff --git a/newt/parse/expr.go b/newt/parse/expr.go
index 429dbb5..74e2aea 100644
--- a/newt/parse/expr.go
+++ b/newt/parse/expr.go
@@ -9,6 +9,16 @@ type ExprSet map[string]*Node
 // ExprMap is a collection of named expression sets.
 type ExprMap map[string]ExprSet
 
+func NewExprSet(exprs []*Node) ExprSet {
+       if len(exprs) == 0 {
+               return nil
+       }
+
+       es := make(ExprSet, len(exprs))
+       es.Add(exprs)
+       return es
+}
+
 // Exprs returns a slice of all expressions contained in the expression set.
 // The resulting slice is sorted.
 func (es ExprSet) Exprs() []*Node {
diff --git a/newt/resolve/resolve.go b/newt/resolve/resolve.go
index c06f207..8fa4be7 100644
--- a/newt/resolve/resolve.go
+++ b/newt/resolve/resolve.go
@@ -233,6 +233,13 @@ func (rpkg *ResolvePackage) AddDep(
 func (rpkg *ResolvePackage) AddApiDep(
        depPkg *ResolvePackage, api string, exprs []*parse.Node) {
 
+       // Satisfy the API dependency.
+       rpkg.reqApiMap[api] = resolveReqApi{
+               satisfied: true,
+               exprs:     parse.NewExprSet(exprs),
+       }
+
+       // Add a reverse dependency to the API-supplier.
        dep := rpkg.Deps[depPkg]
        if dep == nil {
                dep = &ResolveDep{
@@ -240,7 +247,6 @@ func (rpkg *ResolvePackage) AddApiDep(
                }
                rpkg.Deps[depPkg] = dep
        }
-
        if dep.ApiExprMap == nil {
                dep.ApiExprMap = parse.ExprMap{}
        }

Reply via email to