Replace android.BuildOs with Config.BuildOS
Replace the android.BuildOs constant with Config.BuildOS so that it can vary based on the product config. Bug: 190084016 Test: all Soong tests Change-Id: Ia67f872d8b2ab788747a22e3a9659dc21c9775cd
This commit is contained in:
parent
ae86338676
commit
0c66bc615b
22 changed files with 457 additions and 421 deletions
|
@ -290,28 +290,6 @@ func osByName(name string) OsType {
|
|||
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 (
|
||||
// osTypeList contains a list of all the supported OsTypes, including ones not supported
|
||||
// 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.
|
||||
func decodeTargetProductVariables(config *config) (map[OsType][]Target, error) {
|
||||
variables := config.productVariables
|
||||
|
@ -1430,9 +1433,9 @@ func decodeTargetProductVariables(config *config) (map[OsType][]Target, error) {
|
|||
hostCross := false
|
||||
if os.Class == Host {
|
||||
var osSupported bool
|
||||
if os == BuildOs {
|
||||
if os == config.BuildOS {
|
||||
osSupported = true
|
||||
} else if BuildOs.Linux() && os.Linux() {
|
||||
} else if config.BuildOS.Linux() && os.Linux() {
|
||||
// LinuxBionic and Linux are compatible
|
||||
osSupported = true
|
||||
} else {
|
||||
|
@ -1470,11 +1473,11 @@ func decodeTargetProductVariables(config *config) (map[OsType][]Target, error) {
|
|||
}
|
||||
|
||||
// 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.
|
||||
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.
|
||||
|
|
|
@ -108,6 +108,12 @@ type config struct {
|
|||
|
||||
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
|
||||
BuildOSTarget Target // the Target for 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}
|
||||
}
|
||||
|
||||
func fuchsiaTargets() map[OsType][]Target {
|
||||
func fuchsiaTargets(config Config) map[OsType][]Target {
|
||||
return map[OsType][]Target{
|
||||
Fuchsia: {
|
||||
{Fuchsia, Arch{ArchType: Arm64, ArchVariant: "", Abi: []string{"arm64-v8a"}}, NativeBridgeDisabled, "", "", false},
|
||||
},
|
||||
BuildOs: {
|
||||
{BuildOs, Arch{ArchType: X86_64}, NativeBridgeDisabled, "", "", false},
|
||||
config.BuildOS: {
|
||||
{config.BuildOS, Arch{ArchType: X86_64}, NativeBridgeDisabled, "", "", false},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
var PrepareForTestSetDeviceToFuchsia = FixtureModifyConfig(func(config Config) {
|
||||
config.Targets = fuchsiaTargets()
|
||||
config.Targets = fuchsiaTargets(config)
|
||||
})
|
||||
|
||||
func modifyTestConfigToSupportArchMutator(testConfig Config) {
|
||||
config := testConfig.config
|
||||
|
||||
determineBuildOS(config)
|
||||
|
||||
config.Targets = map[OsType][]Target{
|
||||
Android: []Target{
|
||||
{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},
|
||||
},
|
||||
BuildOs: []Target{
|
||||
{BuildOs, Arch{ArchType: X86_64}, NativeBridgeDisabled, "", "", false},
|
||||
{BuildOs, Arch{ArchType: X86}, NativeBridgeDisabled, "", "", false},
|
||||
config.BuildOS: []Target{
|
||||
{config.BuildOS, Arch{ArchType: X86_64}, NativeBridgeDisabled, "", "", false},
|
||||
{config.BuildOS, Arch{ArchType: X86}, NativeBridgeDisabled, "", "", false},
|
||||
},
|
||||
}
|
||||
|
||||
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.BuildOSCommonTarget = getCommonTargets(config.Targets[BuildOs])[0]
|
||||
config.BuildOSTarget = config.Targets[config.BuildOS][0]
|
||||
config.BuildOSCommonTarget = getCommonTargets(config.Targets[config.BuildOS])[0]
|
||||
config.AndroidCommonTarget = getCommonTargets(config.Targets[Android])[0]
|
||||
config.AndroidFirstDeviceTarget = firstTarget(config.Targets[Android], "lib64", "lib32")[0]
|
||||
config.TestProductVariables.DeviceArch = proptools.StringPtr("arm64")
|
||||
|
@ -439,6 +447,8 @@ func NewConfig(srcDir, buildDir string, moduleListFile string, availableEnv map[
|
|||
config.katiEnabled = true
|
||||
}
|
||||
|
||||
determineBuildOS(config)
|
||||
|
||||
// Sets up the map of target OSes to the finer grained compilation targets
|
||||
// that are configured from the product variables.
|
||||
targets, err := decodeTargetProductVariables(config)
|
||||
|
@ -476,8 +486,8 @@ func NewConfig(srcDir, buildDir string, moduleListFile string, availableEnv map[
|
|||
config.Targets = targets
|
||||
|
||||
// Compilation targets for host tools.
|
||||
config.BuildOSTarget = config.Targets[BuildOs][0]
|
||||
config.BuildOSCommonTarget = getCommonTargets(config.Targets[BuildOs])[0]
|
||||
config.BuildOSTarget = config.Targets[config.BuildOS][0]
|
||||
config.BuildOSCommonTarget = getCommonTargets(config.Targets[config.BuildOS])[0]
|
||||
|
||||
// Compilation targets for Android.
|
||||
if len(config.Targets[Android]) > 0 {
|
||||
|
|
|
@ -86,7 +86,7 @@ func (t *prebuiltBuildTool) GenerateAndroidBuildActions(ctx ModuleContext) {
|
|||
|
||||
func (t *prebuiltBuildTool) MakeVars(ctx MakeVarsModuleContext) {
|
||||
if makeVar := String(t.properties.Export_to_make_var); makeVar != "" {
|
||||
if t.Target().Os != BuildOs {
|
||||
if t.Target().Os != ctx.Config().BuildOS {
|
||||
return
|
||||
}
|
||||
ctx.StrictRaw(makeVar, t.toolPath.String())
|
||||
|
|
|
@ -21,360 +21,362 @@ import (
|
|||
"github.com/google/blueprint"
|
||||
)
|
||||
|
||||
var prebuiltsTests = []struct {
|
||||
name string
|
||||
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",
|
||||
}
|
||||
func TestPrebuilts(t *testing.T) {
|
||||
buildOS := TestArchConfig(t.TempDir(), nil, "", nil).BuildOS
|
||||
|
||||
prebuilt {
|
||||
name: "bar",
|
||||
prefer: false,
|
||||
srcs: ["prebuilt_file"],
|
||||
}`,
|
||||
prebuilt: nil,
|
||||
},
|
||||
{
|
||||
name: "prebuilt preferred",
|
||||
modules: `
|
||||
source {
|
||||
name: "bar",
|
||||
}
|
||||
var prebuiltsTests = []struct {
|
||||
name string
|
||||
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 {
|
||||
name: "bar",
|
||||
prefer: true,
|
||||
srcs: ["prebuilt_file"],
|
||||
}`,
|
||||
prebuilt: []OsType{Android, BuildOs},
|
||||
},
|
||||
{
|
||||
name: "prebuilt no file not preferred",
|
||||
modules: `
|
||||
source {
|
||||
name: "bar",
|
||||
}
|
||||
prebuilt {
|
||||
name: "bar",
|
||||
prefer: false,
|
||||
srcs: ["prebuilt_file"],
|
||||
}`,
|
||||
prebuilt: nil,
|
||||
},
|
||||
{
|
||||
name: "prebuilt preferred",
|
||||
modules: `
|
||||
source {
|
||||
name: "bar",
|
||||
}
|
||||
|
||||
prebuilt {
|
||||
name: "bar",
|
||||
prefer: false,
|
||||
}`,
|
||||
prebuilt: nil,
|
||||
},
|
||||
{
|
||||
name: "prebuilt no file preferred",
|
||||
modules: `
|
||||
source {
|
||||
name: "bar",
|
||||
}
|
||||
prebuilt {
|
||||
name: "bar",
|
||||
prefer: true,
|
||||
srcs: ["prebuilt_file"],
|
||||
}`,
|
||||
prebuilt: []OsType{Android, buildOS},
|
||||
},
|
||||
{
|
||||
name: "prebuilt no file not preferred",
|
||||
modules: `
|
||||
source {
|
||||
name: "bar",
|
||||
}
|
||||
|
||||
prebuilt {
|
||||
name: "bar",
|
||||
prefer: true,
|
||||
}`,
|
||||
prebuilt: nil,
|
||||
},
|
||||
{
|
||||
name: "prebuilt file from filegroup preferred",
|
||||
modules: `
|
||||
filegroup {
|
||||
name: "fg",
|
||||
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 {
|
||||
name: "bar",
|
||||
prefer: false,
|
||||
}`,
|
||||
prebuilt: nil,
|
||||
},
|
||||
{
|
||||
name: "prebuilt no file preferred",
|
||||
modules: `
|
||||
source {
|
||||
name: "bar",
|
||||
}
|
||||
|
||||
prebuilt {
|
||||
name: "bar",
|
||||
host_supported: false,
|
||||
prefer: true,
|
||||
srcs: ["prebuilt_file"],
|
||||
}`,
|
||||
prebuilt: []OsType{Android},
|
||||
},
|
||||
{
|
||||
name: "prebuilt file for host only",
|
||||
modules: `
|
||||
source {
|
||||
name: "bar",
|
||||
}
|
||||
prebuilt {
|
||||
name: "bar",
|
||||
prefer: true,
|
||||
}`,
|
||||
prebuilt: nil,
|
||||
},
|
||||
{
|
||||
name: "prebuilt file from filegroup preferred",
|
||||
modules: `
|
||||
filegroup {
|
||||
name: "fg",
|
||||
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 {
|
||||
name: "bar",
|
||||
prefer: true,
|
||||
target: {
|
||||
host: {
|
||||
srcs: ["prebuilt_file"],
|
||||
},
|
||||
},
|
||||
}`,
|
||||
prebuilt: []OsType{BuildOs},
|
||||
},
|
||||
{
|
||||
name: "prebuilt override not preferred",
|
||||
modules: `
|
||||
source {
|
||||
name: "baz",
|
||||
}
|
||||
prebuilt {
|
||||
name: "bar",
|
||||
host_supported: false,
|
||||
prefer: true,
|
||||
srcs: ["prebuilt_file"],
|
||||
}`,
|
||||
prebuilt: []OsType{Android},
|
||||
},
|
||||
{
|
||||
name: "prebuilt file for host only",
|
||||
modules: `
|
||||
source {
|
||||
name: "bar",
|
||||
}
|
||||
|
||||
override_source {
|
||||
name: "bar",
|
||||
base: "baz",
|
||||
}
|
||||
|
||||
prebuilt {
|
||||
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 {
|
||||
name: "bar",
|
||||
prefer: true,
|
||||
target: {
|
||||
host: {
|
||||
srcs: ["prebuilt_file"],
|
||||
},
|
||||
},
|
||||
},
|
||||
}`,
|
||||
prebuilt: []OsType{Android, BuildOs},
|
||||
},
|
||||
{
|
||||
name: "prebuilt use_source_config_var={acme, use_source} - no var specified",
|
||||
modules: `
|
||||
source {
|
||||
name: "bar",
|
||||
}
|
||||
}`,
|
||||
prebuilt: []OsType{buildOS},
|
||||
},
|
||||
{
|
||||
name: "prebuilt override not preferred",
|
||||
modules: `
|
||||
source {
|
||||
name: "baz",
|
||||
}
|
||||
|
||||
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",
|
||||
}
|
||||
override_source {
|
||||
name: "bar",
|
||||
base: "baz",
|
||||
}
|
||||
|
||||
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",
|
||||
prefer: false,
|
||||
srcs: ["prebuilt_file"],
|
||||
}`,
|
||||
prebuilt: nil,
|
||||
},
|
||||
{
|
||||
name: "prebuilt override preferred",
|
||||
modules: `
|
||||
source {
|
||||
name: "baz",
|
||||
}
|
||||
|
||||
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},
|
||||
},
|
||||
}
|
||||
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{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{
|
||||
"prebuilt_file": nil,
|
||||
"source_file": nil,
|
||||
|
|
|
@ -60,7 +60,7 @@ func robolectricTestSuite(ctx SingletonContext, files map[string]InstallPaths) W
|
|||
for _, module := range SortedStringKeys(files) {
|
||||
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")
|
||||
rule := NewRuleBuilder(pctx, ctx)
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
package config
|
||||
|
||||
import (
|
||||
"runtime"
|
||||
"strings"
|
||||
|
||||
"android/soong/android"
|
||||
|
@ -282,7 +283,7 @@ var (
|
|||
var pctx = android.NewPackageContext("android/soong/cc/config")
|
||||
|
||||
func init() {
|
||||
if android.BuildOs == android.Linux {
|
||||
if runtime.GOOS == "linux" {
|
||||
commonGlobalCflags = append(commonGlobalCflags, "-fdebug-prefix-map=/proc/self/cwd=")
|
||||
}
|
||||
|
||||
|
|
|
@ -165,7 +165,7 @@ func makeVarsProvider(ctx android.MakeVarsContext) {
|
|||
sort.Strings(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])
|
||||
if len(hostTargets) > 1 {
|
||||
makeVarsToolchain(ctx, "2ND_", hostTargets[1])
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
package cc
|
||||
|
||||
import (
|
||||
"runtime"
|
||||
"testing"
|
||||
|
||||
"android/soong/android"
|
||||
|
@ -271,8 +272,8 @@ func TestPrebuiltLibrarySharedStem(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestPrebuiltSymlinkedHostBinary(t *testing.T) {
|
||||
if android.BuildOs != android.Linux {
|
||||
t.Skipf("Skipping host prebuilt testing that is only supported on %s not %s", android.Linux, android.BuildOs)
|
||||
if runtime.GOOS != "linux" {
|
||||
t.Skipf("Skipping host prebuilt testing that is only supported on linux not %s", runtime.GOOS)
|
||||
}
|
||||
|
||||
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")
|
||||
foobar := ctx.ModuleForTests("protoc-gen-foobar", buildOS+"_x86_64")
|
||||
|
|
|
@ -172,7 +172,7 @@ func TestPrebuiltEtcHost(t *testing.T) {
|
|||
}
|
||||
`)
|
||||
|
||||
buildOS := android.BuildOs.String()
|
||||
buildOS := result.Config.BuildOS.String()
|
||||
p := result.Module("foo.conf", buildOS+"_common").(*PrebuiltEtc)
|
||||
if !p.Host() {
|
||||
t.Errorf("host bit is not set for a prebuilt_etc_host module.")
|
||||
|
@ -226,7 +226,7 @@ func TestPrebuiltUserShareHostInstallDirPath(t *testing.T) {
|
|||
}
|
||||
`)
|
||||
|
||||
buildOS := android.BuildOs.String()
|
||||
buildOS := result.Config.BuildOS.String()
|
||||
p := result.Module("foo.conf", buildOS+"_common").(*PrebuiltEtc)
|
||||
expected := filepath.Join("out/soong/host", result.Config.PrebuiltOS(), "usr", "share", "bar")
|
||||
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
|
||||
// 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
|
||||
// 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
|
||||
// not need to be returned from this func, unlike the buildBootImageVariantsForAndroidOs func.
|
||||
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
|
||||
|
|
|
@ -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.
|
||||
for _, target := range ctx.Config().Targets[android.BuildOs] {
|
||||
for _, target := range ctx.Config().Targets[ctx.Config().BuildOS] {
|
||||
targets = append(targets, target)
|
||||
}
|
||||
|
||||
|
|
|
@ -16,6 +16,7 @@ package java
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"runtime"
|
||||
"testing"
|
||||
|
||||
"android/soong/android"
|
||||
|
@ -173,9 +174,9 @@ func enabledString(enabled bool) string {
|
|||
}
|
||||
|
||||
func TestDex2oatToolDeps(t *testing.T) {
|
||||
if android.BuildOs != android.Linux {
|
||||
if runtime.GOOS != "linux" {
|
||||
// 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(
|
||||
|
|
|
@ -441,7 +441,7 @@ func TestBinary(t *testing.T) {
|
|||
}
|
||||
`)
|
||||
|
||||
buildOS := android.BuildOs.String()
|
||||
buildOS := ctx.Config().BuildOS.String()
|
||||
|
||||
bar := ctx.ModuleForTests("bar", buildOS+"_common")
|
||||
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)
|
||||
|
||||
|
@ -523,7 +523,7 @@ func TestHostBinaryNoJavaDebugInfoOverride(t *testing.T) {
|
|||
}
|
||||
|
||||
// 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")
|
||||
hostJavaFlags := hostBinary.Module().VariablesForTests()["javacFlags"]
|
||||
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)
|
||||
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)
|
||||
assertDeepEquals(t, "Default installable value should be true.", proptools.BoolPtr(true),
|
||||
module.properties.Installable)
|
||||
|
|
|
@ -15,10 +15,11 @@
|
|||
package java
|
||||
|
||||
import (
|
||||
"android/soong/android"
|
||||
"strconv"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"android/soong/android"
|
||||
)
|
||||
|
||||
func TestKotlin(t *testing.T) {
|
||||
|
@ -114,7 +115,7 @@ func TestKapt(t *testing.T) {
|
|||
t.Run("", func(t *testing.T) {
|
||||
ctx, _ := testJava(t, bp)
|
||||
|
||||
buildOS := android.BuildOs.String()
|
||||
buildOS := ctx.Config().BuildOS.String()
|
||||
|
||||
kapt := ctx.ModuleForTests("foo", "android_common").Rule("kapt")
|
||||
kotlinc := ctx.ModuleForTests("foo", "android_common").Rule("kotlinc")
|
||||
|
@ -182,7 +183,7 @@ func TestKapt(t *testing.T) {
|
|||
android.FixtureMergeEnv(env),
|
||||
).RunTestWithBp(t, bp)
|
||||
|
||||
buildOS := android.BuildOs.String()
|
||||
buildOS := result.Config.BuildOS.String()
|
||||
|
||||
kapt := result.ModuleForTests("foo", "android_common").Rule("kapt")
|
||||
javac := result.ModuleForTests("foo", "android_common").Description("javac")
|
||||
|
|
|
@ -15,7 +15,6 @@
|
|||
package java
|
||||
|
||||
import (
|
||||
"android/soong/android"
|
||||
"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")
|
||||
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")
|
||||
turbine := ctx.ModuleForTests("foo", "android_common").MaybeRule("turbine")
|
||||
|
|
|
@ -83,6 +83,9 @@ type robolectricTest struct {
|
|||
|
||||
testConfig android.Path
|
||||
data android.Paths
|
||||
|
||||
forceOSType android.OsType
|
||||
forceArchType android.ArchType
|
||||
}
|
||||
|
||||
func (r *robolectricTest) TestSuites() []string {
|
||||
|
@ -115,6 +118,9 @@ func (r *robolectricTest) DepsMutator(ctx android.BottomUpMutatorContext) {
|
|||
}
|
||||
|
||||
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.testProperties.Test_config_template, r.testProperties.Test_suites,
|
||||
r.testProperties.Auto_gen_config)
|
||||
|
@ -345,7 +351,7 @@ func RobolectricTestFactory() android.Module {
|
|||
func (r *robolectricTest) InstallBypassMake() bool { return true }
|
||||
func (r *robolectricTest) InstallInTestcases() bool { return true }
|
||||
func (r *robolectricTest) InstallForceOS() (*android.OsType, *android.ArchType) {
|
||||
return &android.BuildOs, &android.BuildArch
|
||||
return &r.forceOSType, &r.forceArchType
|
||||
}
|
||||
|
||||
func robolectricRuntimesFactory() android.Module {
|
||||
|
@ -366,6 +372,9 @@ type robolectricRuntimes struct {
|
|||
props robolectricRuntimesProperties
|
||||
|
||||
runtimes []android.InstallPath
|
||||
|
||||
forceOSType android.OsType
|
||||
forceArchType android.ArchType
|
||||
}
|
||||
|
||||
func (r *robolectricRuntimes) TestSuites() []string {
|
||||
|
@ -385,6 +394,9 @@ func (r *robolectricRuntimes) GenerateAndroidBuildActions(ctx android.ModuleCont
|
|||
return
|
||||
}
|
||||
|
||||
r.forceOSType = ctx.Config().BuildOS
|
||||
r.forceArchType = ctx.Config().BuildArch
|
||||
|
||||
files := android.PathsForModuleSrc(ctx, r.props.Jars)
|
||||
|
||||
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) InstallInTestcases() bool { return true }
|
||||
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 + `
|
||||
}`
|
||||
|
||||
variant := "android_common"
|
||||
if testcase.host == android.Host {
|
||||
variant = android.BuildOs.String() + "_common"
|
||||
variant := func(result *android.TestResult) string {
|
||||
if testcase.host == android.Host {
|
||||
return result.Config.BuildOS.String() + "_common"
|
||||
}
|
||||
return "android_common"
|
||||
}
|
||||
|
||||
convertModulesToPaths := func(cp []string) []string {
|
||||
|
@ -312,7 +314,7 @@ func TestClasspath(t *testing.T) {
|
|||
}
|
||||
|
||||
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")
|
||||
var deps []string
|
||||
|
||||
|
@ -376,7 +378,7 @@ func TestClasspath(t *testing.T) {
|
|||
checkClasspath(t, result, true /* isJava8 */)
|
||||
|
||||
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.")
|
||||
}
|
||||
|
@ -389,7 +391,7 @@ func TestClasspath(t *testing.T) {
|
|||
checkClasspath(t, result, false /* isJava8 */)
|
||||
|
||||
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.")
|
||||
}
|
||||
|
|
|
@ -305,7 +305,7 @@ func (compiler *baseCompiler) compilerDeps(ctx DepsContext, deps Deps) Deps {
|
|||
if !Bool(compiler.Properties.No_stdlibs) {
|
||||
for _, stdlib := range config.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()
|
||||
}
|
||||
deps.Stdlibs = append(deps.Stdlibs, stdlib)
|
||||
|
|
|
@ -176,6 +176,8 @@ func TestProjectJsonBinary(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestProjectJsonBindGen(t *testing.T) {
|
||||
buildOS := android.TestConfig(t.TempDir(), nil, "", nil).BuildOS
|
||||
|
||||
bp := `
|
||||
rust_library {
|
||||
name: "libd",
|
||||
|
@ -214,9 +216,9 @@ func TestProjectJsonBindGen(t *testing.T) {
|
|||
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)
|
||||
}
|
||||
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",
|
||||
rootModule, android.BuildOs.String())
|
||||
rootModule, buildOS.String())
|
||||
}
|
||||
// Check that libbindings1 does not depend on itself.
|
||||
if strings.Contains(rootModule, "libbindings1") {
|
||||
|
|
|
@ -15,19 +15,21 @@
|
|||
package sdk
|
||||
|
||||
import (
|
||||
"android/soong/android"
|
||||
"log"
|
||||
"os"
|
||||
"runtime"
|
||||
"testing"
|
||||
|
||||
"android/soong/android"
|
||||
|
||||
"github.com/google/blueprint/proptools"
|
||||
)
|
||||
|
||||
// Needed in an _test.go file in this package to ensure tests run correctly, particularly in IDE.
|
||||
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.
|
||||
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)
|
||||
}
|
||||
|
||||
|
|
|
@ -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"}
|
||||
for _, arch := range arches {
|
||||
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)
|
||||
if !mod.Host() {
|
||||
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")
|
||||
|
||||
relocated := variant.Output("relocated/lib64/libbar.so")
|
||||
|
|
Loading…
Reference in a new issue