Paul Duffin | c61783b | 2022-10-20 17:21:40 +0100 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
| 3 | # Copyright 2022 Google Inc. All rights reserved. |
| 4 | # |
| 5 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | # you may not use this file except in compliance with the License. |
| 7 | # You may obtain a copy of the License at |
| 8 | # |
| 9 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | # |
| 11 | # Unless required by applicable law or agreed to in writing, software |
| 12 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | # See the License for the specific language governing permissions and |
| 15 | # limitations under the License. |
| 16 | |
| 17 | # Script to detect and report an attempt to access an invalid implementation |
| 18 | # jar. |
| 19 | |
| 20 | MOD=$1 |
| 21 | |
| 22 | cat <<EOF |
| 23 | |
| 24 | $MOD is a java_library that generates a jar file which must not be accessed |
| 25 | from outside the mainline module that provides it. If you are seeing this |
| 26 | message it means that you are incorrectly attempting to use the jar file |
| 27 | from a java_import prebuilt of $MOD. |
| 28 | |
| 29 | This is most likely due to an incorrect dependency on $MOD in an Android.mk |
| 30 | or Android.bp file. Please remove that dependency and replace with |
| 31 | something more appropriate, e.g. a dependency on an API provided by the |
| 32 | module. |
| 33 | |
| 34 | If you do not know where the extraneous dependency was added then you can |
| 35 | run the following command to find a list of all the paths from the target |
| 36 | which you are trying to build to the target which produced this error. |
| 37 | |
| 38 | prebuilts/build-tools/linux-x86/bin/ninja -f out/combined-\${TARGET_PRODUCT}.ninja -t path <target> <invalid-jar> |
| 39 | |
| 40 | Where <target> is the build target you specified on the command line which |
| 41 | produces this error and <invalid-jar> is the rule that failed with this |
| 42 | message. If you are specifying multiple build targets then you will need to |
| 43 | run the above command for every target until you find the cause. |
| 44 | |
| 45 | The command will output one (of the possibly many) dependency paths from |
| 46 | <target> to <invalid-jar>, one file/phony target per line. e.g. it may |
| 47 | output something like this: |
| 48 | |
| 49 | .... |
| 50 | out/soong/.intermediates/acme/broken/android_common/combined/broken.jar |
| 51 | out/soong/.intermediates/prebuilts/module_sdk/art/current/sdk/prebuilt_core-libart/android_common/combined/core-libart.jar |
| 52 | out/soong/.intermediates/prebuilts/module_sdk/art/current/sdk/art-module-sdk_core-libart-error/gen/this-file-will-never-be-created.jar |
| 53 | |
| 54 | The last line is the failing target, the second to last line is a dependency |
| 55 | from the core-libart java_import onto the failing target, the third to last |
| 56 | line is the source of the dependency so you should look in acme/Android.bp |
| 57 | file for the "broken" module. |
| 58 | |
| 59 | EOF |
| 60 | |
| 61 | exit 1 |