aboutsummaryrefslogtreecommitdiffstats
path: root/androidmk
diff options
context:
space:
mode:
authorColin Cross <ccross@android.com>2015-12-01 16:30:55 -0800
committerColin Cross <ccross@android.com>2015-12-01 18:06:33 -0800
commit4bd49c2ce1d578a514f7c16ff395aa64a364b7ac (patch)
treee01b20c6294d388669b60e583fba7e5425c6ad1b /androidmk
parent83163192949e3668401c2caa6a866875d49ccd65 (diff)
downloadbuild_soong-4bd49c2ce1d578a514f7c16ff395aa64a364b7ac.tar.gz
build_soong-4bd49c2ce1d578a514f7c16ff395aa64a364b7ac.tar.bz2
build_soong-4bd49c2ce1d578a514f7c16ff395aa64a364b7ac.zip
androidmk: Add support for TARGET_BUILD_APPS
Change-Id: Iade2dd9fd5b8873d723d5f6f235775f447fb1d98
Diffstat (limited to 'androidmk')
-rw-r--r--androidmk/cmd/androidmk/android.go3
-rw-r--r--androidmk/cmd/androidmk/androidmk.go75
2 files changed, 35 insertions, 43 deletions
diff --git a/androidmk/cmd/androidmk/android.go b/androidmk/cmd/androidmk/android.go
index d76e6844..c45b3f46 100644
--- a/androidmk/cmd/androidmk/android.go
+++ b/androidmk/cmd/androidmk/android.go
@@ -316,6 +316,9 @@ var conditionalTranslations = map[string]map[bool]string{
"USE_MINGW": {
true: "target.windows",
false: "target.not_windows"},
+ "(,$(TARGET_BUILD_APPS))": {
+ false: "product_variables.unbundled_build",
+ },
}
func mydir(args []string) string {
diff --git a/androidmk/cmd/androidmk/androidmk.go b/androidmk/cmd/androidmk/androidmk.go
index 735a240b..4dc4d724 100644
--- a/androidmk/cmd/androidmk/androidmk.go
+++ b/androidmk/cmd/androidmk/androidmk.go
@@ -25,6 +25,8 @@ type bpFile struct {
pos scanner.Position
prevLine, line int
+
+ inModule bool
}
func (f *bpFile) errorf(thing mkparser.MakeThing, s string, args ...interface{}) {
@@ -91,7 +93,7 @@ func main() {
}
var conds []*conditional
- var cond *conditional
+ var assignmentCond *conditional
for _, t := range things {
file.setPos(t.Pos(), t.EndPos())
@@ -102,14 +104,14 @@ func main() {
Comment: []string{"//" + comment.Comment},
})
} else if assignment, ok := t.AsAssignment(); ok {
- handleAssignment(file, assignment, cond)
+ handleAssignment(file, assignment, assignmentCond)
} else if directive, ok := t.AsDirective(); ok {
switch directive.Name {
case "include":
val := directive.Args.Value(file.scope)
switch {
case soongModuleTypes[val]:
- handleModuleConditionals(file, directive, cond)
+ handleModuleConditionals(file, directive, conds)
makeModule(file, val)
case val == clear_vars:
resetModule(file)
@@ -123,10 +125,12 @@ func main() {
if _, ok := conditionalTranslations[args]; ok {
newCond := conditional{args, eq}
conds = append(conds, &newCond)
- if cond == nil {
- cond = &newCond
- } else {
- file.errorf(directive, "unsupported nested conditional")
+ if file.inModule {
+ if assignmentCond == nil {
+ assignmentCond = &newCond
+ } else {
+ file.errorf(directive, "unsupported nested conditional in module")
+ }
}
} else {
file.errorf(directive, "unsupported conditional")
@@ -141,7 +145,7 @@ func main() {
file.errorf(directive, "else from unsupported contitional")
continue
}
- cond.eq = !cond.eq
+ conds[len(conds)-1].eq = !conds[len(conds)-1].eq
case "endif":
if len(conds) == 0 {
file.errorf(directive, "missing if before endif")
@@ -150,8 +154,8 @@ func main() {
file.errorf(directive, "endif from unsupported contitional")
conds = conds[:len(conds)-1]
} else {
- if cond == conds[len(conds)-1] {
- cond = nil
+ if assignmentCond == conds[len(conds)-1] {
+ assignmentCond = nil
}
conds = conds[:len(conds)-1]
}
@@ -258,43 +262,26 @@ func handleAssignment(file *bpFile, assignment mkparser.Assignment, c *condition
}
}
-func handleModuleConditionals(file *bpFile, directive mkparser.Directive, c *conditional) {
- if c == nil {
- return
- }
+func handleModuleConditionals(file *bpFile, directive mkparser.Directive, conds []*conditional) {
+ for _, c := range conds {
+ if c == nil {
+ continue
+ }
- if _, ok := conditionalTranslations[c.cond]; !ok {
- panic("unknown conditional " + c.cond)
- }
+ if _, ok := conditionalTranslations[c.cond]; !ok {
+ panic("unknown conditional " + c.cond)
+ }
- prefix := conditionalTranslations[c.cond][c.eq]
- disabledPrefix := conditionalTranslations[c.cond][!c.eq]
+ disabledPrefix := conditionalTranslations[c.cond][!c.eq]
- names := strings.Split(prefix, ".")
- if len(names) != 2 {
- panic("expected class.type")
- }
- class := names[0]
- typ := names[1]
- classProp := file.localAssignments[class]
-
- // Hoist all properties inside the condtional up to the top level
- file.module.Properties = file.localAssignments[prefix].Value.MapValue
- file.module.Properties = append(file.module.Properties, classProp)
- file.localAssignments[prefix].Value.MapValue = nil
- for i := range classProp.Value.MapValue {
- if classProp.Value.MapValue[i].Name.Name == typ {
- classProp.Value.MapValue = append(classProp.Value.MapValue[:i], classProp.Value.MapValue[i+1:]...)
+ // Create a fake assignment with enabled = false
+ val, err := makeVariableToBlueprint(file, mkparser.SimpleMakeString("false", file.pos), bpparser.Bool)
+ if err == nil {
+ err = setVariable(file, false, disabledPrefix, "enabled", val, true)
+ }
+ if err != nil {
+ file.errorf(directive, err.Error())
}
- }
-
- // Create a fake assignment with enabled = false
- val, err := makeVariableToBlueprint(file, mkparser.SimpleMakeString("true", file.pos), bpparser.Bool)
- if err == nil {
- err = setVariable(file, false, disabledPrefix, "disabled", val, true)
- }
- if err != nil {
- file.errorf(directive, err.Error())
}
}
@@ -305,12 +292,14 @@ func makeModule(file *bpFile, t string) {
}
file.module.RbracePos = file.pos
file.defs = append(file.defs, file.module)
+ file.inModule = false
}
func resetModule(file *bpFile) {
file.module = &bpparser.Module{}
file.module.LbracePos = file.pos
file.localAssignments = make(map[string]*bpparser.Property)
+ file.inModule = true
}
func makeVariableToBlueprint(file *bpFile, val *mkparser.MakeString,