Fix writing soong.variables .

ConfiguredJarList had a marshaler but no unmarshaler.

Bug: 182965747
Test: Presubmits.
Change-Id: Id03669f4a0a3d389063a4e4b11af6d6be63dbba3
This commit is contained in:
Lukacs T. Berki
2021-03-17 13:34:30 +01:00
parent 45a4971808
commit 720b3964fe
4 changed files with 51 additions and 58 deletions

View File

@@ -19,6 +19,7 @@ package android
import (
"encoding/json"
"errors"
"fmt"
"io/ioutil"
"os"
@@ -1635,6 +1636,20 @@ func (l *ConfiguredJarList) UnmarshalJSON(b []byte) error {
return nil
}
func (l *ConfiguredJarList) MarshalJSON() ([]byte, error) {
if len(l.apexes) != len(l.jars) {
return nil, errors.New(fmt.Sprintf("Inconsistent ConfiguredJarList: apexes: %q, jars: %q", l.apexes, l.jars))
}
list := make([]string, 0, len(l.apexes))
for i := 0; i < len(l.apexes); i++ {
list = append(list, l.apexes[i]+":"+l.jars[i])
}
return json.Marshal(list)
}
// ModuleStem hardcodes the stem of framework-minus-apex to return "framework".
//
// TODO(b/139391334): hard coded until we find a good way to query the stem of a