Commit graph

150 commits

Author SHA1 Message Date
Cole Faust
f1f44d3d21 Simplify equality expressions when comparing to "true"
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
2021-11-18 10:15:26 -08:00
Sasha Smundak
422b614355 Generate runtime conversion diagnostics
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
2021-11-18 10:01:37 -08:00
Sasha Smundak
d679785d0d Convert dist-for-goals.
Bug: 198496782
Test: internal
Change-Id: I64ae938a5809238c18aca272ba73e4328fcb9efe
2021-11-18 10:01:37 -08:00
Cole Faust
f83202143a Allow generic if statements
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
2021-11-15 11:29:29 -08:00
Cole Faust
80374405df Merge "Make handleSimpleStatement also handle if statements" 2021-11-12 19:01:41 +00:00
Sasha Smundak
7d934b9c47 Display diagnostic message for each conversion error.
Also, use better names for the error handling entities.

Bug: 204062171
Test: manual
Change-Id: I65869120ed08fc40d9ec6267c882e53aaedde9ed
2021-11-11 15:14:20 -08:00
Treehugger Robot
2a8105d19e Merge "Flag 'override' directives." 2021-11-11 03:17:11 +00:00
Cole Faust
591a1fe158 Make handleSimpleStatement also handle if statements
This simplifies its usage, as it can now handle
virtually any Make node.

Bug: 201700692
Test: go test
Change-Id: I1786a441a706304673ea4a2973a21f93b95b945a
2021-11-10 15:09:39 -08:00
Cole Faust
f8ff9cf68c Merge "Enable mk2rbc warnings/errors by default" 2021-11-10 21:29:26 +00:00
Sasha Smundak
ea3bc3a953 Flag 'override' directives.
Bug: 201087531
Test: internal
Change-Id: I2e08b126d769b1595172b04a3539e99b3e72cb2b
2021-11-10 13:19:01 -08:00
Cole Faust
18e7785f26 Merge "Translate soong_config_get calls to rbc" 2021-11-10 19:46:48 +00:00
Cole Faust
17cecd7b17 Enable mk2rbc warnings/errors by default
Since we are going to be asking partners to start
ensuring that their makefiles work with mk2rbc,
enable warnings by default so they're more visible.
Otherwise, the conversion could appear to succeed
but have some subtle failures.

Bug: 204062171
Test: Manually
Change-Id: I38189031d7357bb3f2c811de90f2821cde10cbcd
2021-11-08 15:21:20 -08:00
Cole Faust
c00184e2d7 Translate soong_config_get calls to rbc
Bug: 201700692
Test: go test
Change-Id: I3621396c048d4a46c1b12342e884709a13eb2b79
2021-11-08 15:10:18 -08:00
Sasha Smundak
35434ed55a Allow non-constant from/to arguments in subst and patsubst
Fixes: 198502623
Test: internal
Change-Id: Ia41a5a2e9315fcce351691749ac15de5df6916a4
2021-11-05 16:30:17 -07:00
Sasha Smundak
c4fa93e76a Handle ifdef for local variables.
Fixes: 205337522
Test: internal
Change-Id: Ib29654e76e8dc7c0982bfe0b471a1aca33935117
2021-11-05 14:42:41 -07:00
Alexander Smundak
d8b1998990 Merge "Fix: negate the condition for is-vendor-board-qcom" 2021-11-05 21:30:58 +00:00
Sasha Smundak
4f1f118a8d Fix: negate the condition for is-vendor-board-qcom
Bug: 193540681
Test: internal
Change-Id: Ia4087574f7cbcd5282687234892314c9a5fcc174
2021-11-05 08:45:49 -07:00
Cole Faust
6ed7cb493d Generate board-specific launchers in mk2rbc
Board config works slightly differently from product config.
It requires the product config variables to be passed into
it. Currently the only generic way to pass info into an RBC
script is via the arguments to rbcrun, which get passed
as global variables, not the product (cfg) variables.
Add a new form of launcher that reads the product variables
from a separate rbc file that is generated in make.

The board configuration also doesn't need inheritance, so it
doesn't call rblf.product_configuration() either.

Bug: 201700692
Test: build/bazel/ci/rbc_product_config.sh -b sdk_phone_x86_64-userdebug
Change-Id: I52fd65b33cf99b45a563284e2849da75a8af8688
2021-11-04 16:19:41 -07:00
Treehugger Robot
c9e85ca825 Merge "Make a pass over our codebase cleaning up non-precise / non-inclusive language." 2021-10-28 20:51:17 +00:00
Joe Onorato
b4638c1ac3 Make a pass over our codebase cleaning up non-precise / non-inclusive language.
Test: treehugger
Bug: 204369779
Change-Id: I6e63cae824d323535cdb14b493edd868df47738d
2021-10-28 10:32:07 -07:00
Sasha Smundak
3a9b8e8943 Convert is-board-platform2/is-board-platform-in-list2/is-vendor-board-qcom macros.
Bug: 193540681
Test: internal
Change-Id: I76c46d89f10b16b75438803479fec4aa468e3010
2021-10-27 11:23:29 -07:00
Sasha Smundak
2afb9d7722 Fix how the rule is displayed in the error message.
Bug: 204001941
Test: internal
Change-Id: I19c73356cc305ec7a6dfd3bddbde775ef9ca4953
2021-10-27 10:56:47 -07:00
Sasha Smundak
6d852dd16a Implement include path annotation.
Include top annotation is a specially formatted comment line providing
the include/inhherit file location hint. E.g., adding
```
```
before
```
$(call inherit-product $(SRC)/foo.mk
```
is a hint to the converter to look for the `foo.mk` files under
`vendor/my_vendor/` in addition to `vendor/google_devices/'

Bug: 193566316
Test: internal
Change-Id: I01c5dde2504f1a9eb724098b1cc03d2176ca2cf9
2021-10-27 10:56:47 -07:00
Sasha Smundak
65b547edc2 Better Soong config namespace support.
Old macros (`add_soong_config/namespace` & `add_soong_config_var_value`) are
going away, to be replaced with `soong_config_set`. A new macro,
`soong_config_append` is added to append to the existing value.
Also, flag the attempts to reference the values of the variables in the
Soong config namespace.

Bug: 200297238
Test: internal
Change-Id: Idb6a31632db75d7faef038b83e6a86d9dcf1e736
2021-10-27 10:56:46 -07:00
Cole Faust
984272b169 Sort codenames in version_defaults.rbc
Without the sort, the codenames were appearing in a random order.
This was causing `go test` to flake.

Test: go test
Change-Id: Ieeb0677503d1521dc4b1aead09ea1ab7ea38b2ea
2021-10-21 15:01:56 -07:00
Sasha Smundak
5f463be4a9 Fix wildcard ('%') handling in the filter pattern.
Fixes: 200094780
Test: internal
Change-Id: I5f6a46679cdfa965ad98b9c0c22ef396a13a0bf6
2021-10-06 09:38:22 -07:00
Cole Faust
ebf79bfb4a Remove mk2rbc's support for using a product name
Now that the product and board config pass makefiles
to mk2rbc, we don't need to support passing a product
name.

Bug: 201700692
Test: Manually
Change-Id: I787f0f98bc5ab3cefeefb7af8d342aba84769925
2021-10-05 11:05:02 -07:00
Cole Faust
07ea503ab3 Make mk2rbc accept either a makefile or product
The current behavior of mk2rbc is that it can accept either
a makefile to convert, or if it's also generating a launcher,
it must accept a product name instead of a makefile.

For board configuration, we need to convert a specific makefile,
but we also want to generate a launcher. Change mk2rbc so that
its non-flag arguments can be either makefiles or product names.

Bug: 201700692
Test: ./build/bazel/ci/rbc_product_config.sh aosp_arm64-userdebug
      with board config changes patched in
Change-Id: I521e31fe0bdc608b8f26c9aa803ca690dd1c538e
2021-10-04 18:09:48 +00:00
Sasha Smundak
868c5e3ab2 Emit unconditional module load only when inherit/include is on the top level.
That is, when a makefile contains
```
ifneq (,$(foo))
  $(call inherit-product,module.mk)
endif
```

module.mk has to be present only if `foo` is set.

Fixes: 200163602
Test: internal
Change-Id: Ic5f10ce8d49d6b87162bfe77922bba5e2cce228b
2021-09-27 10:02:41 -07:00
Sasha Smundak
d7d07ad0b4 Share version settings with product config makefile.
Generate version settings from build/make/core/version_defaults.mk.
The generated settings are then loaded into the launcher code and passed
to the environment setup code.

Bug: 198995713
Test: internal
Change-Id: I66131d2c5b232784a9ff0bba9fbd5db62302aaba
2021-09-13 09:23:05 -07:00
Sasha Smundak
70f1745f3e Look for the AndroidProduct.mk files in the vendor/ hierarchy, too
Bug: 182418325
Test: N/A
Change-Id: I17048b5fda3ac83ca7c2b359abe94ab5ced91511
2021-09-02 09:34:47 -07:00
Sasha Smundak
468e11fbbe Additional heuristics: variables with names ending with _LIST are lists
Bug: 193540681
Test: internal
Change-Id: Ic23bf0f0eadb159285650f0b7e20307788c12387
2021-09-02 09:34:47 -07:00
Bob Badour
36dc7c60b5 [LSC] Add LOCAL_LICENSE_KINDS to build/soong
Added SPDX-license-identifier-Apache-2.0 to:
  java/core-libraries/Android.bp
  mk2rbc/Android.bp

Bug: 68860345
Bug: 151177513
Bug: 151953481

Test: m all

Exempt-From-Owner-Approval: janitorial work
Change-Id: Iaf8546fc945b04b71cd5cb1c7c16a9e15f608d02
2021-08-27 13:30:35 -07:00
Sasha Smundak
0445308bc3 Support product-copy-files-by-pattern macro
Bug: 193566316
Test: internal
Change-Id: I5ffdbaee231669166aaa3f40f84ecac8f571f981
2021-08-17 18:15:03 -07:00
Sasha Smundak
02183cfc53 Most of the TARGET_COPY_OUT_xxx variables are not constant
Bug: 193566316
Test: internal
Change-Id: I484a88de933904a2ac2e36084509838d7a85262c
2021-08-16 13:39:48 -07:00
Sasha Smundak
90be8c5589 Improve dynamic inherit paths handling
Allow up to 150 inherited paths matching the pattern.
When seeing `include $(BOARD_CONFIG_VENDOR_PATH)/BoardConfigVendor.mk`,
search only vendor/google_devices

Bug: 193566316
Test: internal
Change-Id: Ic88cb116075512f87d5a5f7a7f32dabd09ff640c
2021-08-03 11:06:54 -07:00
Sasha Smundak
3deb968aef Translate copy-files, add_soong_config_namespace and add_soong_config_var_value macros
Bug: 194521362
Test: internal

Change-Id: I88fb62f057476d96dfb056813a900e8497e7bbb9
2021-08-03 11:06:54 -07:00
Sasha Smundak
16e0773e7f Translate more Make builtin functions
Adds support for abspath/firstword/dir/lastword/notdir functions

Bug: 194521362
Test: internal
Change-Id: I34dd6a81f21a4ef2f8f0a72bd80284ced8957b5c
2021-08-02 15:13:59 -07:00
Sasha Smundak
6609ba7664 Allow dynamically calculated inherit-product path
Bug: 193566316
Test: internal
Change-Id: Iaa7b68cf459f9a694ae9d37a32c9372cf8a8335a
2021-08-02 14:35:45 -07:00
Sasha Smundak
3880279a0c Add an option to gather CPU profile.
Bug: 172923994
Test: internal
Change-Id: I43e6121855e909eaca2204a811f12174fb8b6b5f
2021-08-01 14:46:56 -07:00
Sasha Smundak
0554d760fb Allow $(filter ...) with arbitrary args if its result is compared to the empty string
Bug: 172923994
Test: internal
Change-Id: Iea36ecaa8940cf4e495ad63125f10d733c3eb2ee
2021-08-01 14:41:03 -07:00
Sasha Smundak
f2c9f8bc14 Fix null pointer exception on error
Bug: 172923994
Test: internal
Change-Id: I21f60e5f386214216e10a51c22247814ca2f2347
2021-07-27 14:40:23 -07:00
Sasha Smundak
b2ac859a69 Options processing: remove redundant check
Bug: 172923994
Test: N/A
Change-Id: I2b07c775f8e3cad78eb6992d3522bef3a9b701b8
2021-07-26 11:12:04 -07:00
Sasha Smundak
f3e072a87e Do not flag as error 'define' directives for the known macros
Bug: 172923994
Test: internal
Change-Id: I4a562ccc1d14bd7d4e8a638823a62d775b056742
2021-07-26 11:12:04 -07:00
Sasha Smundak
94b41c76da Emit mkpatsubst call for $(patsubst ...)
Bug: 172923994
Test: internal
Change-Id: I19f0e104d253230e603a098605736ac36e65818e
2021-07-26 11:12:04 -07:00
Sasha Smundak
9d011abcd5 Emit mksubst call for $(subst ...)
Bug: 172923994
Test: internal
Change-Id: I7994bee61f6f8bdee6eac50ecb8a6064830447a4
2021-07-26 10:25:43 -07:00
Sasha Smundak
b051c4ede3 Product config makefiles to Starlark converter
Test: treehugger; internal tests in mk2rbc_test.go
Bug: 172923994
Change-Id: I43120b9c181ef2b8d9453e743233811b0fec268b
2021-07-14 09:51:10 -07:00
Sasha Smundak
985d56c2ba AndroidProducts.mk file reader
Fixes: 182418325
Test: go test android_products_test.go
Change-Id: Ibb6c4aedacb891d5d7e74ce351b2e19c888adc5d
2021-07-12 09:40:18 -07:00
Sasha Smundak
1471eb2a8f Soong variables reader
Test: go test soong_variables_test.go
Bug: 182395579
Change-Id: I54af165455a7c3de826bf34db6ab88a05e15ca21
2021-07-12 09:40:18 -07:00
Sasha Smundak
472afabf95 Config variables reader
Fixes: 182330871
Test: go test config_variables_test.go
Change-Id: I89240fb0f1900172cb4d62057c86907bb9a1f58f
2021-07-12 09:40:18 -07:00