Fix product variables with no soong.variables
If soong.variables didn't exist, loadFromConfigFile would write default values to soong.variables, but return with the product variables set to the zero values. Replace jsonConfigurable.DefaultConfig() with SetDefaultConfig() that modifies the current object, and call it before writing the values. Change-Id: I7b7404c7a51975dc4493e25c775b3cf56ef335e3
This commit is contained in:
@@ -32,9 +32,8 @@ const productVariablesFileName = "soong.variables"
|
||||
type FileConfigurableOptions struct {
|
||||
}
|
||||
|
||||
func (FileConfigurableOptions) DefaultConfig() jsonConfigurable {
|
||||
f := FileConfigurableOptions{}
|
||||
return f
|
||||
func (f *FileConfigurableOptions) SetDefaultConfig() {
|
||||
*f = FileConfigurableOptions{}
|
||||
}
|
||||
|
||||
type Config struct {
|
||||
@@ -58,7 +57,7 @@ type config struct {
|
||||
}
|
||||
|
||||
type jsonConfigurable interface {
|
||||
DefaultConfig() jsonConfigurable
|
||||
SetDefaultConfig()
|
||||
}
|
||||
|
||||
func loadConfig(config *config) error {
|
||||
@@ -80,7 +79,8 @@ func loadFromConfigFile(configurable jsonConfigurable, filename string) error {
|
||||
// a dependency tracking loop.
|
||||
// Make a file-configurable-options with defaults, write it out using
|
||||
// a json writer.
|
||||
err = saveToConfigFile(configurable.DefaultConfig(), filename)
|
||||
configurable.SetDefaultConfig()
|
||||
err = saveToConfigFile(configurable, filename)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@@ -84,8 +84,8 @@ func stringPtr(v string) *string {
|
||||
return &v
|
||||
}
|
||||
|
||||
func (productVariables) DefaultConfig() jsonConfigurable {
|
||||
v := productVariables{
|
||||
func (v *productVariables) SetDefaultConfig() {
|
||||
*v = productVariables{
|
||||
Device_uses_jemalloc: boolPtr(true),
|
||||
Platform_sdk_version: intPtr(22),
|
||||
HostArch: stringPtr("x86_64"),
|
||||
@@ -98,7 +98,6 @@ func (productVariables) DefaultConfig() jsonConfigurable {
|
||||
DeviceSecondaryCpuVariant: stringPtr("cortex-a15"),
|
||||
DeviceSecondaryAbi: &[]string{"armeabi-v7a"},
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
func VariableMutator(mctx blueprint.EarlyMutatorContext) {
|
||||
|
Reference in New Issue
Block a user