Some functions are called without the use of $(call),
since $(call) is not necessary when the function doesn't
take any arguments. mk2rbc thinks these function calls
are local variables, and converts them as such. This
leads to undefined variable errors when trying to load
(before even executing) the starlark file.
Hardcode a known function that should not be converted
to a local variable.
Bug: 226974242
Test: go test
Change-Id: I5567a34fcc282b181a7e78ac3d5cc9b40bd025a2
This allows the parsing code to be cleaner, as it
doesn't have to care about variable assignments.
Bug: 228518745
Test: go test
Change-Id: I33425c2fb51acab4901bfa82a53d337b75210f8e
While supporting $(eval) in the general case is
impossible, as it would require emitting code at
runtime, it is possible to handle some special cases
that are common throughout the code base.
Specifically, an assignement expression (where the
left hand side is constant) can be converted without
needing to evaluate strings as code, as its whole
right hand side is treated as one string.
However, this eval with an assignemnt can only be
used as a statement, not an expression. So it requires
the eval to be either a top-level expression, or nested
within other expressions that can be converted to
statements such as $(foreach) or $(if).
Bug: 226974242
Test: go test
Change-Id: Ifc52ef9ab7d62a69251918fcde5463f80a98a542
VariableDefinedExpr was under-developed, and would not
take into account if a variable was from the globals
or product config dictionary.
It also always emitted `g.get("VARIABLE") != None`, which
is not correct behavior. In this example makefile:
```
MY_VAR :=
ifdef MY_VAR
$(info MY_VAR is defined)
else
$(info MY_VAR is not defined)
endif
ifdef MY_UNDEFINED_VAR
$(info MY_UNDEFINED_VAR is defined)
else
$(info MY_UNDEFINED_VAR is not defined)
endif
MY_VAR ?= true
MY_UNDEFINED_VAR ?= true
$(info MY_VAR after ?= is $(MY_VAR))
$(info MY_UNDEFINED_VAR after ?= is $(MY_UNDEFINED_VAR))
.PHONY: all
all:
@:
```
We get the output:
MY_VAR is not defined
MY_UNDEFINED_VAR is not defined
MY_VAR after ?= is
MY_UNDEFINED_VAR after ?= is true
So we can see that even if a variable was set, it's considered
not defined if it was set to an empty value. However, ?= works
differently, and does require the != None, so that was left
as is.
Just use a variableRefExpr and rely on the fact
that variables will be truthy if they're defined.
Fixes: 216700361
Test: go test
Change-Id: If8944da2579e8658e3fc4f666b1f3b2815f8c8b1
Converts the following functions from build/make/common/math.mk:
- math_max
- math_min
- math_gt_or_eq
- math_gt
- math_lt
Fixes: 213497955
Test: go test
Change-Id: I8c4e8fee321f03b813428fa10038fa8f06188cef
By having knownFunctions contain parsing interfaces
instead of just metadata about the function, we can
remove some hardcoded special cases.
Bug: 201700692
Test: go test
Change-Id: I1723c7f50b72d42b03380e999aa9601b455a969e
It was only used to substitute variable references to
predefined variables with the predefined value, which
is an easy condition to directly parse into instead
of having a separate evalutation pass.
Bug: 201700692
Test: go test
Change-Id: I543d20a1d6435bfabd9faa90ffb09af3084ed28c
If a boolean type is compared to a string literal with
the value "true", it should just output that boolean
type unchanged (or prefixed with "not" if ifneq).
Fixes: 206637085
Test: go test
Change-Id: I0c116bb68b96d21ba3783c01fc4ca524aaa04143
Instead of inserting a comment with error description into the generated code,
generate a call to a function that will print out a conversion error when executed.
Do not print generic "partially converted" message anymore.
Remove --verbose and --no_warnings options.
Bug: 204062171
Test: internal
Change-Id: Ib126e16dc76f49635e4939e670922f2561781049
Previously, only comparisons between strings/variable references
and other strings/variable references or certain function calls
were allowed. After this cl, any two starlark expressions can
be compared. If they have different types, they will be converted
to strings first.
Fixes: 205995738
Bug: 201700692
Test: go test
Change-Id: Ib463de7b24d3abcd032dbdcba7c3f1351c314d01