aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorandroid-build-team Robot2018-04-24 02:21:16 -0500
committerandroid-build-team Robot2018-04-24 02:21:16 -0500
commit7653693afd643cea02d50b6bf01e6bc3dd86bd54 (patch)
tree66b3629cb180c7aac4aa4d2a5ee17b92f25c4b8e
parentaab3e62e8eeb7822813f9cf8c34714ab0c390d1e (diff)
parent2cc7d9fc783eabbf9ba4bf939a8cdf8569a59254 (diff)
downloadplatform-build-soong-7653693afd643cea02d50b6bf01e6bc3dd86bd54.tar.gz
platform-build-soong-7653693afd643cea02d50b6bf01e6bc3dd86bd54.tar.xz
platform-build-soong-7653693afd643cea02d50b6bf01e6bc3dd86bd54.zip
Snap for 4739962 from 2cc7d9fc783eabbf9ba4bf939a8cdf8569a59254 to pi-release
Change-Id: I137fb360d77f235fe68a43c2a2692a6e66e27469
-rw-r--r--cmd/pom2mk/pom2mk.go28
1 files changed, 23 insertions, 5 deletions
diff --git a/cmd/pom2mk/pom2mk.go b/cmd/pom2mk/pom2mk.go
index bf478961..a609860a 100644
--- a/cmd/pom2mk/pom2mk.go
+++ b/cmd/pom2mk/pom2mk.go
@@ -89,6 +89,16 @@ var sdkVersion string
89var useVersion string 89var useVersion string
90var staticDeps bool 90var staticDeps bool
91 91
92func InList(s string, list []string) bool {
93 for _, l := range list {
94 if l == s {
95 return true
96 }
97 }
98
99 return false
100}
101
92type Dependency struct { 102type Dependency struct {
93 XMLName xml.Name `xml:"dependency"` 103 XMLName xml.Name `xml:"dependency"`
94 104
@@ -139,19 +149,23 @@ func (p Pom) MkName() string {
139} 149}
140 150
141func (p Pom) MkJarDeps() []string { 151func (p Pom) MkJarDeps() []string {
142 return p.MkDeps("jar", "compile") 152 return p.MkDeps("jar", []string{"compile", "runtime"})
143} 153}
144 154
145func (p Pom) MkAarDeps() []string { 155func (p Pom) MkAarDeps() []string {
146 return p.MkDeps("aar", "compile") 156 return p.MkDeps("aar", []string{"compile", "runtime"})
147} 157}
148 158
149// MkDeps obtains dependencies filtered by type and scope. The results of this 159// MkDeps obtains dependencies filtered by type and scope. The results of this
150// method are formatted as Make targets, e.g. run through MavenToMk rules. 160// method are formatted as Make targets, e.g. run through MavenToMk rules.
151func (p Pom) MkDeps(typeExt string, scope string) []string { 161func (p Pom) MkDeps(typeExt string, scopes []string) []string {
152 var ret []string 162 var ret []string
163 if typeExt == "jar" {
164 // all top-level extra deps are assumed to be of type "jar" until we add syntax to specify other types
165 ret = append(ret, extraDeps[p.MkName()]...)
166 }
153 for _, d := range p.Dependencies { 167 for _, d := range p.Dependencies {
154 if d.Type != typeExt || d.Scope != scope { 168 if d.Type != typeExt || !InList(d.Scope, scopes) {
155 continue 169 continue
156 } 170 }
157 name := rewriteNames.MavenToMk(d.GroupId, d.ArtifactId) 171 name := rewriteNames.MavenToMk(d.GroupId, d.ArtifactId)
@@ -350,6 +364,7 @@ The makefile is written to stdout, to be put in the current directory (often as
350 364
351 poms := []*Pom{} 365 poms := []*Pom{}
352 modules := make(map[string]*Pom) 366 modules := make(map[string]*Pom)
367 duplicate := false
353 for _, filename := range filenames { 368 for _, filename := range filenames {
354 pom, err := parse(filename) 369 pom, err := parse(filename)
355 if err != nil { 370 if err != nil {
@@ -363,12 +378,15 @@ The makefile is written to stdout, to be put in the current directory (often as
363 378
364 if old, ok := modules[key]; ok { 379 if old, ok := modules[key]; ok {
365 fmt.Fprintln(os.Stderr, "Module", key, "defined twice:", old.PomFile, pom.PomFile) 380 fmt.Fprintln(os.Stderr, "Module", key, "defined twice:", old.PomFile, pom.PomFile)
366 os.Exit(1) 381 duplicate = true
367 } 382 }
368 383
369 modules[key] = pom 384 modules[key] = pom
370 } 385 }
371 } 386 }
387 if duplicate {
388 os.Exit(1)
389 }
372 390
373 for _, pom := range poms { 391 for _, pom := range poms {
374 pom.FixDeps(modules) 392 pom.FixDeps(modules)