Fix arch specific properties for java modules
Arch specific properties were not being applied to modules with OS set to Common. Test: java_test.go Change-Id: I8f1b49ca51b0cf96f78006dfcd121672e581d9c5
This commit is contained in:
@@ -597,10 +597,6 @@ func (a *ModuleBase) setArchProperties(ctx BottomUpMutatorContext) {
|
|||||||
arch := a.Arch()
|
arch := a.Arch()
|
||||||
os := a.Os()
|
os := a.Os()
|
||||||
|
|
||||||
if arch.ArchType == Common {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
for i := range a.generalProperties {
|
for i := range a.generalProperties {
|
||||||
genProps := a.generalProperties[i]
|
genProps := a.generalProperties[i]
|
||||||
if a.archProperties[i] == nil {
|
if a.archProperties[i] == nil {
|
||||||
@@ -612,6 +608,9 @@ func (a *ModuleBase) setArchProperties(ctx BottomUpMutatorContext) {
|
|||||||
multilibProp := archProps.FieldByName("Multilib")
|
multilibProp := archProps.FieldByName("Multilib")
|
||||||
targetProp := archProps.FieldByName("Target")
|
targetProp := archProps.FieldByName("Target")
|
||||||
|
|
||||||
|
var field string
|
||||||
|
var prefix string
|
||||||
|
|
||||||
// Handle arch-specific properties in the form:
|
// Handle arch-specific properties in the form:
|
||||||
// arch: {
|
// arch: {
|
||||||
// arm64: {
|
// arm64: {
|
||||||
@@ -620,6 +619,7 @@ func (a *ModuleBase) setArchProperties(ctx BottomUpMutatorContext) {
|
|||||||
// },
|
// },
|
||||||
t := arch.ArchType
|
t := arch.ArchType
|
||||||
|
|
||||||
|
if arch.ArchType != Common {
|
||||||
field := proptools.FieldNameForProperty(t.Name)
|
field := proptools.FieldNameForProperty(t.Name)
|
||||||
prefix := "arch." + t.Name
|
prefix := "arch." + t.Name
|
||||||
archStruct := a.appendProperties(ctx, genProps, archProp, field, prefix)
|
archStruct := a.appendProperties(ctx, genProps, archProp, field, prefix)
|
||||||
@@ -673,6 +673,7 @@ func (a *ModuleBase) setArchProperties(ctx BottomUpMutatorContext) {
|
|||||||
field = proptools.FieldNameForProperty(t.Multilib)
|
field = proptools.FieldNameForProperty(t.Multilib)
|
||||||
prefix = "multilib." + t.Multilib
|
prefix = "multilib." + t.Multilib
|
||||||
a.appendProperties(ctx, genProps, multilibProp, field, prefix)
|
a.appendProperties(ctx, genProps, multilibProp, field, prefix)
|
||||||
|
}
|
||||||
|
|
||||||
// Handle host-specific properties in the form:
|
// Handle host-specific properties in the form:
|
||||||
// target: {
|
// target: {
|
||||||
@@ -700,20 +701,24 @@ func (a *ModuleBase) setArchProperties(ctx BottomUpMutatorContext) {
|
|||||||
prefix = "target.linux"
|
prefix = "target.linux"
|
||||||
a.appendProperties(ctx, genProps, targetProp, field, prefix)
|
a.appendProperties(ctx, genProps, targetProp, field, prefix)
|
||||||
|
|
||||||
field = "Linux_" + t.Name
|
if arch.ArchType != Common {
|
||||||
prefix = "target.linux_" + t.Name
|
field = "Linux_" + arch.ArchType.Name
|
||||||
|
prefix = "target.linux_" + arch.ArchType.Name
|
||||||
a.appendProperties(ctx, genProps, targetProp, field, prefix)
|
a.appendProperties(ctx, genProps, targetProp, field, prefix)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if os.Bionic() {
|
if os.Bionic() {
|
||||||
field = "Bionic"
|
field = "Bionic"
|
||||||
prefix = "target.bionic"
|
prefix = "target.bionic"
|
||||||
a.appendProperties(ctx, genProps, targetProp, field, prefix)
|
a.appendProperties(ctx, genProps, targetProp, field, prefix)
|
||||||
|
|
||||||
|
if arch.ArchType != Common {
|
||||||
field = "Bionic_" + t.Name
|
field = "Bionic_" + t.Name
|
||||||
prefix = "target.bionic_" + t.Name
|
prefix = "target.bionic_" + t.Name
|
||||||
a.appendProperties(ctx, genProps, targetProp, field, prefix)
|
a.appendProperties(ctx, genProps, targetProp, field, prefix)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Handle target OS properties in the form:
|
// Handle target OS properties in the form:
|
||||||
// target: {
|
// target: {
|
||||||
@@ -743,9 +748,11 @@ func (a *ModuleBase) setArchProperties(ctx BottomUpMutatorContext) {
|
|||||||
prefix = "target." + os.Name
|
prefix = "target." + os.Name
|
||||||
a.appendProperties(ctx, genProps, targetProp, field, prefix)
|
a.appendProperties(ctx, genProps, targetProp, field, prefix)
|
||||||
|
|
||||||
|
if arch.ArchType != Common {
|
||||||
field = os.Field + "_" + t.Name
|
field = os.Field + "_" + t.Name
|
||||||
prefix = "target." + os.Name + "_" + t.Name
|
prefix = "target." + os.Name + "_" + t.Name
|
||||||
a.appendProperties(ctx, genProps, targetProp, field, prefix)
|
a.appendProperties(ctx, genProps, targetProp, field, prefix)
|
||||||
|
}
|
||||||
|
|
||||||
if (os.Class == Host || os.Class == HostCross) && os != Windows {
|
if (os.Class == Host || os.Class == HostCross) && os != Windows {
|
||||||
field := "Not_windows"
|
field := "Not_windows"
|
||||||
|
@@ -164,6 +164,25 @@ func TestSimple(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestArchSpecific(t *testing.T) {
|
||||||
|
ctx := testJava(t, `
|
||||||
|
java_library {
|
||||||
|
name: "foo",
|
||||||
|
srcs: ["a.java"],
|
||||||
|
target: {
|
||||||
|
android: {
|
||||||
|
srcs: ["b.java"],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
`)
|
||||||
|
|
||||||
|
javac := ctx.ModuleForTests("foo", "android_common").Rule("javac")
|
||||||
|
if len(javac.Inputs) != 2 || javac.Inputs[0].String() != "a.java" || javac.Inputs[1].String() != "b.java" {
|
||||||
|
t.Errorf(`foo inputs %v != ["a.java", "b.java"]`, javac.Inputs)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
var classpathTestcases = []struct {
|
var classpathTestcases = []struct {
|
||||||
name string
|
name string
|
||||||
host android.OsClass
|
host android.OsClass
|
||||||
|
Reference in New Issue
Block a user