From 2738597af04d3795434dea7637528d5a63e4aff3 Mon Sep 17 00:00:00 2001 From: Colin Cross Date: Fri, 18 Sep 2015 10:57:10 -0700 Subject: [PATCH] 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 --- common/config.go | 10 +++++----- common/variable.go | 5 ++--- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/common/config.go b/common/config.go index a7675b979..1cd75d300 100644 --- a/common/config.go +++ b/common/config.go @@ -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 } diff --git a/common/variable.go b/common/variable.go index 5116a9512..a395b41ba 100644 --- a/common/variable.go +++ b/common/variable.go @@ -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) {