Search code examples
c++bazel

How incremental is cc_library in bazel


In bazel documentation (https://docs.bazel.build/versions/master/cpp-use-cases.html) there's an example like this:

cc_library(
   name = "build-all-the-files",
   srcs = glob(["*.cc"])
   hdrs = glob(["*.h"]),
)

How incremental it is? I.e. if I change only one of the *.cc files, will it rebuild the whole target or only what's required?


Solution

  • It will just recompile the modified file. Bazel will then link the library if the object file changes (so if you just change a comment, it may skip the link step).

    You still have doubts? Add the flag -s when you build and you will see what Bazel actually runs.