{"id":17087504,"url":"https://github.com/mum4k/platformio_rules","last_synced_at":"2025-10-17T21:53:37.534Z","repository":{"id":54164015,"uuid":"92693956","full_name":"mum4k/platformio_rules","owner":"mum4k","description":"These are Bazel Skylark rules for building and uploading Arduino programs using the PlatformIO build system.","archived":false,"fork":false,"pushed_at":"2024-01-11T20:23:23.000Z","size":1388,"stargazers_count":26,"open_issues_count":1,"forks_count":14,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-12T21:11:19.597Z","etag":null,"topics":["arduino","arduino-firmware","arduino-platform","bazel-rules"],"latest_commit_sha":null,"homepage":"","language":"Starlark","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mum4k.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","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,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2017-05-28T23:51:37.000Z","updated_at":"2024-11-15T05:15:27.000Z","dependencies_parsed_at":"2025-04-12T21:10:27.885Z","dependency_job_id":"345c6dc8-f3dc-46ef-bfa2-a931c53e1f49","html_url":"https://github.com/mum4k/platformio_rules","commit_stats":null,"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"purl":"pkg:github/mum4k/platformio_rules","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mum4k%2Fplatformio_rules","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mum4k%2Fplatformio_rules/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mum4k%2Fplatformio_rules/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mum4k%2Fplatformio_rules/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mum4k","download_url":"https://codeload.github.com/mum4k/platformio_rules/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mum4k%2Fplatformio_rules/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259439143,"owners_count":22857662,"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":["arduino","arduino-firmware","arduino-platform","bazel-rules"],"created_at":"2024-10-14T13:33:43.169Z","updated_at":"2025-10-17T21:53:37.527Z","avatar_url":"https://github.com/mum4k.png","language":"Starlark","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PlatformIO Bazel rules\n\n[![Build Status](https://travis-ci.com/mum4k/platformio_rules.svg?branch=master)](https://travis-ci.com/mum4k/platformio_rules)\n\nThese are Bazel Starlark rules for building and uploading\n[Arduino](https://www.arduino.cc/) programs using the\n[PlatformIO](http://platformio.org/) build system.\n\n## Disclaimer\n\nThis is not an official Google product.\n\n## Prerequisites\n\nThese rules don't execute the compiler directly. Instead they copy the\nlibraries into a directory structure compatible with the PlatformIO build\nsystem and then execute the build via PlatformIO.\n\nIn order to do this, the rules execute couple of commands which must already be\npresent on the system.  The following commands are required:\n\n*   /bin/cp\n*   /usr/bin/zip\n*   /usr/bin/unzip\n*   /usr/local/bin/platformio\n\nThe first three ar usually available on any linux system. The platformio\ncommand is added by [installing\nPlatformIO](http://docs.platformio.org/en/latest/installation.html).\n\n\n## Setup - Bzlmod\n\nIn order to use these Bazel rules, you must add this repository as a `bazel_dep` and override it with a\n`archive_override` in your `MODULE.bazel` file.\n\n### Modify the MODULE file\n\nSee [Releases](https://github.com/mum4k/platformio_rules/releases) for the most up to date version to update sha256.\n*Below example targets commit `73bca0dbb0942f8c275721269a9c3c6b581e6868`*\n```\nbazel_dep(name = \"platformio_rules\", repo_name = \"platformio_rules\")\narchive_override(\n    module_name = \"platformio_rules\",\n    sha256 = \"f9cdb89e467d01a30787883c8183d022ba0a63f320ae495db3f9966c6aa23328\",\n    strip_prefix = \"platformio_rules-73bca0dbb0942f8c275721269a9c3c6b581e6868\",\n    url = \"https://github.com/mum4k/platformio_rules/archive/73bca0dbb0942f8c275721269a9c3c6b581e6868.tar.gz\",\n)\n```\n\n\n## Setup - WORKSPACE\n\nIn order to use these Bazel rules, you must add this git repository to your\nWORKSPACE file and load the platformio rule definition in every BUILD file\nwhere they are needed.\n\n### Modify the WORKSPACE file\n\nSee [Releases](https://github.com/mum4k/platformio_rules/releases) for the most up to date version to substitute for `tag`.\n\n```\nload(\"@bazel_tools//tools/build_defs/repo:git.bzl\", \"git_repository\")\ngit_repository(\n    name = \"platformio_rules\",\n    remote = \"http://github.com/mum4k/platformio_rules.git\",\n    tag = \"v0.0.14\",\n)\n\nload(\"@platformio_rules//bazel:deps.bzl\", \"platformio_rules_dependencies\")\nplatformio_rules_dependencies()\n\nload(\"@platformio_rules//bazel:transitive.bzl\", \"platformio_rules_transitive_dependencies\")\nplatformio_rules_transitive_dependencies()\n\nload(\"@platformio_rules//bazel:pip_parse.bzl\", \"platformio_rules_pip_parse_dependencies\")\nplatformio_rules_pip_parse_dependencies()\n\nload(\"@platformio_rules//bazel:pip_install.bzl\", \"platformio_rules_pip_install_dependencies\")\nplatformio_rules_pip_install_dependencies()\n```\n\n### Load the rule definitions in the BUILD file\n\nTo load the Starlark definitions in your BUILD file add the following at the top\nof the BUILD file.\n\n```\nload(\n    \"@platformio_rules//platformio:platformio.bzl\",\n    \"platformio_library\",\n    \"platformio_project\",\n)\n```\n\n## Defined rules\n\nThe following rules are defined for PlatformIO:\n\n*  platformio_library\n*  platformio_project\n\nSee the [generated documentation](docs/platformio_doc.md).\n\n## Rules documentation\n\nThese rules have standard Starlark documentation inside the platformio_docs\ndirectory.\n\nTo rebuild the documentation run:\n\n```\nbazel build docs:platformio_docs\n```\n\nAnd then copy the created markdown file:\n\n```\ncp $(bazel info bazel-bin)/docs/platformio_doc.md docs/\n```\n\n## Examples\n\nSee the **tests** subdirectory for a working example.\n\n### Define a PlatformIO library\n\nIn the BUILD file:\n\n```\nplatformio_library(\n    name = \"Convert\",\n    hdr = \"convert.h\",\n    src = \"convert.cc\",\n)\n```\n\n### Define a PlatformIO project\n\nIn the BUILD file:\n\n```\nplatformio_project(\n    name = \"binary_counter\",\n    src = \"binary_counter.cc\",\n    board = \"megaatmega2560\",\n    framework = \"arduino\",\n    platform = \"atmelavr\",\n    deps = [\n        \":Convert\",\n    ],\n    # If you need to you can pass multiple string key-value pairs directly\n    # to PlatformIO. All of these will appear under the environment section in\n    # the generated platformio.ini file. That would be \"[env:megaatmega2560]\" in\n    # this example. For the available options see:\n    # http://docs.platformio.org/en/stable/projectconf.html\n    environment_kwargs = {\n        \"board_f_cpu\": \"16000000L\",\n    }\n)\n```\n\n### Building with the rules\n\nTo build the library defined above you would run:\n\n```\nbazel build :Convert\n```\n\nTo build the project defined above you would run:\n\n```\nbazel build :binary_counter\n```\n\n### Uploading with the rules\n\nWhen you run the project, it will upload the compiled firmware to the connected\nArduino device.\n\n```\nbazel run :binary_counter\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmum4k%2Fplatformio_rules","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmum4k%2Fplatformio_rules","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmum4k%2Fplatformio_rules/lists"}