Update androidmk to match blueprint changes
blueprint/parser.Value is now an Expression interface, update androidmk to match. Change-Id: I01e0b2a83cf430c1981b450d35c8ab0aab6975f1
This commit is contained in:
@@ -14,65 +14,65 @@ const (
|
|||||||
|
|
||||||
var standardProperties = map[string]struct {
|
var standardProperties = map[string]struct {
|
||||||
string
|
string
|
||||||
bpparser.ValueType
|
bpparser.Type
|
||||||
}{
|
}{
|
||||||
// String properties
|
// String properties
|
||||||
"LOCAL_MODULE": {"name", bpparser.String},
|
"LOCAL_MODULE": {"name", bpparser.StringType},
|
||||||
"LOCAL_MODULE_CLASS": {"class", bpparser.String},
|
"LOCAL_MODULE_CLASS": {"class", bpparser.StringType},
|
||||||
"LOCAL_CXX_STL": {"stl", bpparser.String},
|
"LOCAL_CXX_STL": {"stl", bpparser.StringType},
|
||||||
"LOCAL_STRIP_MODULE": {"strip", bpparser.String},
|
"LOCAL_STRIP_MODULE": {"strip", bpparser.StringType},
|
||||||
"LOCAL_MULTILIB": {"compile_multilib", bpparser.String},
|
"LOCAL_MULTILIB": {"compile_multilib", bpparser.StringType},
|
||||||
"LOCAL_ARM_MODE_HACK": {"instruction_set", bpparser.String},
|
"LOCAL_ARM_MODE_HACK": {"instruction_set", bpparser.StringType},
|
||||||
"LOCAL_SDK_VERSION": {"sdk_version", bpparser.String},
|
"LOCAL_SDK_VERSION": {"sdk_version", bpparser.StringType},
|
||||||
"LOCAL_NDK_STL_VARIANT": {"stl", bpparser.String},
|
"LOCAL_NDK_STL_VARIANT": {"stl", bpparser.StringType},
|
||||||
"LOCAL_JAR_MANIFEST": {"manifest", bpparser.String},
|
"LOCAL_JAR_MANIFEST": {"manifest", bpparser.StringType},
|
||||||
"LOCAL_JARJAR_RULES": {"jarjar_rules", bpparser.String},
|
"LOCAL_JARJAR_RULES": {"jarjar_rules", bpparser.StringType},
|
||||||
"LOCAL_CERTIFICATE": {"certificate", bpparser.String},
|
"LOCAL_CERTIFICATE": {"certificate", bpparser.StringType},
|
||||||
"LOCAL_PACKAGE_NAME": {"name", bpparser.String},
|
"LOCAL_PACKAGE_NAME": {"name", bpparser.StringType},
|
||||||
"LOCAL_MODULE_RELATIVE_PATH": {"relative_install_path", bpparser.String},
|
"LOCAL_MODULE_RELATIVE_PATH": {"relative_install_path", bpparser.StringType},
|
||||||
|
|
||||||
// List properties
|
// List properties
|
||||||
"LOCAL_SRC_FILES_EXCLUDE": {"exclude_srcs", bpparser.List},
|
"LOCAL_SRC_FILES_EXCLUDE": {"exclude_srcs", bpparser.ListType},
|
||||||
"LOCAL_SHARED_LIBRARIES": {"shared_libs", bpparser.List},
|
"LOCAL_SHARED_LIBRARIES": {"shared_libs", bpparser.ListType},
|
||||||
"LOCAL_STATIC_LIBRARIES": {"static_libs", bpparser.List},
|
"LOCAL_STATIC_LIBRARIES": {"static_libs", bpparser.ListType},
|
||||||
"LOCAL_WHOLE_STATIC_LIBRARIES": {"whole_static_libs", bpparser.List},
|
"LOCAL_WHOLE_STATIC_LIBRARIES": {"whole_static_libs", bpparser.ListType},
|
||||||
"LOCAL_SYSTEM_SHARED_LIBRARIES": {"system_shared_libs", bpparser.List},
|
"LOCAL_SYSTEM_SHARED_LIBRARIES": {"system_shared_libs", bpparser.ListType},
|
||||||
"LOCAL_ASFLAGS": {"asflags", bpparser.List},
|
"LOCAL_ASFLAGS": {"asflags", bpparser.ListType},
|
||||||
"LOCAL_CLANG_ASFLAGS": {"clang_asflags", bpparser.List},
|
"LOCAL_CLANG_ASFLAGS": {"clang_asflags", bpparser.ListType},
|
||||||
"LOCAL_CFLAGS": {"cflags", bpparser.List},
|
"LOCAL_CFLAGS": {"cflags", bpparser.ListType},
|
||||||
"LOCAL_CONLYFLAGS": {"conlyflags", bpparser.List},
|
"LOCAL_CONLYFLAGS": {"conlyflags", bpparser.ListType},
|
||||||
"LOCAL_CPPFLAGS": {"cppflags", bpparser.List},
|
"LOCAL_CPPFLAGS": {"cppflags", bpparser.ListType},
|
||||||
"LOCAL_REQUIRED_MODULES": {"required", bpparser.List},
|
"LOCAL_REQUIRED_MODULES": {"required", bpparser.ListType},
|
||||||
"LOCAL_MODULE_TAGS": {"tags", bpparser.List},
|
"LOCAL_MODULE_TAGS": {"tags", bpparser.ListType},
|
||||||
"LOCAL_LDLIBS": {"host_ldlibs", bpparser.List},
|
"LOCAL_LDLIBS": {"host_ldlibs", bpparser.ListType},
|
||||||
"LOCAL_CLANG_CFLAGS": {"clang_cflags", bpparser.List},
|
"LOCAL_CLANG_CFLAGS": {"clang_cflags", bpparser.ListType},
|
||||||
"LOCAL_YACCFLAGS": {"yaccflags", bpparser.List},
|
"LOCAL_YACCFLAGS": {"yaccflags", bpparser.ListType},
|
||||||
"LOCAL_SANITIZE_RECOVER": {"sanitize.recover", bpparser.List},
|
"LOCAL_SANITIZE_RECOVER": {"sanitize.recover", bpparser.ListType},
|
||||||
"LOCAL_LOGTAGS_FILES": {"logtags", bpparser.List},
|
"LOCAL_LOGTAGS_FILES": {"logtags", bpparser.ListType},
|
||||||
"LOCAL_EXPORT_SHARED_LIBRARY_HEADERS": {"export_shared_lib_headers", bpparser.List},
|
"LOCAL_EXPORT_SHARED_LIBRARY_HEADERS": {"export_shared_lib_headers", bpparser.ListType},
|
||||||
"LOCAL_EXPORT_STATIC_LIBRARY_HEADERS": {"export_static_lib_headers", bpparser.List},
|
"LOCAL_EXPORT_STATIC_LIBRARY_HEADERS": {"export_static_lib_headers", bpparser.ListType},
|
||||||
|
|
||||||
"LOCAL_JAVA_RESOURCE_DIRS": {"java_resource_dirs", bpparser.List},
|
"LOCAL_JAVA_RESOURCE_DIRS": {"java_resource_dirs", bpparser.ListType},
|
||||||
"LOCAL_JAVACFLAGS": {"javacflags", bpparser.List},
|
"LOCAL_JAVACFLAGS": {"javacflags", bpparser.ListType},
|
||||||
"LOCAL_DX_FLAGS": {"dxflags", bpparser.List},
|
"LOCAL_DX_FLAGS": {"dxflags", bpparser.ListType},
|
||||||
"LOCAL_JAVA_LIBRARIES": {"java_libs", bpparser.List},
|
"LOCAL_JAVA_LIBRARIES": {"java_libs", bpparser.ListType},
|
||||||
"LOCAL_STATIC_JAVA_LIBRARIES": {"java_static_libs", bpparser.List},
|
"LOCAL_STATIC_JAVA_LIBRARIES": {"java_static_libs", bpparser.ListType},
|
||||||
"LOCAL_AIDL_INCLUDES": {"aidl_includes", bpparser.List},
|
"LOCAL_AIDL_INCLUDES": {"aidl_includes", bpparser.ListType},
|
||||||
"LOCAL_AAPT_FLAGS": {"aaptflags", bpparser.List},
|
"LOCAL_AAPT_FLAGS": {"aaptflags", bpparser.ListType},
|
||||||
"LOCAL_PACKAGE_SPLITS": {"package_splits", bpparser.List},
|
"LOCAL_PACKAGE_SPLITS": {"package_splits", bpparser.ListType},
|
||||||
|
|
||||||
// Bool properties
|
// Bool properties
|
||||||
"LOCAL_IS_HOST_MODULE": {"host", bpparser.Bool},
|
"LOCAL_IS_HOST_MODULE": {"host", bpparser.BoolType},
|
||||||
"LOCAL_CLANG": {"clang", bpparser.Bool},
|
"LOCAL_CLANG": {"clang", bpparser.BoolType},
|
||||||
"LOCAL_FORCE_STATIC_EXECUTABLE": {"static_executable", bpparser.Bool},
|
"LOCAL_FORCE_STATIC_EXECUTABLE": {"static_executable", bpparser.BoolType},
|
||||||
"LOCAL_NATIVE_COVERAGE": {"native_coverage", bpparser.Bool},
|
"LOCAL_NATIVE_COVERAGE": {"native_coverage", bpparser.BoolType},
|
||||||
"LOCAL_NO_CRT": {"nocrt", bpparser.Bool},
|
"LOCAL_NO_CRT": {"nocrt", bpparser.BoolType},
|
||||||
"LOCAL_ALLOW_UNDEFINED_SYMBOLS": {"allow_undefined_symbols", bpparser.Bool},
|
"LOCAL_ALLOW_UNDEFINED_SYMBOLS": {"allow_undefined_symbols", bpparser.BoolType},
|
||||||
"LOCAL_RTTI_FLAG": {"rtti", bpparser.Bool},
|
"LOCAL_RTTI_FLAG": {"rtti", bpparser.BoolType},
|
||||||
|
|
||||||
"LOCAL_NO_STANDARD_LIBRARIES": {"no_standard_libraries", bpparser.Bool},
|
"LOCAL_NO_STANDARD_LIBRARIES": {"no_standard_libraries", bpparser.BoolType},
|
||||||
|
|
||||||
"LOCAL_EXPORT_PACKAGE_RESOURCES": {"export_package_resources", bpparser.Bool},
|
"LOCAL_EXPORT_PACKAGE_RESOURCES": {"export_package_resources", bpparser.BoolType},
|
||||||
}
|
}
|
||||||
|
|
||||||
var rewriteProperties = map[string]struct {
|
var rewriteProperties = map[string]struct {
|
||||||
@@ -87,23 +87,26 @@ var rewriteProperties = map[string]struct {
|
|||||||
"LOCAL_LDFLAGS": {ldflags},
|
"LOCAL_LDFLAGS": {ldflags},
|
||||||
}
|
}
|
||||||
|
|
||||||
type listSplitFunc func(bpparser.Value) (string, *bpparser.Value, error)
|
type listSplitFunc func(bpparser.Expression) (string, bpparser.Expression, error)
|
||||||
|
|
||||||
func emptyList(value *bpparser.Value) bool {
|
func emptyList(value bpparser.Expression) bool {
|
||||||
return value.Type == bpparser.List && value.Expression == nil && value.Variable == "" &&
|
if list, ok := value.(*bpparser.List); ok {
|
||||||
len(value.ListValue) == 0
|
return len(list.Values) == 0
|
||||||
|
}
|
||||||
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
func splitBpList(val *bpparser.Value, keyFunc listSplitFunc) (lists map[string]*bpparser.Value, err error) {
|
func splitBpList(val bpparser.Expression, keyFunc listSplitFunc) (lists map[string]bpparser.Expression, err error) {
|
||||||
lists = make(map[string]*bpparser.Value)
|
lists = make(map[string]bpparser.Expression)
|
||||||
|
|
||||||
if val.Expression != nil {
|
switch val := val.(type) {
|
||||||
listsA, err := splitBpList(&val.Expression.Args[0], keyFunc)
|
case *bpparser.Operator:
|
||||||
|
listsA, err := splitBpList(val.Args[0], keyFunc)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
listsB, err := splitBpList(&val.Expression.Args[1], keyFunc)
|
listsB, err := splitBpList(val.Args[1], keyFunc)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -120,94 +123,96 @@ func splitBpList(val *bpparser.Value, keyFunc listSplitFunc) (lists map[string]*
|
|||||||
}
|
}
|
||||||
|
|
||||||
if vA, ok := lists[k]; ok {
|
if vA, ok := lists[k]; ok {
|
||||||
expression := *val.Expression
|
expression := val.Copy().(*bpparser.Operator)
|
||||||
lists[k] = &bpparser.Value{
|
expression.Args = [2]bpparser.Expression{vA, vB}
|
||||||
Type: bpparser.List,
|
lists[k] = expression
|
||||||
Expression: &expression,
|
|
||||||
}
|
|
||||||
lists[k].Expression.Args = [2]bpparser.Value{*vA, *vB}
|
|
||||||
} else {
|
} else {
|
||||||
lists[k] = vB
|
lists[k] = vB
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if val.Variable != "" {
|
case *bpparser.Variable:
|
||||||
key, value, err := keyFunc(*val)
|
key, value, err := keyFunc(val)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
if value.Type == bpparser.List {
|
if value.Type() == bpparser.ListType {
|
||||||
lists[key] = value
|
lists[key] = value
|
||||||
} else {
|
} else {
|
||||||
lists[key] = &bpparser.Value{
|
lists[key] = &bpparser.List{
|
||||||
Type: bpparser.List,
|
Values: []bpparser.Expression{value},
|
||||||
ListValue: []bpparser.Value{*value},
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
case *bpparser.List:
|
||||||
for _, v := range val.ListValue {
|
for _, v := range val.Values {
|
||||||
key, value, err := keyFunc(v)
|
key, value, err := keyFunc(v)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
if _, ok := lists[key]; !ok {
|
l := lists[key]
|
||||||
lists[key] = &bpparser.Value{
|
if l == nil {
|
||||||
Type: bpparser.List,
|
l = &bpparser.List{}
|
||||||
}
|
}
|
||||||
|
l.(*bpparser.List).Values = append(l.(*bpparser.List).Values, value)
|
||||||
|
lists[key] = l
|
||||||
}
|
}
|
||||||
lists[key].ListValue = append(lists[key].ListValue, *value)
|
default:
|
||||||
}
|
panic(fmt.Errorf("unexpected type %t", val))
|
||||||
}
|
}
|
||||||
|
|
||||||
return lists, nil
|
return lists, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func splitLocalGlobalPath(value bpparser.Value) (string, *bpparser.Value, error) {
|
func splitLocalGlobalPath(value bpparser.Expression) (string, bpparser.Expression, error) {
|
||||||
if value.Variable == "LOCAL_PATH" {
|
switch v := value.(type) {
|
||||||
return "local", &bpparser.Value{
|
case *bpparser.Variable:
|
||||||
Type: bpparser.String,
|
if v.Name == "LOCAL_PATH" {
|
||||||
StringValue: ".",
|
return "local", &bpparser.String{
|
||||||
|
Value: ".",
|
||||||
}, nil
|
}, nil
|
||||||
} else if value.Variable != "" {
|
} else {
|
||||||
// TODO: Should we split variables?
|
// TODO: Should we split variables?
|
||||||
return "global", &value, nil
|
return "global", value, nil
|
||||||
}
|
}
|
||||||
|
case *bpparser.Operator:
|
||||||
if value.Type != bpparser.String {
|
if v.Type() != bpparser.StringType {
|
||||||
return "", nil, fmt.Errorf("splitLocalGlobalPath expected a string, got %s", value.Type)
|
return "", nil, fmt.Errorf("splitLocalGlobalPath expected a string, got %s", value.Type)
|
||||||
}
|
}
|
||||||
|
|
||||||
if value.Expression == nil {
|
if v.Operator != '+' {
|
||||||
return "global", &value, nil
|
return "global", value, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
if value.Expression.Operator != '+' {
|
firstOperand := v.Args[0]
|
||||||
return "global", &value, nil
|
secondOperand := v.Args[1]
|
||||||
|
if firstOperand.Type() != bpparser.StringType {
|
||||||
|
return "global", value, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
firstOperand := value.Expression.Args[0]
|
if _, ok := firstOperand.(*bpparser.Operator); ok {
|
||||||
secondOperand := value.Expression.Args[1]
|
return "global", value, nil
|
||||||
if firstOperand.Type != bpparser.String {
|
|
||||||
return "global", &value, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if firstOperand.Expression != nil {
|
if variable, ok := firstOperand.(*bpparser.Variable); !ok || variable.Name != "LOCAL_PATH" {
|
||||||
return "global", &value, nil
|
return "global", value, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
if firstOperand.Variable != "LOCAL_PATH" {
|
local := secondOperand
|
||||||
return "global", &value, nil
|
if s, ok := secondOperand.(*bpparser.String); ok {
|
||||||
|
if strings.HasPrefix(s.Value, "/") {
|
||||||
|
s.Value = s.Value[1:]
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
return "local", local, nil
|
||||||
|
case *bpparser.String:
|
||||||
|
return "global", value, nil
|
||||||
|
default:
|
||||||
|
return "", nil, fmt.Errorf("splitLocalGlobalPath expected a string, got %s", value.Type)
|
||||||
|
|
||||||
if secondOperand.Expression == nil && secondOperand.Variable == "" {
|
|
||||||
if strings.HasPrefix(secondOperand.StringValue, "/") {
|
|
||||||
secondOperand.StringValue = secondOperand.StringValue[1:]
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return "local", &secondOperand, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func localIncludeDirs(file *bpFile, prefix string, value *mkparser.MakeString, appendVariable bool) error {
|
func localIncludeDirs(file *bpFile, prefix string, value *mkparser.MakeString, appendVariable bool) error {
|
||||||
val, err := makeVariableToBlueprint(file, value, bpparser.List)
|
val, err := makeVariableToBlueprint(file, value, bpparser.ListType)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -235,7 +240,7 @@ func localIncludeDirs(file *bpFile, prefix string, value *mkparser.MakeString, a
|
|||||||
}
|
}
|
||||||
|
|
||||||
func exportIncludeDirs(file *bpFile, prefix string, value *mkparser.MakeString, appendVariable bool) error {
|
func exportIncludeDirs(file *bpFile, prefix string, value *mkparser.MakeString, appendVariable bool) error {
|
||||||
val, err := makeVariableToBlueprint(file, value, bpparser.List)
|
val, err := makeVariableToBlueprint(file, value, bpparser.ListType)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -266,44 +271,43 @@ func exportIncludeDirs(file *bpFile, prefix string, value *mkparser.MakeString,
|
|||||||
}
|
}
|
||||||
|
|
||||||
func stem(file *bpFile, prefix string, value *mkparser.MakeString, appendVariable bool) error {
|
func stem(file *bpFile, prefix string, value *mkparser.MakeString, appendVariable bool) error {
|
||||||
val, err := makeVariableToBlueprint(file, value, bpparser.String)
|
val, err := makeVariableToBlueprint(file, value, bpparser.StringType)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
varName := "stem"
|
varName := "stem"
|
||||||
|
|
||||||
if val.Expression != nil && val.Expression.Operator == '+' &&
|
if exp, ok := val.(*bpparser.Operator); ok && exp.Operator == '+' {
|
||||||
val.Expression.Args[0].Variable == "LOCAL_MODULE" {
|
if variable, ok := exp.Args[0].(*bpparser.Variable); ok && variable.Name == "LOCAL_MODULE" {
|
||||||
varName = "suffix"
|
varName = "suffix"
|
||||||
val = &val.Expression.Args[1]
|
val = exp.Args[1]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return setVariable(file, appendVariable, prefix, varName, val, true)
|
return setVariable(file, appendVariable, prefix, varName, val, true)
|
||||||
}
|
}
|
||||||
|
|
||||||
func hostOs(file *bpFile, prefix string, value *mkparser.MakeString, appendVariable bool) error {
|
func hostOs(file *bpFile, prefix string, value *mkparser.MakeString, appendVariable bool) error {
|
||||||
val, err := makeVariableToBlueprint(file, value, bpparser.List)
|
val, err := makeVariableToBlueprint(file, value, bpparser.ListType)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
inList := func(s string) bool {
|
inList := func(s string) bool {
|
||||||
for _, v := range val.ListValue {
|
for _, v := range val.(*bpparser.List).Values {
|
||||||
if v.StringValue == s {
|
if v.(*bpparser.String).Value == s {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
falseValue := &bpparser.Value{
|
falseValue := &bpparser.Bool{
|
||||||
Type: bpparser.Bool,
|
Value: false,
|
||||||
BoolValue: false,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
trueValue := &bpparser.Value{
|
trueValue := &bpparser.Bool{
|
||||||
Type: bpparser.Bool,
|
Value: true,
|
||||||
BoolValue: true,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if inList("windows") {
|
if inList("windows") {
|
||||||
@@ -321,30 +325,27 @@ func hostOs(file *bpFile, prefix string, value *mkparser.MakeString, appendVaria
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func splitSrcsLogtags(value bpparser.Value) (string, *bpparser.Value, error) {
|
func splitSrcsLogtags(value bpparser.Expression) (string, bpparser.Expression, error) {
|
||||||
if value.Variable != "" {
|
switch v := value.(type) {
|
||||||
|
case *bpparser.Variable:
|
||||||
// TODO: attempt to split variables?
|
// TODO: attempt to split variables?
|
||||||
return "srcs", &value, nil
|
return "srcs", value, nil
|
||||||
}
|
case *bpparser.Operator:
|
||||||
|
|
||||||
if value.Type != bpparser.String {
|
|
||||||
return "", nil, fmt.Errorf("splitSrcsLogtags expected a string, got %s", value.Type)
|
|
||||||
}
|
|
||||||
|
|
||||||
if value.Expression != nil {
|
|
||||||
// TODO: attempt to handle expressions?
|
// TODO: attempt to handle expressions?
|
||||||
return "srcs", &value, nil
|
return "srcs", value, nil
|
||||||
|
case *bpparser.String:
|
||||||
|
if strings.HasSuffix(v.Value, ".logtags") {
|
||||||
|
return "logtags", value, nil
|
||||||
|
}
|
||||||
|
return "srcs", value, nil
|
||||||
|
default:
|
||||||
|
return "", nil, fmt.Errorf("splitSrcsLogtags expected a string, got %s", value.Type())
|
||||||
}
|
}
|
||||||
|
|
||||||
if strings.HasSuffix(value.StringValue, ".logtags") {
|
|
||||||
return "logtags", &value, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
return "srcs", &value, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func srcFiles(file *bpFile, prefix string, value *mkparser.MakeString, appendVariable bool) error {
|
func srcFiles(file *bpFile, prefix string, value *mkparser.MakeString, appendVariable bool) error {
|
||||||
val, err := makeVariableToBlueprint(file, value, bpparser.List)
|
val, err := makeVariableToBlueprint(file, value, bpparser.ListType)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -369,31 +370,31 @@ func srcFiles(file *bpFile, prefix string, value *mkparser.MakeString, appendVar
|
|||||||
}
|
}
|
||||||
|
|
||||||
func sanitize(file *bpFile, prefix string, mkvalue *mkparser.MakeString, appendVariable bool) error {
|
func sanitize(file *bpFile, prefix string, mkvalue *mkparser.MakeString, appendVariable bool) error {
|
||||||
val, err := makeVariableToBlueprint(file, mkvalue, bpparser.List)
|
val, err := makeVariableToBlueprint(file, mkvalue, bpparser.ListType)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
lists, err := splitBpList(val, func(value bpparser.Value) (string, *bpparser.Value, error) {
|
lists, err := splitBpList(val, func(value bpparser.Expression) (string, bpparser.Expression, error) {
|
||||||
if value.Variable != "" {
|
switch v := value.(type) {
|
||||||
return "vars", &value, nil
|
case *bpparser.Variable:
|
||||||
}
|
return "vars", value, nil
|
||||||
|
case *bpparser.Operator:
|
||||||
if value.Expression != nil {
|
|
||||||
file.errorf(mkvalue, "unknown sanitize expression")
|
file.errorf(mkvalue, "unknown sanitize expression")
|
||||||
return "unknown", &value, nil
|
return "unknown", value, nil
|
||||||
}
|
case *bpparser.String:
|
||||||
|
switch v.Value {
|
||||||
switch value.StringValue {
|
|
||||||
case "never", "address", "coverage", "integer", "thread", "undefined":
|
case "never", "address", "coverage", "integer", "thread", "undefined":
|
||||||
bpTrue := bpparser.Value{
|
bpTrue := &bpparser.Bool{
|
||||||
Type: bpparser.Bool,
|
Value: true,
|
||||||
BoolValue: true,
|
|
||||||
}
|
}
|
||||||
return value.StringValue, &bpTrue, nil
|
return v.Value, bpTrue, nil
|
||||||
default:
|
default:
|
||||||
file.errorf(mkvalue, "unknown sanitize argument: %s", value.StringValue)
|
file.errorf(mkvalue, "unknown sanitize argument: %s", v.Value)
|
||||||
return "unknown", &value, nil
|
return "unknown", value, nil
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
return "", nil, fmt.Errorf("sanitize expected a string, got %s", value.Type())
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -407,7 +408,7 @@ func sanitize(file *bpFile, prefix string, mkvalue *mkparser.MakeString, appendV
|
|||||||
|
|
||||||
switch k {
|
switch k {
|
||||||
case "never", "address", "coverage", "integer", "thread", "undefined":
|
case "never", "address", "coverage", "integer", "thread", "undefined":
|
||||||
err = setVariable(file, false, prefix, "sanitize."+k, &lists[k].ListValue[0], true)
|
err = setVariable(file, false, prefix, "sanitize."+k, lists[k].(*bpparser.List).Values[0], true)
|
||||||
case "unknown":
|
case "unknown":
|
||||||
// Nothing, we already added the error above
|
// Nothing, we already added the error above
|
||||||
case "vars":
|
case "vars":
|
||||||
@@ -425,30 +426,41 @@ func sanitize(file *bpFile, prefix string, mkvalue *mkparser.MakeString, appendV
|
|||||||
}
|
}
|
||||||
|
|
||||||
func ldflags(file *bpFile, prefix string, mkvalue *mkparser.MakeString, appendVariable bool) error {
|
func ldflags(file *bpFile, prefix string, mkvalue *mkparser.MakeString, appendVariable bool) error {
|
||||||
val, err := makeVariableToBlueprint(file, mkvalue, bpparser.List)
|
val, err := makeVariableToBlueprint(file, mkvalue, bpparser.ListType)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
lists, err := splitBpList(val, func(value bpparser.Value) (string, *bpparser.Value, error) {
|
lists, err := splitBpList(val, func(value bpparser.Expression) (string, bpparser.Expression, error) {
|
||||||
// Anything other than "-Wl,--version_script," + LOCAL_PATH + "<path>" matches ldflags
|
// Anything other than "-Wl,--version_script," + LOCAL_PATH + "<path>" matches ldflags
|
||||||
if value.Variable != "" || value.Expression == nil {
|
exp1, ok := value.(*bpparser.Operator)
|
||||||
return "ldflags", &value, nil
|
if !ok {
|
||||||
|
return "ldflags", value, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
exp := value.Expression.Args[0]
|
exp2, ok := exp1.Args[0].(*bpparser.Operator)
|
||||||
if exp.Variable != "" || exp.Expression == nil || exp.Expression.Args[0].StringValue != "-Wl,--version-script," {
|
if !ok {
|
||||||
return "ldflags", &value, nil
|
return "ldflags", value, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
if exp.Expression.Args[1].Variable != "LOCAL_PATH" {
|
if s, ok := exp2.Args[0].(*bpparser.String); !ok || s.Value != "-Wl,--version-script," {
|
||||||
|
return "ldflags", value, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
if v, ok := exp2.Args[1].(*bpparser.Variable); !ok || v.Name != "LOCAL_PATH" {
|
||||||
file.errorf(mkvalue, "Unrecognized version-script")
|
file.errorf(mkvalue, "Unrecognized version-script")
|
||||||
return "ldflags", &value, nil
|
return "ldflags", value, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
value.Expression.Args[1].StringValue = strings.TrimPrefix(value.Expression.Args[1].StringValue, "/")
|
s, ok := exp1.Args[1].(*bpparser.String)
|
||||||
|
if !ok {
|
||||||
|
file.errorf(mkvalue, "Unrecognized version-script")
|
||||||
|
return "ldflags", value, nil
|
||||||
|
}
|
||||||
|
|
||||||
return "version", &value.Expression.Args[1], nil
|
s.Value = strings.TrimPrefix(s.Value, "/")
|
||||||
|
|
||||||
|
return "version", s, nil
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@@ -462,10 +474,10 @@ func ldflags(file *bpFile, prefix string, mkvalue *mkparser.MakeString, appendVa
|
|||||||
}
|
}
|
||||||
|
|
||||||
if version_script, ok := lists["version"]; ok && !emptyList(version_script) {
|
if version_script, ok := lists["version"]; ok && !emptyList(version_script) {
|
||||||
if len(version_script.ListValue) > 1 {
|
if len(version_script.(*bpparser.List).Values) > 1 {
|
||||||
file.errorf(mkvalue, "multiple version scripts found?")
|
file.errorf(mkvalue, "multiple version scripts found?")
|
||||||
}
|
}
|
||||||
err = setVariable(file, false, prefix, "version_script", &version_script.ListValue[0], true)
|
err = setVariable(file, false, prefix, "version_script", version_script.(*bpparser.List).Values[0], true)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@@ -19,7 +19,7 @@ type bpFile struct {
|
|||||||
comments []bpparser.Comment
|
comments []bpparser.Comment
|
||||||
defs []bpparser.Definition
|
defs []bpparser.Definition
|
||||||
localAssignments map[string]*bpparser.Property
|
localAssignments map[string]*bpparser.Property
|
||||||
globalAssignments map[string]*bpparser.Value
|
globalAssignments map[string]*bpparser.Expression
|
||||||
scope mkparser.Scope
|
scope mkparser.Scope
|
||||||
module *bpparser.Module
|
module *bpparser.Module
|
||||||
|
|
||||||
@@ -34,7 +34,7 @@ func (f *bpFile) errorf(node mkparser.Node, s string, args ...interface{}) {
|
|||||||
s = fmt.Sprintf(s, args...)
|
s = fmt.Sprintf(s, args...)
|
||||||
c := bpparser.Comment{
|
c := bpparser.Comment{
|
||||||
Comment: []string{fmt.Sprintf("// ANDROIDMK TRANSLATION ERROR: %s", s)},
|
Comment: []string{fmt.Sprintf("// ANDROIDMK TRANSLATION ERROR: %s", s)},
|
||||||
Pos: f.bpPos,
|
Slash: f.bpPos,
|
||||||
}
|
}
|
||||||
|
|
||||||
lines := strings.Split(orig, "\n")
|
lines := strings.Split(orig, "\n")
|
||||||
@@ -93,7 +93,7 @@ func convertFile(filename string, buffer *bytes.Buffer) (string, []error) {
|
|||||||
file := &bpFile{
|
file := &bpFile{
|
||||||
scope: androidScope(),
|
scope: androidScope(),
|
||||||
localAssignments: make(map[string]*bpparser.Property),
|
localAssignments: make(map[string]*bpparser.Property),
|
||||||
globalAssignments: make(map[string]*bpparser.Value),
|
globalAssignments: make(map[string]*bpparser.Expression),
|
||||||
}
|
}
|
||||||
|
|
||||||
var conds []*conditional
|
var conds []*conditional
|
||||||
@@ -105,7 +105,7 @@ func convertFile(filename string, buffer *bytes.Buffer) (string, []error) {
|
|||||||
switch x := node.(type) {
|
switch x := node.(type) {
|
||||||
case *mkparser.Comment:
|
case *mkparser.Comment:
|
||||||
file.comments = append(file.comments, bpparser.Comment{
|
file.comments = append(file.comments, bpparser.Comment{
|
||||||
Pos: file.bpPos,
|
Slash: file.bpPos,
|
||||||
Comment: []string{"//" + x.Comment},
|
Comment: []string{"//" + x.Comment},
|
||||||
})
|
})
|
||||||
case *mkparser.Assignment:
|
case *mkparser.Assignment:
|
||||||
@@ -231,8 +231,8 @@ func handleAssignment(file *bpFile, assignment *mkparser.Assignment, c *conditio
|
|||||||
|
|
||||||
var err error
|
var err error
|
||||||
if prop, ok := standardProperties[name]; ok {
|
if prop, ok := standardProperties[name]; ok {
|
||||||
var val *bpparser.Value
|
var val bpparser.Expression
|
||||||
val, err = makeVariableToBlueprint(file, assignment.Value, prop.ValueType)
|
val, err = makeVariableToBlueprint(file, assignment.Value, prop.Type)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
err = setVariable(file, appendVariable, prefix, prop.string, val, true)
|
err = setVariable(file, appendVariable, prefix, prop.string, val, true)
|
||||||
}
|
}
|
||||||
@@ -256,8 +256,8 @@ func handleAssignment(file *bpFile, assignment *mkparser.Assignment, c *conditio
|
|||||||
file.errorf(assignment, "unsupported assignment to %s", name)
|
file.errorf(assignment, "unsupported assignment to %s", name)
|
||||||
return
|
return
|
||||||
default:
|
default:
|
||||||
var val *bpparser.Value
|
var val bpparser.Expression
|
||||||
val, err = makeVariableToBlueprint(file, assignment.Value, bpparser.List)
|
val, err = makeVariableToBlueprint(file, assignment.Value, bpparser.ListType)
|
||||||
err = setVariable(file, appendVariable, prefix, name, val, false)
|
err = setVariable(file, appendVariable, prefix, name, val, false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -279,7 +279,7 @@ func handleModuleConditionals(file *bpFile, directive *mkparser.Directive, conds
|
|||||||
disabledPrefix := conditionalTranslations[c.cond][!c.eq]
|
disabledPrefix := conditionalTranslations[c.cond][!c.eq]
|
||||||
|
|
||||||
// Create a fake assignment with enabled = false
|
// Create a fake assignment with enabled = false
|
||||||
val, err := makeVariableToBlueprint(file, mkparser.SimpleMakeString("false", mkparser.NoPos), bpparser.Bool)
|
val, err := makeVariableToBlueprint(file, mkparser.SimpleMakeString("false", mkparser.NoPos), bpparser.BoolType)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
err = setVariable(file, false, disabledPrefix, "enabled", val, true)
|
err = setVariable(file, false, disabledPrefix, "enabled", val, true)
|
||||||
}
|
}
|
||||||
@@ -292,31 +292,31 @@ func handleModuleConditionals(file *bpFile, directive *mkparser.Directive, conds
|
|||||||
func makeModule(file *bpFile, t string) {
|
func makeModule(file *bpFile, t string) {
|
||||||
file.module.Type = bpparser.Ident{
|
file.module.Type = bpparser.Ident{
|
||||||
Name: t,
|
Name: t,
|
||||||
Pos: file.module.LbracePos,
|
Pos: file.module.LBracePos,
|
||||||
}
|
}
|
||||||
file.module.RbracePos = file.bpPos
|
file.module.RBracePos = file.bpPos
|
||||||
file.defs = append(file.defs, file.module)
|
file.defs = append(file.defs, file.module)
|
||||||
file.inModule = false
|
file.inModule = false
|
||||||
}
|
}
|
||||||
|
|
||||||
func resetModule(file *bpFile) {
|
func resetModule(file *bpFile) {
|
||||||
file.module = &bpparser.Module{}
|
file.module = &bpparser.Module{}
|
||||||
file.module.LbracePos = file.bpPos
|
file.module.LBracePos = file.bpPos
|
||||||
file.localAssignments = make(map[string]*bpparser.Property)
|
file.localAssignments = make(map[string]*bpparser.Property)
|
||||||
file.inModule = true
|
file.inModule = true
|
||||||
}
|
}
|
||||||
|
|
||||||
func makeVariableToBlueprint(file *bpFile, val *mkparser.MakeString,
|
func makeVariableToBlueprint(file *bpFile, val *mkparser.MakeString,
|
||||||
typ bpparser.ValueType) (*bpparser.Value, error) {
|
typ bpparser.Type) (bpparser.Expression, error) {
|
||||||
|
|
||||||
var exp *bpparser.Value
|
var exp bpparser.Expression
|
||||||
var err error
|
var err error
|
||||||
switch typ {
|
switch typ {
|
||||||
case bpparser.List:
|
case bpparser.ListType:
|
||||||
exp, err = makeToListExpression(val, file.scope)
|
exp, err = makeToListExpression(val, file.scope)
|
||||||
case bpparser.String:
|
case bpparser.StringType:
|
||||||
exp, err = makeToStringExpression(val, file.scope)
|
exp, err = makeToStringExpression(val, file.scope)
|
||||||
case bpparser.Bool:
|
case bpparser.BoolType:
|
||||||
exp, err = makeToBoolExpression(val)
|
exp, err = makeToBoolExpression(val)
|
||||||
default:
|
default:
|
||||||
panic("unknown type")
|
panic("unknown type")
|
||||||
@@ -329,7 +329,7 @@ func makeVariableToBlueprint(file *bpFile, val *mkparser.MakeString,
|
|||||||
return exp, nil
|
return exp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func setVariable(file *bpFile, plusequals bool, prefix, name string, value *bpparser.Value, local bool) error {
|
func setVariable(file *bpFile, plusequals bool, prefix, name string, value bpparser.Expression, local bool) error {
|
||||||
|
|
||||||
if prefix != "" {
|
if prefix != "" {
|
||||||
name = prefix + "." + name
|
name = prefix + "." + name
|
||||||
@@ -337,7 +337,7 @@ func setVariable(file *bpFile, plusequals bool, prefix, name string, value *bppa
|
|||||||
|
|
||||||
pos := file.bpPos
|
pos := file.bpPos
|
||||||
|
|
||||||
var oldValue *bpparser.Value
|
var oldValue *bpparser.Expression
|
||||||
if local {
|
if local {
|
||||||
oldProp := file.localAssignments[name]
|
oldProp := file.localAssignments[name]
|
||||||
if oldProp != nil {
|
if oldProp != nil {
|
||||||
@@ -349,12 +349,12 @@ func setVariable(file *bpFile, plusequals bool, prefix, name string, value *bppa
|
|||||||
|
|
||||||
if local {
|
if local {
|
||||||
if oldValue != nil && plusequals {
|
if oldValue != nil && plusequals {
|
||||||
val, err := addValues(oldValue, value)
|
val, err := addValues(*oldValue, value)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("unsupported addition: %s", err.Error())
|
return fmt.Errorf("unsupported addition: %s", err.Error())
|
||||||
}
|
}
|
||||||
val.Expression.Pos = pos
|
val.(*bpparser.Operator).OperatorPos = pos
|
||||||
*oldValue = *val
|
*oldValue = val
|
||||||
} else {
|
} else {
|
||||||
names := strings.Split(name, ".")
|
names := strings.Split(name, ".")
|
||||||
container := &file.module.Properties
|
container := &file.module.Properties
|
||||||
@@ -366,21 +366,20 @@ func setVariable(file *bpFile, plusequals bool, prefix, name string, value *bppa
|
|||||||
prop = &bpparser.Property{
|
prop = &bpparser.Property{
|
||||||
Name: bpparser.Ident{Name: n, Pos: pos},
|
Name: bpparser.Ident{Name: n, Pos: pos},
|
||||||
Pos: pos,
|
Pos: pos,
|
||||||
Value: bpparser.Value{
|
Value: &bpparser.Map{
|
||||||
Type: bpparser.Map,
|
Properties: []*bpparser.Property{},
|
||||||
MapValue: []*bpparser.Property{},
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
file.localAssignments[fqn] = prop
|
file.localAssignments[fqn] = prop
|
||||||
*container = append(*container, prop)
|
*container = append(*container, prop)
|
||||||
}
|
}
|
||||||
container = &prop.Value.MapValue
|
container = &prop.Value.(*bpparser.Map).Properties
|
||||||
}
|
}
|
||||||
|
|
||||||
prop := &bpparser.Property{
|
prop := &bpparser.Property{
|
||||||
Name: bpparser.Ident{Name: names[len(names)-1], Pos: pos},
|
Name: bpparser.Ident{Name: names[len(names)-1], Pos: pos},
|
||||||
Pos: pos,
|
Pos: pos,
|
||||||
Value: *value,
|
Value: value,
|
||||||
}
|
}
|
||||||
file.localAssignments[name] = prop
|
file.localAssignments[name] = prop
|
||||||
*container = append(*container, prop)
|
*container = append(*container, prop)
|
||||||
@@ -392,8 +391,8 @@ func setVariable(file *bpFile, plusequals bool, prefix, name string, value *bppa
|
|||||||
Name: name,
|
Name: name,
|
||||||
Pos: pos,
|
Pos: pos,
|
||||||
},
|
},
|
||||||
Value: *value,
|
Value: value,
|
||||||
OrigValue: *value,
|
OrigValue: value,
|
||||||
Pos: pos,
|
Pos: pos,
|
||||||
Assigner: "+=",
|
Assigner: "+=",
|
||||||
}
|
}
|
||||||
@@ -404,8 +403,8 @@ func setVariable(file *bpFile, plusequals bool, prefix, name string, value *bppa
|
|||||||
Name: name,
|
Name: name,
|
||||||
Pos: pos,
|
Pos: pos,
|
||||||
},
|
},
|
||||||
Value: *value,
|
Value: value,
|
||||||
OrigValue: *value,
|
OrigValue: value,
|
||||||
Pos: pos,
|
Pos: pos,
|
||||||
Assigner: "=",
|
Assigner: "=",
|
||||||
}
|
}
|
||||||
|
@@ -41,9 +41,9 @@ include $(CLEAR_VARS)
|
|||||||
# Name Comment
|
# Name Comment
|
||||||
LOCAL_MODULE := test
|
LOCAL_MODULE := test
|
||||||
# Source comment
|
# Source comment
|
||||||
LOCAL_SRC_FILES := a.c
|
LOCAL_SRC_FILES_EXCLUDE := a.c
|
||||||
# Second source comment
|
# Second source comment
|
||||||
LOCAL_SRC_FILES += b.c
|
LOCAL_SRC_FILES_EXCLUDE += b.c
|
||||||
include $(BUILD_SHARED_LIBRARY)`,
|
include $(BUILD_SHARED_LIBRARY)`,
|
||||||
expected: `
|
expected: `
|
||||||
//
|
//
|
||||||
@@ -55,7 +55,7 @@ cc_library_shared {
|
|||||||
// Name Comment
|
// Name Comment
|
||||||
name: "test",
|
name: "test",
|
||||||
// Source comment
|
// Source comment
|
||||||
srcs: ["a.c"] + ["b.c"], // Second source comment
|
exclude_srcs: ["a.c"] + ["b.c"], // Second source comment
|
||||||
|
|
||||||
}`,
|
}`,
|
||||||
},
|
},
|
||||||
@@ -107,8 +107,7 @@ include $(BUILD_SHARED_LIBRARY)`,
|
|||||||
input = ["testing/include"]
|
input = ["testing/include"]
|
||||||
cc_library_shared {
|
cc_library_shared {
|
||||||
// Comment 1
|
// Comment 1
|
||||||
include_dirs: ["system/core/include"] + // Comment 2
|
include_dirs: ["system/core/include"] + input + ["system/core/include"], // Comment 2
|
||||||
input + ["system/core/include"],
|
|
||||||
local_include_dirs: ["."] + ["include"] + ["test/include"],
|
local_include_dirs: ["."] + ["include"] + ["test/include"],
|
||||||
// Comment 3
|
// Comment 3
|
||||||
}`,
|
}`,
|
||||||
@@ -387,9 +386,6 @@ func TestEndToEnd(t *testing.T) {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO(dwillemsen): remove once bpfmt and androidmk agree
|
|
||||||
got = reformatBlueprint(got)
|
|
||||||
|
|
||||||
if got != expected {
|
if got != expected {
|
||||||
t.Errorf("failed testcase '%s'\ninput:\n%s\n\nexpected:\n%s\ngot:\n%s\n", test.desc, strings.TrimSpace(test.in), expected, got)
|
t.Errorf("failed testcase '%s'\ninput:\n%s\n\nexpected:\n%s\ngot:\n%s\n", test.desc, strings.TrimSpace(test.in), expected, got)
|
||||||
}
|
}
|
||||||
|
@@ -9,43 +9,38 @@ import (
|
|||||||
bpparser "github.com/google/blueprint/parser"
|
bpparser "github.com/google/blueprint/parser"
|
||||||
)
|
)
|
||||||
|
|
||||||
func stringToStringValue(s string) *bpparser.Value {
|
func stringToStringValue(s string) bpparser.Expression {
|
||||||
return &bpparser.Value{
|
return &bpparser.String{
|
||||||
Type: bpparser.String,
|
Value: s,
|
||||||
StringValue: s,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func addValues(val1, val2 *bpparser.Value) (*bpparser.Value, error) {
|
func addValues(val1, val2 bpparser.Expression) (bpparser.Expression, error) {
|
||||||
if val1 == nil {
|
if val1 == nil {
|
||||||
return val2, nil
|
return val2, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
if val1.Type == bpparser.String && val2.Type == bpparser.List {
|
if val1.Type() == bpparser.StringType && val2.Type() == bpparser.ListType {
|
||||||
val1 = &bpparser.Value{
|
val1 = &bpparser.List{
|
||||||
Type: bpparser.List,
|
Values: []bpparser.Expression{val1},
|
||||||
ListValue: []bpparser.Value{*val1},
|
|
||||||
}
|
}
|
||||||
} else if val2.Type == bpparser.String && val1.Type == bpparser.List {
|
} else if val2.Type() == bpparser.StringType && val1.Type() == bpparser.ListType {
|
||||||
val2 = &bpparser.Value{
|
val2 = &bpparser.List{
|
||||||
Type: bpparser.List,
|
Values: []bpparser.Expression{val1},
|
||||||
ListValue: []bpparser.Value{*val1},
|
|
||||||
}
|
}
|
||||||
} else if val1.Type != val2.Type {
|
} else if val1.Type() != val2.Type() {
|
||||||
return nil, fmt.Errorf("cannot add mismatched types")
|
return nil, fmt.Errorf("cannot add mismatched types")
|
||||||
}
|
}
|
||||||
|
|
||||||
return &bpparser.Value{
|
return &bpparser.Operator{
|
||||||
Type: val1.Type,
|
|
||||||
Expression: &bpparser.Expression{
|
|
||||||
Operator: '+',
|
Operator: '+',
|
||||||
Args: [2]bpparser.Value{*val1, *val2},
|
Args: [2]bpparser.Expression{val1, val2},
|
||||||
},
|
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func makeToStringExpression(ms *mkparser.MakeString, scope mkparser.Scope) (*bpparser.Value, error) {
|
func makeToStringExpression(ms *mkparser.MakeString, scope mkparser.Scope) (bpparser.Expression, error) {
|
||||||
var val *bpparser.Value
|
|
||||||
|
var val bpparser.Expression
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
if ms.Strings[0] != "" {
|
if ms.Strings[0] != "" {
|
||||||
@@ -60,12 +55,12 @@ func makeToStringExpression(ms *mkparser.MakeString, scope mkparser.Scope) (*bpp
|
|||||||
if !name.Const() {
|
if !name.Const() {
|
||||||
return nil, fmt.Errorf("Unsupported non-const variable name %s", name.Dump())
|
return nil, fmt.Errorf("Unsupported non-const variable name %s", name.Dump())
|
||||||
}
|
}
|
||||||
tmp := &bpparser.Value{
|
tmp := &bpparser.Variable{
|
||||||
Type: bpparser.String,
|
Name: name.Value(nil),
|
||||||
Variable: name.Value(nil),
|
Value: &bpparser.String{},
|
||||||
}
|
}
|
||||||
|
|
||||||
if tmp.Variable == "TOP" {
|
if tmp.Name == "TOP" {
|
||||||
if s[0] == '/' {
|
if s[0] == '/' {
|
||||||
s = s[1:]
|
s = s[1:]
|
||||||
} else {
|
} else {
|
||||||
@@ -91,37 +86,33 @@ func makeToStringExpression(ms *mkparser.MakeString, scope mkparser.Scope) (*bpp
|
|||||||
return val, nil
|
return val, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func stringToListValue(s string) *bpparser.Value {
|
func stringToListValue(s string) bpparser.Expression {
|
||||||
list := strings.Fields(s)
|
list := strings.Fields(s)
|
||||||
valList := make([]bpparser.Value, len(list))
|
valList := make([]bpparser.Expression, len(list))
|
||||||
for i, l := range list {
|
for i, l := range list {
|
||||||
valList[i] = bpparser.Value{
|
valList[i] = &bpparser.String{
|
||||||
Type: bpparser.String,
|
Value: l,
|
||||||
StringValue: l,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return &bpparser.Value{
|
return &bpparser.List{
|
||||||
Type: bpparser.List,
|
Values: valList,
|
||||||
ListValue: valList,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func makeToListExpression(ms *mkparser.MakeString, scope mkparser.Scope) (*bpparser.Value, error) {
|
func makeToListExpression(ms *mkparser.MakeString, scope mkparser.Scope) (bpparser.Expression, error) {
|
||||||
|
|
||||||
fields := ms.Split(" \t")
|
fields := ms.Split(" \t")
|
||||||
|
|
||||||
var listOfListValues []*bpparser.Value
|
var listOfListValues []bpparser.Expression
|
||||||
|
|
||||||
listValue := &bpparser.Value{
|
listValue := &bpparser.List{}
|
||||||
Type: bpparser.List,
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, f := range fields {
|
for _, f := range fields {
|
||||||
if len(f.Variables) == 1 && f.Strings[0] == "" && f.Strings[1] == "" {
|
if len(f.Variables) == 1 && f.Strings[0] == "" && f.Strings[1] == "" {
|
||||||
if ret, ok := f.Variables[0].EvalFunction(scope); ok {
|
if ret, ok := f.Variables[0].EvalFunction(scope); ok {
|
||||||
listValue.ListValue = append(listValue.ListValue, bpparser.Value{
|
listValue.Values = append(listValue.Values, &bpparser.String{
|
||||||
Type: bpparser.String,
|
Value: ret,
|
||||||
StringValue: ret,
|
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
// Variable by itself, variable is probably a list
|
// Variable by itself, variable is probably a list
|
||||||
@@ -129,21 +120,18 @@ func makeToListExpression(ms *mkparser.MakeString, scope mkparser.Scope) (*bppar
|
|||||||
return nil, fmt.Errorf("unsupported non-const variable name")
|
return nil, fmt.Errorf("unsupported non-const variable name")
|
||||||
}
|
}
|
||||||
if f.Variables[0].Name.Value(nil) == "TOP" {
|
if f.Variables[0].Name.Value(nil) == "TOP" {
|
||||||
listValue.ListValue = append(listValue.ListValue, bpparser.Value{
|
listValue.Values = append(listValue.Values, &bpparser.String{
|
||||||
Type: bpparser.String,
|
Value: ".",
|
||||||
StringValue: ".",
|
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
if len(listValue.ListValue) > 0 {
|
if len(listValue.Values) > 0 {
|
||||||
listOfListValues = append(listOfListValues, listValue)
|
listOfListValues = append(listOfListValues, listValue)
|
||||||
}
|
}
|
||||||
listOfListValues = append(listOfListValues, &bpparser.Value{
|
listOfListValues = append(listOfListValues, &bpparser.Variable{
|
||||||
Type: bpparser.List,
|
Name: f.Variables[0].Name.Value(nil),
|
||||||
Variable: f.Variables[0].Name.Value(nil),
|
Value: &bpparser.List{},
|
||||||
})
|
})
|
||||||
listValue = &bpparser.Value{
|
listValue = &bpparser.List{}
|
||||||
Type: bpparser.List,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -155,11 +143,11 @@ func makeToListExpression(ms *mkparser.MakeString, scope mkparser.Scope) (*bppar
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
listValue.ListValue = append(listValue.ListValue, *s)
|
listValue.Values = append(listValue.Values, s)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(listValue.ListValue) > 0 {
|
if len(listValue.Values) > 0 {
|
||||||
listOfListValues = append(listOfListValues, listValue)
|
listOfListValues = append(listOfListValues, listValue)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -179,7 +167,7 @@ func makeToListExpression(ms *mkparser.MakeString, scope mkparser.Scope) (*bppar
|
|||||||
return val, nil
|
return val, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func stringToBoolValue(s string) (*bpparser.Value, error) {
|
func stringToBoolValue(s string) (bpparser.Expression, error) {
|
||||||
var b bool
|
var b bool
|
||||||
s = strings.TrimSpace(s)
|
s = strings.TrimSpace(s)
|
||||||
switch s {
|
switch s {
|
||||||
@@ -192,22 +180,21 @@ func stringToBoolValue(s string) (*bpparser.Value, error) {
|
|||||||
default:
|
default:
|
||||||
return nil, fmt.Errorf("unexpected bool value %s", s)
|
return nil, fmt.Errorf("unexpected bool value %s", s)
|
||||||
}
|
}
|
||||||
return &bpparser.Value{
|
return &bpparser.Bool{
|
||||||
Type: bpparser.Bool,
|
Value: b,
|
||||||
BoolValue: b,
|
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func makeToBoolExpression(ms *mkparser.MakeString) (*bpparser.Value, error) {
|
func makeToBoolExpression(ms *mkparser.MakeString) (bpparser.Expression, error) {
|
||||||
if !ms.Const() {
|
if !ms.Const() {
|
||||||
if len(ms.Variables) == 1 && ms.Strings[0] == "" && ms.Strings[1] == "" {
|
if len(ms.Variables) == 1 && ms.Strings[0] == "" && ms.Strings[1] == "" {
|
||||||
name := ms.Variables[0].Name
|
name := ms.Variables[0].Name
|
||||||
if !name.Const() {
|
if !name.Const() {
|
||||||
return nil, fmt.Errorf("unsupported non-const variable name")
|
return nil, fmt.Errorf("unsupported non-const variable name")
|
||||||
}
|
}
|
||||||
return &bpparser.Value{
|
return &bpparser.Variable{
|
||||||
Type: bpparser.Bool,
|
Name: name.Value(nil),
|
||||||
Variable: name.Value(nil),
|
Value: &bpparser.Bool{},
|
||||||
}, nil
|
}, nil
|
||||||
} else {
|
} else {
|
||||||
return nil, fmt.Errorf("non-const bool expression %s", ms.Dump())
|
return nil, fmt.Errorf("non-const bool expression %s", ms.Dump())
|
||||||
|
@@ -158,7 +158,7 @@ default $
|
|||||||
# Variant:
|
# Variant:
|
||||||
# Type: bootstrap_go_package
|
# Type: bootstrap_go_package
|
||||||
# Factory: github.com/google/blueprint/bootstrap.newGoPackageModuleFactory.func1
|
# Factory: github.com/google/blueprint/bootstrap.newGoPackageModuleFactory.func1
|
||||||
# Defined: build/blueprint/Blueprints:80:1
|
# Defined: build/blueprint/Blueprints:81:1
|
||||||
|
|
||||||
build $
|
build $
|
||||||
${g.bootstrap.buildDir}/.bootstrap/blueprint-bootstrap/pkg/github.com/google/blueprint/bootstrap.a $
|
${g.bootstrap.buildDir}/.bootstrap/blueprint-bootstrap/pkg/github.com/google/blueprint/bootstrap.a $
|
||||||
@@ -186,7 +186,7 @@ default $
|
|||||||
# Variant:
|
# Variant:
|
||||||
# Type: bootstrap_go_package
|
# Type: bootstrap_go_package
|
||||||
# Factory: github.com/google/blueprint/bootstrap.newGoPackageModuleFactory.func1
|
# Factory: github.com/google/blueprint/bootstrap.newGoPackageModuleFactory.func1
|
||||||
# Defined: build/blueprint/Blueprints:99:1
|
# Defined: build/blueprint/Blueprints:100:1
|
||||||
|
|
||||||
build $
|
build $
|
||||||
${g.bootstrap.buildDir}/.bootstrap/blueprint-bootstrap-bpdoc/pkg/github.com/google/blueprint/bootstrap/bpdoc.a $
|
${g.bootstrap.buildDir}/.bootstrap/blueprint-bootstrap-bpdoc/pkg/github.com/google/blueprint/bootstrap/bpdoc.a $
|
||||||
@@ -207,7 +207,7 @@ default $
|
|||||||
# Variant:
|
# Variant:
|
||||||
# Type: bootstrap_go_package
|
# Type: bootstrap_go_package
|
||||||
# Factory: github.com/google/blueprint/bootstrap.newGoPackageModuleFactory.func1
|
# Factory: github.com/google/blueprint/bootstrap.newGoPackageModuleFactory.func1
|
||||||
# Defined: build/blueprint/Blueprints:46:1
|
# Defined: build/blueprint/Blueprints:47:1
|
||||||
|
|
||||||
build $
|
build $
|
||||||
${g.bootstrap.buildDir}/.bootstrap/blueprint-deptools/pkg/github.com/google/blueprint/deptools.a $
|
${g.bootstrap.buildDir}/.bootstrap/blueprint-deptools/pkg/github.com/google/blueprint/deptools.a $
|
||||||
@@ -228,6 +228,7 @@ default $
|
|||||||
build $
|
build $
|
||||||
${g.bootstrap.buildDir}/.bootstrap/blueprint-parser/test/github.com/google/blueprint/parser.a $
|
${g.bootstrap.buildDir}/.bootstrap/blueprint-parser/test/github.com/google/blueprint/parser.a $
|
||||||
: g.bootstrap.compile $
|
: g.bootstrap.compile $
|
||||||
|
${g.bootstrap.srcDir}/build/blueprint/parser/ast.go $
|
||||||
${g.bootstrap.srcDir}/build/blueprint/parser/modify.go $
|
${g.bootstrap.srcDir}/build/blueprint/parser/modify.go $
|
||||||
${g.bootstrap.srcDir}/build/blueprint/parser/parser.go $
|
${g.bootstrap.srcDir}/build/blueprint/parser/parser.go $
|
||||||
${g.bootstrap.srcDir}/build/blueprint/parser/printer.go $
|
${g.bootstrap.srcDir}/build/blueprint/parser/printer.go $
|
||||||
@@ -274,6 +275,7 @@ default ${g.bootstrap.buildDir}/.bootstrap/blueprint-parser/test/test.passed
|
|||||||
build $
|
build $
|
||||||
${g.bootstrap.buildDir}/.bootstrap/blueprint-parser/pkg/github.com/google/blueprint/parser.a $
|
${g.bootstrap.buildDir}/.bootstrap/blueprint-parser/pkg/github.com/google/blueprint/parser.a $
|
||||||
: g.bootstrap.compile $
|
: g.bootstrap.compile $
|
||||||
|
${g.bootstrap.srcDir}/build/blueprint/parser/ast.go $
|
||||||
${g.bootstrap.srcDir}/build/blueprint/parser/modify.go $
|
${g.bootstrap.srcDir}/build/blueprint/parser/modify.go $
|
||||||
${g.bootstrap.srcDir}/build/blueprint/parser/parser.go $
|
${g.bootstrap.srcDir}/build/blueprint/parser/parser.go $
|
||||||
${g.bootstrap.srcDir}/build/blueprint/parser/printer.go $
|
${g.bootstrap.srcDir}/build/blueprint/parser/printer.go $
|
||||||
@@ -289,7 +291,7 @@ default $
|
|||||||
# Variant:
|
# Variant:
|
||||||
# Type: bootstrap_go_package
|
# Type: bootstrap_go_package
|
||||||
# Factory: github.com/google/blueprint/bootstrap.newGoPackageModuleFactory.func1
|
# Factory: github.com/google/blueprint/bootstrap.newGoPackageModuleFactory.func1
|
||||||
# Defined: build/blueprint/Blueprints:52:1
|
# Defined: build/blueprint/Blueprints:53:1
|
||||||
|
|
||||||
build $
|
build $
|
||||||
${g.bootstrap.buildDir}/.bootstrap/blueprint-pathtools/test/github.com/google/blueprint/pathtools.a $
|
${g.bootstrap.buildDir}/.bootstrap/blueprint-pathtools/test/github.com/google/blueprint/pathtools.a $
|
||||||
@@ -350,7 +352,7 @@ default $
|
|||||||
# Variant:
|
# Variant:
|
||||||
# Type: bootstrap_go_package
|
# Type: bootstrap_go_package
|
||||||
# Factory: github.com/google/blueprint/bootstrap.newGoPackageModuleFactory.func1
|
# Factory: github.com/google/blueprint/bootstrap.newGoPackageModuleFactory.func1
|
||||||
# Defined: build/blueprint/Blueprints:64:1
|
# Defined: build/blueprint/Blueprints:65:1
|
||||||
|
|
||||||
build $
|
build $
|
||||||
${g.bootstrap.buildDir}/.bootstrap/blueprint-proptools/test/github.com/google/blueprint/proptools.a $
|
${g.bootstrap.buildDir}/.bootstrap/blueprint-proptools/test/github.com/google/blueprint/proptools.a $
|
||||||
@@ -419,7 +421,7 @@ default $
|
|||||||
# Variant:
|
# Variant:
|
||||||
# Type: bootstrap_core_go_binary
|
# Type: bootstrap_core_go_binary
|
||||||
# Factory: github.com/google/blueprint/bootstrap.newGoBinaryModuleFactory.func1
|
# Factory: github.com/google/blueprint/bootstrap.newGoBinaryModuleFactory.func1
|
||||||
# Defined: build/blueprint/Blueprints:142:1
|
# Defined: build/blueprint/Blueprints:143:1
|
||||||
|
|
||||||
build ${g.bootstrap.buildDir}/.bootstrap/choosestage/obj/choosestage.a: $
|
build ${g.bootstrap.buildDir}/.bootstrap/choosestage/obj/choosestage.a: $
|
||||||
g.bootstrap.compile $
|
g.bootstrap.compile $
|
||||||
@@ -443,7 +445,7 @@ default ${g.bootstrap.BinDir}/choosestage
|
|||||||
# Variant:
|
# Variant:
|
||||||
# Type: bootstrap_core_go_binary
|
# Type: bootstrap_core_go_binary
|
||||||
# Factory: github.com/google/blueprint/bootstrap.newGoBinaryModuleFactory.func1
|
# Factory: github.com/google/blueprint/bootstrap.newGoBinaryModuleFactory.func1
|
||||||
# Defined: build/blueprint/Blueprints:132:1
|
# Defined: build/blueprint/Blueprints:133:1
|
||||||
|
|
||||||
build ${g.bootstrap.buildDir}/.bootstrap/gotestmain/obj/gotestmain.a: $
|
build ${g.bootstrap.buildDir}/.bootstrap/gotestmain/obj/gotestmain.a: $
|
||||||
g.bootstrap.compile $
|
g.bootstrap.compile $
|
||||||
@@ -467,7 +469,7 @@ default ${g.bootstrap.BinDir}/gotestmain
|
|||||||
# Variant:
|
# Variant:
|
||||||
# Type: bootstrap_core_go_binary
|
# Type: bootstrap_core_go_binary
|
||||||
# Factory: github.com/google/blueprint/bootstrap.newGoBinaryModuleFactory.func1
|
# Factory: github.com/google/blueprint/bootstrap.newGoBinaryModuleFactory.func1
|
||||||
# Defined: build/blueprint/Blueprints:137:1
|
# Defined: build/blueprint/Blueprints:138:1
|
||||||
|
|
||||||
build ${g.bootstrap.buildDir}/.bootstrap/gotestrunner/obj/gotestrunner.a: $
|
build ${g.bootstrap.buildDir}/.bootstrap/gotestrunner/obj/gotestrunner.a: $
|
||||||
g.bootstrap.compile $
|
g.bootstrap.compile $
|
||||||
@@ -491,7 +493,7 @@ default ${g.bootstrap.BinDir}/gotestrunner
|
|||||||
# Variant:
|
# Variant:
|
||||||
# Type: bootstrap_core_go_binary
|
# Type: bootstrap_core_go_binary
|
||||||
# Factory: github.com/google/blueprint/bootstrap.newGoBinaryModuleFactory.func1
|
# Factory: github.com/google/blueprint/bootstrap.newGoBinaryModuleFactory.func1
|
||||||
# Defined: build/blueprint/Blueprints:111:1
|
# Defined: build/blueprint/Blueprints:112:1
|
||||||
|
|
||||||
build ${g.bootstrap.buildDir}/.bootstrap/minibp/obj/minibp.a: $
|
build ${g.bootstrap.buildDir}/.bootstrap/minibp/obj/minibp.a: $
|
||||||
g.bootstrap.compile $
|
g.bootstrap.compile $
|
||||||
|
Reference in New Issue
Block a user