{"id":15570795,"url":"https://github.com/keith/bazel-rust-mobile-demo","last_synced_at":"2025-09-09T23:36:08.425Z","repository":{"id":53261529,"uuid":"490814632","full_name":"keith/bazel-rust-mobile-demo","owner":"keith","description":"An example repository for using rust on iOS and Android with bazel","archived":false,"fork":false,"pushed_at":"2023-07-27T18:19:55.000Z","size":24,"stargazers_count":65,"open_issues_count":1,"forks_count":3,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-02-23T19:29:21.859Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Starlark","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/keith.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":"2022-05-10T18:23:36.000Z","updated_at":"2024-12-19T15:58:01.000Z","dependencies_parsed_at":"2022-08-13T02:30:39.695Z","dependency_job_id":null,"html_url":"https://github.com/keith/bazel-rust-mobile-demo","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/keith/bazel-rust-mobile-demo","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/keith%2Fbazel-rust-mobile-demo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/keith%2Fbazel-rust-mobile-demo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/keith%2Fbazel-rust-mobile-demo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/keith%2Fbazel-rust-mobile-demo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/keith","download_url":"https://codeload.github.com/keith/bazel-rust-mobile-demo/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/keith%2Fbazel-rust-mobile-demo/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":274383847,"owners_count":25275185,"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","status":"online","status_checked_at":"2025-09-09T02:00:10.223Z","response_time":80,"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":[],"created_at":"2024-10-02T17:44:45.555Z","updated_at":"2025-09-09T23:36:08.404Z","avatar_url":"https://github.com/keith.png","language":"Starlark","funding_links":[],"categories":[],"sub_categories":[],"readme":"# bazel-rust-mobile-demo\n\nThis is an example repository for how to setup a bazel build that uses\nrust on iOS and Android. I also did [a talk](https://www.youtube.com/watch?v=e2ID05dpJzo)\non this at bazelcon.\n\n## Usage\n\nYou can explore the code, which has some comments around the issues you\nhit. You can also run each entry point to see them working.\n\nFor a standard `cc_binary` running on your host machine:\n\n```sh\n$ bazel run normal_binary\n...\nFerris says hello!\nSome value from rust: 42\n```\n\nFor an `ios_application` (requires running on macOS with Xcode setup):\n\n```sh\n$ bazel run ios_app\n...\ncom.example.iosapp: 25008\nFerris says hello!\nSome value from rust: 42\n```\n\nFor an `android_application` (requires the android SDK and an emulator\nto be configured):\n\n```sh\n$ bazel mobile-install android_app --fat_apk_cpu=arm64-v8a --start_app\n# View the result in the emulator, or view logs with 'adb logcat'\n```\n\n## Notes\n\n- At the time of writing this setup was tested with bazel 5.1.1\n- The key to targeting the right platforms until the iOS and Android\n  rules natively support bazel platforms is the\n  [`platform_mappings`](platform_mappings) file, and the `platform`\n  rules in the [`BUILD`](BUILD) file\n  ([docs](https://bazel.build/concepts/platforms-intro#platform-mappings))\n- If you don't want to use a root `platform_mappings` file you can pass\n  `--platform_mappings=path/to/platform_mappings`\n- The `rules_rust` patch, and `android_armeabi` platform definition will\n  change with bazel 6.x since\n  https://github.com/bazelbuild/bazel/issues/14982 was fixed\n- When testing Android, depending on your emulator or device you can\n  pass whatever `--fat_apk_cpu` value you need\n- When testing with iOS you can pass whatever `--ios_multi_cpus` value\n  you need\n- When using something like this in production you should checkout\n  [cxx](https://github.com/dtolnay/cxx) which helps bridge between rust\n  and C++\n- This example doesn't include it but using\n  [cargo-raze](https://github.com/google/cargo-raze) works fine for\n  rust dependencies from our testing\n- When using `cargo-raze` with the arm64 iOS simulator you need [this\n  patch](https://github.com/google/cargo-raze/pull/484) for some cases,\n  hopefully it's in a release soon\n- When debugging `platform_mappings` issues,\n  `--toolchain_resolution_debug='.*'` is verbose but very useful\n- If you find any other interesting gotchas when setting this up please\n  submit an issue or PR here so we can document them for the community!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkeith%2Fbazel-rust-mobile-demo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkeith%2Fbazel-rust-mobile-demo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkeith%2Fbazel-rust-mobile-demo/lists"}