{"id":49593744,"url":"https://github.com/jmillikin/rules_m4","last_synced_at":"2026-05-04T02:43:42.639Z","repository":{"id":47953013,"uuid":"161864745","full_name":"jmillikin/rules_m4","owner":"jmillikin","description":"Bazel build rules for GNU M4","archived":false,"fork":false,"pushed_at":"2026-04-06T03:13:04.000Z","size":153,"stargazers_count":18,"open_issues_count":0,"forks_count":15,"subscribers_count":2,"default_branch":"trunk","last_synced_at":"2026-05-04T02:43:20.896Z","etag":null,"topics":["bazel","m4"],"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/jmillikin.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":"AUTHORS","dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2018-12-15T03:09:32.000Z","updated_at":"2026-04-06T03:12:56.000Z","dependencies_parsed_at":"2024-11-16T06:22:47.409Z","dependency_job_id":"ddf248a7-9454-4824-ba9d-dca638ba4374","html_url":"https://github.com/jmillikin/rules_m4","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"purl":"pkg:github/jmillikin/rules_m4","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jmillikin%2Frules_m4","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jmillikin%2Frules_m4/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jmillikin%2Frules_m4/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jmillikin%2Frules_m4/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jmillikin","download_url":"https://codeload.github.com/jmillikin/rules_m4/tar.gz/refs/heads/trunk","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jmillikin%2Frules_m4/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32592720,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-03T22:12:39.696Z","status":"online","status_checked_at":"2026-05-04T02:00:06.625Z","response_time":58,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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","m4"],"created_at":"2026-05-04T02:43:40.182Z","updated_at":"2026-05-04T02:43:42.627Z","avatar_url":"https://github.com/jmillikin.png","language":"Starlark","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Bazel build rules for GNU M4\n\nThe [m4] macro processing language is commonly used as an intermediate format\nfor text-based Unix development tools such as [Bison] and [Flex].\n\nThis Bazel ruleset allows [GNU M4] to be integrated into a Bazel build. It can\nbe used to perform macro expansion with the `//m4:m4.bzl%m4` build rule, or as\na dependency in other rules via the Bazel toolchain system.\n\nCurrently, the only implementation of m4 supported by this ruleset is [GNU M4].\n\nAPI reference: [docs/rules_m4.md](docs/rules_m4.md)\n\n[m4]: https://en.wikipedia.org/wiki/M4_(computer_language)\n[Bison]: https://www.gnu.org/software/bison/\n[Flex]: https://github.com/westes/flex\n[GNU M4]: https://www.gnu.org/software/m4/\n\n## Setup\n\nAdd the following to your `MODULE.bazel`:\n\n```python\nbazel_dep(name = \"rules_m4\", version = \"0.3.1\")\n```\n\nTo specify a version or build with additional C compiler options, use the\n`m4_repository_ext` module extension:\n\n```python\nm4 = use_extension(\n    \"@rules_m4//m4/extensions:m4_repository_ext.bzl\",\n    \"m4_repository_ext\",\n)\nm4.repository(\n    name = \"m4\",\n    version = \"1.4.17\",\n    extra_copts = [\"-O3\"],\n)\nuse_repo(m4, \"m4\")\nregister_toolchains(\"@m4//:toolchain\")\n```\n\nNote that repository names registered with a given bzlmod module extension must\nbe unique within the scope of that extension. See the [Bazel module extensions]\ndocumentation for more details.\n\n[Bazel module extensions]: https://bazel.build/external/extension\n\n## Examples\n\nMacro expansion with the `//m4:m4.bzl%m4` build rule:\n\n```python\nload(\"@rules_m4//m4:m4.bzl\", \"m4\")\n\nm4(\n    name = \"hello_world\",\n    srcs = [\"hello_world.in.txt\"],\n    output = \"hello_world.txt\",\n)\n```\n\nMacro expansion in a `genrule`:\n\n```python\ngenrule(\n    name = \"hello_world_gen\",\n    srcs = [\"hello_world.in.txt\"],\n    outs = [\"hello_world_gen.txt\"],\n    cmd = \"$(M4) $(SRCS) \u003e $@\",\n    toolchains = [\"@rules_m4//m4:current_m4_toolchain\"],\n)\n```\n\nWriting a custom rule that depends on `m4` as a toolchain:\n\n```python\nload(\"@rules_m4//m4:m4.bzl\", \"M4_TOOLCHAIN_TYPE\", \"m4_toolchain\")\n\ndef _my_rule(ctx):\n    m4 = m4_toolchain(ctx)\n    ctx.actions.run(\n        tools = [m4.m4_tool],\n        env = m4.m4_env,\n        # ...\n    )\n\nmy_rule = rule(\n    implementation = _my_rule,\n    toolchains = [M4_TOOLCHAIN_TYPE],\n)\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjmillikin%2Frules_m4","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjmillikin%2Frules_m4","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjmillikin%2Frules_m4/lists"}