{"id":20132532,"url":"https://github.com/aherrmann/bazel-transitions-demo","last_synced_at":"2025-03-02T22:18:27.292Z","repository":{"id":71967611,"uuid":"351366000","full_name":"aherrmann/bazel-transitions-demo","owner":"aherrmann","description":null,"archived":false,"fork":false,"pushed_at":"2022-03-02T14:18:46.000Z","size":6,"stargazers_count":9,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-01-13T09:10:07.179Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Starlark","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/aherrmann.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"open_collective":"bazel-rules-authors-sig"}},"created_at":"2021-03-25T08:45:58.000Z","updated_at":"2024-07-10T13:51:17.000Z","dependencies_parsed_at":"2023-09-13T18:49:06.780Z","dependency_job_id":null,"html_url":"https://github.com/aherrmann/bazel-transitions-demo","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aherrmann%2Fbazel-transitions-demo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aherrmann%2Fbazel-transitions-demo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aherrmann%2Fbazel-transitions-demo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aherrmann%2Fbazel-transitions-demo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/aherrmann","download_url":"https://codeload.github.com/aherrmann/bazel-transitions-demo/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241577159,"owners_count":19984950,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-13T20:53:56.052Z","updated_at":"2025-03-02T22:18:27.263Z","avatar_url":"https://github.com/aherrmann.png","language":"Starlark","funding_links":["https://opencollective.com/bazel-rules-authors-sig"],"categories":[],"sub_categories":[],"readme":"# Demo of Bazel's configuration transitions\n\n## Configuration flags\n\nBuild and run the default configuration:\n\n```\n$ bazel run //app:bin\nUsing community edition\nData file: COMMUNITY\n```\n\nSpecify the configuration on the command line:\n\n```\n$ bazel run //app:bin --//flag:edition=enterprise\nUsing enterprise edition\nData file: ENTERPRISE\n```\n\n## Configuration transitions\n\nThe following targets use configuration transitions to pin a particular\nconfiguration regardless of any command line flags:\n\n```\n$ bazel run //app:bin-ce\nUsing community edition\nData file: COMMUNITY\n\n$ bazel run //app:bin-ee\nUsing enterprise edition\nData file: ENTERPRISE\n```\n\nThe following uses configuration transitions to generate a test-suite over all\nconfigurations:\n\n```\n$ bazel test //app:test-all\n//app:test-all_test_community    PASSED in 0.0s\n//app:test-all_test_enterprise   PASSED in 0.0s\n```\n\n## Bundling multiple configurations\n\nThe following uses configuration transitions and careful combinations of the\n`pkg_tar` rule to bundle multiple configurations into one artifact.\n\n```\n$ bazel build //app:bundle-all\nTarget //app:bundle-all up-to-date:\n  bazel-bin/app/bundle-all.tar\n$ tar tvf bazel-bin/app/bundle-all.tar\ndrwxr-xr-x 0/0               0 2000-01-01 01:00 ./\ndrwxr-xr-x 0/0               0 2000-01-01 01:00 ./community/\n-r-xr-xr-x 0/0          117016 2000-01-01 01:00 ./community/bin\n-r-xr-xr-x 0/0              10 2000-01-01 01:00 ./community/data.txt\ndrwxr-xr-x 0/0               0 2000-01-01 01:00 ./community/bin.runfiles/\ndrwxr-xr-x 0/0               0 2000-01-01 01:00 ./community/bin.runfiles/transitions-demo/\ndrwxr-xr-x 0/0               0 2000-01-01 01:00 ./community/bin.runfiles/transitions-demo/app/\nlrwxr-xr-x 0/0               0 2000-01-01 01:00 ./community/bin.runfiles/transitions-demo/app/data.txt -\u003e ../../../data.txt\ndrwxr-xr-x 0/0               0 2000-01-01 01:00 ./enterprise/\n-r-xr-xr-x 0/0          117024 2000-01-01 01:00 ./enterprise/bin\n-r-xr-xr-x 0/0              11 2000-01-01 01:00 ./enterprise/data.txt\ndrwxr-xr-x 0/0               0 2000-01-01 01:00 ./enterprise/bin.runfiles/\ndrwxr-xr-x 0/0               0 2000-01-01 01:00 ./enterprise/bin.runfiles/transitions-demo/\ndrwxr-xr-x 0/0               0 2000-01-01 01:00 ./enterprise/bin.runfiles/transitions-demo/app/\nlrwxr-xr-x 0/0               0 2000-01-01 01:00 ./enterprise/bin.runfiles/transitions-demo/app/data.txt -\u003e ../../../data.txt\n```\n\n## Gotchas\n\nCombining different configurations of the same target requires some care. It is\npossible to cause collisions when combining such targets in one rule.\n\n```\n$ bazel build //app:gotcha\nINFO: From Writing: bazel-out/k8-fastbuild/bin/app/gotcha.tar:\nDuplicate file in archive: ./bin, picking first occurrence\nDuplicate file in archive: ./data.txt, picking first occurrence\nTarget //app:gotcha up-to-date:\n  bazel-bin/app/gotcha.tar\n$ tar tvf bazel-bin/app/gotcha.tar\ndrwxr-xr-x 0/0               0 2000-01-01 01:00 ./\n-r-xr-xr-x 0/0          117016 2000-01-01 01:00 ./bin-ce\n-r-xr-xr-x 0/0          117016 2000-01-01 01:00 ./bin\n-r-xr-xr-x 0/0              10 2000-01-01 01:00 ./data.txt\n-r-xr-xr-x 0/0          117024 2000-01-01 01:00 ./bin-ee\n```\n\nThis caused a collision in the files `bin` and `data.txt`. The resulting\nartifact will only contain one of the configurations.\n\n## Build definitions\n\nTake a look at [`app/BUILD.bazel`](./app/BUILD.bazel) to see the definitions of\nthe targets above. Take a look at [`flag/defs.bzl`](./flag/defs.bzl) for the\nimplementation.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faherrmann%2Fbazel-transitions-demo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faherrmann%2Fbazel-transitions-demo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faherrmann%2Fbazel-transitions-demo/lists"}