fork/rules_rust
git clone https://git.julia.blue/fork/rules_rust
ba7abedc
gh-pages
1<!DOCTYPE HTML > 2< html lang ="en "class ="light sidebar-visible "dir ="ltr "> 3< head > 4<!-- Book generated using mdBook --> 5< meta charset ="UTF-8 "> 6< title > cargo - rules_rust</ title > 7 8 9<!-- Custom HTML head --> 10 11< meta name ="description "content =""> 12< meta name ="viewport "content ="width=device-width, initial-scale=1 "> 13< meta name ="theme-color "content ="#ffffff "> 14 15< link rel ="icon "href ="favicon.svg "> 16< link rel ="shortcut icon "href ="favicon.png "> 17< link rel ="stylesheet "href ="css/variables.css "> 18< link rel ="stylesheet "href ="css/general.css "> 19< link rel ="stylesheet "href ="css/chrome.css "> 20< link rel ="stylesheet "href ="css/print.css "media ="> 21 22<!-- Fonts --> 23< link rel ="stylesheet "href ="FontAwesome/css/font-awesome.css "> 24< link rel ="stylesheet "href ="fonts/fonts.css "> 25 26<!-- Highlight.js Stylesheets --> 27< link rel ="stylesheet "href ="highlight.css "> 28< link rel ="stylesheet "href ="tomorrow-night.css "> 29< link rel ="stylesheet "href ="ayu-highlight.css "> 30 31<!-- Custom theme stylesheets --> 32 33 34<!-- Provide site root to javascript --> 35< script > 36var path_to_root = "" ; 37var default_theme = window . matchMedia ( "(prefers-color-scheme: dark)" ). matches ?"navy" :"light" ; 38</ script > 39<!-- Start loading toc.js asap --> 40< script src ="toc.js "></ script > 41</ head > 42< body > 43< div id ="body-container "> 44<!-- Work around some values being stored in localStorage wrapped in quotes --> 45< script > 46try { 47var theme = localStorage . getItem ( 'mdbook-theme' ); 48var sidebar = localStorage . getItem ( 'mdbook-sidebar' ); 49 50if ( theme . startsWith ( '"' ) && theme . endsWith ( '"' )) { 51localStorage . setItem ( 'mdbook-theme' , theme . slice ( 1 , theme . length - 1 )); 52} 53 54if ( sidebar . startsWith ( '"' ) && sidebar . endsWith ( '"' )) { 55localStorage . setItem ( 'mdbook-sidebar' , sidebar . slice ( 1 , sidebar . length - 1 )); 56} 57} catch ( e ) { } 58</ script > 59 60<!-- Set the theme before any content is loaded, prevents flash --> 61< script > 62var theme ; 63try { theme = localStorage . getItem ( 'mdbook-theme' ); } catch ( e ) { } 64if ( theme === null || theme === undefined ) { theme = default_theme ; } 65const html = document . documentElement ; 66html . classList . remove ( 'light' ) 67html . classList . add ( theme ); 68html . classList . add ( "js" ); 69</ script > 70 71< input type ="checkbox "id ="sidebar-toggle-anchor "class ="hidden "> 72 73<!-- Hide / unhide sidebar before it is displayed --> 74< script > 75var sidebar = null ; 76var sidebar_toggle = document . getElementById ( "sidebar-toggle-anchor" ); 77if ( document . body . clientWidth >= 1080 ) { 78try { sidebar = localStorage . getItem ( 'mdbook-sidebar' ); } catch ( e ) { } 79sidebar = sidebar || 'visible' ; 80} else { 81sidebar = 'hidden' ; 82} 83sidebar_toggle . checked = sidebar === 'visible' ; 84html . classList . remove ( 'sidebar-visible' ); 85html . classList . add ( "sidebar-" + sidebar ); 86</ script > 87 88< nav id ="sidebar "class ="sidebar "aria-label ="Table of contents "> 89<!-- populated by js --> 90< mdbook-sidebar-scrollbox class ="sidebar-scrollbox "></ mdbook-sidebar-scrollbox > 91< noscript > 92< iframe class ="sidebar-iframe-outer "src ="toc.html "></ iframe > 93</ noscript > 94< div id ="sidebar-resize-handle "class ="sidebar-resize-handle "> 95< div class ="sidebar-resize-indicator "></ div > 96</ div > 97</ nav > 98 99< div id ="page-wrapper "class ="page-wrapper "> 100 101< div class ="page "> 102< div id ="menu-bar-hover-placeholder "></ div > 103< div id ="menu-bar "class ="menu-bar sticky "> 104< div class ="left-buttons "> 105< label id ="sidebar-toggle "class ="icon-button "for ="sidebar-toggle-anchor "title ="Toggle Table of Contents "aria-label ="Toggle Table of Contents "aria-controls ="sidebar "> 106< i class ="fa fa-bars "></ i > 107</ label > 108< button id ="theme-toggle "class ="icon-button "type ="button "title ="Change theme "aria-label ="Change theme "aria-haspopup ="true "aria-expanded ="false "aria-controls ="theme-list "> 109< i class ="fa fa-paint-brush "></ i > 110</ button > 111< ul id ="theme-list "class ="theme-popup "aria-label ="Themes "role ="menu "> 112< li role ="none ">< button role ="menuitem "class ="theme "id ="light "> Light</ button ></ li > 113< li role ="none ">< button role ="menuitem "class ="theme "id ="rust "> Rust</ button ></ li > 114< li role ="none ">< button role ="menuitem "class ="theme "id ="coal "> Coal</ button ></ li > 115< li role ="none ">< button role ="menuitem "class ="theme "id ="navy "> Navy</ button ></ li > 116< li role ="none ">< button role ="menuitem "class ="theme "id ="ayu "> Ayu</ button ></ li > 117</ ul > 118< button id ="search-toggle "class ="icon-button "type ="button "title ="Search. (Shortkey: s) "aria-label ="Toggle Searchbar "aria-expanded ="false "aria-keyshortcuts ="S "aria-controls ="searchbar "> 119< i class ="fa fa-search "></ i > 120</ button > 121</ div > 122 123< h1 class ="menu-title "> rules_rust</ h1 > 124 125< div class ="right-buttons "> 126< a href ="print.html "title ="Print this book "aria-label ="Print this book "> 127< i id ="print-button "class ="fa fa-print "></ i > 128</ a > 129< a href ="https://github.com/bazelbuild/rules_rust "title ="Git repository "aria-label ="Git repository "> 130< i id ="git-repository-button "class ="fa fa-github "></ i > 131</ a > 132 133</ div > 134</ div > 135 136< div id ="search-wrapper "class ="hidden "> 137< form id ="searchbar-outer "class ="searchbar-outer "> 138< input type ="search "id ="searchbar "name ="searchbar "placeholder ="Search this book ... "aria-controls ="searchresults-outer "aria-describedby ="searchresults-header "> 139</ form > 140< div id ="searchresults-outer "class ="searchresults-outer hidden "> 141< div id ="searchresults-header "class ="searchresults-header "></ div > 142< ul id ="searchresults "> 143</ ul > 144</ div > 145</ div > 146 147<!-- Apply ARIA attributes after the sidebar and the sidebar toggle button are added to the DOM --> 148< script > 149document . getElementById ( 'sidebar-toggle' ). setAttribute ( 'aria-expanded' , sidebar === 'visible' ); 150document . getElementById ( 'sidebar' ). setAttribute ( 'aria-hidden' , sidebar !== 'visible' ); 151Array . from ( document . querySelectorAll ( '#sidebar a' )). forEach ( function ( link ) { 152link . setAttribute ( 'tabIndex' , sidebar === 'visible' ?0 :- 1 ); 153}); 154</ script > 155 156< div id ="content "class ="content "> 157< main > 158<!-- Generated with Stardoc: http://skydoc.bazel.build --> 159< h1 id ="cargo ">< a class ="header "href ="#cargo "> Cargo</ a ></ h1 > 160< ul > 161< li >< a href ="#cargo_bootstrap_repository "> cargo_bootstrap_repository</ a ></ li > 162< li >< a href ="#cargo_build_script "> cargo_build_script</ a ></ li > 163< li >< a href ="#cargo_dep_env "> cargo_dep_env</ a ></ li > 164< li >< a href ="#cargo_env "> cargo_env</ a ></ li > 165</ ul > 166< p >< a id ="cargo_dep_env "></ a ></ p > 167< h2 id ="cargo_dep_env ">< a class ="header "href ="#cargo_dep_env "> cargo_dep_env</ a ></ h2 > 168< pre > 169cargo_dep_env(< a href ="#cargo_dep_env-name "> name</ a > ,< a href ="#cargo_dep_env-src "> src</ a > ,< a href ="#cargo_dep_env-out_dir "> out_dir</ a > ) 170</ pre > 171< p > A rule for generating variables for dependent< code > cargo_build_script</ code > s without a build script. This is useful for using Bazel rules instead of a build script, while also generating configuration information for build scripts which depend on this crate.</ p > 172< p >< strong > ATTRIBUTES</ strong ></ p > 173< div class ="table-wrapper ">< table >< thead >< tr >< th style ="text-align: left "> Name</ th >< th style ="text-align: left "> Description</ th >< th style ="text-align: left "> Type</ th >< th style ="text-align: left "> Mandatory</ th >< th style ="text-align: left "> Default</ th ></ tr ></ thead >< tbody > 174< tr >< td style ="text-align: left ">< a id ="cargo_dep_env-name "></ a > name</ td >< td style ="text-align: left "> A unique name for this target.</ td >< td style ="text-align: left ">< a href ="https://bazel.build/concepts/labels#target-names "> Name</ a ></ td >< td style ="text-align: left "> required</ td >< td style ="text-align: left "></ td ></ tr > 175< tr >< td style ="text-align: left ">< a id ="cargo_dep_env-src "></ a > src</ td >< td style ="text-align: left "> File containing additional environment variables to set for build scripts of direct dependencies.< br >< br > This has the same effect as a< code > cargo_build_script</ code > which prints< code > cargo:VAR=VALUE</ code > lines, but without requiring a build script.< br >< br > This files should contain a single variable per line, of format< code > NAME=value</ code > , and newlines may be included in a value by ending a line with a trailing back-slash (< code > \\</ code > ).</ td >< td style ="text-align: left ">< a href ="https://bazel.build/concepts/labels "> Label</ a ></ td >< td style ="text-align: left "> required</ td >< td style ="text-align: left "></ td ></ tr > 176< tr >< td style ="text-align: left ">< a id ="cargo_dep_env-out_dir "></ a > out_dir</ td >< td style ="text-align: left "> Folder containing additional inputs when building all direct dependencies.< br >< br > This has the same effect as a< code > cargo_build_script</ code > which prints puts files into< code > $OUT_DIR</ code > , but without requiring a build script.</ td >< td style ="text-align: left ">< a href ="https://bazel.build/concepts/labels "> Label</ a ></ td >< td style ="text-align: left "> optional</ td >< td style ="text-align: left ">< code > None</ code ></ td ></ tr > 177</ tbody ></ table > 178</ div > 179< p >< a id ="cargo_build_script "></ a ></ p > 180< h2 id ="cargo_build_script ">< a class ="header "href ="#cargo_build_script "> cargo_build_script</ a ></ h2 > 181< pre > 182cargo_build_script(< a href ="#cargo_build_script-name "> name</ a > ,< a href ="#cargo_build_script-edition "> edition</ a > ,< a href ="#cargo_build_script-crate_name "> crate_name</ a > ,< a href ="#cargo_build_script-crate_root "> crate_root</ a > ,< a href ="#cargo_build_script-srcs "> srcs</ a > ,< a href ="#cargo_build_script-crate_features "> crate_features</ a > ,< a href ="#cargo_build_script-version "> version</ a > ,< a href ="#cargo_build_script-deps "> deps</ a > , 183< a href ="#cargo_build_script-link_deps "> link_deps</ a > ,< a href ="#cargo_build_script-proc_macro_deps "> proc_macro_deps</ a > ,< a href ="#cargo_build_script-build_script_env "> build_script_env</ a > ,< a href ="#cargo_build_script-data "> data</ a > ,< a href ="#cargo_build_script-compile_data "> compile_data</ a > ,< a href ="#cargo_build_script-tools "> tools</ a > ,< a href ="#cargo_build_script-links "> links</ a > , 184< a href ="#cargo_build_script-rundir "> rundir</ a > ,< a href ="#cargo_build_script-rustc_env "> rustc_env</ a > ,< a href ="#cargo_build_script-rustc_env_files "> rustc_env_files</ a > ,< a href ="#cargo_build_script-rustc_flags "> rustc_flags</ a > ,< a href ="#cargo_build_script-visibility "> visibility</ a > ,< a href ="#cargo_build_script-tags "> tags</ a > ,< a href ="#cargo_build_script-aliases "> aliases</ a > , 185< a href ="#cargo_build_script-pkg_name "> pkg_name</ a > ,< a href ="#cargo_build_script-kwargs "> kwargs</ a > ) 186</ pre > 187< p > Compile and execute a rust build script to generate build attributes</ p > 188< p > This rules take the same arguments as rust_binary.</ p > 189< p > Example:</ p > 190< p > Suppose you have a crate with a cargo build script< code > build.rs</ code > :</ p > 191< pre >< code class ="language-output "> [workspace]/ 192 hello_lib/ 193 BUILD 194 build.rs 195 src/ 196 lib.rs 197</ code ></ pre > 198< p > Then you want to use the build script in the following:</ p > 199< p >< code > hello_lib/BUILD</ code > :</ p > 200< pre >< code class ="language-python "> package(default_visibility = ["//visibility:public"]) 201 202load("@rules_rust//rust:defs.bzl", "rust_binary", "rust_library") 203load("@rules_rust//cargo:defs.bzl", "cargo_build_script") 204 205# This will run the build script from the root of the workspace, and 206# collect the outputs. 207cargo_build_script( 208 name = "build_script", 209 srcs = ["build.rs"], 210 # Optional environment variables passed during build.rs compilation 211 rustc_env = { 212 "CARGO_PKG_VERSION": "0.1.2", 213 }, 214 # Optional environment variables passed during build.rs execution. 215 # Note that as the build script's working directory is not execroot, 216 # execpath/location will return an absolute path, instead of a relative 217 # one. 218 build_script_env = { 219 "SOME_TOOL_OR_FILE": "$(execpath @tool//:binary)" 220 }, 221 # Optional data/tool dependencies 222 data = ["@tool//:binary"], 223) 224 225rust_library( 226 name = "hello_lib", 227 srcs = [ 228 "src/lib.rs", 229 ], 230 deps = [":build_script"], 231) 232</ code ></ pre > 233< p > The< code > hello_lib</ code > target will be build with the flags and the environment variables declared by the build script in addition to the file generated by it.</ p > 234< p >< strong > PARAMETERS</ strong ></ p > 235< div class ="table-wrapper ">< table >< thead >< tr >< th style ="text-align: left "> Name</ th >< th style ="text-align: left "> Description</ th >< th style ="text-align: left "> Default Value</ th ></ tr ></ thead >< tbody > 236< tr >< td style ="text-align: left ">< a id ="cargo_build_script-name "></ a > name</ td >< td style ="text-align: left "> The name for the underlying rule. This should be the name of the package being compiled, optionally with a suffix of< code > _bs</ code > . Otherwise, you can set the package name via< code > pkg_name</ code > .</ td >< td style ="text-align: left "> none</ td ></ tr > 237< tr >< td style ="text-align: left ">< a id ="cargo_build_script-edition "></ a > edition</ td >< td style ="text-align: left "> The rust edition to use for the internal binary crate.</ td >< td style ="text-align: left ">< code > None</ code ></ td ></ tr > 238< tr >< td style ="text-align: left ">< a id ="cargo_build_script-crate_name "></ a > crate_name</ td >< td style ="text-align: left "> Crate name to use for build script.</ td >< td style ="text-align: left ">< code > None</ code ></ td ></ tr > 239< tr >< td style ="text-align: left ">< a id ="cargo_build_script-crate_root "></ a > crate_root</ td >< td style ="text-align: left "> The file that will be passed to rustc to be used for building this crate.</ td >< td style ="text-align: left ">< code > None</ code ></ td ></ tr > 240< tr >< td style ="text-align: left ">< a id ="cargo_build_script-srcs "></ a > srcs</ td >< td style ="text-align: left "> Souce files of the crate to build. Passing source files here can be used to trigger rebuilds when changes are made.</ td >< td style ="text-align: left ">< code > []</ code ></ td ></ tr > 241< tr >< td style ="text-align: left ">< a id ="cargo_build_script-crate_features "></ a > crate_features</ td >< td style ="text-align: left "> A list of features to enable for the build script.</ td >< td style ="text-align: left ">< code > []</ code ></ td ></ tr > 242< tr >< td style ="text-align: left ">< a id ="cargo_build_script-version "></ a > version</ td >< td style ="text-align: left "> The semantic version (semver) of the crate.</ td >< td style ="text-align: left ">< code > None</ code ></ td ></ tr > 243< tr >< td style ="text-align: left ">< a id ="cargo_build_script-deps "></ a > deps</ td >< td style ="text-align: left "> The build-dependencies of the crate.</ td >< td style ="text-align: left ">< code > []</ code ></ td ></ tr > 244< tr >< td style ="text-align: left ">< a id ="cargo_build_script-link_deps "></ a > link_deps</ td >< td style ="text-align: left "> The subset of the (normal) dependencies of the crate that have the links attribute and therefore provide environment variables to this build script.</ td >< td style ="text-align: left ">< code > []</ code ></ td ></ tr > 245< tr >< td style ="text-align: left ">< a id ="cargo_build_script-proc_macro_deps "></ a > proc_macro_deps</ td >< td style ="text-align: left "> List of rust_proc_macro targets used to build the script.</ td >< td style ="text-align: left ">< code > []</ code ></ td ></ tr > 246< tr >< td style ="text-align: left ">< a id ="cargo_build_script-build_script_env "></ a > build_script_env</ td >< td style ="text-align: left "> Environment variables for build scripts.</ td >< td style ="text-align: left ">< code > {}</ code ></ td ></ tr > 247< tr >< td style ="text-align: left ">< a id ="cargo_build_script-data "></ a > data</ td >< td style ="text-align: left "> Files needed by the build script.</ td >< td style ="text-align: left ">< code > []</ code ></ td ></ tr > 248< tr >< td style ="text-align: left ">< a id ="cargo_build_script-compile_data "></ a > compile_data</ td >< td style ="text-align: left "> Files needed for the compilation of the build script.</ td >< td style ="text-align: left ">< code > []</ code ></ td ></ tr > 249< tr >< td style ="text-align: left ">< a id ="cargo_build_script-tools "></ a > tools</ td >< td style ="text-align: left "> Tools (executables) needed by the build script.</ td >< td style ="text-align: left ">< code > []</ code ></ td ></ tr > 250< tr >< td style ="text-align: left ">< a id ="cargo_build_script-links "></ a > links</ td >< td style ="text-align: left "> Name of the native library this crate links against.</ td >< td style ="text-align: left ">< code > None</ code ></ td ></ tr > 251< tr >< td style ="text-align: left ">< a id ="cargo_build_script-rundir "></ a > rundir</ td >< td style ="text-align: left "> A directory to< code > cd</ code > to before the cargo_build_script is run. This should be a path relative to the exec root.< br >< br > The default behaviour (and the behaviour if rundir is set to the empty string) is to change to the relative path corresponding to the cargo manifest directory, which replicates the normal behaviour of cargo so it is easy to write compatible build scripts.< br >< br > If set to< code > .</ code > , the cargo build script will run in the exec root.</ td >< td style ="text-align: left ">< code > None</ code ></ td ></ tr > 252< tr >< td style ="text-align: left ">< a id ="cargo_build_script-rustc_env "></ a > rustc_env</ td >< td style ="text-align: left "> Environment variables to set in rustc when compiling the build script.</ td >< td style ="text-align: left ">< code > {}</ code ></ td ></ tr > 253< tr >< td style ="text-align: left ">< a id ="cargo_build_script-rustc_env_files "></ a > rustc_env_files</ td >< td style ="text-align: left "> Files containing additional environment variables to set for rustc when building the build script.</ td >< td style ="text-align: left ">< code > []</ code ></ td ></ tr > 254< tr >< td style ="text-align: left ">< a id ="cargo_build_script-rustc_flags "></ a > rustc_flags</ td >< td style ="text-align: left "> List of compiler flags passed to< code > rustc</ code > .</ td >< td style ="text-align: left ">< code > []</ code ></ td ></ tr > 255< tr >< td style ="text-align: left ">< a id ="cargo_build_script-visibility "></ a > visibility</ td >< td style ="text-align: left "> Visibility to apply to the generated build script output.</ td >< td style ="text-align: left ">< code > None</ code ></ td ></ tr > 256< tr >< td style ="text-align: left ">< a id ="cargo_build_script-tags "></ a > tags</ td >< td style ="text-align: left "> (list of str, optional): Tags to apply to the generated build script output.</ td >< td style ="text-align: left ">< code > None</ code ></ td ></ tr > 257< tr >< td style ="text-align: left ">< a id ="cargo_build_script-aliases "></ a > aliases</ td >< td style ="text-align: left "> Remap crates to a new name or moniker for linkage to this target. These are other< code > rust_library</ code > targets and will be presented as the new name given.</ td >< td style ="text-align: left ">< code > None</ code ></ td ></ tr > 258< tr >< td style ="text-align: left ">< a id ="cargo_build_script-pkg_name "></ a > pkg_name</ td >< td style ="text-align: left "> Override the package name used for the build script. This is useful if the build target name gets too long otherwise.</ td >< td style ="text-align: left ">< code > None</ code ></ td ></ tr > 259< tr >< td style ="text-align: left ">< a id ="cargo_build_script-kwargs "></ a > kwargs</ td >< td style ="text-align: left "> Forwards to the underlying< code > rust_binary</ code > rule. An exception is the< code > compatible_with</ code > attribute, which shouldn't be forwarded to the< code > rust_binary</ code > , as the< code > rust_binary</ code > is only built and used in< code > exec</ code > mode. We propagate the< code > compatible_with</ code > attribute to the< code > _build_scirpt_run</ code > target.</ td >< td style ="text-align: left "> none</ td ></ tr > 260</ tbody ></ table > 261</ div > 262< p >< a id ="cargo_env "></ a ></ p > 263< h2 id ="cargo_env ">< a class ="header "href ="#cargo_env "> cargo_env</ a ></ h2 > 264< pre > 265cargo_env(< a href ="#cargo_env-env "> env</ a > ) 266</ pre > 267< p > A helper for generating platform specific environment variables</ p > 268< pre >< code class ="language-python "> load("@rules_rust//rust:defs.bzl", "rust_common") 269load("@rules_rust//cargo:defs.bzl", "cargo_bootstrap_repository", "cargo_env") 270 271cargo_bootstrap_repository( 272 name = "bootstrapped_bin", 273 cargo_lockfile = "//:Cargo.lock", 274 cargo_toml = "//:Cargo.toml", 275 srcs = ["//:resolver_srcs"], 276 version = rust_common.default_version, 277 binary = "my-crate-binary", 278 env = { 279 "x86_64-unknown-linux-gnu": cargo_env({ 280 "FOO": "BAR", 281 }), 282 }, 283 env_label = { 284 "aarch64-unknown-linux-musl": cargo_env({ 285 "DOC": "//:README.md", 286 }), 287 } 288) 289</ code ></ pre > 290< p >< strong > PARAMETERS</ strong ></ p > 291< div class ="table-wrapper ">< table >< thead >< tr >< th style ="text-align: left "> Name</ th >< th style ="text-align: left "> Description</ th >< th style ="text-align: left "> Default Value</ th ></ tr ></ thead >< tbody > 292< tr >< td style ="text-align: left ">< a id ="cargo_env-env "></ a > env</ td >< td style ="text-align: left "> A map of environment variables</ td >< td style ="text-align: left "> none</ td ></ tr > 293</ tbody ></ table > 294</ div > 295< p >< strong > RETURNS</ strong ></ p > 296< p > str: A json encoded string of the environment variables</ p > 297< p >< a id ="cargo_bootstrap_repository "></ a ></ p > 298< h2 id ="cargo_bootstrap_repository ">< a class ="header "href ="#cargo_bootstrap_repository "> cargo_bootstrap_repository</ a ></ h2 > 299< pre > 300cargo_bootstrap_repository(< a href ="#cargo_bootstrap_repository-name "> name</ a > ,< a href ="#cargo_bootstrap_repository-srcs "> srcs</ a > ,< a href ="#cargo_bootstrap_repository-binary "> binary</ a > ,< a href ="#cargo_bootstrap_repository-build_mode "> build_mode</ a > ,< a href ="#cargo_bootstrap_repository-cargo_config "> cargo_config</ a > ,< a href ="#cargo_bootstrap_repository-cargo_lockfile "> cargo_lockfile</ a > ,< a href ="#cargo_bootstrap_repository-cargo_toml "> cargo_toml</ a > , 301< a href ="#cargo_bootstrap_repository-compressed_windows_toolchain_names "> compressed_windows_toolchain_names</ a > ,< a href ="#cargo_bootstrap_repository-env "> env</ a > ,< a href ="#cargo_bootstrap_repository-env_label "> env_label</ a > ,< a href ="#cargo_bootstrap_repository-repo_mapping "> repo_mapping</ a > , 302< a href ="#cargo_bootstrap_repository-rust_toolchain_cargo_template "> rust_toolchain_cargo_template</ a > ,< a href ="#cargo_bootstrap_repository-rust_toolchain_rustc_template "> rust_toolchain_rustc_template</ a > ,< a href ="#cargo_bootstrap_repository-timeout "> timeout</ a > , 303< a href ="#cargo_bootstrap_repository-version "> version</ a > ) 304</ pre > 305< p > A rule for bootstrapping a Rust binary using< a href ="https://doc.rust-lang.org/cargo/ "> Cargo</ a ></ p > 306< p >< strong > ATTRIBUTES</ strong ></ p > 307< div class ="table-wrapper ">< table >< thead >< tr >< th style ="text-align: left "> Name</ th >< th style ="text-align: left "> Description</ th >< th style ="text-align: left "> Type</ th >< th style ="text-align: left "> Mandatory</ th >< th style ="text-align: left "> Default</ th ></ tr ></ thead >< tbody > 308< tr >< td style ="text-align: left ">< a id ="cargo_bootstrap_repository-name "></ a > name</ td >< td style ="text-align: left "> A unique name for this repository.</ td >< td style ="text-align: left ">< a href ="https://bazel.build/concepts/labels#target-names "> Name</ a ></ td >< td style ="text-align: left "> required</ td >< td style ="text-align: left "></ td ></ tr > 309< tr >< td style ="text-align: left ">< a id ="cargo_bootstrap_repository-srcs "></ a > srcs</ td >< td style ="text-align: left "> Souce files of the crate to build. Passing source files here can be used to trigger rebuilds when changes are made</ td >< td style ="text-align: left ">< a href ="https://bazel.build/concepts/labels "> List of labels</ a ></ td >< td style ="text-align: left "> optional</ td >< td style ="text-align: left ">< code > []</ code ></ td ></ tr > 310< tr >< td style ="text-align: left ">< a id ="cargo_bootstrap_repository-binary "></ a > binary</ td >< td style ="text-align: left "> The binary to build (the< code > --bin</ code > parameter for Cargo). If left empty, the repository name will be used.</ td >< td style ="text-align: left "> String</ td >< td style ="text-align: left "> optional</ td >< td style ="text-align: left ">< code > ""</ code ></ td ></ tr > 311< tr >< td style ="text-align: left ">< a id ="cargo_bootstrap_repository-build_mode "></ a > build_mode</ td >< td style ="text-align: left "> The build mode the binary should be built with</ td >< td style ="text-align: left "> String</ td >< td style ="text-align: left "> optional</ td >< td style ="text-align: left ">< code > "release"</ code ></ td ></ tr > 312< tr >< td style ="text-align: left ">< a id ="cargo_bootstrap_repository-cargo_config "></ a > cargo_config</ td >< td style ="text-align: left "> The path of the Cargo configuration (< code > Config.toml</ code > ) file.</ td >< td style ="text-align: left ">< a href ="https://bazel.build/concepts/labels "> Label</ a ></ td >< td style ="text-align: left "> optional</ td >< td style ="text-align: left ">< code > None</ code ></ td ></ tr > 313< tr >< td style ="text-align: left ">< a id ="cargo_bootstrap_repository-cargo_lockfile "></ a > cargo_lockfile</ td >< td style ="text-align: left "> The lockfile of the crate_universe resolver</ td >< td style ="text-align: left ">< a href ="https://bazel.build/concepts/labels "> Label</ a ></ td >< td style ="text-align: left "> required</ td >< td style ="text-align: left "></ td ></ tr > 314< tr >< td style ="text-align: left ">< a id ="cargo_bootstrap_repository-cargo_toml "></ a > cargo_toml</ td >< td style ="text-align: left "> The path of the< code > Cargo.toml</ code > file.</ td >< td style ="text-align: left ">< a href ="https://bazel.build/concepts/labels "> Label</ a ></ td >< td style ="text-align: left "> required</ td >< td style ="text-align: left "></ td ></ tr > 315< tr >< td style ="text-align: left ">< a id ="cargo_bootstrap_repository-compressed_windows_toolchain_names "></ a > compressed_windows_toolchain_names</ td >< td style ="text-align: left "> Wether or not the toolchain names of windows toolchains are expected to be in a< code > compressed</ code > format.</ td >< td style ="text-align: left "> Boolean</ td >< td style ="text-align: left "> optional</ td >< td style ="text-align: left ">< code > True</ code ></ td ></ tr > 316< tr >< td style ="text-align: left ">< a id ="cargo_bootstrap_repository-env "></ a > env</ td >< td style ="text-align: left "> A mapping of platform triple to a set of environment variables. See< a href ="#cargo_env "> cargo_env</ a > for usage details. Additionally, the platform triple< code > *</ code > applies to all platforms.</ td >< td style ="text-align: left ">< a href ="https://bazel.build/rules/lib/dict "> Dictionary: String -> String</ a ></ td >< td style ="text-align: left "> optional</ td >< td style ="text-align: left ">< code > {}</ code ></ td ></ tr > 317< tr >< td style ="text-align: left ">< a id ="cargo_bootstrap_repository-env_label "></ a > env_label</ td >< td style ="text-align: left "> A mapping of platform triple to a set of environment variables. This attribute differs from< code > env</ code > in that all variables passed here must be fully qualified labels of files. See< a href ="#cargo_env "> cargo_env</ a > for usage details. Additionally, the platform triple< code > *</ code > applies to all platforms.</ td >< td style ="text-align: left ">< a href ="https://bazel.build/rules/lib/dict "> Dictionary: String -> String</ a ></ td >< td style ="text-align: left "> optional</ td >< td style ="text-align: left ">< code > {}</ code ></ td ></ tr > 318< tr >< td style ="text-align: left ">< a id ="cargo_bootstrap_repository-repo_mapping "></ a > repo_mapping</ td >< td style ="text-align: left "> In< code > WORKSPACE</ code > context only: a dictionary from local repository name to global repository name. This allows controls over workspace dependency resolution for dependencies of this repository.< br >< br > For example, an entry< code > "@foo": "@bar"</ code > declares that, for any time this repository depends on< code > @foo</ code > (such as a dependency on< code > @foo//some:target</ code > , it should actually resolve that dependency within globally-declared< code > @bar</ code > (< code > @bar//some:target</ code > ).< br >< br > This attribute is< em > not</ em > supported in< code > MODULE.bazel</ code > context (when invoking a repository rule inside a module extension's implementation function).</ td >< td style ="text-align: left ">< a href ="https://bazel.build/rules/lib/dict "> Dictionary: String -> String</ a ></ td >< td style ="text-align: left "> optional</ td >< td style ="text-align: left "></ td ></ tr > 319< tr >< td style ="text-align: left ">< a id ="cargo_bootstrap_repository-rust_toolchain_cargo_template "></ a > rust_toolchain_cargo_template</ td >< td style ="text-align: left "> The template to use for finding the host< code > cargo</ code > binary.< code > {version}</ code > (eg. '1.53.0'),< code > {triple}</ code > (eg. 'x86_64-unknown-linux-gnu'),< code > {arch}</ code > (eg. 'aarch64'),< code > {vendor}</ code > (eg. 'unknown'),< code > {system}</ code > (eg. 'darwin'),< code > {channel}</ code > (eg. 'stable'), and< code > {tool}</ code > (eg. 'rustc.exe') will be replaced in the string if present.</ td >< td style ="text-align: left "> String</ td >< td style ="text-align: left "> optional</ td >< td style ="text-align: left ">< code > "@rust_{system}_{arch}__{triple}__{channel}_tools//:bin/{tool}"</ code ></ td ></ tr > 320< tr >< td style ="text-align: left ">< a id ="cargo_bootstrap_repository-rust_toolchain_rustc_template "></ a > rust_toolchain_rustc_template</ td >< td style ="text-align: left "> The template to use for finding the host< code > rustc</ code > binary.< code > {version}</ code > (eg. '1.53.0'),< code > {triple}</ code > (eg. 'x86_64-unknown-linux-gnu'),< code > {arch}</ code > (eg. 'aarch64'),< code > {vendor}</ code > (eg. 'unknown'),< code > {system}</ code > (eg. 'darwin'),< code > {channel}</ code > (eg. 'stable'), and< code > {tool}</ code > (eg. 'rustc.exe') will be replaced in the string if present.</ td >< td style ="text-align: left "> String</ td >< td style ="text-align: left "> optional</ td >< td style ="text-align: left ">< code > "@rust_{system}_{arch}__{triple}__{channel}_tools//:bin/{tool}"</ code ></ td ></ tr > 321< tr >< td style ="text-align: left ">< a id ="cargo_bootstrap_repository-timeout "></ a > timeout</ td >< td style ="text-align: left "> Maximum duration of the Cargo build command in seconds</ td >< td style ="text-align: left "> Integer</ td >< td style ="text-align: left "> optional</ td >< td style ="text-align: left ">< code > 600</ code ></ td ></ tr > 322< tr >< td style ="text-align: left ">< a id ="cargo_bootstrap_repository-version "></ a > version</ td >< td style ="text-align: left "> The version of Rust the currently registered toolchain is using. Eg.< code > 1.56.0</ code > , or< code > nightly/2021-09-08</ code ></ td >< td style ="text-align: left "> String</ td >< td style ="text-align: left "> optional</ td >< td style ="text-align: left ">< code > "1.83.0"</ code ></ td ></ tr > 323</ tbody ></ table > 324</ div > 325</ main > 326 327< nav class ="nav-wrapper "aria-label ="Page navigation "> 328<!-- Mobile navigation buttons --> 329< a rel ="prev "href ="rust_fmt.html "class ="mobile-nav-chapters previous "title ="Previous chapter "aria-label ="Previous chapter "aria-keyshortcuts ="Left "> 330< i class ="fa fa-angle-left "></ i > 331</ a > 332 333< a rel ="next prefetch "href ="rust_analyzer.html "class ="mobile-nav-chapters next "title ="Next chapter "aria-label ="Next chapter "aria-keyshortcuts ="Right "> 334< i class ="fa fa-angle-right "></ i > 335</ a > 336 337< div style ="clear: both "></ div > 338</ nav > 339</ div > 340</ div > 341 342< nav class ="nav-wide-wrapper "aria-label ="Page navigation "> 343< a rel ="prev "href ="rust_fmt.html "class ="nav-chapters previous "title ="Previous chapter "aria-label ="Previous chapter "aria-keyshortcuts ="Left "> 344< i class ="fa fa-angle-left "></ i > 345</ a > 346 347< a rel ="next prefetch "href ="rust_analyzer.html "class ="nav-chapters next "title ="Next chapter "aria-label ="Next chapter "aria-keyshortcuts ="Right "> 348< i class ="fa fa-angle-right "></ i > 349</ a > 350</ nav > 351 352</ div > 353 354 355 356 357< script > 358window . playground_copyable = true ; 359</ script > 360 361 362< script src ="elasticlunr.min.js "></ script > 363< script src ="mark.min.js "></ script > 364< script src ="searcher.js "></ script > 365 366< script src ="clipboard.min.js "></ script > 367< script src ="highlight.js "></ script > 368< script src ="book.js "></ script > 369 370<!-- Custom JS scripts --> 371 372 373</ div > 374</ body > 375</ html >