Skip to content

Add sample app to tests how many targets were rebuilt #840

Merged
restingbull merged 4 commits intobazel-contrib:masterfrom
nkoroste:nk-deps_sample_app_upsteam
Dec 17, 2022
Merged

Add sample app to tests how many targets were rebuilt #840
restingbull merged 4 commits intobazel-contrib:masterfrom
nkoroste:nk-deps_sample_app_upsteam

Conversation

@nkoroste
Copy link
Copy Markdown
Collaborator

@nkoroste nkoroste commented Oct 5, 2022

This folder contains simple libraries that depends on each other (lib1->lib2->lib3->lib4) for multiple type : java, android, kt, kt android. The purpose is to test compilation avoidance for project following strict deps: in this case, we want ABI changes to leaf library (lib4) to recompilation only lib4, and direct consumer (lib3).

To compile a given library type :

  • bazel build libJava1:src_main for regular java jvm lib
  • bazel build liblibAndroid1Java1:src_main for regular java android lib
  • bazel build libKt1:src_main for regular kotlin jvm lib
  • bazel build libKtAndroid1:src_main libKtAndroid1:src_main_kt for android kotlin lib

For convenience, a simple script 'run.sh' is also provided, which performs an incremental build on all library type after applying an ABI change to all leaves, and output the # of targets that got rebuilt for each library type. This currently output a value of 4 for all types, while we ideally want a value of 2.

Current output without any strict deps optimizations:
cd examples/deps && ./run.sh

Rebuilt libjava targets: 4
Rebuilt libandroid targets: 4
Rebuilt libkt targets: 4
Rebuilt libktandroid targets: 4
Rebuilt libandroid res-only targets: 4
Rebuilt libktandroid res-only targets: 4

@nkoroste nkoroste force-pushed the nk-deps_sample_app_upsteam branch from b5c38dd to e83a422 Compare November 1, 2022 19:52
@nkoroste
Copy link
Copy Markdown
Collaborator Author

nkoroste commented Nov 1, 2022

Rebased against latest master to see if it fixes CI

Comment thread examples/deps/run.sh
@restingbull restingbull merged commit b06bb9e into bazel-contrib:master Dec 17, 2022
nkoroste added a commit that referenced this pull request Sep 29, 2023
Defines `--@io_bazel_rules_kotlin//kotlin/settings:experimental_prune_transitive_deps=True` that will allow you to make java and android to only use direct dependancies when compiling a given target. This significantly speeds up incremental compilations at the cost of adding explicit deps to all targets. 

Relates to bazelbuild/bazel#16426

Can be tested with #840 which will produce the following expected output:
```
cd examples/deps && ./run.sh --@io_bazel_rules_kotlin//kotlin/settings:experimental_prune_transitive_deps=True

Rebuilt libjava targets: 4
Rebuilt libandroid targets: 4
Rebuilt libkt targets: 2
Rebuilt libktandroid targets: 2
Rebuilt libandroid res-only targets: 4
Rebuilt libktandroid res-only targets: 4
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants