Coder Social home page Coder Social logo

bazel-configuration-rebuild's Introduction

Duplicate Builds with Configuration Transitions

The target //:cat is independent of the user defined build flag //:flag. The target //:flag_cat on the other hand depends on the value of the flag and on //:cat as well.

The target //:cat is only built once, and cached under the same action cache key, if the configuration is set via command-line flag.

$ bazel clean --expunge; bazel build //:flag_cat --disk_cache=.cache/default --build_event_publish_all_actions --build_event_json_file=default.json

$ bazel clean --expunge; bazel build //:flag_cat --//:flag=different_flag --disk_cache=.cache/different --build_event_publish_all_actions --build_event_json_file=different.json

$ jq 'select(.id.actionCompleted.label == "//:cat")' <default.json | jq -s length
1

$ jq 'select(.id.actionCompleted.label == "//:cat")' <different.json | jq -s length
1

$ rg 'bin/cat.txt' .cache/*/ac
.cache/default/ac/b9/b966d571c54c4aa37fc5ae7629f95caaa01ad79474fdc406c9e9a79341c950f6
2:"bazel-out/k8-fastbuild/bin/cat.txtD

.cache/different/ac/b9/b966d571c54c4aa37fc5ae7629f95caaa01ad79474fdc406c9e9a79341c950f6
2:"bazel-out/k8-fastbuild/bin/cat.txtD

The targets //:transition_default and //:transition_different use a configuration transition to set the value of the build setting //:flag to "default_flag" and "different_flag" respectively.

The target //:cat is built twice and cached under different action cache keys when building these transition targets, even though //:cat does not depend on the build setting.

$ bazel clean --expunge; bazel build //:transition_default //:transition_different --disk_cache=.cache/transition --build_event_publish_all_actions --build_event_json_file=transition.json

$ jq 'select(.id.actionCompleted.label == "//:cat")' <transition.json | jq -s length
2

$ rg 'bin/cat.txt' .cache/transition/ac
.cache/transition/ac/b9/b966d571c54c4aa37fc5ae7629f95caaa01ad79474fdc406c9e9a79341c950f6
2:"bazel-out/k8-fastbuild/bin/cat.txtD

.cache/transition/ac/8a/8a979615135482bd13afbdf6004d5c87c0a5f3427bcedc299f496eeff4946e29
2:2bazel-out/k8-fastbuild-ST-1d73fa6ab729/bin/cat.txtD

bazel-configuration-rebuild's People

Contributors

aherrmann avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.