Improve error reporting when depending on prebuilt implementation jar
The sdk snapshot must not be including implementation code for boot libraries, the implementation is provided by dex jars within the corresponding APEX. However, the snapshot does need a module for each boot library so that the build can seamlessly access the dex files from the APEX. A java_library boot library (like core-oj) is represented in the snapshot by a java_import module which requires a jar file to be provided, otherwise it is disabled. However, that is provided purely to keep Soong happy and should never be used. Previously, the snapshot would contain an empty file for the jar. As an empty file is an invalid jar any tool (like compiler) that tried to consume it would fail which was the correct behavior. Unfortunately, the error message that was produced was not very helpful, it was just some variant on `invalid file` which lead to a lot of bugs being raised. This change replaces that empty file with a reference to the output from a genrule which runs a script which produces a more useful error message, with information on how to fix the issue, and fails the build. It also adds a Name() method to the SdkMemberProperties type as that is needed in AddInternalModule() to construct the name of the additional module. Tested as follows: In AOSP/master make the following changes: 1. Temporarily set visibility on core-oj and core-libart to //visibility:public. 2. Run packages/modules/common/build/mainline_modules_sdks.py to create the snapshots. For each of the S, T and latest snapshots I did the following in the s-aml-prebuilt-test, t-aml-prebuilt-test and aosp/master branches: 1. Created an Android.bp file containing the following: java_library { name: "broken", static_libs: [ "prebuilt_core-libart", "prebuilt_core-oj", ], } 2. Fix the visibility issues and run `m broken` where it fails with an invalid file. 3. Delete the contents of the prebuilts/module_sdk/art/current/sdk directory. 4. Unpack the relevant version of the art-module-sdk snapshot into the directory. 5. Run `m broken` where it fails with the helpful message. 6. Test the instructions on how to use the ninja -t path tool to identify the cause of the problem and fix it. Bug: 257969510 Test: See above. Change-Id: I125bde2d7202afff84c97daebcef37e21c548a3a
Loading
Please register or sign in to comment