{"id":20968578,"url":"https://github.com/rnburn/rules_cc_module","last_synced_at":"2025-05-14T09:33:53.960Z","repository":{"id":45870150,"uuid":"343638380","full_name":"rnburn/rules_cc_module","owner":"rnburn","description":"Rules for using C++20 modules with bazel","archived":false,"fork":false,"pushed_at":"2022-02-13T07:22:04.000Z","size":130,"stargazers_count":36,"open_issues_count":10,"forks_count":5,"subscribers_count":6,"default_branch":"main","last_synced_at":"2023-07-31T17:25:39.572Z","etag":null,"topics":["bazel","bazel-rules","cpp20","modules"],"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/rnburn.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}},"created_at":"2021-03-02T03:52:02.000Z","updated_at":"2023-07-27T15:29:42.000Z","dependencies_parsed_at":"2022-07-20T21:18:08.064Z","dependency_job_id":null,"html_url":"https://github.com/rnburn/rules_cc_module","commit_stats":null,"previous_names":[],"tags_count":0,"template":null,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rnburn%2Frules_cc_module","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rnburn%2Frules_cc_module/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rnburn%2Frules_cc_module/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rnburn%2Frules_cc_module/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rnburn","download_url":"https://codeload.github.com/rnburn/rules_cc_module/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225285697,"owners_count":17450061,"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","bazel-rules","cpp20","modules"],"created_at":"2024-11-19T03:14:24.376Z","updated_at":"2024-11-19T03:14:24.913Z","avatar_url":"https://github.com/rnburn.png","language":"Starlark","funding_links":[],"categories":[],"sub_categories":[],"readme":"# rules_cc_module\n\nRules to use C++20 modules with Bazel.\n\n## Getting started\n\nNote: Currently only works with a recent version of clang.\n\nBuild a simple module:\n```bazel\ncc_module(\n    name = \"Hello\",\n    src = \"say_hello.cc\", # say_hello exports the module Hello\n)\n\n# Build a binary with the module\ncc_module_binary(\n    name = \"a.out\",\n    srcs = [\n        \"main.cc\",  # We can import Hello in main.cc\n    ],\n    deps = [\n        \":Hello\",\n    ],\n)\n```\n\nBuild a module with implementation units:\n```bazel\ncc_module_binary(\n  name = \"speech\",\n  src = \"speech.cc\",  # speech.cc exports the module speech\n  impl_srcs = [\n    \"speech_impl.cc\", # speech_impl.cc provides implements (but doesn't export) speech\n  ],\n)\n```\n\nInteroperate with regular cc libraries\n```bazel\ncc_module(\n    name = \"a\",\n    src = \"a.cc\",\n)\n\ncc_module_library(\n    name = \"b\",\n    hdrs = [\n        \"b.h\",\n    ],\n    srcs = [\n        \"b.cc\", # b can import module a, but shouldn't export a module\n    ],\n    deps = [\n        \":a\",\n    ],\n)\n\n# We can use b with regular cc rules\ncc_binary(\n    name = \"a.out\",\n    srcs = [\n        \"main.cc\",\n    ],\n    deps = [\n        \":b\",\n    ],\n)\n```\n\n## Documentation\n[How to Use C++20 Modules with Bazel](https://buildingblock.ai/cpp20-modules-bazel)\n\n## Examples\nThe directory [example](https://github.com/rnburn/bazel-cpp20-modules/tree/main/example) demonstrates \nusage and there is a docker image that provides a build environment. To build the examples,\nrun\n```\n./ci/run_docker.sh # spins up a build environment\nbazel build //example/... # build the examples\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frnburn%2Frules_cc_module","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frnburn%2Frules_cc_module","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frnburn%2Frules_cc_module/lists"}