Merge "Replace android.BuildOs with Config.BuildOS" am: 78fd15f7d6
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/1773108 Change-Id: I9f16a9e6fda40df8fcb54e98aa54866cec734a2c
This commit is contained in:
@@ -290,28 +290,6 @@ func osByName(name string) OsType {
|
|||||||
return NoOsType
|
return NoOsType
|
||||||
}
|
}
|
||||||
|
|
||||||
// BuildOs returns the OsType for the OS that the build is running on.
|
|
||||||
var BuildOs = func() OsType {
|
|
||||||
switch runtime.GOOS {
|
|
||||||
case "linux":
|
|
||||||
return Linux
|
|
||||||
case "darwin":
|
|
||||||
return Darwin
|
|
||||||
default:
|
|
||||||
panic(fmt.Sprintf("unsupported OS: %s", runtime.GOOS))
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
|
|
||||||
// BuildArch returns the ArchType for the CPU that the build is running on.
|
|
||||||
var BuildArch = func() ArchType {
|
|
||||||
switch runtime.GOARCH {
|
|
||||||
case "amd64":
|
|
||||||
return X86_64
|
|
||||||
default:
|
|
||||||
panic(fmt.Sprintf("unsupported Arch: %s", runtime.GOARCH))
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
|
|
||||||
var (
|
var (
|
||||||
// osTypeList contains a list of all the supported OsTypes, including ones not supported
|
// osTypeList contains a list of all the supported OsTypes, including ones not supported
|
||||||
// by the current build host or the target device.
|
// by the current build host or the target device.
|
||||||
@@ -1397,6 +1375,31 @@ func (m *ModuleBase) setArchProperties(ctx BottomUpMutatorContext) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// determineBuildOS stores the OS and architecture used for host targets used during the build into
|
||||||
|
// config based on the runtime OS and architecture determined by Go.
|
||||||
|
func determineBuildOS(config *config) {
|
||||||
|
config.BuildOS = func() OsType {
|
||||||
|
switch runtime.GOOS {
|
||||||
|
case "linux":
|
||||||
|
return Linux
|
||||||
|
case "darwin":
|
||||||
|
return Darwin
|
||||||
|
default:
|
||||||
|
panic(fmt.Sprintf("unsupported OS: %s", runtime.GOOS))
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
|
config.BuildArch = func() ArchType {
|
||||||
|
switch runtime.GOARCH {
|
||||||
|
case "amd64":
|
||||||
|
return X86_64
|
||||||
|
default:
|
||||||
|
panic(fmt.Sprintf("unsupported Arch: %s", runtime.GOARCH))
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// Convert the arch product variables into a list of targets for each OsType.
|
// Convert the arch product variables into a list of targets for each OsType.
|
||||||
func decodeTargetProductVariables(config *config) (map[OsType][]Target, error) {
|
func decodeTargetProductVariables(config *config) (map[OsType][]Target, error) {
|
||||||
variables := config.productVariables
|
variables := config.productVariables
|
||||||
@@ -1430,9 +1433,9 @@ func decodeTargetProductVariables(config *config) (map[OsType][]Target, error) {
|
|||||||
hostCross := false
|
hostCross := false
|
||||||
if os.Class == Host {
|
if os.Class == Host {
|
||||||
var osSupported bool
|
var osSupported bool
|
||||||
if os == BuildOs {
|
if os == config.BuildOS {
|
||||||
osSupported = true
|
osSupported = true
|
||||||
} else if BuildOs.Linux() && os.Linux() {
|
} else if config.BuildOS.Linux() && os.Linux() {
|
||||||
// LinuxBionic and Linux are compatible
|
// LinuxBionic and Linux are compatible
|
||||||
osSupported = true
|
osSupported = true
|
||||||
} else {
|
} else {
|
||||||
@@ -1470,11 +1473,11 @@ func decodeTargetProductVariables(config *config) (map[OsType][]Target, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// The primary host target, which must always exist.
|
// The primary host target, which must always exist.
|
||||||
addTarget(BuildOs, *variables.HostArch, nil, nil, nil, NativeBridgeDisabled, nil, nil)
|
addTarget(config.BuildOS, *variables.HostArch, nil, nil, nil, NativeBridgeDisabled, nil, nil)
|
||||||
|
|
||||||
// An optional secondary host target.
|
// An optional secondary host target.
|
||||||
if variables.HostSecondaryArch != nil && *variables.HostSecondaryArch != "" {
|
if variables.HostSecondaryArch != nil && *variables.HostSecondaryArch != "" {
|
||||||
addTarget(BuildOs, *variables.HostSecondaryArch, nil, nil, nil, NativeBridgeDisabled, nil, nil)
|
addTarget(config.BuildOS, *variables.HostSecondaryArch, nil, nil, nil, NativeBridgeDisabled, nil, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Optional cross-compiled host targets, generally Windows.
|
// Optional cross-compiled host targets, generally Windows.
|
||||||
|
@@ -108,6 +108,12 @@ type config struct {
|
|||||||
|
|
||||||
ProductVariablesFileName string
|
ProductVariablesFileName string
|
||||||
|
|
||||||
|
// BuildOS stores the OsType for the OS that the build is running on.
|
||||||
|
BuildOS OsType
|
||||||
|
|
||||||
|
// BuildArch stores the ArchType for the CPU that the build is running on.
|
||||||
|
BuildArch ArchType
|
||||||
|
|
||||||
Targets map[OsType][]Target
|
Targets map[OsType][]Target
|
||||||
BuildOSTarget Target // the Target for tools run on the build machine
|
BuildOSTarget Target // the Target for tools run on the build machine
|
||||||
BuildOSCommonTarget Target // the Target for common (java) tools run on the build machine
|
BuildOSCommonTarget Target // the Target for common (java) tools run on the build machine
|
||||||
@@ -326,41 +332,43 @@ func TestConfig(buildDir string, env map[string]string, bp string, fs map[string
|
|||||||
return Config{config}
|
return Config{config}
|
||||||
}
|
}
|
||||||
|
|
||||||
func fuchsiaTargets() map[OsType][]Target {
|
func fuchsiaTargets(config Config) map[OsType][]Target {
|
||||||
return map[OsType][]Target{
|
return map[OsType][]Target{
|
||||||
Fuchsia: {
|
Fuchsia: {
|
||||||
{Fuchsia, Arch{ArchType: Arm64, ArchVariant: "", Abi: []string{"arm64-v8a"}}, NativeBridgeDisabled, "", "", false},
|
{Fuchsia, Arch{ArchType: Arm64, ArchVariant: "", Abi: []string{"arm64-v8a"}}, NativeBridgeDisabled, "", "", false},
|
||||||
},
|
},
|
||||||
BuildOs: {
|
config.BuildOS: {
|
||||||
{BuildOs, Arch{ArchType: X86_64}, NativeBridgeDisabled, "", "", false},
|
{config.BuildOS, Arch{ArchType: X86_64}, NativeBridgeDisabled, "", "", false},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var PrepareForTestSetDeviceToFuchsia = FixtureModifyConfig(func(config Config) {
|
var PrepareForTestSetDeviceToFuchsia = FixtureModifyConfig(func(config Config) {
|
||||||
config.Targets = fuchsiaTargets()
|
config.Targets = fuchsiaTargets(config)
|
||||||
})
|
})
|
||||||
|
|
||||||
func modifyTestConfigToSupportArchMutator(testConfig Config) {
|
func modifyTestConfigToSupportArchMutator(testConfig Config) {
|
||||||
config := testConfig.config
|
config := testConfig.config
|
||||||
|
|
||||||
|
determineBuildOS(config)
|
||||||
|
|
||||||
config.Targets = map[OsType][]Target{
|
config.Targets = map[OsType][]Target{
|
||||||
Android: []Target{
|
Android: []Target{
|
||||||
{Android, Arch{ArchType: Arm64, ArchVariant: "armv8-a", Abi: []string{"arm64-v8a"}}, NativeBridgeDisabled, "", "", false},
|
{Android, Arch{ArchType: Arm64, ArchVariant: "armv8-a", Abi: []string{"arm64-v8a"}}, NativeBridgeDisabled, "", "", false},
|
||||||
{Android, Arch{ArchType: Arm, ArchVariant: "armv7-a-neon", Abi: []string{"armeabi-v7a"}}, NativeBridgeDisabled, "", "", false},
|
{Android, Arch{ArchType: Arm, ArchVariant: "armv7-a-neon", Abi: []string{"armeabi-v7a"}}, NativeBridgeDisabled, "", "", false},
|
||||||
},
|
},
|
||||||
BuildOs: []Target{
|
config.BuildOS: []Target{
|
||||||
{BuildOs, Arch{ArchType: X86_64}, NativeBridgeDisabled, "", "", false},
|
{config.BuildOS, Arch{ArchType: X86_64}, NativeBridgeDisabled, "", "", false},
|
||||||
{BuildOs, Arch{ArchType: X86}, NativeBridgeDisabled, "", "", false},
|
{config.BuildOS, Arch{ArchType: X86}, NativeBridgeDisabled, "", "", false},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
if runtime.GOOS == "darwin" {
|
if runtime.GOOS == "darwin" {
|
||||||
config.Targets[BuildOs] = config.Targets[BuildOs][:1]
|
config.Targets[config.BuildOS] = config.Targets[config.BuildOS][:1]
|
||||||
}
|
}
|
||||||
|
|
||||||
config.BuildOSTarget = config.Targets[BuildOs][0]
|
config.BuildOSTarget = config.Targets[config.BuildOS][0]
|
||||||
config.BuildOSCommonTarget = getCommonTargets(config.Targets[BuildOs])[0]
|
config.BuildOSCommonTarget = getCommonTargets(config.Targets[config.BuildOS])[0]
|
||||||
config.AndroidCommonTarget = getCommonTargets(config.Targets[Android])[0]
|
config.AndroidCommonTarget = getCommonTargets(config.Targets[Android])[0]
|
||||||
config.AndroidFirstDeviceTarget = firstTarget(config.Targets[Android], "lib64", "lib32")[0]
|
config.AndroidFirstDeviceTarget = firstTarget(config.Targets[Android], "lib64", "lib32")[0]
|
||||||
config.TestProductVariables.DeviceArch = proptools.StringPtr("arm64")
|
config.TestProductVariables.DeviceArch = proptools.StringPtr("arm64")
|
||||||
@@ -439,6 +447,8 @@ func NewConfig(srcDir, buildDir string, moduleListFile string, availableEnv map[
|
|||||||
config.katiEnabled = true
|
config.katiEnabled = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
determineBuildOS(config)
|
||||||
|
|
||||||
// Sets up the map of target OSes to the finer grained compilation targets
|
// Sets up the map of target OSes to the finer grained compilation targets
|
||||||
// that are configured from the product variables.
|
// that are configured from the product variables.
|
||||||
targets, err := decodeTargetProductVariables(config)
|
targets, err := decodeTargetProductVariables(config)
|
||||||
@@ -476,8 +486,8 @@ func NewConfig(srcDir, buildDir string, moduleListFile string, availableEnv map[
|
|||||||
config.Targets = targets
|
config.Targets = targets
|
||||||
|
|
||||||
// Compilation targets for host tools.
|
// Compilation targets for host tools.
|
||||||
config.BuildOSTarget = config.Targets[BuildOs][0]
|
config.BuildOSTarget = config.Targets[config.BuildOS][0]
|
||||||
config.BuildOSCommonTarget = getCommonTargets(config.Targets[BuildOs])[0]
|
config.BuildOSCommonTarget = getCommonTargets(config.Targets[config.BuildOS])[0]
|
||||||
|
|
||||||
// Compilation targets for Android.
|
// Compilation targets for Android.
|
||||||
if len(config.Targets[Android]) > 0 {
|
if len(config.Targets[Android]) > 0 {
|
||||||
|
@@ -86,7 +86,7 @@ func (t *prebuiltBuildTool) GenerateAndroidBuildActions(ctx ModuleContext) {
|
|||||||
|
|
||||||
func (t *prebuiltBuildTool) MakeVars(ctx MakeVarsModuleContext) {
|
func (t *prebuiltBuildTool) MakeVars(ctx MakeVarsModuleContext) {
|
||||||
if makeVar := String(t.properties.Export_to_make_var); makeVar != "" {
|
if makeVar := String(t.properties.Export_to_make_var); makeVar != "" {
|
||||||
if t.Target().Os != BuildOs {
|
if t.Target().Os != ctx.Config().BuildOS {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
ctx.StrictRaw(makeVar, t.toolPath.String())
|
ctx.StrictRaw(makeVar, t.toolPath.String())
|
||||||
|
@@ -21,360 +21,362 @@ import (
|
|||||||
"github.com/google/blueprint"
|
"github.com/google/blueprint"
|
||||||
)
|
)
|
||||||
|
|
||||||
var prebuiltsTests = []struct {
|
func TestPrebuilts(t *testing.T) {
|
||||||
name string
|
buildOS := TestArchConfig(t.TempDir(), nil, "", nil).BuildOS
|
||||||
replaceBp bool // modules is added to default bp boilerplate if false.
|
|
||||||
modules string
|
|
||||||
prebuilt []OsType
|
|
||||||
preparer FixturePreparer
|
|
||||||
}{
|
|
||||||
{
|
|
||||||
name: "no prebuilt",
|
|
||||||
modules: `
|
|
||||||
source {
|
|
||||||
name: "bar",
|
|
||||||
}`,
|
|
||||||
prebuilt: nil,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "no source prebuilt not preferred",
|
|
||||||
modules: `
|
|
||||||
prebuilt {
|
|
||||||
name: "bar",
|
|
||||||
prefer: false,
|
|
||||||
srcs: ["prebuilt_file"],
|
|
||||||
}`,
|
|
||||||
prebuilt: []OsType{Android, BuildOs},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "no source prebuilt preferred",
|
|
||||||
modules: `
|
|
||||||
prebuilt {
|
|
||||||
name: "bar",
|
|
||||||
prefer: true,
|
|
||||||
srcs: ["prebuilt_file"],
|
|
||||||
}`,
|
|
||||||
prebuilt: []OsType{Android, BuildOs},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "prebuilt not preferred",
|
|
||||||
modules: `
|
|
||||||
source {
|
|
||||||
name: "bar",
|
|
||||||
}
|
|
||||||
|
|
||||||
prebuilt {
|
var prebuiltsTests = []struct {
|
||||||
name: "bar",
|
name string
|
||||||
prefer: false,
|
replaceBp bool // modules is added to default bp boilerplate if false.
|
||||||
srcs: ["prebuilt_file"],
|
modules string
|
||||||
}`,
|
prebuilt []OsType
|
||||||
prebuilt: nil,
|
preparer FixturePreparer
|
||||||
},
|
}{
|
||||||
{
|
{
|
||||||
name: "prebuilt preferred",
|
name: "no prebuilt",
|
||||||
modules: `
|
modules: `
|
||||||
source {
|
source {
|
||||||
name: "bar",
|
name: "bar",
|
||||||
}
|
}`,
|
||||||
|
prebuilt: nil,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "no source prebuilt not preferred",
|
||||||
|
modules: `
|
||||||
|
prebuilt {
|
||||||
|
name: "bar",
|
||||||
|
prefer: false,
|
||||||
|
srcs: ["prebuilt_file"],
|
||||||
|
}`,
|
||||||
|
prebuilt: []OsType{Android, buildOS},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "no source prebuilt preferred",
|
||||||
|
modules: `
|
||||||
|
prebuilt {
|
||||||
|
name: "bar",
|
||||||
|
prefer: true,
|
||||||
|
srcs: ["prebuilt_file"],
|
||||||
|
}`,
|
||||||
|
prebuilt: []OsType{Android, buildOS},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "prebuilt not preferred",
|
||||||
|
modules: `
|
||||||
|
source {
|
||||||
|
name: "bar",
|
||||||
|
}
|
||||||
|
|
||||||
prebuilt {
|
prebuilt {
|
||||||
name: "bar",
|
name: "bar",
|
||||||
prefer: true,
|
prefer: false,
|
||||||
srcs: ["prebuilt_file"],
|
srcs: ["prebuilt_file"],
|
||||||
}`,
|
}`,
|
||||||
prebuilt: []OsType{Android, BuildOs},
|
prebuilt: nil,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "prebuilt no file not preferred",
|
name: "prebuilt preferred",
|
||||||
modules: `
|
modules: `
|
||||||
source {
|
source {
|
||||||
name: "bar",
|
name: "bar",
|
||||||
}
|
}
|
||||||
|
|
||||||
prebuilt {
|
prebuilt {
|
||||||
name: "bar",
|
name: "bar",
|
||||||
prefer: false,
|
prefer: true,
|
||||||
}`,
|
srcs: ["prebuilt_file"],
|
||||||
prebuilt: nil,
|
}`,
|
||||||
},
|
prebuilt: []OsType{Android, buildOS},
|
||||||
{
|
},
|
||||||
name: "prebuilt no file preferred",
|
{
|
||||||
modules: `
|
name: "prebuilt no file not preferred",
|
||||||
source {
|
modules: `
|
||||||
name: "bar",
|
source {
|
||||||
}
|
name: "bar",
|
||||||
|
}
|
||||||
|
|
||||||
prebuilt {
|
prebuilt {
|
||||||
name: "bar",
|
name: "bar",
|
||||||
prefer: true,
|
prefer: false,
|
||||||
}`,
|
}`,
|
||||||
prebuilt: nil,
|
prebuilt: nil,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "prebuilt file from filegroup preferred",
|
name: "prebuilt no file preferred",
|
||||||
modules: `
|
modules: `
|
||||||
filegroup {
|
source {
|
||||||
name: "fg",
|
name: "bar",
|
||||||
srcs: ["prebuilt_file"],
|
}
|
||||||
}
|
|
||||||
prebuilt {
|
|
||||||
name: "bar",
|
|
||||||
prefer: true,
|
|
||||||
srcs: [":fg"],
|
|
||||||
}`,
|
|
||||||
prebuilt: []OsType{Android, BuildOs},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "prebuilt module for device only",
|
|
||||||
modules: `
|
|
||||||
source {
|
|
||||||
name: "bar",
|
|
||||||
}
|
|
||||||
|
|
||||||
prebuilt {
|
prebuilt {
|
||||||
name: "bar",
|
name: "bar",
|
||||||
host_supported: false,
|
prefer: true,
|
||||||
prefer: true,
|
}`,
|
||||||
srcs: ["prebuilt_file"],
|
prebuilt: nil,
|
||||||
}`,
|
},
|
||||||
prebuilt: []OsType{Android},
|
{
|
||||||
},
|
name: "prebuilt file from filegroup preferred",
|
||||||
{
|
modules: `
|
||||||
name: "prebuilt file for host only",
|
filegroup {
|
||||||
modules: `
|
name: "fg",
|
||||||
source {
|
srcs: ["prebuilt_file"],
|
||||||
name: "bar",
|
}
|
||||||
}
|
prebuilt {
|
||||||
|
name: "bar",
|
||||||
|
prefer: true,
|
||||||
|
srcs: [":fg"],
|
||||||
|
}`,
|
||||||
|
prebuilt: []OsType{Android, buildOS},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "prebuilt module for device only",
|
||||||
|
modules: `
|
||||||
|
source {
|
||||||
|
name: "bar",
|
||||||
|
}
|
||||||
|
|
||||||
prebuilt {
|
prebuilt {
|
||||||
name: "bar",
|
name: "bar",
|
||||||
prefer: true,
|
host_supported: false,
|
||||||
target: {
|
prefer: true,
|
||||||
host: {
|
srcs: ["prebuilt_file"],
|
||||||
srcs: ["prebuilt_file"],
|
}`,
|
||||||
},
|
prebuilt: []OsType{Android},
|
||||||
},
|
},
|
||||||
}`,
|
{
|
||||||
prebuilt: []OsType{BuildOs},
|
name: "prebuilt file for host only",
|
||||||
},
|
modules: `
|
||||||
{
|
source {
|
||||||
name: "prebuilt override not preferred",
|
name: "bar",
|
||||||
modules: `
|
}
|
||||||
source {
|
|
||||||
name: "baz",
|
|
||||||
}
|
|
||||||
|
|
||||||
override_source {
|
prebuilt {
|
||||||
name: "bar",
|
name: "bar",
|
||||||
base: "baz",
|
prefer: true,
|
||||||
}
|
target: {
|
||||||
|
host: {
|
||||||
prebuilt {
|
srcs: ["prebuilt_file"],
|
||||||
name: "bar",
|
|
||||||
prefer: false,
|
|
||||||
srcs: ["prebuilt_file"],
|
|
||||||
}`,
|
|
||||||
prebuilt: nil,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "prebuilt override preferred",
|
|
||||||
modules: `
|
|
||||||
source {
|
|
||||||
name: "baz",
|
|
||||||
}
|
|
||||||
|
|
||||||
override_source {
|
|
||||||
name: "bar",
|
|
||||||
base: "baz",
|
|
||||||
}
|
|
||||||
|
|
||||||
prebuilt {
|
|
||||||
name: "bar",
|
|
||||||
prefer: true,
|
|
||||||
srcs: ["prebuilt_file"],
|
|
||||||
}`,
|
|
||||||
prebuilt: []OsType{Android, BuildOs},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "prebuilt including default-disabled OS",
|
|
||||||
replaceBp: true,
|
|
||||||
modules: `
|
|
||||||
source {
|
|
||||||
name: "foo",
|
|
||||||
deps: [":bar"],
|
|
||||||
target: {
|
|
||||||
windows: {
|
|
||||||
enabled: true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
source {
|
|
||||||
name: "bar",
|
|
||||||
target: {
|
|
||||||
windows: {
|
|
||||||
enabled: true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
prebuilt {
|
|
||||||
name: "bar",
|
|
||||||
prefer: true,
|
|
||||||
srcs: ["prebuilt_file"],
|
|
||||||
target: {
|
|
||||||
windows: {
|
|
||||||
enabled: true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}`,
|
|
||||||
prebuilt: []OsType{Android, BuildOs, Windows},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "fall back to source for default-disabled OS",
|
|
||||||
replaceBp: true,
|
|
||||||
modules: `
|
|
||||||
source {
|
|
||||||
name: "foo",
|
|
||||||
deps: [":bar"],
|
|
||||||
target: {
|
|
||||||
windows: {
|
|
||||||
enabled: true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
source {
|
|
||||||
name: "bar",
|
|
||||||
target: {
|
|
||||||
windows: {
|
|
||||||
enabled: true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
prebuilt {
|
|
||||||
name: "bar",
|
|
||||||
prefer: true,
|
|
||||||
srcs: ["prebuilt_file"],
|
|
||||||
}`,
|
|
||||||
prebuilt: []OsType{Android, BuildOs},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "prebuilt properties customizable",
|
|
||||||
replaceBp: true,
|
|
||||||
modules: `
|
|
||||||
source {
|
|
||||||
name: "foo",
|
|
||||||
deps: [":bar"],
|
|
||||||
}
|
|
||||||
|
|
||||||
soong_config_module_type {
|
|
||||||
name: "prebuilt_with_config",
|
|
||||||
module_type: "prebuilt",
|
|
||||||
config_namespace: "any_namespace",
|
|
||||||
bool_variables: ["bool_var"],
|
|
||||||
properties: ["prefer"],
|
|
||||||
}
|
|
||||||
|
|
||||||
prebuilt_with_config {
|
|
||||||
name: "bar",
|
|
||||||
prefer: true,
|
|
||||||
srcs: ["prebuilt_file"],
|
|
||||||
soong_config_variables: {
|
|
||||||
bool_var: {
|
|
||||||
prefer: false,
|
|
||||||
conditions_default: {
|
|
||||||
prefer: true,
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
}`,
|
||||||
}`,
|
prebuilt: []OsType{buildOS},
|
||||||
prebuilt: []OsType{Android, BuildOs},
|
},
|
||||||
},
|
{
|
||||||
{
|
name: "prebuilt override not preferred",
|
||||||
name: "prebuilt use_source_config_var={acme, use_source} - no var specified",
|
modules: `
|
||||||
modules: `
|
source {
|
||||||
source {
|
name: "baz",
|
||||||
name: "bar",
|
}
|
||||||
}
|
|
||||||
|
|
||||||
prebuilt {
|
override_source {
|
||||||
name: "bar",
|
name: "bar",
|
||||||
use_source_config_var: {config_namespace: "acme", var_name: "use_source"},
|
base: "baz",
|
||||||
srcs: ["prebuilt_file"],
|
}
|
||||||
}`,
|
|
||||||
// When use_source_env is specified then it will use the prebuilt by default if the environment
|
|
||||||
// variable is not set.
|
|
||||||
prebuilt: []OsType{Android, BuildOs},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "prebuilt use_source_config_var={acme, use_source} - acme_use_source=false",
|
|
||||||
modules: `
|
|
||||||
source {
|
|
||||||
name: "bar",
|
|
||||||
}
|
|
||||||
|
|
||||||
prebuilt {
|
prebuilt {
|
||||||
name: "bar",
|
name: "bar",
|
||||||
use_source_config_var: {config_namespace: "acme", var_name: "use_source"},
|
prefer: false,
|
||||||
srcs: ["prebuilt_file"],
|
srcs: ["prebuilt_file"],
|
||||||
}`,
|
}`,
|
||||||
preparer: FixtureModifyProductVariables(func(variables FixtureProductVariables) {
|
prebuilt: nil,
|
||||||
variables.VendorVars = map[string]map[string]string{
|
},
|
||||||
"acme": {
|
{
|
||||||
"use_source": "false",
|
name: "prebuilt override preferred",
|
||||||
},
|
modules: `
|
||||||
}
|
source {
|
||||||
}),
|
name: "baz",
|
||||||
// Setting the environment variable named in use_source_env to false will cause the prebuilt to
|
}
|
||||||
// be used.
|
|
||||||
prebuilt: []OsType{Android, BuildOs},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "prebuilt use_source_config_var={acme, use_source} - acme_use_source=true",
|
|
||||||
modules: `
|
|
||||||
source {
|
|
||||||
name: "bar",
|
|
||||||
}
|
|
||||||
|
|
||||||
prebuilt {
|
override_source {
|
||||||
name: "bar",
|
name: "bar",
|
||||||
use_source_config_var: {config_namespace: "acme", var_name: "use_source"},
|
base: "baz",
|
||||||
srcs: ["prebuilt_file"],
|
}
|
||||||
}`,
|
|
||||||
preparer: FixtureModifyProductVariables(func(variables FixtureProductVariables) {
|
prebuilt {
|
||||||
variables.VendorVars = map[string]map[string]string{
|
name: "bar",
|
||||||
"acme": {
|
prefer: true,
|
||||||
"use_source": "true",
|
srcs: ["prebuilt_file"],
|
||||||
},
|
}`,
|
||||||
}
|
prebuilt: []OsType{Android, buildOS},
|
||||||
}),
|
},
|
||||||
// Setting the environment variable named in use_source_env to true will cause the source to be
|
{
|
||||||
// used.
|
name: "prebuilt including default-disabled OS",
|
||||||
prebuilt: nil,
|
replaceBp: true,
|
||||||
},
|
modules: `
|
||||||
{
|
source {
|
||||||
name: "prebuilt use_source_config_var={acme, use_source} - acme_use_source=true, no source",
|
name: "foo",
|
||||||
modules: `
|
deps: [":bar"],
|
||||||
prebuilt {
|
target: {
|
||||||
name: "bar",
|
windows: {
|
||||||
use_source_config_var: {config_namespace: "acme", var_name: "use_source"},
|
enabled: true,
|
||||||
srcs: ["prebuilt_file"],
|
},
|
||||||
}`,
|
},
|
||||||
preparer: FixtureModifyProductVariables(func(variables FixtureProductVariables) {
|
}
|
||||||
variables.VendorVars = map[string]map[string]string{
|
|
||||||
"acme": {
|
source {
|
||||||
"use_source": "true",
|
name: "bar",
|
||||||
},
|
target: {
|
||||||
}
|
windows: {
|
||||||
}),
|
enabled: true,
|
||||||
// Although the environment variable says to use source there is no source available.
|
},
|
||||||
prebuilt: []OsType{Android, BuildOs},
|
},
|
||||||
},
|
}
|
||||||
}
|
|
||||||
|
prebuilt {
|
||||||
|
name: "bar",
|
||||||
|
prefer: true,
|
||||||
|
srcs: ["prebuilt_file"],
|
||||||
|
target: {
|
||||||
|
windows: {
|
||||||
|
enabled: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}`,
|
||||||
|
prebuilt: []OsType{Android, buildOS, Windows},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "fall back to source for default-disabled OS",
|
||||||
|
replaceBp: true,
|
||||||
|
modules: `
|
||||||
|
source {
|
||||||
|
name: "foo",
|
||||||
|
deps: [":bar"],
|
||||||
|
target: {
|
||||||
|
windows: {
|
||||||
|
enabled: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
source {
|
||||||
|
name: "bar",
|
||||||
|
target: {
|
||||||
|
windows: {
|
||||||
|
enabled: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
prebuilt {
|
||||||
|
name: "bar",
|
||||||
|
prefer: true,
|
||||||
|
srcs: ["prebuilt_file"],
|
||||||
|
}`,
|
||||||
|
prebuilt: []OsType{Android, buildOS},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "prebuilt properties customizable",
|
||||||
|
replaceBp: true,
|
||||||
|
modules: `
|
||||||
|
source {
|
||||||
|
name: "foo",
|
||||||
|
deps: [":bar"],
|
||||||
|
}
|
||||||
|
|
||||||
|
soong_config_module_type {
|
||||||
|
name: "prebuilt_with_config",
|
||||||
|
module_type: "prebuilt",
|
||||||
|
config_namespace: "any_namespace",
|
||||||
|
bool_variables: ["bool_var"],
|
||||||
|
properties: ["prefer"],
|
||||||
|
}
|
||||||
|
|
||||||
|
prebuilt_with_config {
|
||||||
|
name: "bar",
|
||||||
|
prefer: true,
|
||||||
|
srcs: ["prebuilt_file"],
|
||||||
|
soong_config_variables: {
|
||||||
|
bool_var: {
|
||||||
|
prefer: false,
|
||||||
|
conditions_default: {
|
||||||
|
prefer: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}`,
|
||||||
|
prebuilt: []OsType{Android, buildOS},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "prebuilt use_source_config_var={acme, use_source} - no var specified",
|
||||||
|
modules: `
|
||||||
|
source {
|
||||||
|
name: "bar",
|
||||||
|
}
|
||||||
|
|
||||||
|
prebuilt {
|
||||||
|
name: "bar",
|
||||||
|
use_source_config_var: {config_namespace: "acme", var_name: "use_source"},
|
||||||
|
srcs: ["prebuilt_file"],
|
||||||
|
}`,
|
||||||
|
// When use_source_env is specified then it will use the prebuilt by default if the environment
|
||||||
|
// variable is not set.
|
||||||
|
prebuilt: []OsType{Android, buildOS},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "prebuilt use_source_config_var={acme, use_source} - acme_use_source=false",
|
||||||
|
modules: `
|
||||||
|
source {
|
||||||
|
name: "bar",
|
||||||
|
}
|
||||||
|
|
||||||
|
prebuilt {
|
||||||
|
name: "bar",
|
||||||
|
use_source_config_var: {config_namespace: "acme", var_name: "use_source"},
|
||||||
|
srcs: ["prebuilt_file"],
|
||||||
|
}`,
|
||||||
|
preparer: FixtureModifyProductVariables(func(variables FixtureProductVariables) {
|
||||||
|
variables.VendorVars = map[string]map[string]string{
|
||||||
|
"acme": {
|
||||||
|
"use_source": "false",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
// Setting the environment variable named in use_source_env to false will cause the prebuilt to
|
||||||
|
// be used.
|
||||||
|
prebuilt: []OsType{Android, buildOS},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "prebuilt use_source_config_var={acme, use_source} - acme_use_source=true",
|
||||||
|
modules: `
|
||||||
|
source {
|
||||||
|
name: "bar",
|
||||||
|
}
|
||||||
|
|
||||||
|
prebuilt {
|
||||||
|
name: "bar",
|
||||||
|
use_source_config_var: {config_namespace: "acme", var_name: "use_source"},
|
||||||
|
srcs: ["prebuilt_file"],
|
||||||
|
}`,
|
||||||
|
preparer: FixtureModifyProductVariables(func(variables FixtureProductVariables) {
|
||||||
|
variables.VendorVars = map[string]map[string]string{
|
||||||
|
"acme": {
|
||||||
|
"use_source": "true",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
// Setting the environment variable named in use_source_env to true will cause the source to be
|
||||||
|
// used.
|
||||||
|
prebuilt: nil,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "prebuilt use_source_config_var={acme, use_source} - acme_use_source=true, no source",
|
||||||
|
modules: `
|
||||||
|
prebuilt {
|
||||||
|
name: "bar",
|
||||||
|
use_source_config_var: {config_namespace: "acme", var_name: "use_source"},
|
||||||
|
srcs: ["prebuilt_file"],
|
||||||
|
}`,
|
||||||
|
preparer: FixtureModifyProductVariables(func(variables FixtureProductVariables) {
|
||||||
|
variables.VendorVars = map[string]map[string]string{
|
||||||
|
"acme": {
|
||||||
|
"use_source": "true",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
// Although the environment variable says to use source there is no source available.
|
||||||
|
prebuilt: []OsType{Android, buildOS},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
func TestPrebuilts(t *testing.T) {
|
|
||||||
fs := MockFS{
|
fs := MockFS{
|
||||||
"prebuilt_file": nil,
|
"prebuilt_file": nil,
|
||||||
"source_file": nil,
|
"source_file": nil,
|
||||||
|
@@ -60,7 +60,7 @@ func robolectricTestSuite(ctx SingletonContext, files map[string]InstallPaths) W
|
|||||||
for _, module := range SortedStringKeys(files) {
|
for _, module := range SortedStringKeys(files) {
|
||||||
installedPaths = append(installedPaths, files[module]...)
|
installedPaths = append(installedPaths, files[module]...)
|
||||||
}
|
}
|
||||||
testCasesDir := pathForInstall(ctx, BuildOs, X86, "testcases", false).ToMakePath()
|
testCasesDir := pathForInstall(ctx, ctx.Config().BuildOS, X86, "testcases", false).ToMakePath()
|
||||||
|
|
||||||
outputFile := PathForOutput(ctx, "packaging", "robolectric-tests.zip")
|
outputFile := PathForOutput(ctx, "packaging", "robolectric-tests.zip")
|
||||||
rule := NewRuleBuilder(pctx, ctx)
|
rule := NewRuleBuilder(pctx, ctx)
|
||||||
|
@@ -15,6 +15,7 @@
|
|||||||
package config
|
package config
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"runtime"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"android/soong/android"
|
"android/soong/android"
|
||||||
@@ -282,7 +283,7 @@ var (
|
|||||||
var pctx = android.NewPackageContext("android/soong/cc/config")
|
var pctx = android.NewPackageContext("android/soong/cc/config")
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
if android.BuildOs == android.Linux {
|
if runtime.GOOS == "linux" {
|
||||||
commonGlobalCflags = append(commonGlobalCflags, "-fdebug-prefix-map=/proc/self/cwd=")
|
commonGlobalCflags = append(commonGlobalCflags, "-fdebug-prefix-map=/proc/self/cwd=")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -165,7 +165,7 @@ func makeVarsProvider(ctx android.MakeVarsContext) {
|
|||||||
sort.Strings(ndkKnownLibs)
|
sort.Strings(ndkKnownLibs)
|
||||||
ctx.Strict("NDK_KNOWN_LIBS", strings.Join(ndkKnownLibs, " "))
|
ctx.Strict("NDK_KNOWN_LIBS", strings.Join(ndkKnownLibs, " "))
|
||||||
|
|
||||||
hostTargets := ctx.Config().Targets[android.BuildOs]
|
hostTargets := ctx.Config().Targets[ctx.Config().BuildOS]
|
||||||
makeVarsToolchain(ctx, "", hostTargets[0])
|
makeVarsToolchain(ctx, "", hostTargets[0])
|
||||||
if len(hostTargets) > 1 {
|
if len(hostTargets) > 1 {
|
||||||
makeVarsToolchain(ctx, "2ND_", hostTargets[1])
|
makeVarsToolchain(ctx, "2ND_", hostTargets[1])
|
||||||
|
@@ -15,6 +15,7 @@
|
|||||||
package cc
|
package cc
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"runtime"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"android/soong/android"
|
"android/soong/android"
|
||||||
@@ -271,8 +272,8 @@ func TestPrebuiltLibrarySharedStem(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestPrebuiltSymlinkedHostBinary(t *testing.T) {
|
func TestPrebuiltSymlinkedHostBinary(t *testing.T) {
|
||||||
if android.BuildOs != android.Linux {
|
if runtime.GOOS != "linux" {
|
||||||
t.Skipf("Skipping host prebuilt testing that is only supported on %s not %s", android.Linux, android.BuildOs)
|
t.Skipf("Skipping host prebuilt testing that is only supported on linux not %s", runtime.GOOS)
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx := testPrebuilt(t, `
|
ctx := testPrebuilt(t, `
|
||||||
|
@@ -51,7 +51,7 @@ func TestProto(t *testing.T) {
|
|||||||
},
|
},
|
||||||
}`)
|
}`)
|
||||||
|
|
||||||
buildOS := android.BuildOs.String()
|
buildOS := ctx.Config().BuildOS.String()
|
||||||
|
|
||||||
proto := ctx.ModuleForTests("libfoo", "android_arm_armv7-a-neon_shared").Output("proto/a.pb.cc")
|
proto := ctx.ModuleForTests("libfoo", "android_arm_armv7-a-neon_shared").Output("proto/a.pb.cc")
|
||||||
foobar := ctx.ModuleForTests("protoc-gen-foobar", buildOS+"_x86_64")
|
foobar := ctx.ModuleForTests("protoc-gen-foobar", buildOS+"_x86_64")
|
||||||
|
@@ -188,7 +188,7 @@ func TestPrebuiltEtcHost(t *testing.T) {
|
|||||||
}
|
}
|
||||||
`)
|
`)
|
||||||
|
|
||||||
buildOS := android.BuildOs.String()
|
buildOS := result.Config.BuildOS.String()
|
||||||
p := result.Module("foo.conf", buildOS+"_common").(*PrebuiltEtc)
|
p := result.Module("foo.conf", buildOS+"_common").(*PrebuiltEtc)
|
||||||
if !p.Host() {
|
if !p.Host() {
|
||||||
t.Errorf("host bit is not set for a prebuilt_etc_host module.")
|
t.Errorf("host bit is not set for a prebuilt_etc_host module.")
|
||||||
@@ -242,7 +242,7 @@ func TestPrebuiltUserShareHostInstallDirPath(t *testing.T) {
|
|||||||
}
|
}
|
||||||
`)
|
`)
|
||||||
|
|
||||||
buildOS := android.BuildOs.String()
|
buildOS := result.Config.BuildOS.String()
|
||||||
p := result.Module("foo.conf", buildOS+"_common").(*PrebuiltEtc)
|
p := result.Module("foo.conf", buildOS+"_common").(*PrebuiltEtc)
|
||||||
expected := filepath.Join("out/soong/host", result.Config.PrebuiltOS(), "usr", "share", "bar")
|
expected := filepath.Join("out/soong/host", result.Config.PrebuiltOS(), "usr", "share", "bar")
|
||||||
android.AssertPathRelativeToTopEquals(t, "install dir", expected, p.installDirPath)
|
android.AssertPathRelativeToTopEquals(t, "install dir", expected, p.installDirPath)
|
||||||
|
@@ -523,14 +523,14 @@ func buildBootImageVariantsForAndroidOs(ctx android.ModuleContext, image *bootIm
|
|||||||
}
|
}
|
||||||
|
|
||||||
// buildBootImageVariantsForBuildOs generates rules to build the boot image variants for the
|
// buildBootImageVariantsForBuildOs generates rules to build the boot image variants for the
|
||||||
// android.BuildOs OsType, i.e. the type of OS on which the build is being running.
|
// config.BuildOS OsType, i.e. the type of OS on which the build is being running.
|
||||||
//
|
//
|
||||||
// The files need to be generated into their predefined location because they are used from there
|
// The files need to be generated into their predefined location because they are used from there
|
||||||
// both within Soong and outside, e.g. for ART based host side testing and also for use by some
|
// both within Soong and outside, e.g. for ART based host side testing and also for use by some
|
||||||
// cloud based tools. However, they are not needed by callers of this function and so the paths do
|
// cloud based tools. However, they are not needed by callers of this function and so the paths do
|
||||||
// not need to be returned from this func, unlike the buildBootImageVariantsForAndroidOs func.
|
// not need to be returned from this func, unlike the buildBootImageVariantsForAndroidOs func.
|
||||||
func buildBootImageVariantsForBuildOs(ctx android.ModuleContext, image *bootImageConfig, profile android.WritablePath) {
|
func buildBootImageVariantsForBuildOs(ctx android.ModuleContext, image *bootImageConfig, profile android.WritablePath) {
|
||||||
buildBootImageForOsType(ctx, image, profile, android.BuildOs)
|
buildBootImageForOsType(ctx, image, profile, ctx.Config().BuildOS)
|
||||||
}
|
}
|
||||||
|
|
||||||
// buildBootImageForOsType takes a bootImageConfig, a profile file and an android.OsType
|
// buildBootImageForOsType takes a bootImageConfig, a profile file and an android.OsType
|
||||||
|
@@ -32,7 +32,7 @@ func dexpreoptTargets(ctx android.PathContext) []android.Target {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// We may also need the images on host in order to run host-based tests.
|
// We may also need the images on host in order to run host-based tests.
|
||||||
for _, target := range ctx.Config().Targets[android.BuildOs] {
|
for _, target := range ctx.Config().Targets[ctx.Config().BuildOS] {
|
||||||
targets = append(targets, target)
|
targets = append(targets, target)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -16,6 +16,7 @@ package java
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"runtime"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"android/soong/android"
|
"android/soong/android"
|
||||||
@@ -173,9 +174,9 @@ func enabledString(enabled bool) string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestDex2oatToolDeps(t *testing.T) {
|
func TestDex2oatToolDeps(t *testing.T) {
|
||||||
if android.BuildOs != android.Linux {
|
if runtime.GOOS != "linux" {
|
||||||
// The host binary paths checked below are build OS dependent.
|
// The host binary paths checked below are build OS dependent.
|
||||||
t.Skipf("Unsupported build OS %s", android.BuildOs)
|
t.Skipf("Unsupported build OS %s", runtime.GOOS)
|
||||||
}
|
}
|
||||||
|
|
||||||
preparers := android.GroupFixturePreparers(
|
preparers := android.GroupFixturePreparers(
|
||||||
|
@@ -441,7 +441,7 @@ func TestBinary(t *testing.T) {
|
|||||||
}
|
}
|
||||||
`)
|
`)
|
||||||
|
|
||||||
buildOS := android.BuildOs.String()
|
buildOS := ctx.Config().BuildOS.String()
|
||||||
|
|
||||||
bar := ctx.ModuleForTests("bar", buildOS+"_common")
|
bar := ctx.ModuleForTests("bar", buildOS+"_common")
|
||||||
barJar := bar.Output("bar.jar").Output.String()
|
barJar := bar.Output("bar.jar").Output.String()
|
||||||
@@ -478,7 +478,7 @@ func TestTest(t *testing.T) {
|
|||||||
}
|
}
|
||||||
`)
|
`)
|
||||||
|
|
||||||
buildOS := android.BuildOs.String()
|
buildOS := ctx.Config().BuildOS.String()
|
||||||
|
|
||||||
foo := ctx.ModuleForTests("foo", buildOS+"_common").Module().(*TestHost)
|
foo := ctx.ModuleForTests("foo", buildOS+"_common").Module().(*TestHost)
|
||||||
|
|
||||||
@@ -523,7 +523,7 @@ func TestHostBinaryNoJavaDebugInfoOverride(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// check that -g is not overridden for host modules
|
// check that -g is not overridden for host modules
|
||||||
buildOS := android.BuildOs.String()
|
buildOS := result.Config.BuildOS.String()
|
||||||
hostBinary := result.ModuleForTests("host_binary", buildOS+"_common")
|
hostBinary := result.ModuleForTests("host_binary", buildOS+"_common")
|
||||||
hostJavaFlags := hostBinary.Module().VariablesForTests()["javacFlags"]
|
hostJavaFlags := hostBinary.Module().VariablesForTests()["javacFlags"]
|
||||||
if strings.Contains(hostJavaFlags, "-g:source,lines") {
|
if strings.Contains(hostJavaFlags, "-g:source,lines") {
|
||||||
@@ -1371,7 +1371,7 @@ func TestDataNativeBinaries(t *testing.T) {
|
|||||||
}
|
}
|
||||||
`)
|
`)
|
||||||
|
|
||||||
buildOS := android.BuildOs.String()
|
buildOS := ctx.Config().BuildOS.String()
|
||||||
|
|
||||||
test := ctx.ModuleForTests("foo", buildOS+"_common").Module().(*TestHost)
|
test := ctx.ModuleForTests("foo", buildOS+"_common").Module().(*TestHost)
|
||||||
entries := android.AndroidMkEntriesForTest(t, ctx, test)[0]
|
entries := android.AndroidMkEntriesForTest(t, ctx, test)[0]
|
||||||
@@ -1387,7 +1387,7 @@ func TestDefaultInstallable(t *testing.T) {
|
|||||||
}
|
}
|
||||||
`)
|
`)
|
||||||
|
|
||||||
buildOS := android.BuildOs.String()
|
buildOS := ctx.Config().BuildOS.String()
|
||||||
module := ctx.ModuleForTests("foo", buildOS+"_common").Module().(*TestHost)
|
module := ctx.ModuleForTests("foo", buildOS+"_common").Module().(*TestHost)
|
||||||
assertDeepEquals(t, "Default installable value should be true.", proptools.BoolPtr(true),
|
assertDeepEquals(t, "Default installable value should be true.", proptools.BoolPtr(true),
|
||||||
module.properties.Installable)
|
module.properties.Installable)
|
||||||
|
@@ -15,10 +15,11 @@
|
|||||||
package java
|
package java
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"android/soong/android"
|
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"android/soong/android"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestKotlin(t *testing.T) {
|
func TestKotlin(t *testing.T) {
|
||||||
@@ -114,7 +115,7 @@ func TestKapt(t *testing.T) {
|
|||||||
t.Run("", func(t *testing.T) {
|
t.Run("", func(t *testing.T) {
|
||||||
ctx, _ := testJava(t, bp)
|
ctx, _ := testJava(t, bp)
|
||||||
|
|
||||||
buildOS := android.BuildOs.String()
|
buildOS := ctx.Config().BuildOS.String()
|
||||||
|
|
||||||
kapt := ctx.ModuleForTests("foo", "android_common").Rule("kapt")
|
kapt := ctx.ModuleForTests("foo", "android_common").Rule("kapt")
|
||||||
kotlinc := ctx.ModuleForTests("foo", "android_common").Rule("kotlinc")
|
kotlinc := ctx.ModuleForTests("foo", "android_common").Rule("kotlinc")
|
||||||
@@ -182,7 +183,7 @@ func TestKapt(t *testing.T) {
|
|||||||
android.FixtureMergeEnv(env),
|
android.FixtureMergeEnv(env),
|
||||||
).RunTestWithBp(t, bp)
|
).RunTestWithBp(t, bp)
|
||||||
|
|
||||||
buildOS := android.BuildOs.String()
|
buildOS := result.Config.BuildOS.String()
|
||||||
|
|
||||||
kapt := result.ModuleForTests("foo", "android_common").Rule("kapt")
|
kapt := result.ModuleForTests("foo", "android_common").Rule("kapt")
|
||||||
javac := result.ModuleForTests("foo", "android_common").Description("javac")
|
javac := result.ModuleForTests("foo", "android_common").Description("javac")
|
||||||
|
@@ -15,7 +15,6 @@
|
|||||||
package java
|
package java
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"android/soong/android"
|
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -58,7 +57,7 @@ func TestPlugin(t *testing.T) {
|
|||||||
}
|
}
|
||||||
`)
|
`)
|
||||||
|
|
||||||
buildOS := android.BuildOs.String()
|
buildOS := ctx.Config().BuildOS.String()
|
||||||
|
|
||||||
javac := ctx.ModuleForTests("foo", "android_common").Rule("javac")
|
javac := ctx.ModuleForTests("foo", "android_common").Rule("javac")
|
||||||
turbine := ctx.ModuleForTests("foo", "android_common").MaybeRule("turbine")
|
turbine := ctx.ModuleForTests("foo", "android_common").MaybeRule("turbine")
|
||||||
@@ -98,7 +97,7 @@ func TestPluginGeneratesApi(t *testing.T) {
|
|||||||
}
|
}
|
||||||
`)
|
`)
|
||||||
|
|
||||||
buildOS := android.BuildOs.String()
|
buildOS := ctx.Config().BuildOS.String()
|
||||||
|
|
||||||
javac := ctx.ModuleForTests("foo", "android_common").Rule("javac")
|
javac := ctx.ModuleForTests("foo", "android_common").Rule("javac")
|
||||||
turbine := ctx.ModuleForTests("foo", "android_common").MaybeRule("turbine")
|
turbine := ctx.ModuleForTests("foo", "android_common").MaybeRule("turbine")
|
||||||
|
@@ -83,6 +83,9 @@ type robolectricTest struct {
|
|||||||
|
|
||||||
testConfig android.Path
|
testConfig android.Path
|
||||||
data android.Paths
|
data android.Paths
|
||||||
|
|
||||||
|
forceOSType android.OsType
|
||||||
|
forceArchType android.ArchType
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *robolectricTest) TestSuites() []string {
|
func (r *robolectricTest) TestSuites() []string {
|
||||||
@@ -115,6 +118,9 @@ func (r *robolectricTest) DepsMutator(ctx android.BottomUpMutatorContext) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (r *robolectricTest) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
func (r *robolectricTest) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
||||||
|
r.forceOSType = ctx.Config().BuildOS
|
||||||
|
r.forceArchType = ctx.Config().BuildArch
|
||||||
|
|
||||||
r.testConfig = tradefed.AutoGenRobolectricTestConfig(ctx, r.testProperties.Test_config,
|
r.testConfig = tradefed.AutoGenRobolectricTestConfig(ctx, r.testProperties.Test_config,
|
||||||
r.testProperties.Test_config_template, r.testProperties.Test_suites,
|
r.testProperties.Test_config_template, r.testProperties.Test_suites,
|
||||||
r.testProperties.Auto_gen_config)
|
r.testProperties.Auto_gen_config)
|
||||||
@@ -345,7 +351,7 @@ func RobolectricTestFactory() android.Module {
|
|||||||
func (r *robolectricTest) InstallBypassMake() bool { return true }
|
func (r *robolectricTest) InstallBypassMake() bool { return true }
|
||||||
func (r *robolectricTest) InstallInTestcases() bool { return true }
|
func (r *robolectricTest) InstallInTestcases() bool { return true }
|
||||||
func (r *robolectricTest) InstallForceOS() (*android.OsType, *android.ArchType) {
|
func (r *robolectricTest) InstallForceOS() (*android.OsType, *android.ArchType) {
|
||||||
return &android.BuildOs, &android.BuildArch
|
return &r.forceOSType, &r.forceArchType
|
||||||
}
|
}
|
||||||
|
|
||||||
func robolectricRuntimesFactory() android.Module {
|
func robolectricRuntimesFactory() android.Module {
|
||||||
@@ -366,6 +372,9 @@ type robolectricRuntimes struct {
|
|||||||
props robolectricRuntimesProperties
|
props robolectricRuntimesProperties
|
||||||
|
|
||||||
runtimes []android.InstallPath
|
runtimes []android.InstallPath
|
||||||
|
|
||||||
|
forceOSType android.OsType
|
||||||
|
forceArchType android.ArchType
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *robolectricRuntimes) TestSuites() []string {
|
func (r *robolectricRuntimes) TestSuites() []string {
|
||||||
@@ -385,6 +394,9 @@ func (r *robolectricRuntimes) GenerateAndroidBuildActions(ctx android.ModuleCont
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
r.forceOSType = ctx.Config().BuildOS
|
||||||
|
r.forceArchType = ctx.Config().BuildArch
|
||||||
|
|
||||||
files := android.PathsForModuleSrc(ctx, r.props.Jars)
|
files := android.PathsForModuleSrc(ctx, r.props.Jars)
|
||||||
|
|
||||||
androidAllDir := android.PathForModuleInstall(ctx, "android-all")
|
androidAllDir := android.PathForModuleInstall(ctx, "android-all")
|
||||||
@@ -417,5 +429,5 @@ func (r *robolectricRuntimes) GenerateAndroidBuildActions(ctx android.ModuleCont
|
|||||||
func (r *robolectricRuntimes) InstallBypassMake() bool { return true }
|
func (r *robolectricRuntimes) InstallBypassMake() bool { return true }
|
||||||
func (r *robolectricRuntimes) InstallInTestcases() bool { return true }
|
func (r *robolectricRuntimes) InstallInTestcases() bool { return true }
|
||||||
func (r *robolectricRuntimes) InstallForceOS() (*android.OsType, *android.ArchType) {
|
func (r *robolectricRuntimes) InstallForceOS() (*android.OsType, *android.ArchType) {
|
||||||
return &android.BuildOs, &android.BuildArch
|
return &r.forceOSType, &r.forceArchType
|
||||||
}
|
}
|
||||||
|
@@ -255,9 +255,11 @@ func TestClasspath(t *testing.T) {
|
|||||||
` + testcase.properties + `
|
` + testcase.properties + `
|
||||||
}`
|
}`
|
||||||
|
|
||||||
variant := "android_common"
|
variant := func(result *android.TestResult) string {
|
||||||
if testcase.host == android.Host {
|
if testcase.host == android.Host {
|
||||||
variant = android.BuildOs.String() + "_common"
|
return result.Config.BuildOS.String() + "_common"
|
||||||
|
}
|
||||||
|
return "android_common"
|
||||||
}
|
}
|
||||||
|
|
||||||
convertModulesToPaths := func(cp []string) []string {
|
convertModulesToPaths := func(cp []string) []string {
|
||||||
@@ -312,7 +314,7 @@ func TestClasspath(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
checkClasspath := func(t *testing.T, result *android.TestResult, isJava8 bool) {
|
checkClasspath := func(t *testing.T, result *android.TestResult, isJava8 bool) {
|
||||||
foo := result.ModuleForTests("foo", variant)
|
foo := result.ModuleForTests("foo", variant(result))
|
||||||
javac := foo.Rule("javac")
|
javac := foo.Rule("javac")
|
||||||
var deps []string
|
var deps []string
|
||||||
|
|
||||||
@@ -376,7 +378,7 @@ func TestClasspath(t *testing.T) {
|
|||||||
checkClasspath(t, result, true /* isJava8 */)
|
checkClasspath(t, result, true /* isJava8 */)
|
||||||
|
|
||||||
if testcase.host != android.Host {
|
if testcase.host != android.Host {
|
||||||
aidl := result.ModuleForTests("foo", variant).Rule("aidl")
|
aidl := result.ModuleForTests("foo", variant(result)).Rule("aidl")
|
||||||
|
|
||||||
android.AssertStringDoesContain(t, "aidl command", aidl.RuleParams.Command, testcase.aidl+" -I.")
|
android.AssertStringDoesContain(t, "aidl command", aidl.RuleParams.Command, testcase.aidl+" -I.")
|
||||||
}
|
}
|
||||||
@@ -389,7 +391,7 @@ func TestClasspath(t *testing.T) {
|
|||||||
checkClasspath(t, result, false /* isJava8 */)
|
checkClasspath(t, result, false /* isJava8 */)
|
||||||
|
|
||||||
if testcase.host != android.Host {
|
if testcase.host != android.Host {
|
||||||
aidl := result.ModuleForTests("foo", variant).Rule("aidl")
|
aidl := result.ModuleForTests("foo", variant(result)).Rule("aidl")
|
||||||
|
|
||||||
android.AssertStringDoesContain(t, "aidl command", aidl.RuleParams.Command, testcase.aidl+" -I.")
|
android.AssertStringDoesContain(t, "aidl command", aidl.RuleParams.Command, testcase.aidl+" -I.")
|
||||||
}
|
}
|
||||||
|
@@ -305,7 +305,7 @@ func (compiler *baseCompiler) compilerDeps(ctx DepsContext, deps Deps) Deps {
|
|||||||
if !Bool(compiler.Properties.No_stdlibs) {
|
if !Bool(compiler.Properties.No_stdlibs) {
|
||||||
for _, stdlib := range config.Stdlibs {
|
for _, stdlib := range config.Stdlibs {
|
||||||
// If we're building for the primary arch of the build host, use the compiler's stdlibs
|
// If we're building for the primary arch of the build host, use the compiler's stdlibs
|
||||||
if ctx.Target().Os == android.BuildOs {
|
if ctx.Target().Os == ctx.Config().BuildOS {
|
||||||
stdlib = stdlib + "_" + ctx.toolchain().RustTriple()
|
stdlib = stdlib + "_" + ctx.toolchain().RustTriple()
|
||||||
}
|
}
|
||||||
deps.Stdlibs = append(deps.Stdlibs, stdlib)
|
deps.Stdlibs = append(deps.Stdlibs, stdlib)
|
||||||
|
@@ -176,6 +176,8 @@ func TestProjectJsonBinary(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestProjectJsonBindGen(t *testing.T) {
|
func TestProjectJsonBindGen(t *testing.T) {
|
||||||
|
buildOS := android.TestConfig(t.TempDir(), nil, "", nil).BuildOS
|
||||||
|
|
||||||
bp := `
|
bp := `
|
||||||
rust_library {
|
rust_library {
|
||||||
name: "libd",
|
name: "libd",
|
||||||
@@ -214,9 +216,9 @@ func TestProjectJsonBindGen(t *testing.T) {
|
|||||||
if strings.Contains(rootModule, "libbindings1") && !strings.Contains(rootModule, "android_arm64") {
|
if strings.Contains(rootModule, "libbindings1") && !strings.Contains(rootModule, "android_arm64") {
|
||||||
t.Errorf("The source path for libbindings1 does not contain android_arm64, got %v", rootModule)
|
t.Errorf("The source path for libbindings1 does not contain android_arm64, got %v", rootModule)
|
||||||
}
|
}
|
||||||
if strings.Contains(rootModule, "libbindings2") && !strings.Contains(rootModule, android.BuildOs.String()) {
|
if strings.Contains(rootModule, "libbindings2") && !strings.Contains(rootModule, buildOS.String()) {
|
||||||
t.Errorf("The source path for libbindings2 does not contain the BuildOs, got %v; want %v",
|
t.Errorf("The source path for libbindings2 does not contain the BuildOs, got %v; want %v",
|
||||||
rootModule, android.BuildOs.String())
|
rootModule, buildOS.String())
|
||||||
}
|
}
|
||||||
// Check that libbindings1 does not depend on itself.
|
// Check that libbindings1 does not depend on itself.
|
||||||
if strings.Contains(rootModule, "libbindings1") {
|
if strings.Contains(rootModule, "libbindings1") {
|
||||||
|
@@ -15,19 +15,21 @@
|
|||||||
package sdk
|
package sdk
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"android/soong/android"
|
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
|
"runtime"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"android/soong/android"
|
||||||
|
|
||||||
"github.com/google/blueprint/proptools"
|
"github.com/google/blueprint/proptools"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Needed in an _test.go file in this package to ensure tests run correctly, particularly in IDE.
|
// Needed in an _test.go file in this package to ensure tests run correctly, particularly in IDE.
|
||||||
func TestMain(m *testing.M) {
|
func TestMain(m *testing.M) {
|
||||||
if android.BuildOs != android.Linux {
|
if runtime.GOOS != "linux" {
|
||||||
// b/145598135 - Generating host snapshots for anything other than linux is not supported.
|
// b/145598135 - Generating host snapshots for anything other than linux is not supported.
|
||||||
log.Printf("Skipping as sdk snapshot generation is only supported on %s not %s", android.Linux, android.BuildOs)
|
log.Printf("Skipping as sdk snapshot generation is only supported on linux not %s", runtime.GOOS)
|
||||||
os.Exit(0)
|
os.Exit(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -115,7 +115,7 @@ func TestShTest_dataModules(t *testing.T) {
|
|||||||
}
|
}
|
||||||
`)
|
`)
|
||||||
|
|
||||||
buildOS := android.BuildOs.String()
|
buildOS := config.BuildOS.String()
|
||||||
arches := []string{"android_arm64_armv8-a", buildOS + "_x86_64"}
|
arches := []string{"android_arm64_armv8-a", buildOS + "_x86_64"}
|
||||||
for _, arch := range arches {
|
for _, arch := range arches {
|
||||||
variant := ctx.ModuleForTests("foo", arch)
|
variant := ctx.ModuleForTests("foo", arch)
|
||||||
@@ -155,7 +155,7 @@ func TestShTestHost(t *testing.T) {
|
|||||||
}
|
}
|
||||||
`)
|
`)
|
||||||
|
|
||||||
buildOS := android.BuildOs.String()
|
buildOS := ctx.Config().BuildOS.String()
|
||||||
mod := ctx.ModuleForTests("foo", buildOS+"_x86_64").Module().(*ShTest)
|
mod := ctx.ModuleForTests("foo", buildOS+"_x86_64").Module().(*ShTest)
|
||||||
if !mod.Host() {
|
if !mod.Host() {
|
||||||
t.Errorf("host bit is not set for a sh_test_host module.")
|
t.Errorf("host bit is not set for a sh_test_host module.")
|
||||||
@@ -192,7 +192,7 @@ func TestShTestHost_dataDeviceModules(t *testing.T) {
|
|||||||
}
|
}
|
||||||
`)
|
`)
|
||||||
|
|
||||||
buildOS := android.BuildOs.String()
|
buildOS := config.BuildOS.String()
|
||||||
variant := ctx.ModuleForTests("foo", buildOS+"_x86_64")
|
variant := ctx.ModuleForTests("foo", buildOS+"_x86_64")
|
||||||
|
|
||||||
relocated := variant.Output("relocated/lib64/libbar.so")
|
relocated := variant.Output("relocated/lib64/libbar.so")
|
||||||
|
Reference in New Issue
Block a user