NOTE: The functionality for this repository has moved to cgrindel/bazel-starlib.
This repository contains Bazel rules and macros that copy files from the Bazel output directories to the workspace directory.
Have you ever wanted to copy the output of a Bazel build step to your source directory (e.g., generated documentation, formatted source files)? Instead of recreating the logic to perform this trick in every Bazel project, try using the updatesrc_update rule and the updatesrc_update_all macro.
The following provides a quick introduction on how to use the rules in this repository. Also, check out the documentation and the examples for more information.
Add the following to your WORKSPACE
file to add this repository and its dependencies.
http_archive(
name = "cgrindel_rules_updatesrc",
sha256 = "18eb6620ac4684c2bc722b8fe447dfaba76f73d73e2dfcaf837f542379ed9bc3",
strip_prefix = "rules_updatesrc-0.1.0",
urls = ["https://github.com/cgrindel/rules_updatesrc/archive/v0.1.0.tar.gz"],
)
load(
"@cgrindel_rules_updatesrc//updatesrc:deps.bzl",
"updatesrc_rules_dependencies",
)
updatesrc_rules_dependencies()
At the root of your workspace, create a BUILD.bazel
file, if you don't have one. Add the
following:
load(
"@cgrindel_rules_updatesrc//updatesrc:updatesrc.bzl",
"updatesrc_update_all",
)
# Define a runnable target to execute all of the updatesrc_update targets
# that are defined in your workspace.
updatesrc_update_all(
name = "update_all",
)
In every Bazel package that contains source files that should be updated from build output, add a updatesrc_update declaration. For more information on how to configure the declaration check out the documentation and the examples.
load(
"@cgrindel_rules_updatesrc//updatesrc:updatesrc.bzl",
"updatesrc_update",
)
updatesrc_update(
name = "update",
# ...
)
To execute all of the updatesrc_update targets, run the update all target at the root of your workspace.
$ bazel run //:update_all
- How to Use
rules_updatesrc
- Check out the examples
- Peruse the documentation