{"id":20563247,"url":"https://github.com/gazebosim/gz-bazel","last_synced_at":"2025-04-14T14:42:39.097Z","repository":{"id":42444435,"uuid":"268876101","full_name":"gazebosim/gz-bazel","owner":"gazebosim","description":"gz-bazel provides a set of Bazel build rules that are used by the Gazebo projects.","archived":false,"fork":false,"pushed_at":"2024-11-07T17:47:24.000Z","size":207,"stargazers_count":7,"open_issues_count":7,"forks_count":8,"subscribers_count":4,"default_branch":"garden","last_synced_at":"2025-03-28T03:41:20.470Z","etag":null,"topics":["bazel","cpp","gazebo","ignition-robotics"],"latest_commit_sha":null,"homepage":"https://gazebosim.org","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gazebosim.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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}},"created_at":"2020-06-02T18:18:02.000Z","updated_at":"2024-10-18T00:06:23.000Z","dependencies_parsed_at":"2023-01-20T04:18:37.258Z","dependency_job_id":"c8f9feed-4406-452f-913d-8efad6cdb4ea","html_url":"https://github.com/gazebosim/gz-bazel","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/gazebosim%2Fgz-bazel","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gazebosim%2Fgz-bazel/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gazebosim%2Fgz-bazel/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gazebosim%2Fgz-bazel/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gazebosim","download_url":"https://codeload.github.com/gazebosim/gz-bazel/tar.gz/refs/heads/garden","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248898625,"owners_count":21179805,"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":["bazel","cpp","gazebo","ignition-robotics"],"created_at":"2024-11-16T04:17:11.593Z","updated_at":"2025-04-14T14:42:39.075Z","avatar_url":"https://github.com/gazebosim.png","language":"Python","readme":"# gz-bazel\n\ngz-bazel provides a set of Bazel build rules that are used by the Gazebo projects.\n\nThis branch is compatible with the Garden release of Gazebo.\n\n## Initial Setup\n\nTo build, we make the assumption that all necessary libraries and dependencies are checked out in a single directory.\n\nThe following instructions assume that you are using Ubuntu 22.04\n\n### Installing Bazel\n\nTo use your system package manager, follow the [Bazel Instructions](https://docs.bazel.build/versions/master/install-ubuntu.html) to install for your platform.\n\nFor Ubuntu 22.04\n```\n# Install the bazel repos\nsudo apt install apt-transport-https curl gnupg -y\ncurl -fsSL https://bazel.build/bazel-release.pub.gpg | gpg --dearmor \u003ebazel-archive-keyring.gpg\nsudo mv bazel-archive-keyring.gpg /usr/share/keyrings\necho \"deb [arch=amd64 signed-by=/usr/share/keyrings/bazel-archive-keyring.gpg] https://storage.googleapis.com/bazel-apt stable jdk1.8\" | sudo tee /etc/apt/sources.list.d/bazel.list\n\n# Install latest stable bazel version\nsudo apt update \u0026\u0026 sudo apt install bazel\n```\n\n\nAlternatively, if you intend to work with multiple bazel versions, you can use [Bazelisk](https://github.com/bazelbuild/bazelisk), which automatically picks a good version of bazel given your current working directory.\n\n```\n# Download bazelisk from Github releases\nwget https://github.com/bazelbuild/bazelisk/releases/download/v1.16.0/bazelisk-linux-amd64\n\n# Place it somewhere in your USER path\nmv bazelisk-linux-amd64 ~/.local/bin/bazel\nchmod +x ~/.local/bin/bazel\n\n# OR place it in your system path\n/usr/local/bin/bazel\nchmod +x /usr/local/bin/bazel\n```\n\n### Setting up the workspace\n\nTo begin with, make a directory to contain the workspace\n\n```\nmkdir ~/gz/\ncd ~/gz/\n```\n\nThen clone each of the Gazebo packages.  For convenience, we have provided a `.repos` file containing the relevant branches for each package.\n\n```\nwget https://raw.githubusercontent.com/gazebosim/gz-bazel/garden/example/bazel.repos\nvcs import . \u003c bazel.repos\n```\n\nYou can then install all necessary dependencies with the following:\n\n```\nsudo apt update\nsudo apt install -y -qq --no-install-recommends \\\n  $(sort -u $(find . -iname 'packages-jammy.apt' -o -iname 'packages.apt') | grep -Ev \"libignition|libsdformat|ogre|libgz\" | tr '\\n' ' ')\n```\n\nFinally, it is necessary to add a few files to the root of the workspace for bazel.\n\n```\ncd ~/gz/\nln -sf ./bazel/example/WORKSPACE.example ./WORKSPACE\nln -sf ./bazel/example/BUILD.bazel.example ./BUILD.bazel\nln -sf ./bazel/example/bazelrc.example ./.bazelrc\nln -sf ./bazel/example/bazelproject.example ./.bazelproject\n```\n\n## Building with Bazel\n\n### Building the entire workspace\n\nOnce the workspace is setup, building is straightforward:\n\n```\ncd ~/gz\nbazel build //...\n```\n\nTo test:\n\n```\nbazel test //...\n```\n\n### Building a subset of the workspace\n\nTo build all targets in a subpackage, for example gz-common:\n\n```\ncd ~/gz\nbazel build //common/...\n```\n\nGazebo components are generally kept in subdirectories, to select those targets:\n\n```\ncd ~/gz\nbazel build //common/graphics/...\n```\n\nTo see a list of all available targets:\n\n```\ncd ~/gz\nbazel query //...\n```\n\n## Writing Bazel rules\n\n### Linting\n\nUse [buildifer](https://github.com/bazelbuild/buildtools/blob/master/buildifier/README.md) to lint build files\n\n```\ncd ~/gz\nbazel-bin/bazel/lint/buildifier --all         # Reformat all Bazel files.\nbazel-bin/bazel/lint/buildifier //common/BUILD.bazel  # Only reformat one file.\n```\n\nIf buildifier was not built with the workspace (this is unusual), build it via\n\n```\ncd ~/gz\nbazel build //bazel/lint:buildifier\n```\n\n# Credits\n\nMany of the bazel skylib rules and external package repositories are from [the drake project](https://drake.mit.edu/), \nand modified for use with the Gazebo project.\nFor this reason, this repository is licensed under the same BSD-3-Clause license as Drake.\nFor more information on how Drake utilizes bazel, consult [the documentation](https://drake.mit.edu/bazel.html).\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgazebosim%2Fgz-bazel","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgazebosim%2Fgz-bazel","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgazebosim%2Fgz-bazel/lists"}