Commit graph

18 commits

Author SHA1 Message Date
Cole Faust
da9770eb67 Show load cycles when running mk2rbc
Previously, if there was a cycle of load statements,
mk2rbc would exit with status code 1 but not give
any message indicating what went wrong.

Bug: 226974242
Test: Manually
Change-Id: I7d30cad08bd3abcd761b5f28a63a2cc66b45e805
2022-04-27 15:13:47 -07:00
Cole Faust
9b6111aaed Remove --root, require the cwd to be the root
This allows us to use relative paths everywhere.
It also produces more accurate emulation of TOPDIR,
which should be an empty string.

Bug: 213508006
Test: go test
Change-Id: Ie4e357687486e84e9f4aad0f6776d8feb2b9fc63
2022-02-07 11:45:01 -08:00
Cole Faust
8d47c48082 Use soong's finder to find included makefiles in mk2rbc
Having soong generate a list of makefiles for mk2rbc
to look through is much faster than having mk2rbc search
itself. Profiling the readLinesFromeFile() function that
reads the list of makefiles shows it takes on the order
of 200 microseconds, much faster than the ~5 seconds
it takes for mk2rbc to search the tree itself.

This CL also allows include statements that are prefixed
with a variable. The concern with this was that there
would be a lot of load statemnts emitted for generic
include statements, causing the generated code to look
ugly, and converting and loading all those files could
cause performance issues. On the performance issues
front, there's already a check that it doesn't result
in over 150 potentially included files. We can lower
that number if necessary, but it's probably good for now.
On the generated code front, while it's true that it's
ugly, it's better to have working but ugly generated
code than refusing to generate anything working at all.

To ensure the soong finder step isn't slowed down due
to having to find a bunch of new makefiles, I profiled
the combination of newSourceFinder and FindSources in main.go:

Baseline incremental:
338.011634ms
340.853335ms
348.541762ms
333.229644ms
349.124824ms

Baseline clean:
1.003836419s
1.006203912s
996.193648ms
1.031005604s
1.03691152s

Modified incremental:
349.029285ms
349.264496ms
351.774948ms
337.63187ms
359.425306ms

Modified clean:
1.028238704s
1.053103506s
1.032757506s
1.016631201s
1.04288108s

So we can see the times are barely affected by this change.

Fixes: 213508006
Test: go test
Change-Id: Iab18bfb127ba3b7e63f2c01f69064805a8398764
2022-02-07 11:41:28 -08:00
Cole Faust
864028a71b Support passing input variables to the product configuration
Since rblf_env / rblf_cli are not typed properly, accept
input variables via a file so that they can be converted
with the correct types.

Bug: 201700692
Test: go test
Change-Id: I9b56067cfe396d1bcd8d62c353ff222dd61a6c9f
2021-12-02 16:19:19 -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
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
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
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
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
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
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
b2ac859a69 Options processing: remove redundant check
Bug: 172923994
Test: N/A
Change-Id: I2b07c775f8e3cad78eb6992d3522bef3a9b701b8
2021-07-26 11:12:04 -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