|
@@ -16,7 +16,6 @@ package dexpreopt
|
|
|
|
|
|
import (
|
|
|
"encoding/json"
|
|
|
- "io/ioutil"
|
|
|
"strings"
|
|
|
|
|
|
"android/soong/android"
|
|
@@ -185,7 +184,7 @@ func constructWritablePath(ctx android.PathContext, path string) android.Writabl
|
|
|
// soongConfig argument. LoadGlobalConfig is used directly in Soong and in
|
|
|
// dexpreopt_gen called from Make to read the $OUT/dexpreopt.config written by
|
|
|
// Make.
|
|
|
-func LoadGlobalConfig(ctx android.PathContext, path string, soongConfig GlobalSoongConfig) (GlobalConfig, []byte, error) {
|
|
|
+func LoadGlobalConfig(ctx android.PathContext, data []byte, soongConfig GlobalSoongConfig) (GlobalConfig, error) {
|
|
|
type GlobalJSONConfig struct {
|
|
|
GlobalConfig
|
|
|
|
|
@@ -196,9 +195,9 @@ func LoadGlobalConfig(ctx android.PathContext, path string, soongConfig GlobalSo
|
|
|
}
|
|
|
|
|
|
config := GlobalJSONConfig{}
|
|
|
- data, err := loadConfig(ctx, path, &config)
|
|
|
+ err := json.Unmarshal(data, &config)
|
|
|
if err != nil {
|
|
|
- return config.GlobalConfig, nil, err
|
|
|
+ return config.GlobalConfig, err
|
|
|
}
|
|
|
|
|
|
// Construct paths that require a PathContext.
|
|
@@ -209,13 +208,13 @@ func LoadGlobalConfig(ctx android.PathContext, path string, soongConfig GlobalSo
|
|
|
// either CreateGlobalSoongConfig or LoadGlobalSoongConfig).
|
|
|
config.GlobalConfig.SoongConfig = soongConfig
|
|
|
|
|
|
- return config.GlobalConfig, data, nil
|
|
|
+ return config.GlobalConfig, nil
|
|
|
}
|
|
|
|
|
|
// LoadModuleConfig reads a per-module dexpreopt.config file into a ModuleConfig struct. It is not used in Soong, which
|
|
|
// receives a ModuleConfig struct directly from java/dexpreopt.go. It is used in dexpreopt_gen called from oMake to
|
|
|
// read the module dexpreopt.config written by Make.
|
|
|
-func LoadModuleConfig(ctx android.PathContext, path string) (ModuleConfig, error) {
|
|
|
+func LoadModuleConfig(ctx android.PathContext, data []byte) (ModuleConfig, error) {
|
|
|
type ModuleJSONConfig struct {
|
|
|
ModuleConfig
|
|
|
|
|
@@ -233,7 +232,7 @@ func LoadModuleConfig(ctx android.PathContext, path string) (ModuleConfig, error
|
|
|
|
|
|
config := ModuleJSONConfig{}
|
|
|
|
|
|
- _, err := loadConfig(ctx, path, &config)
|
|
|
+ err := json.Unmarshal(data, &config)
|
|
|
if err != nil {
|
|
|
return config.ModuleConfig, err
|
|
|
}
|
|
@@ -289,10 +288,10 @@ type globalJsonSoongConfig struct {
|
|
|
|
|
|
// LoadGlobalSoongConfig reads the dexpreopt_soong.config file into a
|
|
|
// GlobalSoongConfig struct. It is only used in dexpreopt_gen.
|
|
|
-func LoadGlobalSoongConfig(ctx android.PathContext, path string) (GlobalSoongConfig, error) {
|
|
|
+func LoadGlobalSoongConfig(ctx android.PathContext, data []byte) (GlobalSoongConfig, error) {
|
|
|
var jc globalJsonSoongConfig
|
|
|
|
|
|
- _, err := loadConfig(ctx, path, &jc)
|
|
|
+ err := json.Unmarshal(data, &jc)
|
|
|
if err != nil {
|
|
|
return GlobalSoongConfig{}, err
|
|
|
}
|
|
@@ -352,26 +351,6 @@ func (s *globalSoongConfigSingleton) MakeVars(ctx android.MakeVarsContext) {
|
|
|
}, " "))
|
|
|
}
|
|
|
|
|
|
-func loadConfig(ctx android.PathContext, path string, config interface{}) ([]byte, error) {
|
|
|
- r, err := ctx.Fs().Open(path)
|
|
|
- if err != nil {
|
|
|
- return nil, err
|
|
|
- }
|
|
|
- defer r.Close()
|
|
|
-
|
|
|
- data, err := ioutil.ReadAll(r)
|
|
|
- if err != nil {
|
|
|
- return nil, err
|
|
|
- }
|
|
|
-
|
|
|
- err = json.Unmarshal(data, config)
|
|
|
- if err != nil {
|
|
|
- return nil, err
|
|
|
- }
|
|
|
-
|
|
|
- return data, nil
|
|
|
-}
|
|
|
-
|
|
|
func GlobalConfigForTests(ctx android.PathContext) GlobalConfig {
|
|
|
return GlobalConfig{
|
|
|
DisablePreopt: false,
|