Comments (4)
Well, replacing this:
rules_android/rules/dex_desugar_aspect.bzl
Lines 46 to 61 in 2a9528b
with this workaround / hack gets it working again:
deps_list = []
for attr in _aspect_attrs():
if attr == "deps" and hasattr(ctx, "split_attr"):
deps = _utils.dedupe_split_attr(ctx.split_attr.deps)
else:
deps = getattr(ctx.attr, attr, [])
if str(type(deps)) == "list":
deps_list += deps
elif str(type(deps)) == "Target":
deps_list.append(deps)
return deps_list
but it would be good to figure out why the ordering is different and maybe address that. That'll take some more time.
from rules_android.
Yes it looks like one part of the code is looking through jars from one configuration, and trying to look up those same jars in a dict formed from jars in a another configuration.
In this code specifically:
Lines 386 to 392 in bb7b5cf
with the above repro the jar is bazel-out/k8-fastbuild-android-ST-a9ac79439181/bin/java/com/basicapp/libbasic_lib.jar
and dex_archives_dict
contains
bazel-out/k8-fastbuild-android-ST-9b738726d3a8/bin/java/com/basicapp/libbasic_lib.jar -> bazel-out/k8-fastbuild-android-ST-9b738726d3a8/bin/java/com/basicapp/_dx/basic_lib/libbasic_lib.jar.dex.zip
bazel-out/k8-fastbuild-android-ST-9b738726d3a8/bin/java/com/basicapp/_migrated/basic_lib_resources.jar -> bazel-out/k8-fastbuild-android-ST-9b738726d3a8/bin/java/com/basicapp/_dx/basic_lib/basic_lib_resources.jar.dex.zip
even though libbasic_lib.jar
is in the dict, it's from a different configuration (k8-fastbuild-android-ST-a9ac79439181
, k8-fastbuild-android-ST-9b738726d3a8
). Interestingly this does not appear to happen internally (i.e. with multiple values to --android_platforms
)....
from rules_android.
I'm pretty sure this comes down to differences in how the split transition is handled in different parts of the code.
In
Lines 93 to 94 in 2a9528b
the value for dex_archives_dict
(eventually) comes from ctx.attr.deps
:
and the value for classpath
(eventually) comes from ctx.split_attr.deps
:
dedupe_split_attr
sorts the branches of the split_attr
by key:
Line 298 in 2a9528b
while ctx.attr.deps
has a bunch of legacy behavior:
I suppose internally these just so happen to come out in the same order.
from rules_android.
I think I've gotten to the bottom of all this. This comes down to differences in which split of a split transition gets returned when the attribute that has the split transition is accessed via ctx.attr
.
Way deep in bazel there is this little sort
call:
https://github.com/bazelbuild/bazel/blob/94dcfc5739bca155922811703c95793a39b21a3a/src/main/java/com/google/devtools/build/lib/analysis/producers/PrerequisitesProducer.java#L322
Which split gets returns comes down to the mnemonic of the configuration for each split:
https://github.com/bazelbuild/bazel/blob/94dcfc5739bca155922811703c95793a39b21a3a/src/main/java/com/google/devtools/build/lib/skyframe/ConfiguredTargetAndData.java#L315
In the repro, the mnemonics look like
k8-fastbuild-android-ST-9b738726d3a8
k8-fastbuild-android-ST-a9ac79439181
The cpu is k8
in both, so the order is ending up being based on the hash -- almost arbitrary. (Had the hashes come out a little different, we might never have noticed this problem...)
Internally, they look like
arm64-v8a-fastbuild-android-ST-66eefe4ed9be
armeabi-v7a-fastbuild-android-ST-9d65607305a3
with the correct android cpu at the beginning, so that when these are sorted, they come out the same as when sorting the keys from ctx.split_attr.deps
. (This might be more coincidental than purposeful, but it works.)
The mnemonic is determined by this code over here:
https://github.com/bazelbuild/bazel/blob/94dcfc5739bca155922811703c95793a39b21a3a/src/main/java/com/google/devtools/build/lib/analysis/config/OutputPathMnemonicComputer.java#L178
And the cpu value is determined here:
https://github.com/bazelbuild/bazel/blob/94dcfc5739bca155922811703c95793a39b21a3a/src/main/java/com/google/devtools/build/lib/analysis/config/OutputPathMnemonicComputer.java#L243
And indeed in bazel coreOptions.cpu
/ --cpu
is k8
in both cases -- and so setting coreOptions.platformInOutputDir
via --experimental_platform_in_output_dir
should get the correct cpu from the platform.
However, --experimental_platform_in_output_dir
is not actually set internally -- so how is the correct cpu being set... Indeed internally coreOptions.cpu
/ --cpu
is arm64-v8a
and armeabi-v7a
for the relevant splits.... After a little more digging, the final piece is platform mappings: we have a platform mapping that sets --cpu
to the correct values.
So the expedient solution is to just set --experimental_platform_in_output_dir
. Presumably eventually that will become the default and it will all just work, but we should probably just access the deps via split_attr
to ensure the correct split is used.
from rules_android.
Related Issues (20)
- The Starlark implementaiton of process_deploy_jar fails to execute java.create_deploy_jar HOT 5
- Build fails when `--incremental_dexing` is disabled HOT 1
- Remove dependencies on --experimental_google_legacy_api and --experimental_enable_android_migration_apis HOT 1
- Can't build example basicapp HOT 5
- _copy_file and _copy_dir fail on macOS
- AAR libraries from Maven don't expose their resources unlike in built-in Android rules HOT 3
- Mobile install v3 doesn't work with --start=debug HOT 1
- Flags underneath rules/flags/ aren't working correctly HOT 1
- mobile-install fails with dependencies from rules_jvm_external HOT 6
- Unable to build with rules_android due to maven install issue HOT 2
- [Bazel CI] android_sdk_repository & android_sdk_repository_platforms_tests are failing with Bazel@HEAD HOT 1
- Bazel query broken at HEAD
- [Bazel CI] ERROR occurred during the fetch of repository 'rules_android_maven'
- APK doesn't include *.version files in metadata
- Rules use entire Android SDK dir as input instead of explicit files which may case poor cache hit HOT 1
- documentation for targets under android_sdk_repository
- Bash is not necessarily in /bin/bash
- No matching toolchains found for types @@bazel_tools//tools/android:sdk_toolchain_type even though called register_toolchains HOT 2
- [FR] Option for mobile-install command to install to all connected devices
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rules_android.