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 > all symbols - 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< h1 id ="rust-rules ">< a class ="header "href ="#rust-rules "> Rust rules</ a ></ h1 > 159< ul > 160< li >< a href ="#CrateInfo "> CrateInfo</ a ></ li > 161< li >< a href ="#DepInfo "> DepInfo</ a ></ li > 162< li >< a href ="#StdLibInfo "> StdLibInfo</ a ></ li > 163< li >< a href ="#capture_clippy_output "> capture_clippy_output</ a ></ li > 164< li >< a href ="#cargo_bootstrap_repository "> cargo_bootstrap_repository</ a ></ li > 165< li >< a href ="#cargo_build_script "> cargo_build_script</ a ></ li > 166< li >< a href ="#cargo_dep_env "> cargo_dep_env</ a ></ li > 167< li >< a href ="#cargo_env "> cargo_env</ a ></ li > 168< li >< a href ="#error_format "> error_format</ a ></ li > 169< li >< a href ="#extra_rustc_flag "> extra_rustc_flag</ a ></ li > 170< li >< a href ="#extra_rustc_flags "> extra_rustc_flags</ a ></ li > 171< li >< a href ="#fail_when_enabled "> fail_when_enabled</ a ></ li > 172< li >< a href ="#incompatible_flag "> incompatible_flag</ a ></ li > 173< li >< a href ="#rules_rust_dependencies "> rules_rust_dependencies</ a ></ li > 174< li >< a href ="#rust_analyzer_aspect "> rust_analyzer_aspect</ a ></ li > 175< li >< a href ="#rust_analyzer_toolchain "> rust_analyzer_toolchain</ a ></ li > 176< li >< a href ="#rust_analyzer_toolchain_repository "> rust_analyzer_toolchain_repository</ a ></ li > 177< li >< a href ="#rust_binary "> rust_binary</ a ></ li > 178< li >< a href ="#rust_clippy "> rust_clippy</ a ></ li > 179< li >< a href ="#rust_clippy_aspect "> rust_clippy_aspect</ a ></ li > 180< li >< a href ="#rust_doc "> rust_doc</ a ></ li > 181< li >< a href ="#rust_doc_test "> rust_doc_test</ a ></ li > 182< li >< a href ="#rust_library "> rust_library</ a ></ li > 183< li >< a href ="#rust_library_group "> rust_library_group</ a ></ li > 184< li >< a href ="#rust_proc_macro "> rust_proc_macro</ a ></ li > 185< li >< a href ="#rust_register_toolchains "> rust_register_toolchains</ a ></ li > 186< li >< a href ="#rust_repositories "> rust_repositories</ a ></ li > 187< li >< a href ="#rust_repository_set "> rust_repository_set</ a ></ li > 188< li >< a href ="#rust_shared_library "> rust_shared_library</ a ></ li > 189< li >< a href ="#rust_static_library "> rust_static_library</ a ></ li > 190< li >< a href ="#rust_stdlib_filegroup "> rust_stdlib_filegroup</ a ></ li > 191< li >< a href ="#rust_test "> rust_test</ a ></ li > 192< li >< a href ="#rust_test_suite "> rust_test_suite</ a ></ li > 193< li >< a href ="#rust_toolchain "> rust_toolchain</ a ></ li > 194< li >< a href ="#rust_toolchain_repository "> rust_toolchain_repository</ a ></ li > 195< li >< a href ="#rust_toolchain_repository_proxy "> rust_toolchain_repository_proxy</ a ></ li > 196< li >< a href ="#rust_toolchain_tools_repository "> rust_toolchain_tools_repository</ a ></ li > 197< li >< a href ="#rustfmt_aspect "> rustfmt_aspect</ a ></ li > 198< li >< a href ="#rustfmt_test "> rustfmt_test</ a ></ li > 199< li >< a href ="#rustfmt_toolchain "> rustfmt_toolchain</ a ></ li > 200</ ul > 201< p >< a id ="capture_clippy_output "></ a ></ p > 202< h2 id ="capture_clippy_output ">< a class ="header "href ="#capture_clippy_output "> capture_clippy_output</ a ></ h2 > 203< pre > 204capture_clippy_output(< a href ="#capture_clippy_output-name "> name</ a > ) 205</ pre > 206< p > Control whether to print clippy output or store it to a file, using the configured error_format.</ p > 207< p >< strong > ATTRIBUTES</ strong ></ p > 208< 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 > 209< tr >< td style ="text-align: left ">< a id ="capture_clippy_output-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 > 210</ tbody ></ table > 211</ div > 212< p >< a id ="cargo_dep_env "></ a ></ p > 213< h2 id ="cargo_dep_env ">< a class ="header "href ="#cargo_dep_env "> cargo_dep_env</ a ></ h2 > 214< pre > 215cargo_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 > ) 216</ pre > 217< 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 > 218< p >< strong > ATTRIBUTES</ strong ></ p > 219< 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 > 220< 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 > 221< 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 > 222< 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 > 223</ tbody ></ table > 224</ div > 225< p >< a id ="error_format "></ a ></ p > 226< h2 id ="error_format ">< a class ="header "href ="#error_format "> error_format</ a ></ h2 > 227< pre > 228error_format(< a href ="#error_format-name "> name</ a > ) 229</ pre > 230< p > Change the< a href ="https://doc.rust-lang.org/rustc/command-line-arguments.html#option-error-format "> --error-format</ a > flag from the command line with< code > --@rules_rust//rust/settings:error_format</ code > . See rustc documentation for valid values.</ p > 231< p >< strong > ATTRIBUTES</ strong ></ p > 232< 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 > 233< tr >< td style ="text-align: left ">< a id ="error_format-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 > 234</ tbody ></ table > 235</ div > 236< p >< a id ="extra_rustc_flag "></ a ></ p > 237< h2 id ="extra_rustc_flag ">< a class ="header "href ="#extra_rustc_flag "> extra_rustc_flag</ a ></ h2 > 238< pre > 239extra_rustc_flag(< a href ="#extra_rustc_flag-name "> name</ a > ) 240</ pre > 241< p > Add additional rustc_flag from the command line with< code > --@rules_rust//rust/settings:extra_rustc_flag</ code > . Multiple uses are accumulated and appended after the extra_rustc_flags.</ p > 242< p >< strong > ATTRIBUTES</ strong ></ p > 243< 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 > 244< tr >< td style ="text-align: left ">< a id ="extra_rustc_flag-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 > 245</ tbody ></ table > 246</ div > 247< p >< a id ="extra_rustc_flags "></ a ></ p > 248< h2 id ="extra_rustc_flags ">< a class ="header "href ="#extra_rustc_flags "> extra_rustc_flags</ a ></ h2 > 249< pre > 250extra_rustc_flags(< a href ="#extra_rustc_flags-name "> name</ a > ) 251</ pre > 252< p > Add additional rustc_flags from the command line with< code > --@rules_rust//rust/settings:extra_rustc_flags</ code > . This flag should only be used for flags that need to be applied across the entire build. For options that apply to individual crates, use the rustc_flags attribute on the individual crate's rule instead. NOTE: These flags not applied to the exec configuration (proc-macros, cargo_build_script, etc); use< code > --@rules_rust//rust/settings:extra_exec_rustc_flags</ code > to apply flags to the exec configuration.</ p > 253< p >< strong > ATTRIBUTES</ strong ></ p > 254< 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 > 255< tr >< td style ="text-align: left ">< a id ="extra_rustc_flags-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 > 256</ tbody ></ table > 257</ div > 258< p >< a id ="incompatible_flag "></ a ></ p > 259< h2 id ="incompatible_flag ">< a class ="header "href ="#incompatible_flag "> incompatible_flag</ a ></ h2 > 260< pre > 261incompatible_flag(< a href ="#incompatible_flag-name "> name</ a > ,< a href ="#incompatible_flag-issue "> issue</ a > ) 262</ pre > 263< p > A rule defining an incompatible flag.</ p > 264< p >< strong > ATTRIBUTES</ strong ></ p > 265< 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 > 266< tr >< td style ="text-align: left ">< a id ="incompatible_flag-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 > 267< tr >< td style ="text-align: left ">< a id ="incompatible_flag-issue "></ a > issue</ td >< td style ="text-align: left "> The link to the github issue associated with this flag</ td >< td style ="text-align: left "> String</ td >< td style ="text-align: left "> required</ td >< td style ="text-align: left "></ td ></ tr > 268</ tbody ></ table > 269</ div > 270< p >< a id ="rust_analyzer_toolchain "></ a ></ p > 271< h2 id ="rust_analyzer_toolchain ">< a class ="header "href ="#rust_analyzer_toolchain "> rust_analyzer_toolchain</ a ></ h2 > 272< pre > 273rust_analyzer_toolchain(< a href ="#rust_analyzer_toolchain-name "> name</ a > ,< a href ="#rust_analyzer_toolchain-proc_macro_srv "> proc_macro_srv</ a > ,< a href ="#rust_analyzer_toolchain-rustc "> rustc</ a > ,< a href ="#rust_analyzer_toolchain-rustc_srcs "> rustc_srcs</ a > ) 274</ pre > 275< p > A toolchain for< a href ="https://rust-analyzer.github.io/ "> rust-analyzer</ a > .</ p > 276< p >< strong > ATTRIBUTES</ strong ></ p > 277< 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 > 278< tr >< td style ="text-align: left ">< a id ="rust_analyzer_toolchain-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 > 279< tr >< td style ="text-align: left ">< a id ="rust_analyzer_toolchain-proc_macro_srv "></ a > proc_macro_srv</ td >< td style ="text-align: left "> The path to a< code > rust_analyzer_proc_macro_srv</ code > binary.</ 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 > 280< tr >< td style ="text-align: left ">< a id ="rust_analyzer_toolchain-rustc "></ a > rustc</ td >< td style ="text-align: left "> The path to a< code > rustc</ code > binary.</ 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 > 281< tr >< td style ="text-align: left ">< a id ="rust_analyzer_toolchain-rustc_srcs "></ a > rustc_srcs</ td >< td style ="text-align: left "> The source code of rustc.</ 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 > 282</ tbody ></ table > 283</ div > 284< p >< a id ="rust_binary "></ a ></ p > 285< h2 id ="rust_binary ">< a class ="header "href ="#rust_binary "> rust_binary</ a ></ h2 > 286< pre > 287rust_binary(< a href ="#rust_binary-name "> name</ a > ,< a href ="#rust_binary-deps "> deps</ a > ,< a href ="#rust_binary-srcs "> srcs</ a > ,< a href ="#rust_binary-data "> data</ a > ,< a href ="#rust_binary-aliases "> aliases</ a > ,< a href ="#rust_binary-alwayslink "> alwayslink</ a > ,< a href ="#rust_binary-binary_name "> binary_name</ a > ,< a href ="#rust_binary-compile_data "> compile_data</ a > ,< a href ="#rust_binary-crate_features "> crate_features</ a > , 288< a href ="#rust_binary-crate_name "> crate_name</ a > ,< a href ="#rust_binary-crate_root "> crate_root</ a > ,< a href ="#rust_binary-crate_type "> crate_type</ a > ,< a href ="#rust_binary-edition "> edition</ a > ,< a href ="#rust_binary-env "> env</ a > ,< a href ="#rust_binary-experimental_use_cc_common_link "> experimental_use_cc_common_link</ a > , 289< a href ="#rust_binary-linker_script "> linker_script</ a > ,< a href ="#rust_binary-malloc "> malloc</ a > ,< a href ="#rust_binary-out_binary "> out_binary</ a > ,< a href ="#rust_binary-platform "> platform</ a > ,< a href ="#rust_binary-proc_macro_deps "> proc_macro_deps</ a > ,< a href ="#rust_binary-rustc_env "> rustc_env</ a > ,< a href ="#rust_binary-rustc_env_files "> rustc_env_files</ a > , 290< a href ="#rust_binary-rustc_flags "> rustc_flags</ a > ,< a href ="#rust_binary-stamp "> stamp</ a > ,< a href ="#rust_binary-version "> version</ a > ) 291</ pre > 292< p > Builds a Rust binary crate.</ p > 293< p > Example:</ p > 294< p > Suppose you have the following directory structure for a Rust project with a 295library crate,< code > hello_lib</ code > , and a binary crate,< code > hello_world</ code > that uses the 296< code > hello_lib</ code > library:</ p > 297< pre >< code class ="language-output "> [workspace]/ 298 WORKSPACE 299 hello_lib/ 300 BUILD 301 src/ 302 lib.rs 303 hello_world/ 304 BUILD 305 src/ 306 main.rs 307</ code ></ pre > 308< p >< code > hello_lib/src/lib.rs</ code > :</ p > 309< pre >< pre class ="playground ">< code class ="language-rust ">< span class ="boring "> #![allow(unused)] 310</ span >< span class ="boring "> fn main() { 311</ span > pub struct Greeter { 312 greeting: String, 313} 314 315impl Greeter { 316 pub fn new(greeting: &str) -> Greeter { 317 Greeter { greeting: greeting.to_string(), } 318 } 319 320 pub fn greet(&self, thing: &str) { 321 println!("{} {}", &self.greeting, thing); 322 } 323} 324< span class ="boring "> }</ span ></ code ></ pre ></ pre > 325< p >< code > hello_lib/BUILD</ code > :</ p > 326< pre >< code class ="language-python "> package(default_visibility = ["//visibility:public"]) 327 328load("@rules_rust//rust:defs.bzl", "rust_library") 329 330rust_library( 331 name = "hello_lib", 332 srcs = ["src/lib.rs"], 333) 334</ code ></ pre > 335< p >< code > hello_world/src/main.rs</ code > :</ p > 336< pre >< pre class ="playground ">< code class ="language-rust "> extern crate hello_lib; 337 338fn main() { 339 let hello = hello_lib::Greeter::new("Hello"); 340 hello.greet("world"); 341}</ code ></ pre ></ pre > 342< p >< code > hello_world/BUILD</ code > :</ p > 343< pre >< code class ="language-python "> load("@rules_rust//rust:defs.bzl", "rust_binary") 344 345rust_binary( 346 name = "hello_world", 347 srcs = ["src/main.rs"], 348 deps = ["//hello_lib"], 349) 350</ code ></ pre > 351< p > Build and run< code > hello_world</ code > :</ p > 352< pre >< code > $ bazel run //hello_world 353INFO: Found 1 target... 354Target //examples/rust/hello_world:hello_world up-to-date: 355bazel-bin/examples/rust/hello_world/hello_world 356INFO: Elapsed time: 1.308s, Critical Path: 1.22s 357 358INFO: Running command line: bazel-bin/examples/rust/hello_world/hello_world 359Hello world 360</ code ></ pre > 361< p > On Windows, a PDB file containing debugging information is available under 362the key< code > pdb_file</ code > in< code > OutputGroupInfo</ code > . Similarly on macOS, a dSYM folder 363is available under the key< code > dsym_folder</ code > in< code > OutputGroupInfo</ code > .</ p > 364< p >< strong > ATTRIBUTES</ strong ></ p > 365< 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 > 366< tr >< td style ="text-align: left ">< a id ="rust_binary-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 > 367< tr >< td style ="text-align: left ">< a id ="rust_binary-deps "></ a > deps</ td >< td style ="text-align: left "> List of other libraries to be linked to this library target.< br >< br > These can be either other< code > rust_library</ code > targets or< code > cc_library</ code > targets if linking a native library.</ 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 > 368< tr >< td style ="text-align: left ">< a id ="rust_binary-srcs "></ a > srcs</ td >< td style ="text-align: left "> List of Rust< code > .rs</ code > source files used to build the library.< br >< br > If< code > srcs</ code > contains more than one file, then there must be a file either named< code > lib.rs</ code > . Otherwise,< code > crate_root</ code > must be set to the source file that is the root of the crate to be passed to rustc to build this crate.</ 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 > 369< tr >< td style ="text-align: left ">< a id ="rust_binary-data "></ a > data</ td >< td style ="text-align: left "> List of files used by this rule at compile time and runtime.< br >< br > If including data at compile time with include_str!() and similar, prefer< code > compile_data</ code > over< code > data</ code > , to prevent the data also being included in the runfiles.</ 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 > 370< tr >< td style ="text-align: left ">< a id ="rust_binary-aliases "></ a > aliases</ td >< td style ="text-align: left "> Remap crates to a new name or moniker for linkage to this target< br >< br > These are other< code > rust_library</ code > targets and will be presented as the new name given.</ td >< td style ="text-align: left ">< a href ="https://bazel.build/rules/lib/dict "> Dictionary: Label -> String</ a ></ td >< td style ="text-align: left "> optional</ td >< td style ="text-align: left ">< code > {}</ code ></ td ></ tr > 371< tr >< td style ="text-align: left ">< a id ="rust_binary-alwayslink "></ a > alwayslink</ td >< td style ="text-align: left "> If 1, any binary that depends (directly or indirectly) on this library will link in all the object files even if some contain no symbols referenced by the binary.< br >< br > This attribute is used by the C++ Starlark API when passing CcInfo providers.</ td >< td style ="text-align: left "> Boolean</ td >< td style ="text-align: left "> optional</ td >< td style ="text-align: left ">< code > False</ code ></ td ></ tr > 372< tr >< td style ="text-align: left ">< a id ="rust_binary-binary_name "></ a > binary_name</ td >< td style ="text-align: left "> Override the resulting binary file name. By default, the binary file will be named using the< code > name</ code > attribute on this rule, however sometimes that is not deseriable.</ td >< td style ="text-align: left "> String</ td >< td style ="text-align: left "> optional</ td >< td style ="text-align: left ">< code > ""</ code ></ td ></ tr > 373< tr >< td style ="text-align: left ">< a id ="rust_binary-compile_data "></ a > compile_data</ td >< td style ="text-align: left "> List of files used by this rule at compile time.< br >< br > This attribute can be used to specify any data files that are embedded into the library, such as via the< a href ="https://doc.rust-lang.org/std/macro.include_str!.html ">< code > include_str!</ code ></ a > macro.</ 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 > 374< tr >< td style ="text-align: left ">< a id ="rust_binary-crate_features "></ a > crate_features</ td >< td style ="text-align: left "> List of features to enable for this crate.< br >< br > Features are defined in the code using the< code > #[cfg(feature = "foo")]</ code > configuration option. The features listed here will be passed to< code > rustc</ code > with< code > --cfg feature="${feature_name}"</ code > flags.</ td >< td style ="text-align: left "> List of strings</ td >< td style ="text-align: left "> optional</ td >< td style ="text-align: left ">< code > []</ code ></ td ></ tr > 375< tr >< td style ="text-align: left ">< a id ="rust_binary-crate_name "></ a > crate_name</ td >< td style ="text-align: left "> Crate name to use for this target.< br >< br > This must be a valid Rust identifier, i.e. it may contain only alphanumeric characters and underscores. Defaults to the target name, with any hyphens replaced by underscores.</ td >< td style ="text-align: left "> String</ td >< td style ="text-align: left "> optional</ td >< td style ="text-align: left ">< code > ""</ code ></ td ></ tr > 376< tr >< td style ="text-align: left ">< a id ="rust_binary-crate_root "></ a > crate_root</ td >< td style ="text-align: left "> The file that will be passed to< code > rustc</ code > to be used for building this crate.< br >< br > If< code > crate_root</ code > is not set, then this rule will look for a< code > lib.rs</ code > file (or< code > main.rs</ code > for rust_binary) or the single file in< code > srcs</ code > if< code > srcs</ code > contains only one 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 > 377< tr >< td style ="text-align: left ">< a id ="rust_binary-crate_type "></ a > crate_type</ td >< td style ="text-align: left "> Crate type that will be passed to< code > rustc</ code > to be used for building this crate.< br >< br > This option is a temporary workaround and should be used only when building for WebAssembly targets (//rust/platform:wasi and //rust/platform:wasm).</ td >< td style ="text-align: left "> String</ td >< td style ="text-align: left "> optional</ td >< td style ="text-align: left ">< code > "bin"</ code ></ td ></ tr > 378< tr >< td style ="text-align: left ">< a id ="rust_binary-edition "></ a > edition</ td >< td style ="text-align: left "> The rust edition to use for this crate. Defaults to the edition specified in the rust_toolchain.</ td >< td style ="text-align: left "> String</ td >< td style ="text-align: left "> optional</ td >< td style ="text-align: left ">< code > ""</ code ></ td ></ tr > 379< tr >< td style ="text-align: left ">< a id ="rust_binary-env "></ a > env</ td >< td style ="text-align: left "> Specifies additional environment variables to set when the target is executed by bazel run. Values are subject to< code > $(rootpath)</ code > ,< code > $(execpath)</ code > , location, and< a href ="https://docs.bazel.build/versions/master/be/make-variables.html "> "Make variable"</ a > substitution.< br >< br > Execpath returns absolute path, and in order to be able to construct the absolute path we need to wrap the test binary in a launcher. Using a launcher comes with complications, such as more complicated debugger attachment.</ 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 > 380< tr >< td style ="text-align: left ">< a id ="rust_binary-experimental_use_cc_common_link "></ a > experimental_use_cc_common_link</ td >< td style ="text-align: left "> Whether to use cc_common.link to link rust binaries. Possible values: [-1, 0, 1]. -1 means use the value of the toolchain.experimental_use_cc_common_link boolean build setting to determine. 0 means do not use cc_common.link (use rustc instead). 1 means use cc_common.link.</ td >< td style ="text-align: left "> Integer</ td >< td style ="text-align: left "> optional</ td >< td style ="text-align: left ">< code > -1</ code ></ td ></ tr > 381< tr >< td style ="text-align: left ">< a id ="rust_binary-linker_script "></ a > linker_script</ td >< td style ="text-align: left "> Link script to forward into linker via rustc options.</ 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 > 382< tr >< td style ="text-align: left ">< a id ="rust_binary-malloc "></ a > malloc</ td >< td style ="text-align: left "> Override the default dependency on< code > malloc</ code > .< br >< br > By default, Rust binaries linked with cc_common.link are linked against< code > @bazel_tools//tools/cpp:malloc"</ code > , which is an empty library and the resulting binary will use libc's< code > malloc</ code > . This label must refer to a< code > cc_library</ code > rule.</ 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 > "@bazel_tools//tools/cpp:malloc"</ code ></ td ></ tr > 383< tr >< td style ="text-align: left ">< a id ="rust_binary-out_binary "></ a > out_binary</ td >< td style ="text-align: left "> Force a target, regardless of it's< code > crate_type</ code > , to always mark the file as executable. This attribute is only used to support wasm targets but is expected to be removed following a resolution to https://github.com/bazelbuild/rules_rust/issues/771.</ td >< td style ="text-align: left "> Boolean</ td >< td style ="text-align: left "> optional</ td >< td style ="text-align: left ">< code > False</ code ></ td ></ tr > 384< tr >< td style ="text-align: left ">< a id ="rust_binary-platform "></ a > platform</ td >< td style ="text-align: left "> Optional platform to transition the binary to.</ 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 > 385< tr >< td style ="text-align: left ">< a id ="rust_binary-proc_macro_deps "></ a > proc_macro_deps</ td >< td style ="text-align: left "> List of< code > rust_proc_macro</ code > targets used to help build this library target.</ 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 > 386< tr >< td style ="text-align: left ">< a id ="rust_binary-rustc_env "></ a > rustc_env</ td >< td style ="text-align: left "> Dictionary of additional< code > "key": "value"</ code > environment variables to set for rustc.< br >< br > rust_test()/rust_binary() rules can use $(rootpath //package:target) to pass in the location of a generated file or external tool. Cargo build scripts that wish to expand locations should use cargo_build_script()'s build_script_env argument instead, as build scripts are run in a different environment - see cargo_build_script()'s documentation for more.</ 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 > 387< tr >< td style ="text-align: left ">< a id ="rust_binary-rustc_env_files "></ a > rustc_env_files</ td >< td style ="text-align: left "> Files containing additional environment variables to set for rustc.< br >< br > These 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 > ).< br >< br > The order that these files will be processed is unspecified, so multiple definitions of a particular variable are discouraged.< br >< br > Note that the variables here are subject to< a href ="https://docs.bazel.build/versions/main/user-manual.html#workspace_status "> workspace status</ a > stamping should the< code > stamp</ code > attribute be enabled. Stamp variables should be wrapped in brackets in order to be resolved. E.g.< code > NAME={WORKSPACE_STATUS_VARIABLE}</ code > .</ 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 > 388< tr >< td style ="text-align: left ">< a id ="rust_binary-rustc_flags "></ a > rustc_flags</ td >< td style ="text-align: left "> List of compiler flags passed to< code > rustc</ code > .< br >< br > These strings are subject to Make variable expansion for predefined source/output path variables like< code > $location</ code > ,< code > $execpath</ code > , and< code > $rootpath</ code > . This expansion is useful if you wish to pass a generated file of arguments to rustc:< code > @$(location //package:target)</ code > .</ td >< td style ="text-align: left "> List of strings</ td >< td style ="text-align: left "> optional</ td >< td style ="text-align: left ">< code > []</ code ></ td ></ tr > 389< tr >< td style ="text-align: left ">< a id ="rust_binary-stamp "></ a > stamp</ td >< td style ="text-align: left "> Whether to encode build information into the< code > Rustc</ code > action. Possible values:< br >< br > -< code > stamp = 1</ code > : Always stamp the build information into the< code > Rustc</ code > action, even in< a href ="https://docs.bazel.build/versions/main/user-manual.html#flag--stamp "> --nostamp</ a > builds. This setting should be avoided, since it potentially kills remote caching for the target and any downstream actions that depend on it.< br >< br > -< code > stamp = 0</ code > : Always replace build information by constant values. This gives good build result caching.< br >< br > -< code > stamp = -1</ code > : Embedding of build information is controlled by the< a href ="https://docs.bazel.build/versions/main/user-manual.html#flag--stamp "> --[no]stamp</ a > flag.< br >< br > Stamped targets are not rebuilt unless their dependencies change.< br >< br > For example if a< code > rust_library</ code > is stamped, and a< code > rust_binary</ code > depends on that library, the stamped library won't be rebuilt when we change sources of the< code > rust_binary</ code > . This is different from how< a href ="https://docs.bazel.build/versions/main/be/c-cpp.html#cc_library.linkstamp ">< code > cc_library.linkstamps</ code ></ a > behaves.</ td >< td style ="text-align: left "> Integer</ td >< td style ="text-align: left "> optional</ td >< td style ="text-align: left ">< code > -1</ code ></ td ></ tr > 390< tr >< td style ="text-align: left ">< a id ="rust_binary-version "></ a > version</ td >< td style ="text-align: left "> A version to inject in the cargo environment variable.</ td >< td style ="text-align: left "> String</ td >< td style ="text-align: left "> optional</ td >< td style ="text-align: left ">< code > "0.0.0"</ code ></ td ></ tr > 391</ tbody ></ table > 392</ div > 393< p >< a id ="rust_clippy "></ a ></ p > 394< h2 id ="rust_clippy ">< a class ="header "href ="#rust_clippy "> rust_clippy</ a ></ h2 > 395< pre > 396rust_clippy(< a href ="#rust_clippy-name "> name</ a > ,< a href ="#rust_clippy-deps "> deps</ a > ) 397</ pre > 398< p > Executes the clippy checker on a specific target.</ p > 399< p > Similar to< code > rust_clippy_aspect</ code > , but allows specifying a list of dependencies within the build system.</ p > 400< p > For example, given the following example targets:</ p > 401< pre >< code class ="language-python "> load("@rules_rust//rust:defs.bzl", "rust_library", "rust_test") 402 403rust_library( 404 name = "hello_lib", 405 srcs = ["src/lib.rs"], 406) 407 408rust_test( 409 name = "greeting_test", 410 srcs = ["tests/greeting.rs"], 411 deps = [":hello_lib"], 412) 413</ code ></ pre > 414< p > Rust clippy can be set as a build target with the following:</ p > 415< pre >< code class ="language-python "> load("@rules_rust//rust:defs.bzl", "rust_clippy") 416 417rust_clippy( 418 name = "hello_library_clippy", 419 testonly = True, 420 deps = [ 421 ":hello_lib", 422 ":greeting_test", 423 ], 424) 425</ code ></ pre > 426< p >< strong > ATTRIBUTES</ strong ></ p > 427< 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 > 428< tr >< td style ="text-align: left ">< a id ="rust_clippy-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 > 429< tr >< td style ="text-align: left ">< a id ="rust_clippy-deps "></ a > deps</ td >< td style ="text-align: left "> Rust targets to run clippy on.</ 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 > 430</ tbody ></ table > 431</ div > 432< p >< a id ="rust_doc "></ a ></ p > 433< h2 id ="rust_doc ">< a class ="header "href ="#rust_doc "> rust_doc</ a ></ h2 > 434< pre > 435rust_doc(< a href ="#rust_doc-name "> name</ a > ,< a href ="#rust_doc-crate "> crate</ a > ,< a href ="#rust_doc-html_after_content "> html_after_content</ a > ,< a href ="#rust_doc-html_before_content "> html_before_content</ a > ,< a href ="#rust_doc-html_in_header "> html_in_header</ a > ,< a href ="#rust_doc-markdown_css "> markdown_css</ a > , 436< a href ="#rust_doc-rustc_flags "> rustc_flags</ a > ,< a href ="#rust_doc-rustdoc_flags "> rustdoc_flags</ a > ) 437</ pre > 438< p > Generates code documentation.</ p > 439< p > Example: 440Suppose you have the following directory structure for a Rust library crate:</ p > 441< pre >< code > [workspace]/ 442 WORKSPACE 443 hello_lib/ 444 BUILD 445 src/ 446 lib.rs 447</ code ></ pre > 448< p > To build< a href ="https://doc.rust-lang.org/book/documentation.html ">< code > rustdoc</ code ></ a > documentation for the< code > hello_lib</ code > crate, define a< code > rust_doc</ code > rule that depends on the the< code > hello_lib</ code > < code > rust_library</ code > target:</ p > 449< pre >< code class ="language-python "> package(default_visibility = ["//visibility:public"]) 450 451load("@rules_rust//rust:defs.bzl", "rust_library", "rust_doc") 452 453rust_library( 454 name = "hello_lib", 455 srcs = ["src/lib.rs"], 456) 457 458rust_doc( 459 name = "hello_lib_doc", 460 crate = ":hello_lib", 461) 462</ code ></ pre > 463< p > Running< code > bazel build //hello_lib:hello_lib_doc</ code > will build a zip file containing the documentation for the< code > hello_lib</ code > library crate generated by< code > rustdoc</ code > .</ p > 464< p >< strong > ATTRIBUTES</ strong ></ p > 465< 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 > 466< tr >< td style ="text-align: left ">< a id ="rust_doc-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 > 467< tr >< td style ="text-align: left ">< a id ="rust_doc-crate "></ a > crate</ td >< td style ="text-align: left "> The label of the target to generate code documentation for.< br >< br >< code > rust_doc</ code > can generate HTML code documentation for the source files of< code > rust_library</ code > or< code > rust_binary</ code > targets.</ 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 > 468< tr >< td style ="text-align: left ">< a id ="rust_doc-html_after_content "></ a > html_after_content</ td >< td style ="text-align: left "> File to add in< code > <body></ code > , after content.</ 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 > 469< tr >< td style ="text-align: left ">< a id ="rust_doc-html_before_content "></ a > html_before_content</ td >< td style ="text-align: left "> File to add in< code > <body></ code > , before content.</ 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 > 470< tr >< td style ="text-align: left ">< a id ="rust_doc-html_in_header "></ a > html_in_header</ td >< td style ="text-align: left "> File to add to< code > <head></ code > .</ 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 > 471< tr >< td style ="text-align: left ">< a id ="rust_doc-markdown_css "></ a > markdown_css</ td >< td style ="text-align: left "> CSS files to include via< code > <link></ code > in a rendered Markdown file.</ 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 > 472< tr >< td style ="text-align: left ">< a id ="rust_doc-rustc_flags "></ a > rustc_flags</ td >< td style ="text-align: left ">< strong > Deprecated</ strong > : use< code > rustdoc_flags</ code > instead</ td >< td style ="text-align: left "> List of strings</ td >< td style ="text-align: left "> optional</ td >< td style ="text-align: left ">< code > []</ code ></ td ></ tr > 473< tr >< td style ="text-align: left ">< a id ="rust_doc-rustdoc_flags "></ a > rustdoc_flags</ td >< td style ="text-align: left "> List of flags passed to< code > rustdoc</ code > .< br >< br > These strings are subject to Make variable expansion for predefined source/output path variables like< code > $location</ code > ,< code > $execpath</ code > , and< code > $rootpath</ code > . This expansion is useful if you wish to pass a generated file of arguments to rustc:< code > @$(location //package:target)</ code > .</ td >< td style ="text-align: left "> List of strings</ td >< td style ="text-align: left "> optional</ td >< td style ="text-align: left ">< code > []</ code ></ td ></ tr > 474</ tbody ></ table > 475</ div > 476< p >< a id ="rust_doc_test "></ a ></ p > 477< h2 id ="rust_doc_test ">< a class ="header "href ="#rust_doc_test "> rust_doc_test</ a ></ h2 > 478< pre > 479rust_doc_test(< a href ="#rust_doc_test-name "> name</ a > ,< a href ="#rust_doc_test-deps "> deps</ a > ,< a href ="#rust_doc_test-crate "> crate</ a > ,< a href ="#rust_doc_test-proc_macro_deps "> proc_macro_deps</ a > ) 480</ pre > 481< p > Runs Rust documentation tests.</ p > 482< p > Example:</ p > 483< p > Suppose you have the following directory structure for a Rust library crate:</ p > 484< pre >< code class ="language-output "> [workspace]/ 485WORKSPACE 486hello_lib/ 487 BUILD 488 src/ 489 lib.rs 490</ code ></ pre > 491< p > To run< a href ="https://doc.rust-lang.org/book/documentation.html#documentation-as-tests "> documentation tests</ a > for the< code > hello_lib</ code > crate, define a< code > rust_doc_test</ code > target that depends on the< code > hello_lib</ code > < code > rust_library</ code > target:</ p > 492< pre >< code class ="language-python "> package(default_visibility = ["//visibility:public"]) 493 494load("@rules_rust//rust:defs.bzl", "rust_library", "rust_doc_test") 495 496rust_library( 497 name = "hello_lib", 498 srcs = ["src/lib.rs"], 499) 500 501rust_doc_test( 502 name = "hello_lib_doc_test", 503 crate = ":hello_lib", 504) 505</ code ></ pre > 506< p > Running< code > bazel test //hello_lib:hello_lib_doc_test</ code > will run all documentation tests for the< code > hello_lib</ code > library crate.</ p > 507< p >< strong > ATTRIBUTES</ strong ></ p > 508< 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 > 509< tr >< td style ="text-align: left ">< a id ="rust_doc_test-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 > 510< tr >< td style ="text-align: left ">< a id ="rust_doc_test-deps "></ a > deps</ td >< td style ="text-align: left "> List of other libraries to be linked to this library target.< br >< br > These can be either other< code > rust_library</ code > targets or< code > cc_library</ code > targets if linking a native library.</ 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 > 511< tr >< td style ="text-align: left ">< a id ="rust_doc_test-crate "></ a > crate</ td >< td style ="text-align: left "> The label of the target to generate code documentation for.< code > rust_doc_test</ code > can generate HTML code documentation for the source files of< code > rust_library</ code > or< code > rust_binary</ code > targets.</ 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 > 512< tr >< td style ="text-align: left ">< a id ="rust_doc_test-proc_macro_deps "></ a > proc_macro_deps</ td >< td style ="text-align: left "> List of< code > rust_proc_macro</ code > targets used to help build this library target.</ 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 > 513</ tbody ></ table > 514</ div > 515< p >< a id ="rust_library "></ a ></ p > 516< h2 id ="rust_library ">< a class ="header "href ="#rust_library "> rust_library</ a ></ h2 > 517< pre > 518rust_library(< a href ="#rust_library-name "> name</ a > ,< a href ="#rust_library-deps "> deps</ a > ,< a href ="#rust_library-srcs "> srcs</ a > ,< a href ="#rust_library-data "> data</ a > ,< a href ="#rust_library-aliases "> aliases</ a > ,< a href ="#rust_library-alwayslink "> alwayslink</ a > ,< a href ="#rust_library-compile_data "> compile_data</ a > ,< a href ="#rust_library-crate_features "> crate_features</ a > ,< a href ="#rust_library-crate_name "> crate_name</ a > , 519< a href ="#rust_library-crate_root "> crate_root</ a > ,< a href ="#rust_library-disable_pipelining "> disable_pipelining</ a > ,< a href ="#rust_library-edition "> edition</ a > ,< a href ="#rust_library-proc_macro_deps "> proc_macro_deps</ a > ,< a href ="#rust_library-rustc_env "> rustc_env</ a > ,< a href ="#rust_library-rustc_env_files "> rustc_env_files</ a > , 520< a href ="#rust_library-rustc_flags "> rustc_flags</ a > ,< a href ="#rust_library-stamp "> stamp</ a > ,< a href ="#rust_library-version "> version</ a > ) 521</ pre > 522< p > Builds a Rust library crate.</ p > 523< p > Example:</ p > 524< p > Suppose you have the following directory structure for a simple Rust library crate:</ p > 525< pre >< code class ="language-output "> [workspace]/ 526 WORKSPACE 527 hello_lib/ 528 BUILD 529 src/ 530 greeter.rs 531 lib.rs 532</ code ></ pre > 533< p >< code > hello_lib/src/greeter.rs</ code > :</ p > 534< pre >< pre class ="playground ">< code class ="language-rust ">< span class ="boring "> #![allow(unused)] 535</ span >< span class ="boring "> fn main() { 536</ span > pub struct Greeter { 537 greeting: String, 538} 539 540impl Greeter { 541 pub fn new(greeting: &str) -> Greeter { 542 Greeter { greeting: greeting.to_string(), } 543 } 544 545 pub fn greet(&self, thing: &str) { 546 println!("{} {}", &self.greeting, thing); 547 } 548} 549< span class ="boring "> }</ span ></ code ></ pre ></ pre > 550< p >< code > hello_lib/src/lib.rs</ code > :</ p > 551< pre >< pre class ="playground ">< code class ="language-rust ">< span class ="boring "> #![allow(unused)] 552</ span >< span class ="boring "> fn main() { 553</ span > pub mod greeter; 554< span class ="boring "> }</ span ></ code ></ pre ></ pre > 555< p >< code > hello_lib/BUILD</ code > :</ p > 556< pre >< code class ="language-python "> package(default_visibility = ["//visibility:public"]) 557 558load("@rules_rust//rust:defs.bzl", "rust_library") 559 560rust_library( 561 name = "hello_lib", 562 srcs = [ 563 "src/greeter.rs", 564 "src/lib.rs", 565 ], 566) 567</ code ></ pre > 568< p > Build the library:</ p > 569< pre >< code class ="language-output "> $ bazel build //hello_lib 570INFO: Found 1 target... 571Target //examples/rust/hello_lib:hello_lib up-to-date: 572bazel-bin/examples/rust/hello_lib/libhello_lib.rlib 573INFO: Elapsed time: 1.245s, Critical Path: 1.01s 574</ code ></ pre > 575< p >< strong > ATTRIBUTES</ strong ></ p > 576< 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 > 577< tr >< td style ="text-align: left ">< a id ="rust_library-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 > 578< tr >< td style ="text-align: left ">< a id ="rust_library-deps "></ a > deps</ td >< td style ="text-align: left "> List of other libraries to be linked to this library target.< br >< br > These can be either other< code > rust_library</ code > targets or< code > cc_library</ code > targets if linking a native library.</ 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 > 579< tr >< td style ="text-align: left ">< a id ="rust_library-srcs "></ a > srcs</ td >< td style ="text-align: left "> List of Rust< code > .rs</ code > source files used to build the library.< br >< br > If< code > srcs</ code > contains more than one file, then there must be a file either named< code > lib.rs</ code > . Otherwise,< code > crate_root</ code > must be set to the source file that is the root of the crate to be passed to rustc to build this crate.</ 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 > 580< tr >< td style ="text-align: left ">< a id ="rust_library-data "></ a > data</ td >< td style ="text-align: left "> List of files used by this rule at compile time and runtime.< br >< br > If including data at compile time with include_str!() and similar, prefer< code > compile_data</ code > over< code > data</ code > , to prevent the data also being included in the runfiles.</ 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 > 581< tr >< td style ="text-align: left ">< a id ="rust_library-aliases "></ a > aliases</ td >< td style ="text-align: left "> Remap crates to a new name or moniker for linkage to this target< br >< br > These are other< code > rust_library</ code > targets and will be presented as the new name given.</ td >< td style ="text-align: left ">< a href ="https://bazel.build/rules/lib/dict "> Dictionary: Label -> String</ a ></ td >< td style ="text-align: left "> optional</ td >< td style ="text-align: left ">< code > {}</ code ></ td ></ tr > 582< tr >< td style ="text-align: left ">< a id ="rust_library-alwayslink "></ a > alwayslink</ td >< td style ="text-align: left "> If 1, any binary that depends (directly or indirectly) on this library will link in all the object files even if some contain no symbols referenced by the binary.< br >< br > This attribute is used by the C++ Starlark API when passing CcInfo providers.</ td >< td style ="text-align: left "> Boolean</ td >< td style ="text-align: left "> optional</ td >< td style ="text-align: left ">< code > False</ code ></ td ></ tr > 583< tr >< td style ="text-align: left ">< a id ="rust_library-compile_data "></ a > compile_data</ td >< td style ="text-align: left "> List of files used by this rule at compile time.< br >< br > This attribute can be used to specify any data files that are embedded into the library, such as via the< a href ="https://doc.rust-lang.org/std/macro.include_str!.html ">< code > include_str!</ code ></ a > macro.</ 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 > 584< tr >< td style ="text-align: left ">< a id ="rust_library-crate_features "></ a > crate_features</ td >< td style ="text-align: left "> List of features to enable for this crate.< br >< br > Features are defined in the code using the< code > #[cfg(feature = "foo")]</ code > configuration option. The features listed here will be passed to< code > rustc</ code > with< code > --cfg feature="${feature_name}"</ code > flags.</ td >< td style ="text-align: left "> List of strings</ td >< td style ="text-align: left "> optional</ td >< td style ="text-align: left ">< code > []</ code ></ td ></ tr > 585< tr >< td style ="text-align: left ">< a id ="rust_library-crate_name "></ a > crate_name</ td >< td style ="text-align: left "> Crate name to use for this target.< br >< br > This must be a valid Rust identifier, i.e. it may contain only alphanumeric characters and underscores. Defaults to the target name, with any hyphens replaced by underscores.</ td >< td style ="text-align: left "> String</ td >< td style ="text-align: left "> optional</ td >< td style ="text-align: left ">< code > ""</ code ></ td ></ tr > 586< tr >< td style ="text-align: left ">< a id ="rust_library-crate_root "></ a > crate_root</ td >< td style ="text-align: left "> The file that will be passed to< code > rustc</ code > to be used for building this crate.< br >< br > If< code > crate_root</ code > is not set, then this rule will look for a< code > lib.rs</ code > file (or< code > main.rs</ code > for rust_binary) or the single file in< code > srcs</ code > if< code > srcs</ code > contains only one 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 > 587< tr >< td style ="text-align: left ">< a id ="rust_library-disable_pipelining "></ a > disable_pipelining</ td >< td style ="text-align: left "> Disables pipelining for this rule if it is globally enabled. This will cause this rule to not produce a< code > .rmeta</ code > file and all the dependent crates will instead use the< code > .rlib</ code > file.</ td >< td style ="text-align: left "> Boolean</ td >< td style ="text-align: left "> optional</ td >< td style ="text-align: left ">< code > False</ code ></ td ></ tr > 588< tr >< td style ="text-align: left ">< a id ="rust_library-edition "></ a > edition</ td >< td style ="text-align: left "> The rust edition to use for this crate. Defaults to the edition specified in the rust_toolchain.</ td >< td style ="text-align: left "> String</ td >< td style ="text-align: left "> optional</ td >< td style ="text-align: left ">< code > ""</ code ></ td ></ tr > 589< tr >< td style ="text-align: left ">< a id ="rust_library-proc_macro_deps "></ a > proc_macro_deps</ td >< td style ="text-align: left "> List of< code > rust_proc_macro</ code > targets used to help build this library target.</ 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 > 590< tr >< td style ="text-align: left ">< a id ="rust_library-rustc_env "></ a > rustc_env</ td >< td style ="text-align: left "> Dictionary of additional< code > "key": "value"</ code > environment variables to set for rustc.< br >< br > rust_test()/rust_binary() rules can use $(rootpath //package:target) to pass in the location of a generated file or external tool. Cargo build scripts that wish to expand locations should use cargo_build_script()'s build_script_env argument instead, as build scripts are run in a different environment - see cargo_build_script()'s documentation for more.</ 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 > 591< tr >< td style ="text-align: left ">< a id ="rust_library-rustc_env_files "></ a > rustc_env_files</ td >< td style ="text-align: left "> Files containing additional environment variables to set for rustc.< br >< br > These 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 > ).< br >< br > The order that these files will be processed is unspecified, so multiple definitions of a particular variable are discouraged.< br >< br > Note that the variables here are subject to< a href ="https://docs.bazel.build/versions/main/user-manual.html#workspace_status "> workspace status</ a > stamping should the< code > stamp</ code > attribute be enabled. Stamp variables should be wrapped in brackets in order to be resolved. E.g.< code > NAME={WORKSPACE_STATUS_VARIABLE}</ code > .</ 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 > 592< tr >< td style ="text-align: left ">< a id ="rust_library-rustc_flags "></ a > rustc_flags</ td >< td style ="text-align: left "> List of compiler flags passed to< code > rustc</ code > .< br >< br > These strings are subject to Make variable expansion for predefined source/output path variables like< code > $location</ code > ,< code > $execpath</ code > , and< code > $rootpath</ code > . This expansion is useful if you wish to pass a generated file of arguments to rustc:< code > @$(location //package:target)</ code > .</ td >< td style ="text-align: left "> List of strings</ td >< td style ="text-align: left "> optional</ td >< td style ="text-align: left ">< code > []</ code ></ td ></ tr > 593< tr >< td style ="text-align: left ">< a id ="rust_library-stamp "></ a > stamp</ td >< td style ="text-align: left "> Whether to encode build information into the< code > Rustc</ code > action. Possible values:< br >< br > -< code > stamp = 1</ code > : Always stamp the build information into the< code > Rustc</ code > action, even in< a href ="https://docs.bazel.build/versions/main/user-manual.html#flag--stamp "> --nostamp</ a > builds. This setting should be avoided, since it potentially kills remote caching for the target and any downstream actions that depend on it.< br >< br > -< code > stamp = 0</ code > : Always replace build information by constant values. This gives good build result caching.< br >< br > -< code > stamp = -1</ code > : Embedding of build information is controlled by the< a href ="https://docs.bazel.build/versions/main/user-manual.html#flag--stamp "> --[no]stamp</ a > flag.< br >< br > Stamped targets are not rebuilt unless their dependencies change.< br >< br > For example if a< code > rust_library</ code > is stamped, and a< code > rust_binary</ code > depends on that library, the stamped library won't be rebuilt when we change sources of the< code > rust_binary</ code > . This is different from how< a href ="https://docs.bazel.build/versions/main/be/c-cpp.html#cc_library.linkstamp ">< code > cc_library.linkstamps</ code ></ a > behaves.</ td >< td style ="text-align: left "> Integer</ td >< td style ="text-align: left "> optional</ td >< td style ="text-align: left ">< code > 0</ code ></ td ></ tr > 594< tr >< td style ="text-align: left ">< a id ="rust_library-version "></ a > version</ td >< td style ="text-align: left "> A version to inject in the cargo environment variable.</ td >< td style ="text-align: left "> String</ td >< td style ="text-align: left "> optional</ td >< td style ="text-align: left ">< code > "0.0.0"</ code ></ td ></ tr > 595</ tbody ></ table > 596</ div > 597< p >< a id ="rust_library_group "></ a ></ p > 598< h2 id ="rust_library_group ">< a class ="header "href ="#rust_library_group "> rust_library_group</ a ></ h2 > 599< pre > 600rust_library_group(< a href ="#rust_library_group-name "> name</ a > ,< a href ="#rust_library_group-deps "> deps</ a > ) 601</ pre > 602< p > Functions as an alias for a set of dependencies.</ p > 603< p > Specifically, the following are equivalent:</ p > 604< pre >< code class ="language-starlark "> rust_library_group( 605 name = "crate_group", 606 deps = [ 607 ":crate1", 608 ":crate2", 609 ], 610) 611 612rust_library( 613 name = "foobar", 614 deps = [":crate_group"], 615 ... 616) 617</ code ></ pre > 618< p > and</ p > 619< pre >< code class ="language-starlark "> rust_library( 620 name = "foobar", 621 deps = [ 622 ":crate1", 623 ":crate2", 624 ], 625 ... 626) 627</ code ></ pre > 628< p >< strong > ATTRIBUTES</ strong ></ p > 629< 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 > 630< tr >< td style ="text-align: left ">< a id ="rust_library_group-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 > 631< tr >< td style ="text-align: left ">< a id ="rust_library_group-deps "></ a > deps</ td >< td style ="text-align: left "> Other dependencies to forward through this crate group.</ 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 > 632</ tbody ></ table > 633</ div > 634< p >< a id ="rust_proc_macro "></ a ></ p > 635< h2 id ="rust_proc_macro ">< a class ="header "href ="#rust_proc_macro "> rust_proc_macro</ a ></ h2 > 636< pre > 637rust_proc_macro(< a href ="#rust_proc_macro-name "> name</ a > ,< a href ="#rust_proc_macro-deps "> deps</ a > ,< a href ="#rust_proc_macro-srcs "> srcs</ a > ,< a href ="#rust_proc_macro-data "> data</ a > ,< a href ="#rust_proc_macro-aliases "> aliases</ a > ,< a href ="#rust_proc_macro-alwayslink "> alwayslink</ a > ,< a href ="#rust_proc_macro-compile_data "> compile_data</ a > ,< a href ="#rust_proc_macro-crate_features "> crate_features</ a > , 638< a href ="#rust_proc_macro-crate_name "> crate_name</ a > ,< a href ="#rust_proc_macro-crate_root "> crate_root</ a > ,< a href ="#rust_proc_macro-edition "> edition</ a > ,< a href ="#rust_proc_macro-proc_macro_deps "> proc_macro_deps</ a > ,< a href ="#rust_proc_macro-rustc_env "> rustc_env</ a > ,< a href ="#rust_proc_macro-rustc_env_files "> rustc_env_files</ a > , 639< a href ="#rust_proc_macro-rustc_flags "> rustc_flags</ a > ,< a href ="#rust_proc_macro-stamp "> stamp</ a > ,< a href ="#rust_proc_macro-version "> version</ a > ) 640</ pre > 641< p > Builds a Rust proc-macro crate.</ p > 642< p >< strong > ATTRIBUTES</ strong ></ p > 643< 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 > 644< tr >< td style ="text-align: left ">< a id ="rust_proc_macro-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 > 645< tr >< td style ="text-align: left ">< a id ="rust_proc_macro-deps "></ a > deps</ td >< td style ="text-align: left "> List of other libraries to be linked to this library target.< br >< br > These can be either other< code > rust_library</ code > targets or< code > cc_library</ code > targets if linking a native library.</ 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 > 646< tr >< td style ="text-align: left ">< a id ="rust_proc_macro-srcs "></ a > srcs</ td >< td style ="text-align: left "> List of Rust< code > .rs</ code > source files used to build the library.< br >< br > If< code > srcs</ code > contains more than one file, then there must be a file either named< code > lib.rs</ code > . Otherwise,< code > crate_root</ code > must be set to the source file that is the root of the crate to be passed to rustc to build this crate.</ 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 > 647< tr >< td style ="text-align: left ">< a id ="rust_proc_macro-data "></ a > data</ td >< td style ="text-align: left "> List of files used by this rule at compile time and runtime.< br >< br > If including data at compile time with include_str!() and similar, prefer< code > compile_data</ code > over< code > data</ code > , to prevent the data also being included in the runfiles.</ 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 > 648< tr >< td style ="text-align: left ">< a id ="rust_proc_macro-aliases "></ a > aliases</ td >< td style ="text-align: left "> Remap crates to a new name or moniker for linkage to this target< br >< br > These are other< code > rust_library</ code > targets and will be presented as the new name given.</ td >< td style ="text-align: left ">< a href ="https://bazel.build/rules/lib/dict "> Dictionary: Label -> String</ a ></ td >< td style ="text-align: left "> optional</ td >< td style ="text-align: left ">< code > {}</ code ></ td ></ tr > 649< tr >< td style ="text-align: left ">< a id ="rust_proc_macro-alwayslink "></ a > alwayslink</ td >< td style ="text-align: left "> If 1, any binary that depends (directly or indirectly) on this library will link in all the object files even if some contain no symbols referenced by the binary.< br >< br > This attribute is used by the C++ Starlark API when passing CcInfo providers.</ td >< td style ="text-align: left "> Boolean</ td >< td style ="text-align: left "> optional</ td >< td style ="text-align: left ">< code > False</ code ></ td ></ tr > 650< tr >< td style ="text-align: left ">< a id ="rust_proc_macro-compile_data "></ a > compile_data</ td >< td style ="text-align: left "> List of files used by this rule at compile time.< br >< br > This attribute can be used to specify any data files that are embedded into the library, such as via the< a href ="https://doc.rust-lang.org/std/macro.include_str!.html ">< code > include_str!</ code ></ a > macro.</ 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 > 651< tr >< td style ="text-align: left ">< a id ="rust_proc_macro-crate_features "></ a > crate_features</ td >< td style ="text-align: left "> List of features to enable for this crate.< br >< br > Features are defined in the code using the< code > #[cfg(feature = "foo")]</ code > configuration option. The features listed here will be passed to< code > rustc</ code > with< code > --cfg feature="${feature_name}"</ code > flags.</ td >< td style ="text-align: left "> List of strings</ td >< td style ="text-align: left "> optional</ td >< td style ="text-align: left ">< code > []</ code ></ td ></ tr > 652< tr >< td style ="text-align: left ">< a id ="rust_proc_macro-crate_name "></ a > crate_name</ td >< td style ="text-align: left "> Crate name to use for this target.< br >< br > This must be a valid Rust identifier, i.e. it may contain only alphanumeric characters and underscores. Defaults to the target name, with any hyphens replaced by underscores.</ td >< td style ="text-align: left "> String</ td >< td style ="text-align: left "> optional</ td >< td style ="text-align: left ">< code > ""</ code ></ td ></ tr > 653< tr >< td style ="text-align: left ">< a id ="rust_proc_macro-crate_root "></ a > crate_root</ td >< td style ="text-align: left "> The file that will be passed to< code > rustc</ code > to be used for building this crate.< br >< br > If< code > crate_root</ code > is not set, then this rule will look for a< code > lib.rs</ code > file (or< code > main.rs</ code > for rust_binary) or the single file in< code > srcs</ code > if< code > srcs</ code > contains only one 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 > 654< tr >< td style ="text-align: left ">< a id ="rust_proc_macro-edition "></ a > edition</ td >< td style ="text-align: left "> The rust edition to use for this crate. Defaults to the edition specified in the rust_toolchain.</ td >< td style ="text-align: left "> String</ td >< td style ="text-align: left "> optional</ td >< td style ="text-align: left ">< code > ""</ code ></ td ></ tr > 655< tr >< td style ="text-align: left ">< a id ="rust_proc_macro-proc_macro_deps "></ a > proc_macro_deps</ td >< td style ="text-align: left "> List of< code > rust_proc_macro</ code > targets used to help build this library target.</ 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 > 656< tr >< td style ="text-align: left ">< a id ="rust_proc_macro-rustc_env "></ a > rustc_env</ td >< td style ="text-align: left "> Dictionary of additional< code > "key": "value"</ code > environment variables to set for rustc.< br >< br > rust_test()/rust_binary() rules can use $(rootpath //package:target) to pass in the location of a generated file or external tool. Cargo build scripts that wish to expand locations should use cargo_build_script()'s build_script_env argument instead, as build scripts are run in a different environment - see cargo_build_script()'s documentation for more.</ 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 > 657< tr >< td style ="text-align: left ">< a id ="rust_proc_macro-rustc_env_files "></ a > rustc_env_files</ td >< td style ="text-align: left "> Files containing additional environment variables to set for rustc.< br >< br > These 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 > ).< br >< br > The order that these files will be processed is unspecified, so multiple definitions of a particular variable are discouraged.< br >< br > Note that the variables here are subject to< a href ="https://docs.bazel.build/versions/main/user-manual.html#workspace_status "> workspace status</ a > stamping should the< code > stamp</ code > attribute be enabled. Stamp variables should be wrapped in brackets in order to be resolved. E.g.< code > NAME={WORKSPACE_STATUS_VARIABLE}</ code > .</ 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 > 658< tr >< td style ="text-align: left ">< a id ="rust_proc_macro-rustc_flags "></ a > rustc_flags</ td >< td style ="text-align: left "> List of compiler flags passed to< code > rustc</ code > .< br >< br > These strings are subject to Make variable expansion for predefined source/output path variables like< code > $location</ code > ,< code > $execpath</ code > , and< code > $rootpath</ code > . This expansion is useful if you wish to pass a generated file of arguments to rustc:< code > @$(location //package:target)</ code > .</ td >< td style ="text-align: left "> List of strings</ td >< td style ="text-align: left "> optional</ td >< td style ="text-align: left ">< code > []</ code ></ td ></ tr > 659< tr >< td style ="text-align: left ">< a id ="rust_proc_macro-stamp "></ a > stamp</ td >< td style ="text-align: left "> Whether to encode build information into the< code > Rustc</ code > action. Possible values:< br >< br > -< code > stamp = 1</ code > : Always stamp the build information into the< code > Rustc</ code > action, even in< a href ="https://docs.bazel.build/versions/main/user-manual.html#flag--stamp "> --nostamp</ a > builds. This setting should be avoided, since it potentially kills remote caching for the target and any downstream actions that depend on it.< br >< br > -< code > stamp = 0</ code > : Always replace build information by constant values. This gives good build result caching.< br >< br > -< code > stamp = -1</ code > : Embedding of build information is controlled by the< a href ="https://docs.bazel.build/versions/main/user-manual.html#flag--stamp "> --[no]stamp</ a > flag.< br >< br > Stamped targets are not rebuilt unless their dependencies change.< br >< br > For example if a< code > rust_library</ code > is stamped, and a< code > rust_binary</ code > depends on that library, the stamped library won't be rebuilt when we change sources of the< code > rust_binary</ code > . This is different from how< a href ="https://docs.bazel.build/versions/main/be/c-cpp.html#cc_library.linkstamp ">< code > cc_library.linkstamps</ code ></ a > behaves.</ td >< td style ="text-align: left "> Integer</ td >< td style ="text-align: left "> optional</ td >< td style ="text-align: left ">< code > 0</ code ></ td ></ tr > 660< tr >< td style ="text-align: left ">< a id ="rust_proc_macro-version "></ a > version</ td >< td style ="text-align: left "> A version to inject in the cargo environment variable.</ td >< td style ="text-align: left "> String</ td >< td style ="text-align: left "> optional</ td >< td style ="text-align: left ">< code > "0.0.0"</ code ></ td ></ tr > 661</ tbody ></ table > 662</ div > 663< p >< a id ="rust_shared_library "></ a ></ p > 664< h2 id ="rust_shared_library ">< a class ="header "href ="#rust_shared_library "> rust_shared_library</ a ></ h2 > 665< pre > 666rust_shared_library(< a href ="#rust_shared_library-name "> name</ a > ,< a href ="#rust_shared_library-deps "> deps</ a > ,< a href ="#rust_shared_library-srcs "> srcs</ a > ,< a href ="#rust_shared_library-data "> data</ a > ,< a href ="#rust_shared_library-aliases "> aliases</ a > ,< a href ="#rust_shared_library-alwayslink "> alwayslink</ a > ,< a href ="#rust_shared_library-compile_data "> compile_data</ a > ,< a href ="#rust_shared_library-crate_features "> crate_features</ a > , 667< a href ="#rust_shared_library-crate_name "> crate_name</ a > ,< a href ="#rust_shared_library-crate_root "> crate_root</ a > ,< a href ="#rust_shared_library-edition "> edition</ a > ,< a href ="#rust_shared_library-experimental_use_cc_common_link "> experimental_use_cc_common_link</ a > ,< a href ="#rust_shared_library-malloc "> malloc</ a > , 668< a href ="#rust_shared_library-platform "> platform</ a > ,< a href ="#rust_shared_library-proc_macro_deps "> proc_macro_deps</ a > ,< a href ="#rust_shared_library-rustc_env "> rustc_env</ a > ,< a href ="#rust_shared_library-rustc_env_files "> rustc_env_files</ a > ,< a href ="#rust_shared_library-rustc_flags "> rustc_flags</ a > ,< a href ="#rust_shared_library-stamp "> stamp</ a > , 669< a href ="#rust_shared_library-version "> version</ a > ) 670</ pre > 671< p > Builds a Rust shared library.</ p > 672< p > This shared library will contain all transitively reachable crates and native objects. 673It is meant to be used when producing an artifact that is then consumed by some other build system 674(for example to produce a shared library that Python program links against).</ p > 675< p > This rule provides CcInfo, so it can be used everywhere Bazel expects< code > rules_cc</ code > .</ p > 676< p > When building the whole binary in Bazel, use< code > rust_library</ code > instead.</ p > 677< p >< strong > ATTRIBUTES</ strong ></ p > 678< 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 > 679< tr >< td style ="text-align: left ">< a id ="rust_shared_library-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 > 680< tr >< td style ="text-align: left ">< a id ="rust_shared_library-deps "></ a > deps</ td >< td style ="text-align: left "> List of other libraries to be linked to this library target.< br >< br > These can be either other< code > rust_library</ code > targets or< code > cc_library</ code > targets if linking a native library.</ 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 > 681< tr >< td style ="text-align: left ">< a id ="rust_shared_library-srcs "></ a > srcs</ td >< td style ="text-align: left "> List of Rust< code > .rs</ code > source files used to build the library.< br >< br > If< code > srcs</ code > contains more than one file, then there must be a file either named< code > lib.rs</ code > . Otherwise,< code > crate_root</ code > must be set to the source file that is the root of the crate to be passed to rustc to build this crate.</ 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 > 682< tr >< td style ="text-align: left ">< a id ="rust_shared_library-data "></ a > data</ td >< td style ="text-align: left "> List of files used by this rule at compile time and runtime.< br >< br > If including data at compile time with include_str!() and similar, prefer< code > compile_data</ code > over< code > data</ code > , to prevent the data also being included in the runfiles.</ 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 > 683< tr >< td style ="text-align: left ">< a id ="rust_shared_library-aliases "></ a > aliases</ td >< td style ="text-align: left "> Remap crates to a new name or moniker for linkage to this target< br >< br > These are other< code > rust_library</ code > targets and will be presented as the new name given.</ td >< td style ="text-align: left ">< a href ="https://bazel.build/rules/lib/dict "> Dictionary: Label -> String</ a ></ td >< td style ="text-align: left "> optional</ td >< td style ="text-align: left ">< code > {}</ code ></ td ></ tr > 684< tr >< td style ="text-align: left ">< a id ="rust_shared_library-alwayslink "></ a > alwayslink</ td >< td style ="text-align: left "> If 1, any binary that depends (directly or indirectly) on this library will link in all the object files even if some contain no symbols referenced by the binary.< br >< br > This attribute is used by the C++ Starlark API when passing CcInfo providers.</ td >< td style ="text-align: left "> Boolean</ td >< td style ="text-align: left "> optional</ td >< td style ="text-align: left ">< code > False</ code ></ td ></ tr > 685< tr >< td style ="text-align: left ">< a id ="rust_shared_library-compile_data "></ a > compile_data</ td >< td style ="text-align: left "> List of files used by this rule at compile time.< br >< br > This attribute can be used to specify any data files that are embedded into the library, such as via the< a href ="https://doc.rust-lang.org/std/macro.include_str!.html ">< code > include_str!</ code ></ a > macro.</ 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 > 686< tr >< td style ="text-align: left ">< a id ="rust_shared_library-crate_features "></ a > crate_features</ td >< td style ="text-align: left "> List of features to enable for this crate.< br >< br > Features are defined in the code using the< code > #[cfg(feature = "foo")]</ code > configuration option. The features listed here will be passed to< code > rustc</ code > with< code > --cfg feature="${feature_name}"</ code > flags.</ td >< td style ="text-align: left "> List of strings</ td >< td style ="text-align: left "> optional</ td >< td style ="text-align: left ">< code > []</ code ></ td ></ tr > 687< tr >< td style ="text-align: left ">< a id ="rust_shared_library-crate_name "></ a > crate_name</ td >< td style ="text-align: left "> Crate name to use for this target.< br >< br > This must be a valid Rust identifier, i.e. it may contain only alphanumeric characters and underscores. Defaults to the target name, with any hyphens replaced by underscores.</ td >< td style ="text-align: left "> String</ td >< td style ="text-align: left "> optional</ td >< td style ="text-align: left ">< code > ""</ code ></ td ></ tr > 688< tr >< td style ="text-align: left ">< a id ="rust_shared_library-crate_root "></ a > crate_root</ td >< td style ="text-align: left "> The file that will be passed to< code > rustc</ code > to be used for building this crate.< br >< br > If< code > crate_root</ code > is not set, then this rule will look for a< code > lib.rs</ code > file (or< code > main.rs</ code > for rust_binary) or the single file in< code > srcs</ code > if< code > srcs</ code > contains only one 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 > 689< tr >< td style ="text-align: left ">< a id ="rust_shared_library-edition "></ a > edition</ td >< td style ="text-align: left "> The rust edition to use for this crate. Defaults to the edition specified in the rust_toolchain.</ td >< td style ="text-align: left "> String</ td >< td style ="text-align: left "> optional</ td >< td style ="text-align: left ">< code > ""</ code ></ td ></ tr > 690< tr >< td style ="text-align: left ">< a id ="rust_shared_library-experimental_use_cc_common_link "></ a > experimental_use_cc_common_link</ td >< td style ="text-align: left "> Whether to use cc_common.link to link rust binaries. Possible values: [-1, 0, 1]. -1 means use the value of the toolchain.experimental_use_cc_common_link boolean build setting to determine. 0 means do not use cc_common.link (use rustc instead). 1 means use cc_common.link.</ td >< td style ="text-align: left "> Integer</ td >< td style ="text-align: left "> optional</ td >< td style ="text-align: left ">< code > -1</ code ></ td ></ tr > 691< tr >< td style ="text-align: left ">< a id ="rust_shared_library-malloc "></ a > malloc</ td >< td style ="text-align: left "> Override the default dependency on< code > malloc</ code > .< br >< br > By default, Rust binaries linked with cc_common.link are linked against< code > @bazel_tools//tools/cpp:malloc"</ code > , which is an empty library and the resulting binary will use libc's< code > malloc</ code > . This label must refer to a< code > cc_library</ code > rule.</ 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 > "@bazel_tools//tools/cpp:malloc"</ code ></ td ></ tr > 692< tr >< td style ="text-align: left ">< a id ="rust_shared_library-platform "></ a > platform</ td >< td style ="text-align: left "> Optional platform to transition the shared library to.</ 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 > 693< tr >< td style ="text-align: left ">< a id ="rust_shared_library-proc_macro_deps "></ a > proc_macro_deps</ td >< td style ="text-align: left "> List of< code > rust_proc_macro</ code > targets used to help build this library target.</ 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 > 694< tr >< td style ="text-align: left ">< a id ="rust_shared_library-rustc_env "></ a > rustc_env</ td >< td style ="text-align: left "> Dictionary of additional< code > "key": "value"</ code > environment variables to set for rustc.< br >< br > rust_test()/rust_binary() rules can use $(rootpath //package:target) to pass in the location of a generated file or external tool. Cargo build scripts that wish to expand locations should use cargo_build_script()'s build_script_env argument instead, as build scripts are run in a different environment - see cargo_build_script()'s documentation for more.</ 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 > 695< tr >< td style ="text-align: left ">< a id ="rust_shared_library-rustc_env_files "></ a > rustc_env_files</ td >< td style ="text-align: left "> Files containing additional environment variables to set for rustc.< br >< br > These 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 > ).< br >< br > The order that these files will be processed is unspecified, so multiple definitions of a particular variable are discouraged.< br >< br > Note that the variables here are subject to< a href ="https://docs.bazel.build/versions/main/user-manual.html#workspace_status "> workspace status</ a > stamping should the< code > stamp</ code > attribute be enabled. Stamp variables should be wrapped in brackets in order to be resolved. E.g.< code > NAME={WORKSPACE_STATUS_VARIABLE}</ code > .</ 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 > 696< tr >< td style ="text-align: left ">< a id ="rust_shared_library-rustc_flags "></ a > rustc_flags</ td >< td style ="text-align: left "> List of compiler flags passed to< code > rustc</ code > .< br >< br > These strings are subject to Make variable expansion for predefined source/output path variables like< code > $location</ code > ,< code > $execpath</ code > , and< code > $rootpath</ code > . This expansion is useful if you wish to pass a generated file of arguments to rustc:< code > @$(location //package:target)</ code > .</ td >< td style ="text-align: left "> List of strings</ td >< td style ="text-align: left "> optional</ td >< td style ="text-align: left ">< code > []</ code ></ td ></ tr > 697< tr >< td style ="text-align: left ">< a id ="rust_shared_library-stamp "></ a > stamp</ td >< td style ="text-align: left "> Whether to encode build information into the< code > Rustc</ code > action. Possible values:< br >< br > -< code > stamp = 1</ code > : Always stamp the build information into the< code > Rustc</ code > action, even in< a href ="https://docs.bazel.build/versions/main/user-manual.html#flag--stamp "> --nostamp</ a > builds. This setting should be avoided, since it potentially kills remote caching for the target and any downstream actions that depend on it.< br >< br > -< code > stamp = 0</ code > : Always replace build information by constant values. This gives good build result caching.< br >< br > -< code > stamp = -1</ code > : Embedding of build information is controlled by the< a href ="https://docs.bazel.build/versions/main/user-manual.html#flag--stamp "> --[no]stamp</ a > flag.< br >< br > Stamped targets are not rebuilt unless their dependencies change.< br >< br > For example if a< code > rust_library</ code > is stamped, and a< code > rust_binary</ code > depends on that library, the stamped library won't be rebuilt when we change sources of the< code > rust_binary</ code > . This is different from how< a href ="https://docs.bazel.build/versions/main/be/c-cpp.html#cc_library.linkstamp ">< code > cc_library.linkstamps</ code ></ a > behaves.</ td >< td style ="text-align: left "> Integer</ td >< td style ="text-align: left "> optional</ td >< td style ="text-align: left ">< code > 0</ code ></ td ></ tr > 698< tr >< td style ="text-align: left ">< a id ="rust_shared_library-version "></ a > version</ td >< td style ="text-align: left "> A version to inject in the cargo environment variable.</ td >< td style ="text-align: left "> String</ td >< td style ="text-align: left "> optional</ td >< td style ="text-align: left ">< code > "0.0.0"</ code ></ td ></ tr > 699</ tbody ></ table > 700</ div > 701< p >< a id ="rust_static_library "></ a ></ p > 702< h2 id ="rust_static_library ">< a class ="header "href ="#rust_static_library "> rust_static_library</ a ></ h2 > 703< pre > 704rust_static_library(< a href ="#rust_static_library-name "> name</ a > ,< a href ="#rust_static_library-deps "> deps</ a > ,< a href ="#rust_static_library-srcs "> srcs</ a > ,< a href ="#rust_static_library-data "> data</ a > ,< a href ="#rust_static_library-aliases "> aliases</ a > ,< a href ="#rust_static_library-alwayslink "> alwayslink</ a > ,< a href ="#rust_static_library-compile_data "> compile_data</ a > ,< a href ="#rust_static_library-crate_features "> crate_features</ a > , 705< a href ="#rust_static_library-crate_name "> crate_name</ a > ,< a href ="#rust_static_library-crate_root "> crate_root</ a > ,< a href ="#rust_static_library-edition "> edition</ a > ,< a href ="#rust_static_library-platform "> platform</ a > ,< a href ="#rust_static_library-proc_macro_deps "> proc_macro_deps</ a > ,< a href ="#rust_static_library-rustc_env "> rustc_env</ a > , 706< a href ="#rust_static_library-rustc_env_files "> rustc_env_files</ a > ,< a href ="#rust_static_library-rustc_flags "> rustc_flags</ a > ,< a href ="#rust_static_library-stamp "> stamp</ a > ,< a href ="#rust_static_library-version "> version</ a > ) 707</ pre > 708< p > Builds a Rust static library.</ p > 709< p > This static library will contain all transitively reachable crates and native objects. 710It is meant to be used when producing an artifact that is then consumed by some other build system 711(for example to produce an archive that Python program links against).</ p > 712< p > This rule provides CcInfo, so it can be used everywhere Bazel expects< code > rules_cc</ code > .</ p > 713< p > When building the whole binary in Bazel, use< code > rust_library</ code > instead.</ p > 714< p >< strong > ATTRIBUTES</ strong ></ p > 715< 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 > 716< tr >< td style ="text-align: left ">< a id ="rust_static_library-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 > 717< tr >< td style ="text-align: left ">< a id ="rust_static_library-deps "></ a > deps</ td >< td style ="text-align: left "> List of other libraries to be linked to this library target.< br >< br > These can be either other< code > rust_library</ code > targets or< code > cc_library</ code > targets if linking a native library.</ 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 > 718< tr >< td style ="text-align: left ">< a id ="rust_static_library-srcs "></ a > srcs</ td >< td style ="text-align: left "> List of Rust< code > .rs</ code > source files used to build the library.< br >< br > If< code > srcs</ code > contains more than one file, then there must be a file either named< code > lib.rs</ code > . Otherwise,< code > crate_root</ code > must be set to the source file that is the root of the crate to be passed to rustc to build this crate.</ 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 > 719< tr >< td style ="text-align: left ">< a id ="rust_static_library-data "></ a > data</ td >< td style ="text-align: left "> List of files used by this rule at compile time and runtime.< br >< br > If including data at compile time with include_str!() and similar, prefer< code > compile_data</ code > over< code > data</ code > , to prevent the data also being included in the runfiles.</ 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 > 720< tr >< td style ="text-align: left ">< a id ="rust_static_library-aliases "></ a > aliases</ td >< td style ="text-align: left "> Remap crates to a new name or moniker for linkage to this target< br >< br > These are other< code > rust_library</ code > targets and will be presented as the new name given.</ td >< td style ="text-align: left ">< a href ="https://bazel.build/rules/lib/dict "> Dictionary: Label -> String</ a ></ td >< td style ="text-align: left "> optional</ td >< td style ="text-align: left ">< code > {}</ code ></ td ></ tr > 721< tr >< td style ="text-align: left ">< a id ="rust_static_library-alwayslink "></ a > alwayslink</ td >< td style ="text-align: left "> If 1, any binary that depends (directly or indirectly) on this library will link in all the object files even if some contain no symbols referenced by the binary.< br >< br > This attribute is used by the C++ Starlark API when passing CcInfo providers.</ td >< td style ="text-align: left "> Boolean</ td >< td style ="text-align: left "> optional</ td >< td style ="text-align: left ">< code > False</ code ></ td ></ tr > 722< tr >< td style ="text-align: left ">< a id ="rust_static_library-compile_data "></ a > compile_data</ td >< td style ="text-align: left "> List of files used by this rule at compile time.< br >< br > This attribute can be used to specify any data files that are embedded into the library, such as via the< a href ="https://doc.rust-lang.org/std/macro.include_str!.html ">< code > include_str!</ code ></ a > macro.</ 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 > 723< tr >< td style ="text-align: left ">< a id ="rust_static_library-crate_features "></ a > crate_features</ td >< td style ="text-align: left "> List of features to enable for this crate.< br >< br > Features are defined in the code using the< code > #[cfg(feature = "foo")]</ code > configuration option. The features listed here will be passed to< code > rustc</ code > with< code > --cfg feature="${feature_name}"</ code > flags.</ td >< td style ="text-align: left "> List of strings</ td >< td style ="text-align: left "> optional</ td >< td style ="text-align: left ">< code > []</ code ></ td ></ tr > 724< tr >< td style ="text-align: left ">< a id ="rust_static_library-crate_name "></ a > crate_name</ td >< td style ="text-align: left "> Crate name to use for this target.< br >< br > This must be a valid Rust identifier, i.e. it may contain only alphanumeric characters and underscores. Defaults to the target name, with any hyphens replaced by underscores.</ td >< td style ="text-align: left "> String</ td >< td style ="text-align: left "> optional</ td >< td style ="text-align: left ">< code > ""</ code ></ td ></ tr > 725< tr >< td style ="text-align: left ">< a id ="rust_static_library-crate_root "></ a > crate_root</ td >< td style ="text-align: left "> The file that will be passed to< code > rustc</ code > to be used for building this crate.< br >< br > If< code > crate_root</ code > is not set, then this rule will look for a< code > lib.rs</ code > file (or< code > main.rs</ code > for rust_binary) or the single file in< code > srcs</ code > if< code > srcs</ code > contains only one 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 > 726< tr >< td style ="text-align: left ">< a id ="rust_static_library-edition "></ a > edition</ td >< td style ="text-align: left "> The rust edition to use for this crate. Defaults to the edition specified in the rust_toolchain.</ td >< td style ="text-align: left "> String</ td >< td style ="text-align: left "> optional</ td >< td style ="text-align: left ">< code > ""</ code ></ td ></ tr > 727< tr >< td style ="text-align: left ">< a id ="rust_static_library-platform "></ a > platform</ td >< td style ="text-align: left "> Optional platform to transition the static library to.</ 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 > 728< tr >< td style ="text-align: left ">< a id ="rust_static_library-proc_macro_deps "></ a > proc_macro_deps</ td >< td style ="text-align: left "> List of< code > rust_proc_macro</ code > targets used to help build this library target.</ 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 > 729< tr >< td style ="text-align: left ">< a id ="rust_static_library-rustc_env "></ a > rustc_env</ td >< td style ="text-align: left "> Dictionary of additional< code > "key": "value"</ code > environment variables to set for rustc.< br >< br > rust_test()/rust_binary() rules can use $(rootpath //package:target) to pass in the location of a generated file or external tool. Cargo build scripts that wish to expand locations should use cargo_build_script()'s build_script_env argument instead, as build scripts are run in a different environment - see cargo_build_script()'s documentation for more.</ 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 > 730< tr >< td style ="text-align: left ">< a id ="rust_static_library-rustc_env_files "></ a > rustc_env_files</ td >< td style ="text-align: left "> Files containing additional environment variables to set for rustc.< br >< br > These 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 > ).< br >< br > The order that these files will be processed is unspecified, so multiple definitions of a particular variable are discouraged.< br >< br > Note that the variables here are subject to< a href ="https://docs.bazel.build/versions/main/user-manual.html#workspace_status "> workspace status</ a > stamping should the< code > stamp</ code > attribute be enabled. Stamp variables should be wrapped in brackets in order to be resolved. E.g.< code > NAME={WORKSPACE_STATUS_VARIABLE}</ code > .</ 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 > 731< tr >< td style ="text-align: left ">< a id ="rust_static_library-rustc_flags "></ a > rustc_flags</ td >< td style ="text-align: left "> List of compiler flags passed to< code > rustc</ code > .< br >< br > These strings are subject to Make variable expansion for predefined source/output path variables like< code > $location</ code > ,< code > $execpath</ code > , and< code > $rootpath</ code > . This expansion is useful if you wish to pass a generated file of arguments to rustc:< code > @$(location //package:target)</ code > .</ td >< td style ="text-align: left "> List of strings</ td >< td style ="text-align: left "> optional</ td >< td style ="text-align: left ">< code > []</ code ></ td ></ tr > 732< tr >< td style ="text-align: left ">< a id ="rust_static_library-stamp "></ a > stamp</ td >< td style ="text-align: left "> Whether to encode build information into the< code > Rustc</ code > action. Possible values:< br >< br > -< code > stamp = 1</ code > : Always stamp the build information into the< code > Rustc</ code > action, even in< a href ="https://docs.bazel.build/versions/main/user-manual.html#flag--stamp "> --nostamp</ a > builds. This setting should be avoided, since it potentially kills remote caching for the target and any downstream actions that depend on it.< br >< br > -< code > stamp = 0</ code > : Always replace build information by constant values. This gives good build result caching.< br >< br > -< code > stamp = -1</ code > : Embedding of build information is controlled by the< a href ="https://docs.bazel.build/versions/main/user-manual.html#flag--stamp "> --[no]stamp</ a > flag.< br >< br > Stamped targets are not rebuilt unless their dependencies change.< br >< br > For example if a< code > rust_library</ code > is stamped, and a< code > rust_binary</ code > depends on that library, the stamped library won't be rebuilt when we change sources of the< code > rust_binary</ code > . This is different from how< a href ="https://docs.bazel.build/versions/main/be/c-cpp.html#cc_library.linkstamp ">< code > cc_library.linkstamps</ code ></ a > behaves.</ td >< td style ="text-align: left "> Integer</ td >< td style ="text-align: left "> optional</ td >< td style ="text-align: left ">< code > 0</ code ></ td ></ tr > 733< tr >< td style ="text-align: left ">< a id ="rust_static_library-version "></ a > version</ td >< td style ="text-align: left "> A version to inject in the cargo environment variable.</ td >< td style ="text-align: left "> String</ td >< td style ="text-align: left "> optional</ td >< td style ="text-align: left ">< code > "0.0.0"</ code ></ td ></ tr > 734</ tbody ></ table > 735</ div > 736< p >< a id ="rust_stdlib_filegroup "></ a ></ p > 737< h2 id ="rust_stdlib_filegroup ">< a class ="header "href ="#rust_stdlib_filegroup "> rust_stdlib_filegroup</ a ></ h2 > 738< pre > 739rust_stdlib_filegroup(< a href ="#rust_stdlib_filegroup-name "> name</ a > ,< a href ="#rust_stdlib_filegroup-srcs "> srcs</ a > ) 740</ pre > 741< p > A dedicated filegroup-like rule for Rust stdlib artifacts.</ p > 742< p >< strong > ATTRIBUTES</ strong ></ p > 743< 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 > 744< tr >< td style ="text-align: left ">< a id ="rust_stdlib_filegroup-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 > 745< tr >< td style ="text-align: left ">< a id ="rust_stdlib_filegroup-srcs "></ a > srcs</ td >< td style ="text-align: left "> The list of targets/files that are components of the rust-stdlib file group</ td >< td style ="text-align: left ">< a href ="https://bazel.build/concepts/labels "> List of labels</ a ></ td >< td style ="text-align: left "> required</ td >< td style ="text-align: left "></ td ></ tr > 746</ tbody ></ table > 747</ div > 748< p >< a id ="rust_test "></ a ></ p > 749< h2 id ="rust_test ">< a class ="header "href ="#rust_test "> rust_test</ a ></ h2 > 750< pre > 751rust_test(< a href ="#rust_test-name "> name</ a > ,< a href ="#rust_test-deps "> deps</ a > ,< a href ="#rust_test-srcs "> srcs</ a > ,< a href ="#rust_test-data "> data</ a > ,< a href ="#rust_test-aliases "> aliases</ a > ,< a href ="#rust_test-alwayslink "> alwayslink</ a > ,< a href ="#rust_test-compile_data "> compile_data</ a > ,< a href ="#rust_test-crate "> crate</ a > ,< a href ="#rust_test-crate_features "> crate_features</ a > , 752< a href ="#rust_test-crate_name "> crate_name</ a > ,< a href ="#rust_test-crate_root "> crate_root</ a > ,< a href ="#rust_test-edition "> edition</ a > ,< a href ="#rust_test-env "> env</ a > ,< a href ="#rust_test-env_inherit "> env_inherit</ a > ,< a href ="#rust_test-experimental_use_cc_common_link "> experimental_use_cc_common_link</ a > ,< a href ="#rust_test-malloc "> malloc</ a > , 753< a href ="#rust_test-platform "> platform</ a > ,< a href ="#rust_test-proc_macro_deps "> proc_macro_deps</ a > ,< a href ="#rust_test-rustc_env "> rustc_env</ a > ,< a href ="#rust_test-rustc_env_files "> rustc_env_files</ a > ,< a href ="#rust_test-rustc_flags "> rustc_flags</ a > ,< a href ="#rust_test-stamp "> stamp</ a > , 754< a href ="#rust_test-use_libtest_harness "> use_libtest_harness</ a > ,< a href ="#rust_test-version "> version</ a > ) 755</ pre > 756< p > Builds a Rust test crate.</ p > 757< p > Examples:</ p > 758< p > Suppose you have the following directory structure for a Rust library crate with unit test code in the library sources:</ p > 759< pre >< code class ="language-output "> [workspace]/ 760 WORKSPACE 761 hello_lib/ 762 BUILD 763 src/ 764 lib.rs 765</ code ></ pre > 766< p >< code > hello_lib/src/lib.rs</ code > :</ p > 767< pre >< pre class ="playground ">< code class ="language-rust ">< span class ="boring "> #![allow(unused)] 768</ span >< span class ="boring "> fn main() { 769</ span > pub struct Greeter { 770 greeting: String, 771} 772 773impl Greeter { 774 pub fn new(greeting: &str) -> Greeter { 775 Greeter { greeting: greeting.to_string(), } 776 } 777 778 pub fn greet(&self, thing: &str) -> String { 779 format!("{} {}", &self.greeting, thing) 780 } 781} 782 783#[cfg(test)] 784mod test { 785 use super::Greeter; 786 787 #[test] 788 fn test_greeting() { 789 let hello = Greeter::new("Hi"); 790 assert_eq!("Hi Rust", hello.greet("Rust")); 791 } 792} 793< span class ="boring "> }</ span ></ code ></ pre ></ pre > 794< p > To build and run the tests, simply add a< code > rust_test</ code > rule with no< code > srcs</ code > 795and only depends on the< code > hello_lib</ code > < code > rust_library</ code > target via the 796< code > crate</ code > attribute:</ p > 797< p >< code > hello_lib/BUILD</ code > :</ p > 798< pre >< code class ="language-python "> load("@rules_rust//rust:defs.bzl", "rust_library", "rust_test") 799 800rust_library( 801 name = "hello_lib", 802 srcs = ["src/lib.rs"], 803) 804 805rust_test( 806 name = "hello_lib_test", 807 crate = ":hello_lib", 808 # You may add other deps that are specific to the test configuration 809 deps = ["//some/dev/dep"], 810) 811</ code ></ pre > 812< p > Run the test with< code > bazel test //hello_lib:hello_lib_test</ code > .</ p > 813< h3 id ="example-test-directory ">< a class ="header "href ="#example-test-directory "> Example:< code > test</ code > directory</ a ></ h3 > 814< p > Integration tests that live in the< a href ="http://doc.rust-lang.org/book/testing.html#the-tests-directory ">< code > tests</ code > directory</ a > , they are essentially built as separate crates. Suppose you have the following directory structure where< code > greeting.rs</ code > is an integration test for the< code > hello_lib</ code > library crate:</ p > 815< pre >< code class ="language-output "> [workspace]/ 816 WORKSPACE 817 hello_lib/ 818 BUILD 819 src/ 820 lib.rs 821 tests/ 822 greeting.rs 823</ code ></ pre > 824< p >< code > hello_lib/tests/greeting.rs</ code > :</ p > 825< pre >< pre class ="playground ">< code class ="language-rust ">< span class ="boring "> #![allow(unused)] 826</ span >< span class ="boring "> fn main() { 827</ span > extern crate hello_lib; 828 829use hello_lib; 830 831#[test] 832fn test_greeting() { 833 let hello = greeter::Greeter::new("Hello"); 834 assert_eq!("Hello world", hello.greeting("world")); 835} 836< span class ="boring "> }</ span ></ code ></ pre ></ pre > 837< p > To build the< code > greeting.rs</ code > integration test, simply add a< code > rust_test</ code > target 838with< code > greeting.rs</ code > in< code > srcs</ code > and a dependency on the< code > hello_lib</ code > target:</ p > 839< p >< code > hello_lib/BUILD</ code > :</ p > 840< pre >< code class ="language-python "> load("@rules_rust//rust:defs.bzl", "rust_library", "rust_test") 841 842rust_library( 843 name = "hello_lib", 844 srcs = ["src/lib.rs"], 845) 846 847rust_test( 848 name = "greeting_test", 849 srcs = ["tests/greeting.rs"], 850 deps = [":hello_lib"], 851) 852</ code ></ pre > 853< p > Run the test with< code > bazel test //hello_lib:greeting_test</ code > .</ p > 854< p >< strong > ATTRIBUTES</ strong ></ p > 855< 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 > 856< tr >< td style ="text-align: left ">< a id ="rust_test-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 > 857< tr >< td style ="text-align: left ">< a id ="rust_test-deps "></ a > deps</ td >< td style ="text-align: left "> List of other libraries to be linked to this library target.< br >< br > These can be either other< code > rust_library</ code > targets or< code > cc_library</ code > targets if linking a native library.</ 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 > 858< tr >< td style ="text-align: left ">< a id ="rust_test-srcs "></ a > srcs</ td >< td style ="text-align: left "> List of Rust< code > .rs</ code > source files used to build the library.< br >< br > If< code > srcs</ code > contains more than one file, then there must be a file either named< code > lib.rs</ code > . Otherwise,< code > crate_root</ code > must be set to the source file that is the root of the crate to be passed to rustc to build this crate.</ 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 > 859< tr >< td style ="text-align: left ">< a id ="rust_test-data "></ a > data</ td >< td style ="text-align: left "> List of files used by this rule at compile time and runtime.< br >< br > If including data at compile time with include_str!() and similar, prefer< code > compile_data</ code > over< code > data</ code > , to prevent the data also being included in the runfiles.</ 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 > 860< tr >< td style ="text-align: left ">< a id ="rust_test-aliases "></ a > aliases</ td >< td style ="text-align: left "> Remap crates to a new name or moniker for linkage to this target< br >< br > These are other< code > rust_library</ code > targets and will be presented as the new name given.</ td >< td style ="text-align: left ">< a href ="https://bazel.build/rules/lib/dict "> Dictionary: Label -> String</ a ></ td >< td style ="text-align: left "> optional</ td >< td style ="text-align: left ">< code > {}</ code ></ td ></ tr > 861< tr >< td style ="text-align: left ">< a id ="rust_test-alwayslink "></ a > alwayslink</ td >< td style ="text-align: left "> If 1, any binary that depends (directly or indirectly) on this library will link in all the object files even if some contain no symbols referenced by the binary.< br >< br > This attribute is used by the C++ Starlark API when passing CcInfo providers.</ td >< td style ="text-align: left "> Boolean</ td >< td style ="text-align: left "> optional</ td >< td style ="text-align: left ">< code > False</ code ></ td ></ tr > 862< tr >< td style ="text-align: left ">< a id ="rust_test-compile_data "></ a > compile_data</ td >< td style ="text-align: left "> List of files used by this rule at compile time.< br >< br > This attribute can be used to specify any data files that are embedded into the library, such as via the< a href ="https://doc.rust-lang.org/std/macro.include_str!.html ">< code > include_str!</ code ></ a > macro.</ 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 > 863< tr >< td style ="text-align: left ">< a id ="rust_test-crate "></ a > crate</ td >< td style ="text-align: left "> Target inline tests declared in the given crate< br >< br > These tests are typically those that would be held out under< code > #[cfg(test)]</ code > declarations.</ 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 > 864< tr >< td style ="text-align: left ">< a id ="rust_test-crate_features "></ a > crate_features</ td >< td style ="text-align: left "> List of features to enable for this crate.< br >< br > Features are defined in the code using the< code > #[cfg(feature = "foo")]</ code > configuration option. The features listed here will be passed to< code > rustc</ code > with< code > --cfg feature="${feature_name}"</ code > flags.</ td >< td style ="text-align: left "> List of strings</ td >< td style ="text-align: left "> optional</ td >< td style ="text-align: left ">< code > []</ code ></ td ></ tr > 865< tr >< td style ="text-align: left ">< a id ="rust_test-crate_name "></ a > crate_name</ td >< td style ="text-align: left "> Crate name to use for this target.< br >< br > This must be a valid Rust identifier, i.e. it may contain only alphanumeric characters and underscores. Defaults to the target name, with any hyphens replaced by underscores.</ td >< td style ="text-align: left "> String</ td >< td style ="text-align: left "> optional</ td >< td style ="text-align: left ">< code > ""</ code ></ td ></ tr > 866< tr >< td style ="text-align: left ">< a id ="rust_test-crate_root "></ a > crate_root</ td >< td style ="text-align: left "> The file that will be passed to< code > rustc</ code > to be used for building this crate.< br >< br > If< code > crate_root</ code > is not set, then this rule will look for a< code > lib.rs</ code > file (or< code > main.rs</ code > for rust_binary) or the single file in< code > srcs</ code > if< code > srcs</ code > contains only one 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 > 867< tr >< td style ="text-align: left ">< a id ="rust_test-edition "></ a > edition</ td >< td style ="text-align: left "> The rust edition to use for this crate. Defaults to the edition specified in the rust_toolchain.</ td >< td style ="text-align: left "> String</ td >< td style ="text-align: left "> optional</ td >< td style ="text-align: left ">< code > ""</ code ></ td ></ tr > 868< tr >< td style ="text-align: left ">< a id ="rust_test-env "></ a > env</ td >< td style ="text-align: left "> Specifies additional environment variables to set when the test is executed by bazel test. Values are subject to< code > $(rootpath)</ code > ,< code > $(execpath)</ code > , location, and< a href ="https://docs.bazel.build/versions/master/be/make-variables.html "> "Make variable"</ a > substitution.</ 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 > 869< tr >< td style ="text-align: left ">< a id ="rust_test-env_inherit "></ a > env_inherit</ td >< td style ="text-align: left "> Specifies additional environment variables to inherit from the external environment when the test is executed by bazel test.</ td >< td style ="text-align: left "> List of strings</ td >< td style ="text-align: left "> optional</ td >< td style ="text-align: left ">< code > []</ code ></ td ></ tr > 870< tr >< td style ="text-align: left ">< a id ="rust_test-experimental_use_cc_common_link "></ a > experimental_use_cc_common_link</ td >< td style ="text-align: left "> Whether to use cc_common.link to link rust binaries. Possible values: [-1, 0, 1]. -1 means use the value of the toolchain.experimental_use_cc_common_link boolean build setting to determine. 0 means do not use cc_common.link (use rustc instead). 1 means use cc_common.link.</ td >< td style ="text-align: left "> Integer</ td >< td style ="text-align: left "> optional</ td >< td style ="text-align: left ">< code > -1</ code ></ td ></ tr > 871< tr >< td style ="text-align: left ">< a id ="rust_test-malloc "></ a > malloc</ td >< td style ="text-align: left "> Override the default dependency on< code > malloc</ code > .< br >< br > By default, Rust binaries linked with cc_common.link are linked against< code > @bazel_tools//tools/cpp:malloc"</ code > , which is an empty library and the resulting binary will use libc's< code > malloc</ code > . This label must refer to a< code > cc_library</ code > rule.</ 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 > "@bazel_tools//tools/cpp:malloc"</ code ></ td ></ tr > 872< tr >< td style ="text-align: left ">< a id ="rust_test-platform "></ a > platform</ td >< td style ="text-align: left "> Optional platform to transition the test to.</ 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 > 873< tr >< td style ="text-align: left ">< a id ="rust_test-proc_macro_deps "></ a > proc_macro_deps</ td >< td style ="text-align: left "> List of< code > rust_proc_macro</ code > targets used to help build this library target.</ 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 > 874< tr >< td style ="text-align: left ">< a id ="rust_test-rustc_env "></ a > rustc_env</ td >< td style ="text-align: left "> Dictionary of additional< code > "key": "value"</ code > environment variables to set for rustc.< br >< br > rust_test()/rust_binary() rules can use $(rootpath //package:target) to pass in the location of a generated file or external tool. Cargo build scripts that wish to expand locations should use cargo_build_script()'s build_script_env argument instead, as build scripts are run in a different environment - see cargo_build_script()'s documentation for more.</ 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 > 875< tr >< td style ="text-align: left ">< a id ="rust_test-rustc_env_files "></ a > rustc_env_files</ td >< td style ="text-align: left "> Files containing additional environment variables to set for rustc.< br >< br > These 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 > ).< br >< br > The order that these files will be processed is unspecified, so multiple definitions of a particular variable are discouraged.< br >< br > Note that the variables here are subject to< a href ="https://docs.bazel.build/versions/main/user-manual.html#workspace_status "> workspace status</ a > stamping should the< code > stamp</ code > attribute be enabled. Stamp variables should be wrapped in brackets in order to be resolved. E.g.< code > NAME={WORKSPACE_STATUS_VARIABLE}</ code > .</ 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 > 876< tr >< td style ="text-align: left ">< a id ="rust_test-rustc_flags "></ a > rustc_flags</ td >< td style ="text-align: left "> List of compiler flags passed to< code > rustc</ code > .< br >< br > These strings are subject to Make variable expansion for predefined source/output path variables like< code > $location</ code > ,< code > $execpath</ code > , and< code > $rootpath</ code > . This expansion is useful if you wish to pass a generated file of arguments to rustc:< code > @$(location //package:target)</ code > .</ td >< td style ="text-align: left "> List of strings</ td >< td style ="text-align: left "> optional</ td >< td style ="text-align: left ">< code > []</ code ></ td ></ tr > 877< tr >< td style ="text-align: left ">< a id ="rust_test-stamp "></ a > stamp</ td >< td style ="text-align: left "> Whether to encode build information into the< code > Rustc</ code > action. Possible values:< br >< br > -< code > stamp = 1</ code > : Always stamp the build information into the< code > Rustc</ code > action, even in< a href ="https://docs.bazel.build/versions/main/user-manual.html#flag--stamp "> --nostamp</ a > builds. This setting should be avoided, since it potentially kills remote caching for the target and any downstream actions that depend on it.< br >< br > -< code > stamp = 0</ code > : Always replace build information by constant values. This gives good build result caching.< br >< br > -< code > stamp = -1</ code > : Embedding of build information is controlled by the< a href ="https://docs.bazel.build/versions/main/user-manual.html#flag--stamp "> --[no]stamp</ a > flag.< br >< br > Stamped targets are not rebuilt unless their dependencies change.< br >< br > For example if a< code > rust_library</ code > is stamped, and a< code > rust_binary</ code > depends on that library, the stamped library won't be rebuilt when we change sources of the< code > rust_binary</ code > . This is different from how< a href ="https://docs.bazel.build/versions/main/be/c-cpp.html#cc_library.linkstamp ">< code > cc_library.linkstamps</ code ></ a > behaves.</ td >< td style ="text-align: left "> Integer</ td >< td style ="text-align: left "> optional</ td >< td style ="text-align: left ">< code > 0</ code ></ td ></ tr > 878< tr >< td style ="text-align: left ">< a id ="rust_test-use_libtest_harness "></ a > use_libtest_harness</ td >< td style ="text-align: left "> Whether to use< code > libtest</ code > . For targets using this flag, individual tests can be run by using the< a href ="https://docs.bazel.build/versions/4.0.0/command-line-reference.html#flag--test_arg "> --test_arg</ a > flag. E.g.< code > bazel test //src:rust_test --test_arg=foo::test::test_fn</ code > .</ 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 > 879< tr >< td style ="text-align: left ">< a id ="rust_test-version "></ a > version</ td >< td style ="text-align: left "> A version to inject in the cargo environment variable.</ td >< td style ="text-align: left "> String</ td >< td style ="text-align: left "> optional</ td >< td style ="text-align: left ">< code > "0.0.0"</ code ></ td ></ tr > 880</ tbody ></ table > 881</ div > 882< p >< a id ="rust_toolchain "></ a ></ p > 883< h2 id ="rust_toolchain ">< a class ="header "href ="#rust_toolchain "> rust_toolchain</ a ></ h2 > 884< pre > 885rust_toolchain(< a href ="#rust_toolchain-name "> name</ a > ,< a href ="#rust_toolchain-allocator_library "> allocator_library</ a > ,< a href ="#rust_toolchain-binary_ext "> binary_ext</ a > ,< a href ="#rust_toolchain-cargo "> cargo</ a > ,< a href ="#rust_toolchain-cargo_clippy "> cargo_clippy</ a > ,< a href ="#rust_toolchain-clippy_driver "> clippy_driver</ a > ,< a href ="#rust_toolchain-debug_info "> debug_info</ a > , 886< a href ="#rust_toolchain-default_edition "> default_edition</ a > ,< a href ="#rust_toolchain-dylib_ext "> dylib_ext</ a > ,< a href ="#rust_toolchain-env "> env</ a > ,< a href ="#rust_toolchain-exec_triple "> exec_triple</ a > ,< a href ="#rust_toolchain-experimental_link_std_dylib "> experimental_link_std_dylib</ a > , 887< a href ="#rust_toolchain-experimental_use_cc_common_link "> experimental_use_cc_common_link</ a > ,< a href ="#rust_toolchain-extra_exec_rustc_flags "> extra_exec_rustc_flags</ a > ,< a href ="#rust_toolchain-extra_rustc_flags "> extra_rustc_flags</ a > , 888< a href ="#rust_toolchain-extra_rustc_flags_for_crate_types "> extra_rustc_flags_for_crate_types</ a > ,< a href ="#rust_toolchain-global_allocator_library "> global_allocator_library</ a > ,< a href ="#rust_toolchain-llvm_cov "> llvm_cov</ a > ,< a href ="#rust_toolchain-llvm_profdata "> llvm_profdata</ a > , 889< a href ="#rust_toolchain-llvm_tools "> llvm_tools</ a > ,< a href ="#rust_toolchain-opt_level "> opt_level</ a > ,< a href ="#rust_toolchain-per_crate_rustc_flags "> per_crate_rustc_flags</ a > ,< a href ="#rust_toolchain-rust_doc "> rust_doc</ a > ,< a href ="#rust_toolchain-rust_std "> rust_std</ a > ,< a href ="#rust_toolchain-rustc "> rustc</ a > ,< a href ="#rust_toolchain-rustc_lib "> rustc_lib</ a > , 890< a href ="#rust_toolchain-rustfmt "> rustfmt</ a > ,< a href ="#rust_toolchain-staticlib_ext "> staticlib_ext</ a > ,< a href ="#rust_toolchain-stdlib_linkflags "> stdlib_linkflags</ a > ,< a href ="#rust_toolchain-strip_level "> strip_level</ a > ,< a href ="#rust_toolchain-target_json "> target_json</ a > ,< a href ="#rust_toolchain-target_triple "> target_triple</ a > ) 891</ pre > 892< p > Declares a Rust toolchain for use.</ p > 893< p > This is for declaring a custom toolchain, eg. for configuring a particular version of rust or supporting a new platform.</ p > 894< p > Example:</ p > 895< p > Suppose the core rust team has ported the compiler to a new target CPU, called< code > cpuX</ code > . This support can be used in Bazel by defining a new toolchain definition and declaration:</ p > 896< pre >< code class ="language-python "> load('@rules_rust//rust:toolchain.bzl', 'rust_toolchain') 897 898rust_toolchain( 899 name = "rust_cpuX_impl", 900 binary_ext = "", 901 dylib_ext = ".so", 902 exec_triple = "cpuX-unknown-linux-gnu", 903 rust_doc = "@rust_cpuX//:rustdoc", 904 rust_std = "@rust_cpuX//:rust_std", 905 rustc = "@rust_cpuX//:rustc", 906 rustc_lib = "@rust_cpuX//:rustc_lib", 907 staticlib_ext = ".a", 908 stdlib_linkflags = ["-lpthread", "-ldl"], 909 target_triple = "cpuX-unknown-linux-gnu", 910) 911 912toolchain( 913 name = "rust_cpuX", 914 exec_compatible_with = [ 915 "@platforms//cpu:cpuX", 916 "@platforms//os:linux", 917 ], 918 target_compatible_with = [ 919 "@platforms//cpu:cpuX", 920 "@platforms//os:linux", 921 ], 922 toolchain = ":rust_cpuX_impl", 923) 924</ code ></ pre > 925< p > Then, either add the label of the toolchain rule to< code > register_toolchains</ code > in the WORKSPACE, or pass it to the< code > "--extra_toolchains"</ code > flag for Bazel, and it will be used.</ p > 926< p > See< code > @rules_rust//rust:repositories.bzl</ code > for examples of defining the< code > @rust_cpuX</ code > repository with the actual binaries and libraries.</ p > 927< p >< strong > ATTRIBUTES</ strong ></ p > 928< 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 > 929< tr >< td style ="text-align: left ">< a id ="rust_toolchain-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 > 930< tr >< td style ="text-align: left ">< a id ="rust_toolchain-allocator_library "></ a > allocator_library</ td >< td style ="text-align: left "> Target that provides allocator functions when rust_library targets are embedded in a cc_binary.</ 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 > "@rules_rust//ffi/cc/allocator_library"</ code ></ td ></ tr > 931< tr >< td style ="text-align: left ">< a id ="rust_toolchain-binary_ext "></ a > binary_ext</ td >< td style ="text-align: left "> The extension for binaries created from rustc.</ td >< td style ="text-align: left "> String</ td >< td style ="text-align: left "> required</ td >< td style ="text-align: left "></ td ></ tr > 932< tr >< td style ="text-align: left ">< a id ="rust_toolchain-cargo "></ a > cargo</ td >< td style ="text-align: left "> The location of the< code > cargo</ code > binary. Can be a direct source or a filegroup containing one item.</ 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 > 933< tr >< td style ="text-align: left ">< a id ="rust_toolchain-cargo_clippy "></ a > cargo_clippy</ td >< td style ="text-align: left "> The location of the< code > cargo_clippy</ code > binary. Can be a direct source or a filegroup containing one item.</ 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 > 934< tr >< td style ="text-align: left ">< a id ="rust_toolchain-clippy_driver "></ a > clippy_driver</ td >< td style ="text-align: left "> The location of the< code > clippy-driver</ code > binary. Can be a direct source or a filegroup containing one item.</ 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 > 935< tr >< td style ="text-align: left ">< a id ="rust_toolchain-debug_info "></ a > debug_info</ td >< td style ="text-align: left "> Rustc debug info levels per opt level</ 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 > {"dbg": "2", "fastbuild": "0", "opt": "0"}</ code ></ td ></ tr > 936< tr >< td style ="text-align: left ">< a id ="rust_toolchain-default_edition "></ a > default_edition</ td >< td style ="text-align: left "> The edition to use for rust_* rules that don't specify an edition. If absent, every rule is required to specify its< code > edition</ code > attribute.</ td >< td style ="text-align: left "> String</ td >< td style ="text-align: left "> optional</ td >< td style ="text-align: left ">< code > ""</ code ></ td ></ tr > 937< tr >< td style ="text-align: left ">< a id ="rust_toolchain-dylib_ext "></ a > dylib_ext</ td >< td style ="text-align: left "> The extension for dynamic libraries created from rustc.</ td >< td style ="text-align: left "> String</ td >< td style ="text-align: left "> required</ td >< td style ="text-align: left "></ td ></ tr > 938< tr >< td style ="text-align: left ">< a id ="rust_toolchain-env "></ a > env</ td >< td style ="text-align: left "> Environment variables to set in actions.</ 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 > 939< tr >< td style ="text-align: left ">< a id ="rust_toolchain-exec_triple "></ a > exec_triple</ td >< td style ="text-align: left "> The platform triple for the toolchains execution environment. For more details see: https://docs.bazel.build/versions/master/skylark/rules.html#configurations</ td >< td style ="text-align: left "> String</ td >< td style ="text-align: left "> required</ td >< td style ="text-align: left "></ td ></ tr > 940< tr >< td style ="text-align: left ">< a id ="rust_toolchain-experimental_link_std_dylib "></ a > experimental_link_std_dylib</ td >< td style ="text-align: left "> Label to a boolean build setting that controls whether whether to link libstd dynamically.</ 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 > "@rules_rust//rust/settings:experimental_link_std_dylib"</ code ></ td ></ tr > 941< tr >< td style ="text-align: left ">< a id ="rust_toolchain-experimental_use_cc_common_link "></ a > experimental_use_cc_common_link</ td >< td style ="text-align: left "> Label to a boolean build setting that controls whether cc_common.link is used to link rust binaries.</ 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 > "@rules_rust//rust/settings:experimental_use_cc_common_link"</ code ></ td ></ tr > 942< tr >< td style ="text-align: left ">< a id ="rust_toolchain-extra_exec_rustc_flags "></ a > extra_exec_rustc_flags</ td >< td style ="text-align: left "> Extra flags to pass to rustc in exec configuration</ td >< td style ="text-align: left "> List of strings</ td >< td style ="text-align: left "> optional</ td >< td style ="text-align: left ">< code > []</ code ></ td ></ tr > 943< tr >< td style ="text-align: left ">< a id ="rust_toolchain-extra_rustc_flags "></ a > extra_rustc_flags</ td >< td style ="text-align: left "> Extra flags to pass to rustc in non-exec configuration. Subject to location expansion with respect to the srcs of the< code > rust_std</ code > attribute.</ td >< td style ="text-align: left "> List of strings</ td >< td style ="text-align: left "> optional</ td >< td style ="text-align: left ">< code > []</ code ></ td ></ tr > 944< tr >< td style ="text-align: left ">< a id ="rust_toolchain-extra_rustc_flags_for_crate_types "></ a > extra_rustc_flags_for_crate_types</ td >< td style ="text-align: left "> Extra flags to pass to rustc based on crate type</ td >< td style ="text-align: left ">< a href ="https://bazel.build/rules/lib/dict "> Dictionary: String -> List of strings</ a ></ td >< td style ="text-align: left "> optional</ td >< td style ="text-align: left ">< code > {}</ code ></ td ></ tr > 945< tr >< td style ="text-align: left ">< a id ="rust_toolchain-global_allocator_library "></ a > global_allocator_library</ td >< td style ="text-align: left "> Target that provides allocator functions for when a global allocator is present.</ 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 > "@rules_rust//ffi/cc/global_allocator_library"</ code ></ td ></ tr > 946< tr >< td style ="text-align: left ">< a id ="rust_toolchain-llvm_cov "></ a > llvm_cov</ td >< td style ="text-align: left "> The location of the< code > llvm-cov</ code > binary. Can be a direct source or a filegroup containing one item. If None, rust code is not instrumented for coverage.</ 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 > 947< tr >< td style ="text-align: left ">< a id ="rust_toolchain-llvm_profdata "></ a > llvm_profdata</ td >< td style ="text-align: left "> The location of the< code > llvm-profdata</ code > binary. Can be a direct source or a filegroup containing one item. If< code > llvm_cov</ code > is None, this can be None as well and rust code is not instrumented for coverage.</ 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 > 948< tr >< td style ="text-align: left ">< a id ="rust_toolchain-llvm_tools "></ a > llvm_tools</ td >< td style ="text-align: left "> LLVM tools that are shipped with the Rust toolchain.</ 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 > 949< tr >< td style ="text-align: left ">< a id ="rust_toolchain-opt_level "></ a > opt_level</ td >< td style ="text-align: left "> Rustc optimization levels.</ 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 > {"dbg": "0", "fastbuild": "0", "opt": "3"}</ code ></ td ></ tr > 950< tr >< td style ="text-align: left ">< a id ="rust_toolchain-per_crate_rustc_flags "></ a > per_crate_rustc_flags</ td >< td style ="text-align: left "> Extra flags to pass to rustc in non-exec configuration</ td >< td style ="text-align: left "> List of strings</ td >< td style ="text-align: left "> optional</ td >< td style ="text-align: left ">< code > []</ code ></ td ></ tr > 951< tr >< td style ="text-align: left ">< a id ="rust_toolchain-rust_doc "></ a > rust_doc</ td >< td style ="text-align: left "> The location of the< code > rustdoc</ code > binary. Can be a direct source or a filegroup containing one item.</ 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 > 952< tr >< td style ="text-align: left ">< a id ="rust_toolchain-rust_std "></ a > rust_std</ td >< td style ="text-align: left "> The Rust standard library.</ 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 > 953< tr >< td style ="text-align: left ">< a id ="rust_toolchain-rustc "></ a > rustc</ td >< td style ="text-align: left "> The location of the< code > rustc</ code > binary. Can be a direct source or a filegroup containing one item.</ 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 > 954< tr >< td style ="text-align: left ">< a id ="rust_toolchain-rustc_lib "></ a > rustc_lib</ td >< td style ="text-align: left "> The libraries used by rustc during compilation.</ 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 > 955< tr >< td style ="text-align: left ">< a id ="rust_toolchain-rustfmt "></ a > rustfmt</ td >< td style ="text-align: left ">< strong > Deprecated</ strong > : Instead see< a href ="#rustfmt_toolchain "> rustfmt_toolchain</ a ></ 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 > 956< tr >< td style ="text-align: left ">< a id ="rust_toolchain-staticlib_ext "></ a > staticlib_ext</ td >< td style ="text-align: left "> The extension for static libraries created from rustc.</ td >< td style ="text-align: left "> String</ td >< td style ="text-align: left "> required</ td >< td style ="text-align: left "></ td ></ tr > 957< tr >< td style ="text-align: left ">< a id ="rust_toolchain-stdlib_linkflags "></ a > stdlib_linkflags</ td >< td style ="text-align: left "> Additional linker flags to use when Rust standard library is linked by a C++ linker (rustc will deal with these automatically). Subject to location expansion with respect to the srcs of the< code > rust_std</ code > attribute.</ td >< td style ="text-align: left "> List of strings</ td >< td style ="text-align: left "> required</ td >< td style ="text-align: left "></ td ></ tr > 958< tr >< td style ="text-align: left ">< a id ="rust_toolchain-strip_level "></ a > strip_level</ td >< td style ="text-align: left "> Rustc strip levels. For all potential options, see https://doc.rust-lang.org/rustc/codegen-options/index.html#strip</ 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 > {"dbg": "none", "fastbuild": "none", "opt": "debuginfo"}</ code ></ td ></ tr > 959< tr >< td style ="text-align: left ">< a id ="rust_toolchain-target_json "></ a > target_json</ td >< td style ="text-align: left "> Override the target_triple with a custom target specification. For more details see: https://doc.rust-lang.org/rustc/targets/custom.html</ td >< td style ="text-align: left "> String</ td >< td style ="text-align: left "> optional</ td >< td style ="text-align: left ">< code > ""</ code ></ td ></ tr > 960< tr >< td style ="text-align: left ">< a id ="rust_toolchain-target_triple "></ a > target_triple</ td >< td style ="text-align: left "> The platform triple for the toolchains target environment. For more details see: https://docs.bazel.build/versions/master/skylark/rules.html#configurations</ td >< td style ="text-align: left "> String</ td >< td style ="text-align: left "> optional</ td >< td style ="text-align: left ">< code > ""</ code ></ td ></ tr > 961</ tbody ></ table > 962</ div > 963< p >< a id ="rustfmt_test "></ a ></ p > 964< h2 id ="rustfmt_test ">< a class ="header "href ="#rustfmt_test "> rustfmt_test</ a ></ h2 > 965< pre > 966rustfmt_test(< a href ="#rustfmt_test-name "> name</ a > ,< a href ="#rustfmt_test-targets "> targets</ a > ) 967</ pre > 968< p > A test rule for performing< code > rustfmt --check</ code > on a set of targets</ p > 969< p >< strong > ATTRIBUTES</ strong ></ p > 970< 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 > 971< tr >< td style ="text-align: left ">< a id ="rustfmt_test-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 > 972< tr >< td style ="text-align: left ">< a id ="rustfmt_test-targets "></ a > targets</ td >< td style ="text-align: left "> Rust targets to run< code > rustfmt --check</ code > on.</ 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 > 973</ tbody ></ table > 974</ div > 975< p >< a id ="rustfmt_toolchain "></ a ></ p > 976< h2 id ="rustfmt_toolchain ">< a class ="header "href ="#rustfmt_toolchain "> rustfmt_toolchain</ a ></ h2 > 977< pre > 978rustfmt_toolchain(< a href ="#rustfmt_toolchain-name "> name</ a > ,< a href ="#rustfmt_toolchain-rustc "> rustc</ a > ,< a href ="#rustfmt_toolchain-rustc_lib "> rustc_lib</ a > ,< a href ="#rustfmt_toolchain-rustfmt "> rustfmt</ a > ) 979</ pre > 980< p > A toolchain for< a href ="https://rust-lang.github.io/rustfmt/ "> rustfmt</ a ></ p > 981< p >< strong > ATTRIBUTES</ strong ></ p > 982< 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 > 983< tr >< td style ="text-align: left ">< a id ="rustfmt_toolchain-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 > 984< tr >< td style ="text-align: left ">< a id ="rustfmt_toolchain-rustc "></ a > rustc</ td >< td style ="text-align: left "> The location of the< code > rustc</ code > binary. Can be a direct source or a filegroup containing one item.</ 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 > 985< tr >< td style ="text-align: left ">< a id ="rustfmt_toolchain-rustc_lib "></ a > rustc_lib</ td >< td style ="text-align: left "> The libraries used by rustc during compilation.</ 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 > 986< tr >< td style ="text-align: left ">< a id ="rustfmt_toolchain-rustfmt "></ a > rustfmt</ td >< td style ="text-align: left "> The location of the< code > rustfmt</ code > binary. Can be a direct source or a filegroup containing one item.</ 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 > 987</ tbody ></ table > 988</ div > 989< p >< a id ="CrateInfo "></ a ></ p > 990< h2 id ="crateinfo ">< a class ="header "href ="#crateinfo "> CrateInfo</ a ></ h2 > 991< pre > 992CrateInfo(< a href ="#CrateInfo-aliases "> aliases</ a > ,< a href ="#CrateInfo-compile_data "> compile_data</ a > ,< a href ="#CrateInfo-compile_data_targets "> compile_data_targets</ a > ,< a href ="#CrateInfo-data "> data</ a > ,< a href ="#CrateInfo-deps "> deps</ a > ,< a href ="#CrateInfo-edition "> edition</ a > ,< a href ="#CrateInfo-is_test "> is_test</ a > ,< a href ="#CrateInfo-metadata "> metadata</ a > ,< a href ="#CrateInfo-name "> name</ a > , 993< a href ="#CrateInfo-output "> output</ a > ,< a href ="#CrateInfo-owner "> owner</ a > ,< a href ="#CrateInfo-proc_macro_deps "> proc_macro_deps</ a > ,< a href ="#CrateInfo-root "> root</ a > ,< a href ="#CrateInfo-rustc_env "> rustc_env</ a > ,< a href ="#CrateInfo-rustc_env_files "> rustc_env_files</ a > ,< a href ="#CrateInfo-rustc_output "> rustc_output</ a > , 994< a href ="#CrateInfo-rustc_rmeta_output "> rustc_rmeta_output</ a > ,< a href ="#CrateInfo-srcs "> srcs</ a > ,< a href ="#CrateInfo-std_dylib "> std_dylib</ a > ,< a href ="#CrateInfo-type "> type</ a > ,< a href ="#CrateInfo-wrapped_crate_type "> wrapped_crate_type</ a > ) 995</ pre > 996< p > A provider containing general Crate information.</ p > 997< p >< strong > FIELDS</ strong ></ p > 998< div class ="table-wrapper ">< table >< thead >< tr >< th style ="text-align: left "> Name</ th >< th style ="text-align: left "> Description</ th ></ tr ></ thead >< tbody > 999< tr >< td style ="text-align: left ">< a id ="CrateInfo-aliases "></ a > aliases</ td >< td style ="text-align: left "> Dict[Label, String]: Renamed and aliased crates</ td ></ tr > 1000< tr >< td style ="text-align: left ">< a id ="CrateInfo-compile_data "></ a > compile_data</ td >< td style ="text-align: left "> depset[File]: Compile data required by this crate.</ td ></ tr > 1001< tr >< td style ="text-align: left ">< a id ="CrateInfo-compile_data_targets "></ a > compile_data_targets</ td >< td style ="text-align: left "> depset[Label]: Compile data targets required by this crate.</ td ></ tr > 1002< tr >< td style ="text-align: left ">< a id ="CrateInfo-data "></ a > data</ td >< td style ="text-align: left "> depset[File]: Compile data required by crates that use the current crate as a proc-macro.</ td ></ tr > 1003< tr >< td style ="text-align: left ">< a id ="CrateInfo-deps "></ a > deps</ td >< td style ="text-align: left "> depset[DepVariantInfo]: This crate's (rust or cc) dependencies' providers.</ td ></ tr > 1004< tr >< td style ="text-align: left ">< a id ="CrateInfo-edition "></ a > edition</ td >< td style ="text-align: left "> str: The edition of this crate.</ td ></ tr > 1005< tr >< td style ="text-align: left ">< a id ="CrateInfo-is_test "></ a > is_test</ td >< td style ="text-align: left "> bool: If the crate is being compiled in a test context</ td ></ tr > 1006< tr >< td style ="text-align: left ">< a id ="CrateInfo-metadata "></ a > metadata</ td >< td style ="text-align: left "> File: The output from rustc from producing the output file. It is optional.</ td ></ tr > 1007< tr >< td style ="text-align: left ">< a id ="CrateInfo-name "></ a > name</ td >< td style ="text-align: left "> str: The name of this crate.</ td ></ tr > 1008< tr >< td style ="text-align: left ">< a id ="CrateInfo-output "></ a > output</ td >< td style ="text-align: left "> File: The output File that will be produced, depends on crate type.</ td ></ tr > 1009< tr >< td style ="text-align: left ">< a id ="CrateInfo-owner "></ a > owner</ td >< td style ="text-align: left "> Label: The label of the target that produced this CrateInfo</ td ></ tr > 1010< tr >< td style ="text-align: left ">< a id ="CrateInfo-proc_macro_deps "></ a > proc_macro_deps</ td >< td style ="text-align: left "> depset[DepVariantInfo]: This crate's rust proc_macro dependencies' providers.</ td ></ tr > 1011< tr >< td style ="text-align: left ">< a id ="CrateInfo-root "></ a > root</ td >< td style ="text-align: left "> File: The source File entrypoint to this crate, eg. lib.rs</ td ></ tr > 1012< tr >< td style ="text-align: left ">< a id ="CrateInfo-rustc_env "></ a > rustc_env</ td >< td style ="text-align: left "> Dict[String, String]: Additional< code > "key": "value"</ code > environment variables to set for rustc.</ td ></ tr > 1013< tr >< td style ="text-align: left ">< a id ="CrateInfo-rustc_env_files "></ a > rustc_env_files</ td >< td style ="text-align: left "> [File]: Files containing additional environment variables to set for rustc.</ td ></ tr > 1014< tr >< td style ="text-align: left ">< a id ="CrateInfo-rustc_output "></ a > rustc_output</ td >< td style ="text-align: left "> File: The output from rustc from producing the output file. It is optional.</ td ></ tr > 1015< tr >< td style ="text-align: left ">< a id ="CrateInfo-rustc_rmeta_output "></ a > rustc_rmeta_output</ td >< td style ="text-align: left "> File: The rmeta file produced for this crate. It is optional.</ td ></ tr > 1016< tr >< td style ="text-align: left ">< a id ="CrateInfo-srcs "></ a > srcs</ td >< td style ="text-align: left "> depset[File]: All source Files that are part of the crate.</ td ></ tr > 1017< tr >< td style ="text-align: left ">< a id ="CrateInfo-std_dylib "></ a > std_dylib</ td >< td style ="text-align: left "> File: libstd.so file</ td ></ tr > 1018< tr >< td style ="text-align: left ">< a id ="CrateInfo-type "></ a > type</ td >< td style ="text-align: left "> str: The type of this crate (see< a href ="https://doc.rust-lang.org/rustc/command-line-arguments.html#--crate-type-a-list-of-types-of-crates-for-the-compiler-to-emit "> rustc --crate-type</ a > ).</ td ></ tr > 1019< tr >< td style ="text-align: left ">< a id ="CrateInfo-wrapped_crate_type "></ a > wrapped_crate_type</ td >< td style ="text-align: left "> str, optional: The original crate type for targets generated using a previously defined crate (typically tests using the< code > rust_test::crate</ code > attribute)</ td ></ tr > 1020</ tbody ></ table > 1021</ div > 1022< p >< a id ="DepInfo "></ a ></ p > 1023< h2 id ="depinfo ">< a class ="header "href ="#depinfo "> DepInfo</ a ></ h2 > 1024< pre > 1025DepInfo(< a href ="#DepInfo-dep_env "> dep_env</ a > ,< a href ="#DepInfo-direct_crates "> direct_crates</ a > ,< a href ="#DepInfo-link_search_path_files "> link_search_path_files</ a > ,< a href ="#DepInfo-transitive_build_infos "> transitive_build_infos</ a > , 1026< a href ="#DepInfo-transitive_crate_outputs "> transitive_crate_outputs</ a > ,< a href ="#DepInfo-transitive_crates "> transitive_crates</ a > ,< a href ="#DepInfo-transitive_data "> transitive_data</ a > ,< a href ="#DepInfo-transitive_metadata_outputs "> transitive_metadata_outputs</ a > , 1027< a href ="#DepInfo-transitive_noncrates "> transitive_noncrates</ a > ,< a href ="#DepInfo-transitive_proc_macro_data "> transitive_proc_macro_data</ a > ) 1028</ pre > 1029< p > A provider containing information about a Crate's dependencies.</ p > 1030< p >< strong > FIELDS</ strong ></ p > 1031< div class ="table-wrapper ">< table >< thead >< tr >< th style ="text-align: left "> Name</ th >< th style ="text-align: left "> Description</ th ></ tr ></ thead >< tbody > 1032< tr >< td style ="text-align: left ">< a id ="DepInfo-dep_env "></ a > dep_env</ td >< td style ="text-align: left "> File: File with environment variables direct dependencies build scripts rely upon.</ td ></ tr > 1033< tr >< td style ="text-align: left ">< a id ="DepInfo-direct_crates "></ a > direct_crates</ td >< td style ="text-align: left "> depset[AliasableDepInfo]</ td ></ tr > 1034< tr >< td style ="text-align: left ">< a id ="DepInfo-link_search_path_files "></ a > link_search_path_files</ td >< td style ="text-align: left "> depset[File]: All transitive files containing search paths to pass to the linker</ td ></ tr > 1035< tr >< td style ="text-align: left ">< a id ="DepInfo-transitive_build_infos "></ a > transitive_build_infos</ td >< td style ="text-align: left "> depset[BuildInfo]</ td ></ tr > 1036< tr >< td style ="text-align: left ">< a id ="DepInfo-transitive_crate_outputs "></ a > transitive_crate_outputs</ td >< td style ="text-align: left "> depset[File]: All transitive crate outputs.</ td ></ tr > 1037< tr >< td style ="text-align: left ">< a id ="DepInfo-transitive_crates "></ a > transitive_crates</ td >< td style ="text-align: left "> depset[CrateInfo]</ td ></ tr > 1038< tr >< td style ="text-align: left ">< a id ="DepInfo-transitive_data "></ a > transitive_data</ td >< td style ="text-align: left "> depset[File]: Data of all transitive non-macro dependencies.</ td ></ tr > 1039< tr >< td style ="text-align: left ">< a id ="DepInfo-transitive_metadata_outputs "></ a > transitive_metadata_outputs</ td >< td style ="text-align: left "> depset[File]: All transitive metadata dependencies (.rmeta, for crates that provide them) and all transitive object dependencies (.rlib) for crates that don't provide metadata.</ td ></ tr > 1040< tr >< td style ="text-align: left ">< a id ="DepInfo-transitive_noncrates "></ a > transitive_noncrates</ td >< td style ="text-align: left "> depset[LinkerInput]: All transitive dependencies that aren't crates.</ td ></ tr > 1041< tr >< td style ="text-align: left ">< a id ="DepInfo-transitive_proc_macro_data "></ a > transitive_proc_macro_data</ td >< td style ="text-align: left "> depset[File]: Data of all transitive proc-macro dependencies, and non-macro dependencies of those macros.</ td ></ tr > 1042</ tbody ></ table > 1043</ div > 1044< p >< a id ="StdLibInfo "></ a ></ p > 1045< h2 id ="stdlibinfo ">< a class ="header "href ="#stdlibinfo "> StdLibInfo</ a ></ h2 > 1046< pre > 1047StdLibInfo(< a href ="#StdLibInfo-alloc_files "> alloc_files</ a > ,< a href ="#StdLibInfo-between_alloc_and_core_files "> between_alloc_and_core_files</ a > ,< a href ="#StdLibInfo-between_core_and_std_files "> between_core_and_std_files</ a > ,< a href ="#StdLibInfo-core_files "> core_files</ a > , 1048< a href ="#StdLibInfo-dot_a_files "> dot_a_files</ a > ,< a href ="#StdLibInfo-memchr_files "> memchr_files</ a > ,< a href ="#StdLibInfo-panic_files "> panic_files</ a > ,< a href ="#StdLibInfo-self_contained_files "> self_contained_files</ a > ,< a href ="#StdLibInfo-srcs "> srcs</ a > ,< a href ="#StdLibInfo-std_dylib "> std_dylib</ a > ,< a href ="#StdLibInfo-std_files "> std_files</ a > , 1049< a href ="#StdLibInfo-std_rlibs "> std_rlibs</ a > ,< a href ="#StdLibInfo-test_files "> test_files</ a > ) 1050</ pre > 1051< p > A collection of files either found within the< code > rust-stdlib</ code > artifact or generated based on existing files.</ p > 1052< p >< strong > FIELDS</ strong ></ p > 1053< div class ="table-wrapper ">< table >< thead >< tr >< th style ="text-align: left "> Name</ th >< th style ="text-align: left "> Description</ th ></ tr ></ thead >< tbody > 1054< tr >< td style ="text-align: left ">< a id ="StdLibInfo-alloc_files "></ a > alloc_files</ td >< td style ="text-align: left "> List[File]:< code > .a</ code > files related to the< code > alloc</ code > module.</ td ></ tr > 1055< tr >< td style ="text-align: left ">< a id ="StdLibInfo-between_alloc_and_core_files "></ a > between_alloc_and_core_files</ td >< td style ="text-align: left "> List[File]:< code > .a</ code > files related to the< code > compiler_builtins</ code > module.</ td ></ tr > 1056< tr >< td style ="text-align: left ">< a id ="StdLibInfo-between_core_and_std_files "></ a > between_core_and_std_files</ td >< td style ="text-align: left "> List[File]:< code > .a</ code > files related to all modules except< code > adler</ code > ,< code > alloc</ code > ,< code > compiler_builtins</ code > ,< code > core</ code > , and< code > std</ code > .</ td ></ tr > 1057< tr >< td style ="text-align: left ">< a id ="StdLibInfo-core_files "></ a > core_files</ td >< td style ="text-align: left "> List[File]:< code > .a</ code > files related to the< code > core</ code > and< code > adler</ code > modules</ td ></ tr > 1058< tr >< td style ="text-align: left ">< a id ="StdLibInfo-dot_a_files "></ a > dot_a_files</ td >< td style ="text-align: left "> Depset[File]: Generated< code > .a</ code > files</ td ></ tr > 1059< tr >< td style ="text-align: left ">< a id ="StdLibInfo-memchr_files "></ a > memchr_files</ td >< td style ="text-align: left "> Depset[File]:< code > .a</ code > files associated with the< code > memchr</ code > module.</ td ></ tr > 1060< tr >< td style ="text-align: left ">< a id ="StdLibInfo-panic_files "></ a > panic_files</ td >< td style ="text-align: left "> Depset[File]:< code > .a</ code > files associated with< code > panic_unwind</ code > and< code > panic_abort</ code > .</ td ></ tr > 1061< tr >< td style ="text-align: left ">< a id ="StdLibInfo-self_contained_files "></ a > self_contained_files</ td >< td style ="text-align: left "> List[File]: All< code > .o</ code > files from the< code > self-contained</ code > directory.</ td ></ tr > 1062< tr >< td style ="text-align: left ">< a id ="StdLibInfo-srcs "></ a > srcs</ td >< td style ="text-align: left "> List[Target]: All targets from the original< code > srcs</ code > attribute.</ td ></ tr > 1063< tr >< td style ="text-align: left ">< a id ="StdLibInfo-std_dylib "></ a > std_dylib</ td >< td style ="text-align: left "> File: libstd.so file</ td ></ tr > 1064< tr >< td style ="text-align: left ">< a id ="StdLibInfo-std_files "></ a > std_files</ td >< td style ="text-align: left "> Depset[File]:< code > .a</ code > files associated with the< code > std</ code > module.</ td ></ tr > 1065< tr >< td style ="text-align: left ">< a id ="StdLibInfo-std_rlibs "></ a > std_rlibs</ td >< td style ="text-align: left "> List[File]: All< code > .rlib</ code > files</ td ></ tr > 1066< tr >< td style ="text-align: left ">< a id ="StdLibInfo-test_files "></ a > test_files</ td >< td style ="text-align: left "> Depset[File]:< code > .a</ code > files associated with the< code > test</ code > module.</ td ></ tr > 1067</ tbody ></ table > 1068</ div > 1069< p >< a id ="cargo_build_script "></ a ></ p > 1070< h2 id ="cargo_build_script ">< a class ="header "href ="#cargo_build_script "> cargo_build_script</ a ></ h2 > 1071< pre > 1072cargo_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 > , 1073< 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 > , 1074< 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 > , 1075< a href ="#cargo_build_script-pkg_name "> pkg_name</ a > ,< a href ="#cargo_build_script-kwargs "> kwargs</ a > ) 1076</ pre > 1077< p > Compile and execute a rust build script to generate build attributes</ p > 1078< p > This rules take the same arguments as rust_binary.</ p > 1079< p > Example:</ p > 1080< p > Suppose you have a crate with a cargo build script< code > build.rs</ code > :</ p > 1081< pre >< code class ="language-output "> [workspace]/ 1082 hello_lib/ 1083 BUILD 1084 build.rs 1085 src/ 1086 lib.rs 1087</ code ></ pre > 1088< p > Then you want to use the build script in the following:</ p > 1089< p >< code > hello_lib/BUILD</ code > :</ p > 1090< pre >< code class ="language-python "> package(default_visibility = ["//visibility:public"]) 1091 1092load("@rules_rust//rust:defs.bzl", "rust_binary", "rust_library") 1093load("@rules_rust//cargo:defs.bzl", "cargo_build_script") 1094 1095# This will run the build script from the root of the workspace, and 1096# collect the outputs. 1097cargo_build_script( 1098 name = "build_script", 1099 srcs = ["build.rs"], 1100 # Optional environment variables passed during build.rs compilation 1101 rustc_env = { 1102 "CARGO_PKG_VERSION": "0.1.2", 1103 }, 1104 # Optional environment variables passed during build.rs execution. 1105 # Note that as the build script's working directory is not execroot, 1106 # execpath/location will return an absolute path, instead of a relative 1107 # one. 1108 build_script_env = { 1109 "SOME_TOOL_OR_FILE": "$(execpath @tool//:binary)" 1110 }, 1111 # Optional data/tool dependencies 1112 data = ["@tool//:binary"], 1113) 1114 1115rust_library( 1116 name = "hello_lib", 1117 srcs = [ 1118 "src/lib.rs", 1119 ], 1120 deps = [":build_script"], 1121) 1122</ code ></ pre > 1123< 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 > 1124< p >< strong > PARAMETERS</ strong ></ p > 1125< 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 > 1126< 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 > 1127< 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 > 1128< 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 > 1129< 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 > 1130< 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 > 1131< 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 > 1132< 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 > 1133< 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 > 1134< 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 > 1135< 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 > 1136< 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 > 1137< 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 > 1138< 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 > 1139< 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 > 1140< 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 > 1141< 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 > 1142< 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 > 1143< 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 > 1144< 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 > 1145< 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 > 1146< 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 > 1147< 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 > 1148< 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 > 1149< 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 > 1150</ tbody ></ table > 1151</ div > 1152< p >< a id ="cargo_env "></ a ></ p > 1153< h2 id ="cargo_env ">< a class ="header "href ="#cargo_env "> cargo_env</ a ></ h2 > 1154< pre > 1155cargo_env(< a href ="#cargo_env-env "> env</ a > ) 1156</ pre > 1157< p > A helper for generating platform specific environment variables</ p > 1158< pre >< code class ="language-python "> load("@rules_rust//rust:defs.bzl", "rust_common") 1159load("@rules_rust//cargo:defs.bzl", "cargo_bootstrap_repository", "cargo_env") 1160 1161cargo_bootstrap_repository( 1162 name = "bootstrapped_bin", 1163 cargo_lockfile = "//:Cargo.lock", 1164 cargo_toml = "//:Cargo.toml", 1165 srcs = ["//:resolver_srcs"], 1166 version = rust_common.default_version, 1167 binary = "my-crate-binary", 1168 env = { 1169 "x86_64-unknown-linux-gnu": cargo_env({ 1170 "FOO": "BAR", 1171 }), 1172 }, 1173 env_label = { 1174 "aarch64-unknown-linux-musl": cargo_env({ 1175 "DOC": "//:README.md", 1176 }), 1177 } 1178) 1179</ code ></ pre > 1180< p >< strong > PARAMETERS</ strong ></ p > 1181< 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 > 1182< 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 > 1183</ tbody ></ table > 1184</ div > 1185< p >< strong > RETURNS</ strong ></ p > 1186< p > str: A json encoded string of the environment variables</ p > 1187< p >< a id ="rules_rust_dependencies "></ a ></ p > 1188< h2 id ="rules_rust_dependencies ">< a class ="header "href ="#rules_rust_dependencies "> rules_rust_dependencies</ a ></ h2 > 1189< pre > 1190rules_rust_dependencies() 1191</ pre > 1192< p > Dependencies used in the implementation of< code > rules_rust</ code > .</ p > 1193< p >< a id ="rust_analyzer_toolchain_repository "></ a ></ p > 1194< h2 id ="rust_analyzer_toolchain_repository ">< a class ="header "href ="#rust_analyzer_toolchain_repository "> rust_analyzer_toolchain_repository</ a ></ h2 > 1195< pre > 1196rust_analyzer_toolchain_repository(< a href ="#rust_analyzer_toolchain_repository-name "> name</ a > ,< a href ="#rust_analyzer_toolchain_repository-version "> version</ a > ,< a href ="#rust_analyzer_toolchain_repository-exec_compatible_with "> exec_compatible_with</ a > ,< a href ="#rust_analyzer_toolchain_repository-target_compatible_with "> target_compatible_with</ a > , 1197< a href ="#rust_analyzer_toolchain_repository-sha256s "> sha256s</ a > ,< a href ="#rust_analyzer_toolchain_repository-urls "> urls</ a > ,< a href ="#rust_analyzer_toolchain_repository-auth "> auth</ a > ,< a href ="#rust_analyzer_toolchain_repository-netrc "> netrc</ a > ,< a href ="#rust_analyzer_toolchain_repository-auth_patterns "> auth_patterns</ a > ) 1198</ pre > 1199< p > Assemble a remote rust_analyzer_toolchain target based on the given params.</ p > 1200< p >< strong > PARAMETERS</ strong ></ p > 1201< 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 > 1202< tr >< td style ="text-align: left ">< a id ="rust_analyzer_toolchain_repository-name "></ a > name</ td >< td style ="text-align: left "> The name of the toolchain proxy repository contianing the registerable toolchain.</ td >< td style ="text-align: left "> none</ td ></ tr > 1203< tr >< td style ="text-align: left ">< a id ="rust_analyzer_toolchain_repository-version "></ a > version</ td >< td style ="text-align: left "> The version of the tool among "nightly", "beta', or an exact version.</ td >< td style ="text-align: left "> none</ td ></ tr > 1204< tr >< td style ="text-align: left ">< a id ="rust_analyzer_toolchain_repository-exec_compatible_with "></ a > exec_compatible_with</ td >< td style ="text-align: left "> A list of constraints for the execution platform for this toolchain.</ td >< td style ="text-align: left ">< code > []</ code ></ td ></ tr > 1205< tr >< td style ="text-align: left ">< a id ="rust_analyzer_toolchain_repository-target_compatible_with "></ a > target_compatible_with</ td >< td style ="text-align: left "> A list of constraints for the target platform for this toolchain.</ td >< td style ="text-align: left ">< code > []</ code ></ td ></ tr > 1206< tr >< td style ="text-align: left ">< a id ="rust_analyzer_toolchain_repository-sha256s "></ a > sha256s</ td >< td style ="text-align: left "> A dict associating tool subdirectories to sha256 hashes. See< a href ="#rust_register_toolchains "> rust_register_toolchains</ a > for more details.</ td >< td style ="text-align: left ">< code > None</ code ></ td ></ tr > 1207< tr >< td style ="text-align: left ">< a id ="rust_analyzer_toolchain_repository-urls "></ a > urls</ td >< td style ="text-align: left "> A list of mirror urls containing the tools from the Rust-lang static file server. These must contain the '{}' used to substitute the tool being fetched (using .format). Defaults to ['https://static.rust-lang.org/dist/{}.tar.xz']</ td >< td style ="text-align: left ">< code > None</ code ></ td ></ tr > 1208< tr >< td style ="text-align: left ">< a id ="rust_analyzer_toolchain_repository-auth "></ a > auth</ td >< td style ="text-align: left "> Auth object compatible with repository_ctx.download to use when downloading files. See< a href ="https://docs.bazel.build/versions/main/skylark/lib/repository_ctx.html#download "> repository_ctx.download</ a > for more details.</ td >< td style ="text-align: left ">< code > None</ code ></ td ></ tr > 1209< tr >< td style ="text-align: left ">< a id ="rust_analyzer_toolchain_repository-netrc "></ a > netrc</ td >< td style ="text-align: left "> .netrc file to use for authentication; mirrors the eponymous attribute from http_archive</ td >< td style ="text-align: left ">< code > None</ code ></ td ></ tr > 1210< tr >< td style ="text-align: left ">< a id ="rust_analyzer_toolchain_repository-auth_patterns "></ a > auth_patterns</ td >< td style ="text-align: left "> Override mapping of hostnames to authorization patterns; mirrors the eponymous attribute from http_archive</ td >< td style ="text-align: left ">< code > None</ code ></ td ></ tr > 1211</ tbody ></ table > 1212</ div > 1213< p >< strong > RETURNS</ strong ></ p > 1214< p > str: The name of a registerable rust_analyzer_toolchain.</ p > 1215< p >< a id ="rust_register_toolchains "></ a ></ p > 1216< h2 id ="rust_register_toolchains ">< a class ="header "href ="#rust_register_toolchains "> rust_register_toolchains</ a ></ h2 > 1217< pre > 1218rust_register_toolchains(< a href ="#rust_register_toolchains-dev_components "> dev_components</ a > ,< a href ="#rust_register_toolchains-edition "> edition</ a > ,< a href ="#rust_register_toolchains-allocator_library "> allocator_library</ a > ,< a href ="#rust_register_toolchains-global_allocator_library "> global_allocator_library</ a > , 1219< a href ="#rust_register_toolchains-register_toolchains "> register_toolchains</ a > ,< a href ="#rust_register_toolchains-rustfmt_version "> rustfmt_version</ a > ,< a href ="#rust_register_toolchains-rust_analyzer_version "> rust_analyzer_version</ a > ,< a href ="#rust_register_toolchains-sha256s "> sha256s</ a > , 1220< a href ="#rust_register_toolchains-extra_target_triples "> extra_target_triples</ a > ,< a href ="#rust_register_toolchains-extra_rustc_flags "> extra_rustc_flags</ a > ,< a href ="#rust_register_toolchains-extra_exec_rustc_flags "> extra_exec_rustc_flags</ a > ,< a href ="#rust_register_toolchains-urls "> urls</ a > , 1221< a href ="#rust_register_toolchains-versions "> versions</ a > ,< a href ="#rust_register_toolchains-aliases "> aliases</ a > ,< a href ="#rust_register_toolchains-hub_name "> hub_name</ a > ,< a href ="#rust_register_toolchains-compact_windows_names "> compact_windows_names</ a > ) 1222</ pre > 1223< p > Emits a default set of toolchains for Linux, MacOS, and Freebsd</ p > 1224< p > Skip this macro and call the< code > rust_repository_set</ code > macros directly if you need a compiler for other hosts or for additional target triples.</ p > 1225< p > The< code > sha256s</ code > attribute represents a dict associating tool subdirectories to sha256 hashes. As an example:</ p > 1226< pre >< code class ="language-python "> { 1227 "rust-1.46.0-x86_64-unknown-linux-gnu": "e3b98bc3440fe92817881933f9564389eccb396f5f431f33d48b979fa2fbdcf5", 1228 "rustfmt-1.4.12-x86_64-unknown-linux-gnu": "1894e76913303d66bf40885a601462844eec15fca9e76a6d13c390d7000d64b0", 1229 "rust-std-1.46.0-x86_64-unknown-linux-gnu": "ac04aef80423f612c0079829b504902de27a6997214eb58ab0765d02f7ec1dbc", 1230} 1231</ code ></ pre > 1232< p > This would match for< code > exec_triple = "x86_64-unknown-linux-gnu"</ code > . If not specified, rules_rust pulls from a non-exhaustive list of known checksums..</ p > 1233< p > See< code > load_arbitrary_tool</ code > in< code > @rules_rust//rust:repositories.bzl</ code > for more details.</ p > 1234< p >< strong > PARAMETERS</ strong ></ p > 1235< 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 > 1236< tr >< td style ="text-align: left ">< a id ="rust_register_toolchains-dev_components "></ a > dev_components</ td >< td style ="text-align: left "> Whether to download the rustc-dev components (defaults to False). Requires version to be "nightly".</ td >< td style ="text-align: left ">< code > False</ code ></ td ></ tr > 1237< tr >< td style ="text-align: left ">< a id ="rust_register_toolchains-edition "></ a > edition</ td >< td style ="text-align: left "> The rust edition to be used by default (2015, 2018, or 2021). If absent, every target is required to specify its< code > edition</ code > attribute.</ td >< td style ="text-align: left ">< code > None</ code ></ td ></ tr > 1238< tr >< td style ="text-align: left ">< a id ="rust_register_toolchains-allocator_library "></ a > allocator_library</ td >< td style ="text-align: left "> Target that provides allocator functions when rust_library targets are embedded in a cc_binary.</ td >< td style ="text-align: left ">< code > None</ code ></ td ></ tr > 1239< tr >< td style ="text-align: left ">< a id ="rust_register_toolchains-global_allocator_library "></ a > global_allocator_library</ td >< td style ="text-align: left "> Target that provides allocator functions when global allocator is used with cc_common.link.</ td >< td style ="text-align: left ">< code > None</ code ></ td ></ tr > 1240< tr >< td style ="text-align: left ">< a id ="rust_register_toolchains-register_toolchains "></ a > register_toolchains</ td >< td style ="text-align: left "> If true, repositories will be generated to produce and register< code > rust_toolchain</ code > targets.</ td >< td style ="text-align: left ">< code > True</ code ></ td ></ tr > 1241< tr >< td style ="text-align: left ">< a id ="rust_register_toolchains-rustfmt_version "></ a > rustfmt_version</ td >< td style ="text-align: left "> The version of rustfmt. If none is supplied and only a single version in< code > versions</ code > is given, then this defaults to that version, otherwise will default to the default nightly version.</ td >< td style ="text-align: left ">< code > None</ code ></ td ></ tr > 1242< tr >< td style ="text-align: left ">< a id ="rust_register_toolchains-rust_analyzer_version "></ a > rust_analyzer_version</ td >< td style ="text-align: left "> The version of Rustc to pair with rust-analyzer.</ td >< td style ="text-align: left ">< code > None</ code ></ td ></ tr > 1243< tr >< td style ="text-align: left ">< a id ="rust_register_toolchains-sha256s "></ a > sha256s</ td >< td style ="text-align: left "> A dict associating tool subdirectories to sha256 hashes.</ td >< td style ="text-align: left ">< code > None</ code ></ td ></ tr > 1244< tr >< td style ="text-align: left ">< a id ="rust_register_toolchains-extra_target_triples "></ a > extra_target_triples</ td >< td style ="text-align: left "> Additional rust-style targets that rust toolchains should support.</ td >< td style ="text-align: left ">< code > ["wasm32-unknown-unknown", "wasm32-wasip1"]</ code ></ td ></ tr > 1245< tr >< td style ="text-align: left ">< a id ="rust_register_toolchains-extra_rustc_flags "></ a > extra_rustc_flags</ td >< td style ="text-align: left "> Dictionary of target triples to list of extra flags to pass to rustc in non-exec configuration.</ td >< td style ="text-align: left ">< code > None</ code ></ td ></ tr > 1246< tr >< td style ="text-align: left ">< a id ="rust_register_toolchains-extra_exec_rustc_flags "></ a > extra_exec_rustc_flags</ td >< td style ="text-align: left "> Extra flags to pass to rustc in exec configuration.</ td >< td style ="text-align: left ">< code > None</ code ></ td ></ tr > 1247< tr >< td style ="text-align: left ">< a id ="rust_register_toolchains-urls "></ a > urls</ td >< td style ="text-align: left "> A list of mirror urls containing the tools from the Rust-lang static file server. These must contain the '{}' used to substitute the tool being fetched (using .format).</ td >< td style ="text-align: left ">< code > ["https://static.rust-lang.org/dist/{}.tar.xz"]</ code ></ td ></ tr > 1248< tr >< td style ="text-align: left ">< a id ="rust_register_toolchains-versions "></ a > versions</ td >< td style ="text-align: left "> A list of toolchain versions to download. This parameter only accepts one versions per channel. E.g.< code > ["1.65.0", "nightly/2022-11-02", "beta/2020-12-30"]</ code > .</ td >< td style ="text-align: left ">< code > ["1.83.0", "nightly/2024-11-28"]</ code ></ td ></ tr > 1249< tr >< td style ="text-align: left ">< a id ="rust_register_toolchains-aliases "></ a > aliases</ td >< td style ="text-align: left "> A mapping of "full" repository name to another name to use instead.</ td >< td style ="text-align: left ">< code > {}</ code ></ td ></ tr > 1250< tr >< td style ="text-align: left ">< a id ="rust_register_toolchains-hub_name "></ a > hub_name</ td >< td style ="text-align: left "> The name of the bzlmod hub repository for toolchains.</ td >< td style ="text-align: left ">< code > None</ code ></ td ></ tr > 1251< tr >< td style ="text-align: left ">< a id ="rust_register_toolchains-compact_windows_names "></ a > compact_windows_names</ td >< td style ="text-align: left "> Whether or not to produce compact repository names for windows toolchains. This is to avoid MAX_PATH issues.</ td >< td style ="text-align: left ">< code > True</ code ></ td ></ tr > 1252</ tbody ></ table > 1253</ div > 1254< p >< a id ="rust_repositories "></ a ></ p > 1255< h2 id ="rust_repositories ">< a class ="header "href ="#rust_repositories "> rust_repositories</ a ></ h2 > 1256< pre > 1257rust_repositories(< a href ="#rust_repositories-kwargs "> kwargs</ a > ) 1258</ pre > 1259< p >< strong > Deprecated</ strong > : Use< a href ="#rules_rust_dependencies "> rules_rust_dependencies</ a > and< a href ="#rust_register_toolchains "> rust_register_toolchains</ a > directly.</ p > 1260< p >< strong > PARAMETERS</ strong ></ p > 1261< 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 > 1262< tr >< td style ="text-align: left ">< a id ="rust_repositories-kwargs "></ a > kwargs</ td >< td style ="text-align: left "> Keyword arguments for the< code > rust_register_toolchains</ code > macro.</ td >< td style ="text-align: left "> none</ td ></ tr > 1263</ tbody ></ table > 1264</ div > 1265< p >< a id ="rust_repository_set "></ a ></ p > 1266< h2 id ="rust_repository_set ">< a class ="header "href ="#rust_repository_set "> rust_repository_set</ a ></ h2 > 1267< pre > 1268rust_repository_set(< a href ="#rust_repository_set-name "> name</ a > ,< a href ="#rust_repository_set-versions "> versions</ a > ,< a href ="#rust_repository_set-exec_triple "> exec_triple</ a > ,< a href ="#rust_repository_set-target_settings "> target_settings</ a > ,< a href ="#rust_repository_set-allocator_library "> allocator_library</ a > , 1269< a href ="#rust_repository_set-global_allocator_library "> global_allocator_library</ a > ,< a href ="#rust_repository_set-extra_target_triples "> extra_target_triples</ a > ,< a href ="#rust_repository_set-rustfmt_version "> rustfmt_version</ a > ,< a href ="#rust_repository_set-edition "> edition</ a > , 1270< a href ="#rust_repository_set-dev_components "> dev_components</ a > ,< a href ="#rust_repository_set-extra_rustc_flags "> extra_rustc_flags</ a > ,< a href ="#rust_repository_set-extra_exec_rustc_flags "> extra_exec_rustc_flags</ a > ,< a href ="#rust_repository_set-opt_level "> opt_level</ a > ,< a href ="#rust_repository_set-sha256s "> sha256s</ a > , 1271< a href ="#rust_repository_set-urls "> urls</ a > ,< a href ="#rust_repository_set-auth "> auth</ a > ,< a href ="#rust_repository_set-netrc "> netrc</ a > ,< a href ="#rust_repository_set-auth_patterns "> auth_patterns</ a > ,< a href ="#rust_repository_set-register_toolchain "> register_toolchain</ a > ,< a href ="#rust_repository_set-exec_compatible_with "> exec_compatible_with</ a > , 1272< a href ="#rust_repository_set-default_target_compatible_with "> default_target_compatible_with</ a > ,< a href ="#rust_repository_set-aliases "> aliases</ a > ,< a href ="#rust_repository_set-compact_windows_names "> compact_windows_names</ a > ) 1273</ pre > 1274< p > Assembles a remote repository for the given toolchain params, produces a proxy repository to contain the toolchain declaration, and registers the toolchains.</ p > 1275< p >< strong > PARAMETERS</ strong ></ p > 1276< 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 > 1277< tr >< td style ="text-align: left ">< a id ="rust_repository_set-name "></ a > name</ td >< td style ="text-align: left "> The name of the generated repository</ td >< td style ="text-align: left "> none</ td ></ tr > 1278< tr >< td style ="text-align: left ">< a id ="rust_repository_set-versions "></ a > versions</ td >< td style ="text-align: left "> A list of toolchain versions to download. This paramter only accepts one versions per channel. E.g.< code > ["1.65.0", "nightly/2022-11-02", "beta/2020-12-30"]</ code > .</ td >< td style ="text-align: left "> none</ td ></ tr > 1279< tr >< td style ="text-align: left ">< a id ="rust_repository_set-exec_triple "></ a > exec_triple</ td >< td style ="text-align: left "> The Rust-style target that this compiler runs on</ td >< td style ="text-align: left "> none</ td ></ tr > 1280< tr >< td style ="text-align: left ">< a id ="rust_repository_set-target_settings "></ a > target_settings</ td >< td style ="text-align: left "> A list of config_settings that must be satisfied by the target configuration in order for this set of toolchains to be selected during toolchain resolution.</ td >< td style ="text-align: left ">< code > []</ code ></ td ></ tr > 1281< tr >< td style ="text-align: left ">< a id ="rust_repository_set-allocator_library "></ a > allocator_library</ td >< td style ="text-align: left "> Target that provides allocator functions when rust_library targets are embedded in a cc_binary.</ td >< td style ="text-align: left ">< code > None</ code ></ td ></ tr > 1282< tr >< td style ="text-align: left ">< a id ="rust_repository_set-global_allocator_library "></ a > global_allocator_library</ td >< td style ="text-align: left "> Target that provides allocator functions a global allocator is used with cc_common.link.</ td >< td style ="text-align: left ">< code > None</ code ></ td ></ tr > 1283< tr >< td style ="text-align: left ">< a id ="rust_repository_set-extra_target_triples "></ a > extra_target_triples</ td >< td style ="text-align: left "> Additional rust-style targets that this set of toolchains should support. If a map, values should be (optional) target_compatible_with lists for that particular target triple.</ td >< td style ="text-align: left ">< code > {}</ code ></ td ></ tr > 1284< tr >< td style ="text-align: left ">< a id ="rust_repository_set-rustfmt_version "></ a > rustfmt_version</ td >< td style ="text-align: left "> The version of rustfmt to be associated with the toolchain.</ td >< td style ="text-align: left ">< code > None</ code ></ td ></ tr > 1285< tr >< td style ="text-align: left ">< a id ="rust_repository_set-edition "></ a > edition</ td >< td style ="text-align: left "> The rust edition to be used by default (2015, 2018, or 2021). If absent, every rule is required to specify its< code > edition</ code > attribute.</ td >< td style ="text-align: left ">< code > None</ code ></ td ></ tr > 1286< tr >< td style ="text-align: left ">< a id ="rust_repository_set-dev_components "></ a > dev_components</ td >< td style ="text-align: left "> Whether to download the rustc-dev components. Requires version to be "nightly".</ td >< td style ="text-align: left ">< code > False</ code ></ td ></ tr > 1287< tr >< td style ="text-align: left ">< a id ="rust_repository_set-extra_rustc_flags "></ a > extra_rustc_flags</ td >< td style ="text-align: left "> Dictionary of target triples to list of extra flags to pass to rustc in non-exec configuration.</ td >< td style ="text-align: left ">< code > None</ code ></ td ></ tr > 1288< tr >< td style ="text-align: left ">< a id ="rust_repository_set-extra_exec_rustc_flags "></ a > extra_exec_rustc_flags</ td >< td style ="text-align: left "> Extra flags to pass to rustc in exec configuration.</ td >< td style ="text-align: left ">< code > None</ code ></ td ></ tr > 1289< tr >< td style ="text-align: left ">< a id ="rust_repository_set-opt_level "></ a > opt_level</ td >< td style ="text-align: left "> Dictionary of target triples to optimiztion config.</ td >< td style ="text-align: left ">< code > None</ code ></ td ></ tr > 1290< tr >< td style ="text-align: left ">< a id ="rust_repository_set-sha256s "></ a > sha256s</ td >< td style ="text-align: left "> A dict associating tool subdirectories to sha256 hashes. See< a href ="#rust_register_toolchains "> rust_register_toolchains</ a > for more details.</ td >< td style ="text-align: left ">< code > None</ code ></ td ></ tr > 1291< tr >< td style ="text-align: left ">< a id ="rust_repository_set-urls "></ a > urls</ td >< td style ="text-align: left "> A list of mirror urls containing the tools from the Rust-lang static file server. These must contain the '{}' used to substitute the tool being fetched (using .format).</ td >< td style ="text-align: left ">< code > ["https://static.rust-lang.org/dist/{}.tar.xz"]</ code ></ td ></ tr > 1292< tr >< td style ="text-align: left ">< a id ="rust_repository_set-auth "></ a > auth</ td >< td style ="text-align: left "> Auth object compatible with repository_ctx.download to use when downloading files. See< a href ="https://docs.bazel.build/versions/main/skylark/lib/repository_ctx.html#download "> repository_ctx.download</ a > for more details.</ td >< td style ="text-align: left ">< code > None</ code ></ td ></ tr > 1293< tr >< td style ="text-align: left ">< a id ="rust_repository_set-netrc "></ a > netrc</ td >< td style ="text-align: left "> .netrc file to use for authentication; mirrors the eponymous attribute from http_archive</ td >< td style ="text-align: left ">< code > None</ code ></ td ></ tr > 1294< tr >< td style ="text-align: left ">< a id ="rust_repository_set-auth_patterns "></ a > auth_patterns</ td >< td style ="text-align: left "> Override mapping of hostnames to authorization patterns; mirrors the eponymous attribute from http_archive</ td >< td style ="text-align: left ">< code > None</ code ></ td ></ tr > 1295< tr >< td style ="text-align: left ">< a id ="rust_repository_set-register_toolchain "></ a > register_toolchain</ td >< td style ="text-align: left "> If True, the generated< code > rust_toolchain</ code > target will become a registered toolchain.</ td >< td style ="text-align: left ">< code > True</ code ></ td ></ tr > 1296< tr >< td style ="text-align: left ">< a id ="rust_repository_set-exec_compatible_with "></ a > exec_compatible_with</ td >< td style ="text-align: left "> A list of constraints for the execution platform for this toolchain.</ td >< td style ="text-align: left ">< code > None</ code ></ td ></ tr > 1297< tr >< td style ="text-align: left ">< a id ="rust_repository_set-default_target_compatible_with "></ a > default_target_compatible_with</ td >< td style ="text-align: left "> A list of constraints for the target platform for this toolchain when the exec platform is the same as the target platform.</ td >< td style ="text-align: left ">< code > None</ code ></ td ></ tr > 1298< tr >< td style ="text-align: left ">< a id ="rust_repository_set-aliases "></ a > aliases</ td >< td style ="text-align: left "> Replacement names to use for toolchains created by this macro.</ td >< td style ="text-align: left ">< code > {}</ code ></ td ></ tr > 1299< tr >< td style ="text-align: left ">< a id ="rust_repository_set-compact_windows_names "></ a > compact_windows_names</ td >< td style ="text-align: left "> Whether or not to produce compact repository names for windows toolchains. This is to avoid MAX_PATH issues.</ td >< td style ="text-align: left ">< code > True</ code ></ td ></ tr > 1300</ tbody ></ table > 1301</ div > 1302< p >< a id ="rust_test_suite "></ a ></ p > 1303< h2 id ="rust_test_suite ">< a class ="header "href ="#rust_test_suite "> rust_test_suite</ a ></ h2 > 1304< pre > 1305rust_test_suite(< a href ="#rust_test_suite-name "> name</ a > ,< a href ="#rust_test_suite-srcs "> srcs</ a > ,< a href ="#rust_test_suite-shared_srcs "> shared_srcs</ a > ,< a href ="#rust_test_suite-kwargs "> kwargs</ a > ) 1306</ pre > 1307< p > A rule for creating a test suite for a set of< code > rust_test</ code > targets.</ p > 1308< p > This rule can be used for setting up typical rust< a href ="https://doc.rust-lang.org/rust-by-example/testing/integration_testing.html "> integration tests</ a > . Given the following 1309directory structure:</ p > 1310< pre >< code class ="language-text "> [crate]/ 1311 BUILD.bazel 1312 src/ 1313 lib.rs 1314 main.rs 1315 tests/ 1316 integrated_test_a.rs 1317 integrated_test_b.rs 1318 integrated_test_c.rs 1319 patterns/ 1320 fibonacci_test.rs 1321 helpers/ 1322 mod.rs 1323</ code ></ pre > 1324< p > The rule can be used to generate< a href ="#rust_test "> rust_test</ a > targets for each source file under< code > tests</ code > 1325and a< a href ="https://docs.bazel.build/versions/master/be/general.html#test_suite "> test_suite</ a > which encapsulates all tests.</ p > 1326< pre >< code class ="language-python "> load("//rust:defs.bzl", "rust_binary", "rust_library", "rust_test_suite") 1327 1328rust_library( 1329 name = "math_lib", 1330 srcs = ["src/lib.rs"], 1331) 1332 1333rust_binary( 1334 name = "math_bin", 1335 srcs = ["src/main.rs"], 1336) 1337 1338rust_test_suite( 1339 name = "integrated_tests_suite", 1340 srcs = glob(["tests/**"]), 1341 shared_srcs=glob(["tests/helpers/**"]), 1342 deps = [":math_lib"], 1343) 1344</ code ></ pre > 1345< p >< strong > PARAMETERS</ strong ></ p > 1346< 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 > 1347< tr >< td style ="text-align: left ">< a id ="rust_test_suite-name "></ a > name</ td >< td style ="text-align: left "> The name of the< code > test_suite</ code > .</ td >< td style ="text-align: left "> none</ td ></ tr > 1348< tr >< td style ="text-align: left ">< a id ="rust_test_suite-srcs "></ a > srcs</ td >< td style ="text-align: left "> All test sources, typically< code > glob(["tests/**/*.rs"])</ code > .</ td >< td style ="text-align: left "> none</ td ></ tr > 1349< tr >< td style ="text-align: left ">< a id ="rust_test_suite-shared_srcs "></ a > shared_srcs</ td >< td style ="text-align: left "> Optional argument for sources shared among tests, typically helper functions.</ td >< td style ="text-align: left ">< code > []</ code ></ td ></ tr > 1350< tr >< td style ="text-align: left ">< a id ="rust_test_suite-kwargs "></ a > kwargs</ td >< td style ="text-align: left "> Additional keyword arguments for the underyling< a href ="#rust_test "> rust_test</ a > targets. The< code > tags</ code > argument is also passed to the generated< code > test_suite</ code > target.</ td >< td style ="text-align: left "> none</ td ></ tr > 1351</ tbody ></ table > 1352</ div > 1353< p >< a id ="rust_toolchain_repository "></ a ></ p > 1354< h2 id ="rust_toolchain_repository ">< a class ="header "href ="#rust_toolchain_repository "> rust_toolchain_repository</ a ></ h2 > 1355< pre > 1356rust_toolchain_repository(< a href ="#rust_toolchain_repository-name "> name</ a > ,< a href ="#rust_toolchain_repository-version "> version</ a > ,< a href ="#rust_toolchain_repository-exec_triple "> exec_triple</ a > ,< a href ="#rust_toolchain_repository-target_triple "> target_triple</ a > ,< a href ="#rust_toolchain_repository-exec_compatible_with "> exec_compatible_with</ a > , 1357< a href ="#rust_toolchain_repository-target_compatible_with "> target_compatible_with</ a > ,< a href ="#rust_toolchain_repository-target_settings "> target_settings</ a > ,< a href ="#rust_toolchain_repository-channel "> channel</ a > ,< a href ="#rust_toolchain_repository-allocator_library "> allocator_library</ a > , 1358< a href ="#rust_toolchain_repository-global_allocator_library "> global_allocator_library</ a > ,< a href ="#rust_toolchain_repository-rustfmt_version "> rustfmt_version</ a > ,< a href ="#rust_toolchain_repository-edition "> edition</ a > ,< a href ="#rust_toolchain_repository-dev_components "> dev_components</ a > , 1359< a href ="#rust_toolchain_repository-extra_rustc_flags "> extra_rustc_flags</ a > ,< a href ="#rust_toolchain_repository-extra_exec_rustc_flags "> extra_exec_rustc_flags</ a > ,< a href ="#rust_toolchain_repository-opt_level "> opt_level</ a > ,< a href ="#rust_toolchain_repository-sha256s "> sha256s</ a > ,< a href ="#rust_toolchain_repository-urls "> urls</ a > ,< a href ="#rust_toolchain_repository-auth "> auth</ a > , 1360< a href ="#rust_toolchain_repository-netrc "> netrc</ a > ,< a href ="#rust_toolchain_repository-auth_patterns "> auth_patterns</ a > ) 1361</ pre > 1362< p > Assembles a remote repository for the given toolchain params, produces a proxy repository to contain the toolchain declaration, and registers the toolchains.</ p > 1363< p >< strong > PARAMETERS</ strong ></ p > 1364< 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 > 1365< tr >< td style ="text-align: left ">< a id ="rust_toolchain_repository-name "></ a > name</ td >< td style ="text-align: left "> The name of the generated repository</ td >< td style ="text-align: left "> none</ td ></ tr > 1366< tr >< td style ="text-align: left ">< a id ="rust_toolchain_repository-version "></ a > version</ td >< td style ="text-align: left "> The version of the tool among "nightly", "beta", or an exact version.</ td >< td style ="text-align: left "> none</ td ></ tr > 1367< tr >< td style ="text-align: left ">< a id ="rust_toolchain_repository-exec_triple "></ a > exec_triple</ td >< td style ="text-align: left "> The Rust-style target that this compiler runs on.</ td >< td style ="text-align: left "> none</ td ></ tr > 1368< tr >< td style ="text-align: left ">< a id ="rust_toolchain_repository-target_triple "></ a > target_triple</ td >< td style ="text-align: left "> The Rust-style target to build for.</ td >< td style ="text-align: left "> none</ td ></ tr > 1369< tr >< td style ="text-align: left ">< a id ="rust_toolchain_repository-exec_compatible_with "></ a > exec_compatible_with</ td >< td style ="text-align: left "> A list of constraints for the execution platform for this toolchain.</ td >< td style ="text-align: left ">< code > None</ code ></ td ></ tr > 1370< tr >< td style ="text-align: left ">< a id ="rust_toolchain_repository-target_compatible_with "></ a > target_compatible_with</ td >< td style ="text-align: left "> A list of constraints for the target platform for this toolchain.</ td >< td style ="text-align: left ">< code > None</ code ></ td ></ tr > 1371< tr >< td style ="text-align: left ">< a id ="rust_toolchain_repository-target_settings "></ a > target_settings</ td >< td style ="text-align: left "> A list of config_settings that must be satisfied by the target configuration in order for this toolchain to be selected during toolchain resolution.</ td >< td style ="text-align: left ">< code > []</ code ></ td ></ tr > 1372< tr >< td style ="text-align: left ">< a id ="rust_toolchain_repository-channel "></ a > channel</ td >< td style ="text-align: left "> The channel of the Rust toolchain.</ td >< td style ="text-align: left ">< code > None</ code ></ td ></ tr > 1373< tr >< td style ="text-align: left ">< a id ="rust_toolchain_repository-allocator_library "></ a > allocator_library</ td >< td style ="text-align: left "> Target that provides allocator functions when rust_library targets are embedded in a cc_binary.</ td >< td style ="text-align: left ">< code > None</ code ></ td ></ tr > 1374< tr >< td style ="text-align: left ">< a id ="rust_toolchain_repository-global_allocator_library "></ a > global_allocator_library</ td >< td style ="text-align: left "> Target that provides allocator functions when a global allocator is used with cc_common.link.</ td >< td style ="text-align: left ">< code > None</ code ></ td ></ tr > 1375< tr >< td style ="text-align: left ">< a id ="rust_toolchain_repository-rustfmt_version "></ a > rustfmt_version</ td >< td style ="text-align: left "> The version of rustfmt to be associated with the toolchain.</ td >< td style ="text-align: left ">< code > None</ code ></ td ></ tr > 1376< tr >< td style ="text-align: left ">< a id ="rust_toolchain_repository-edition "></ a > edition</ td >< td style ="text-align: left "> The rust edition to be used by default (2015, 2018, or 2021). If absent, every rule is required to specify its< code > edition</ code > attribute.</ td >< td style ="text-align: left ">< code > None</ code ></ td ></ tr > 1377< tr >< td style ="text-align: left ">< a id ="rust_toolchain_repository-dev_components "></ a > dev_components</ td >< td style ="text-align: left "> Whether to download the rustc-dev components. Requires version to be "nightly". Defaults to False.</ td >< td style ="text-align: left ">< code > False</ code ></ td ></ tr > 1378< tr >< td style ="text-align: left ">< a id ="rust_toolchain_repository-extra_rustc_flags "></ a > extra_rustc_flags</ td >< td style ="text-align: left "> Extra flags to pass to rustc in non-exec configuration.</ td >< td style ="text-align: left ">< code > None</ code ></ td ></ tr > 1379< tr >< td style ="text-align: left ">< a id ="rust_toolchain_repository-extra_exec_rustc_flags "></ a > extra_exec_rustc_flags</ td >< td style ="text-align: left "> Extra flags to pass to rustc in exec configuration.</ td >< td style ="text-align: left ">< code > None</ code ></ td ></ tr > 1380< tr >< td style ="text-align: left ">< a id ="rust_toolchain_repository-opt_level "></ a > opt_level</ td >< td style ="text-align: left "> Optimization level config for this toolchain.</ td >< td style ="text-align: left ">< code > None</ code ></ td ></ tr > 1381< tr >< td style ="text-align: left ">< a id ="rust_toolchain_repository-sha256s "></ a > sha256s</ td >< td style ="text-align: left "> A dict associating tool subdirectories to sha256 hashes. See< a href ="#rust_register_toolchains "> rust_register_toolchains</ a > for more details.</ td >< td style ="text-align: left ">< code > None</ code ></ td ></ tr > 1382< tr >< td style ="text-align: left ">< a id ="rust_toolchain_repository-urls "></ a > urls</ td >< td style ="text-align: left "> A list of mirror urls containing the tools from the Rust-lang static file server. These must contain the '{}' used to substitute the tool being fetched (using .format). Defaults to ['https://static.rust-lang.org/dist/{}.tar.xz']</ td >< td style ="text-align: left ">< code > ["https://static.rust-lang.org/dist/{}.tar.xz"]</ code ></ td ></ tr > 1383< tr >< td style ="text-align: left ">< a id ="rust_toolchain_repository-auth "></ a > auth</ td >< td style ="text-align: left "> Auth object compatible with repository_ctx.download to use when downloading files. See< a href ="https://docs.bazel.build/versions/main/skylark/lib/repository_ctx.html#download "> repository_ctx.download</ a > for more details.</ td >< td style ="text-align: left ">< code > None</ code ></ td ></ tr > 1384< tr >< td style ="text-align: left ">< a id ="rust_toolchain_repository-netrc "></ a > netrc</ td >< td style ="text-align: left "> .netrc file to use for authentication; mirrors the eponymous attribute from http_archive</ td >< td style ="text-align: left ">< code > None</ code ></ td ></ tr > 1385< tr >< td style ="text-align: left ">< a id ="rust_toolchain_repository-auth_patterns "></ a > auth_patterns</ td >< td style ="text-align: left "> A list of patterns to match against urls for which the auth object should be used.</ td >< td style ="text-align: left ">< code > None</ code ></ td ></ tr > 1386</ tbody ></ table > 1387</ div > 1388< p >< strong > RETURNS</ strong ></ p > 1389< p > str: The name of the registerable toolchain created by this rule.</ p > 1390< p >< a id ="rust_analyzer_aspect "></ a ></ p > 1391< h2 id ="rust_analyzer_aspect ">< a class ="header "href ="#rust_analyzer_aspect "> rust_analyzer_aspect</ a ></ h2 > 1392< pre > 1393rust_analyzer_aspect(< a href ="#rust_analyzer_aspect-name "> name</ a > ) 1394</ pre > 1395< p > Annotates rust rules with RustAnalyzerInfo later used to build a rust-project.json</ p > 1396< p >< strong > ASPECT ATTRIBUTES</ strong ></ p > 1397< div class ="table-wrapper ">< table >< thead >< tr >< th style ="text-align: left "> Name</ th >< th style ="text-align: left "> Type</ th ></ tr ></ thead >< tbody > 1398< tr >< td style ="text-align: left "> deps</ td >< td style ="text-align: left "> String</ td ></ tr > 1399< tr >< td style ="text-align: left "> proc_macro_deps</ td >< td style ="text-align: left "> String</ td ></ tr > 1400< tr >< td style ="text-align: left "> crate</ td >< td style ="text-align: left "> String</ td ></ tr > 1401< tr >< td style ="text-align: left "> actual</ td >< td style ="text-align: left "> String</ td ></ tr > 1402< tr >< td style ="text-align: left "> proto</ td >< td style ="text-align: left "> String</ td ></ tr > 1403</ tbody ></ table > 1404</ div > 1405< p >< strong > ATTRIBUTES</ strong ></ p > 1406< 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 > 1407< tr >< td style ="text-align: left ">< a id ="rust_analyzer_aspect-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 > 1408</ tbody ></ table > 1409</ div > 1410< p >< a id ="rust_clippy_aspect "></ a ></ p > 1411< h2 id ="rust_clippy_aspect ">< a class ="header "href ="#rust_clippy_aspect "> rust_clippy_aspect</ a ></ h2 > 1412< pre > 1413rust_clippy_aspect(< a href ="#rust_clippy_aspect-name "> name</ a > ) 1414</ pre > 1415< p > Executes the clippy checker on specified targets.</ p > 1416< p > This aspect applies to existing rust_library, rust_test, and rust_binary rules.</ p > 1417< p > As an example, if the following is defined in< code > examples/hello_lib/BUILD.bazel</ code > :</ p > 1418< pre >< code class ="language-python "> load("@rules_rust//rust:defs.bzl", "rust_library", "rust_test") 1419 1420rust_library( 1421 name = "hello_lib", 1422 srcs = ["src/lib.rs"], 1423) 1424 1425rust_test( 1426 name = "greeting_test", 1427 srcs = ["tests/greeting.rs"], 1428 deps = [":hello_lib"], 1429) 1430</ code ></ pre > 1431< p > Then the targets can be analyzed with clippy using the following command:</ p > 1432< pre >< code class ="language-output "> $ bazel build --aspects=@rules_rust//rust:defs.bzl%rust_clippy_aspect --output_groups=clippy_checks //hello_lib:all 1433</ code ></ pre > 1434< p >< strong > ASPECT ATTRIBUTES</ strong ></ p > 1435< p >< strong > ATTRIBUTES</ strong ></ p > 1436< 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 > 1437< tr >< td style ="text-align: left ">< a id ="rust_clippy_aspect-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 > 1438</ tbody ></ table > 1439</ div > 1440< p >< a id ="rustfmt_aspect "></ a ></ p > 1441< h2 id ="rustfmt_aspect ">< a class ="header "href ="#rustfmt_aspect "> rustfmt_aspect</ a ></ h2 > 1442< pre > 1443rustfmt_aspect(< a href ="#rustfmt_aspect-name "> name</ a > ) 1444</ pre > 1445< p > This aspect is used to gather information about a crate for use in rustfmt and perform rustfmt checks</ p > 1446< p > Output Groups:</ p > 1447< ul > 1448< li >< code > rustfmt_checks</ code > : Executes< code > rustfmt --check</ code > on the specified target.</ li > 1449</ ul > 1450< p > The build setting< code > @rules_rust//rust/settings:rustfmt.toml</ code > is used to control the Rustfmt< a href ="https://rust-lang.github.io/rustfmt/ "> configuration settings</ a > 1451used at runtime.</ p > 1452< p > This aspect is executed on any target which provides the< code > CrateInfo</ code > provider. However 1453users may tag a target with< code > no-rustfmt</ code > or< code > no-format</ code > to have it skipped. Additionally, 1454generated source files are also ignored by this aspect.</ p > 1455< p >< strong > ASPECT ATTRIBUTES</ strong ></ p > 1456< p >< strong > ATTRIBUTES</ strong ></ p > 1457< 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 > 1458< tr >< td style ="text-align: left ">< a id ="rustfmt_aspect-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 > 1459</ tbody ></ table > 1460</ div > 1461< p >< a id ="cargo_bootstrap_repository "></ a ></ p > 1462< h2 id ="cargo_bootstrap_repository ">< a class ="header "href ="#cargo_bootstrap_repository "> cargo_bootstrap_repository</ a ></ h2 > 1463< pre > 1464cargo_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 > , 1465< 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 > , 1466< 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 > , 1467< a href ="#cargo_bootstrap_repository-version "> version</ a > ) 1468</ pre > 1469< p > A rule for bootstrapping a Rust binary using< a href ="https://doc.rust-lang.org/cargo/ "> Cargo</ a ></ p > 1470< p >< strong > ATTRIBUTES</ strong ></ p > 1471< 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 > 1472< 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 > 1473< 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 > 1474< 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 > 1475< 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 > 1476< 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 > 1477< 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 > 1478< 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 > 1479< 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 > 1480< 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 > 1481< 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 > 1482< 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 > 1483< 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 > 1484< 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 > 1485< 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 > 1486< 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 > 1487</ tbody ></ table > 1488</ div > 1489< p >< a id ="rust_toolchain_repository_proxy "></ a ></ p > 1490< h2 id ="rust_toolchain_repository_proxy ">< a class ="header "href ="#rust_toolchain_repository_proxy "> rust_toolchain_repository_proxy</ a ></ h2 > 1491< pre > 1492rust_toolchain_repository_proxy(< a href ="#rust_toolchain_repository_proxy-name "> name</ a > ,< a href ="#rust_toolchain_repository_proxy-exec_compatible_with "> exec_compatible_with</ a > ,< a href ="#rust_toolchain_repository_proxy-repo_mapping "> repo_mapping</ a > ,< a href ="#rust_toolchain_repository_proxy-target_compatible_with "> target_compatible_with</ a > , 1493< a href ="#rust_toolchain_repository_proxy-target_settings "> target_settings</ a > ,< a href ="#rust_toolchain_repository_proxy-toolchain "> toolchain</ a > ,< a href ="#rust_toolchain_repository_proxy-toolchain_type "> toolchain_type</ a > ) 1494</ pre > 1495< p > Generates a toolchain-bearing repository that declares the toolchains from some other rust_toolchain_repository.</ p > 1496< p >< strong > ATTRIBUTES</ strong ></ p > 1497< 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 > 1498< tr >< td style ="text-align: left ">< a id ="rust_toolchain_repository_proxy-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 > 1499< tr >< td style ="text-align: left ">< a id ="rust_toolchain_repository_proxy-exec_compatible_with "></ a > exec_compatible_with</ td >< td style ="text-align: left "> A list of constraints for the execution platform for this toolchain.</ td >< td style ="text-align: left "> List of strings</ td >< td style ="text-align: left "> optional</ td >< td style ="text-align: left ">< code > []</ code ></ td ></ tr > 1500< tr >< td style ="text-align: left ">< a id ="rust_toolchain_repository_proxy-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 > 1501< tr >< td style ="text-align: left ">< a id ="rust_toolchain_repository_proxy-target_compatible_with "></ a > target_compatible_with</ td >< td style ="text-align: left "> A list of constraints for the target platform for this toolchain.</ td >< td style ="text-align: left "> List of strings</ td >< td style ="text-align: left "> optional</ td >< td style ="text-align: left ">< code > []</ code ></ td ></ tr > 1502< tr >< td style ="text-align: left ">< a id ="rust_toolchain_repository_proxy-target_settings "></ a > target_settings</ td >< td style ="text-align: left "> A list of config_settings that must be satisfied by the target configuration in order for this toolchain to be selected during toolchain resolution.</ td >< td style ="text-align: left "> List of strings</ td >< td style ="text-align: left "> optional</ td >< td style ="text-align: left ">< code > []</ code ></ td ></ tr > 1503< tr >< td style ="text-align: left ">< a id ="rust_toolchain_repository_proxy-toolchain "></ a > toolchain</ td >< td style ="text-align: left "> The name of the toolchain implementation target.</ td >< td style ="text-align: left "> String</ td >< td style ="text-align: left "> required</ td >< td style ="text-align: left "></ td ></ tr > 1504< tr >< td style ="text-align: left ">< a id ="rust_toolchain_repository_proxy-toolchain_type "></ a > toolchain_type</ td >< td style ="text-align: left "> The toolchain type of the toolchain to declare</ td >< td style ="text-align: left "> String</ td >< td style ="text-align: left "> required</ td >< td style ="text-align: left "></ td ></ tr > 1505</ tbody ></ table > 1506</ div > 1507< p >< a id ="rust_toolchain_tools_repository "></ a ></ p > 1508< h2 id ="rust_toolchain_tools_repository ">< a class ="header "href ="#rust_toolchain_tools_repository "> rust_toolchain_tools_repository</ a ></ h2 > 1509< pre > 1510rust_toolchain_tools_repository(< a href ="#rust_toolchain_tools_repository-name "> name</ a > ,< a href ="#rust_toolchain_tools_repository-allocator_library "> allocator_library</ a > ,< a href ="#rust_toolchain_tools_repository-auth "> auth</ a > ,< a href ="#rust_toolchain_tools_repository-auth_patterns "> auth_patterns</ a > ,< a href ="#rust_toolchain_tools_repository-dev_components "> dev_components</ a > , 1511< a href ="#rust_toolchain_tools_repository-edition "> edition</ a > ,< a href ="#rust_toolchain_tools_repository-exec_triple "> exec_triple</ a > ,< a href ="#rust_toolchain_tools_repository-extra_exec_rustc_flags "> extra_exec_rustc_flags</ a > ,< a href ="#rust_toolchain_tools_repository-extra_rustc_flags "> extra_rustc_flags</ a > , 1512< a href ="#rust_toolchain_tools_repository-global_allocator_library "> global_allocator_library</ a > ,< a href ="#rust_toolchain_tools_repository-netrc "> netrc</ a > ,< a href ="#rust_toolchain_tools_repository-opt_level "> opt_level</ a > ,< a href ="#rust_toolchain_tools_repository-repo_mapping "> repo_mapping</ a > , 1513< a href ="#rust_toolchain_tools_repository-rustfmt_version "> rustfmt_version</ a > ,< a href ="#rust_toolchain_tools_repository-sha256s "> sha256s</ a > ,< a href ="#rust_toolchain_tools_repository-target_triple "> target_triple</ a > ,< a href ="#rust_toolchain_tools_repository-urls "> urls</ a > ,< a href ="#rust_toolchain_tools_repository-version "> version</ a > ) 1514</ pre > 1515< p > Composes a single workspace containing the toolchain components for compiling on a given platform to a series of target platforms.</ p > 1516< p > A given instance of this rule should be accompanied by a toolchain_repository_proxy invocation to declare its toolchains to Bazel; the indirection allows separating toolchain selection from toolchain fetching.</ p > 1517< p >< strong > ATTRIBUTES</ strong ></ p > 1518< 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 > 1519< tr >< td style ="text-align: left ">< a id ="rust_toolchain_tools_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 > 1520< tr >< td style ="text-align: left ">< a id ="rust_toolchain_tools_repository-allocator_library "></ a > allocator_library</ td >< td style ="text-align: left "> Target that provides allocator functions when rust_library targets are embedded in a cc_binary.</ td >< td style ="text-align: left "> String</ td >< td style ="text-align: left "> optional</ td >< td style ="text-align: left ">< code > "@rules_rust//ffi/cc/allocator_library"</ code ></ td ></ tr > 1521< tr >< td style ="text-align: left ">< a id ="rust_toolchain_tools_repository-auth "></ a > auth</ td >< td style ="text-align: left "> Auth object compatible with repository_ctx.download to use when downloading files. See< a href ="https://docs.bazel.build/versions/main/skylark/lib/repository_ctx.html#download "> repository_ctx.download</ a > for more details.</ 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 > 1522< tr >< td style ="text-align: left ">< a id ="rust_toolchain_tools_repository-auth_patterns "></ a > auth_patterns</ td >< td style ="text-align: left "> A list of patterns to match against urls for which the auth object should be used.</ td >< td style ="text-align: left "> List of strings</ td >< td style ="text-align: left "> optional</ td >< td style ="text-align: left ">< code > []</ code ></ td ></ tr > 1523< tr >< td style ="text-align: left ">< a id ="rust_toolchain_tools_repository-dev_components "></ a > dev_components</ td >< td style ="text-align: left "> Whether to download the rustc-dev components (defaults to False). Requires version to be "nightly".</ td >< td style ="text-align: left "> Boolean</ td >< td style ="text-align: left "> optional</ td >< td style ="text-align: left ">< code > False</ code ></ td ></ tr > 1524< tr >< td style ="text-align: left ">< a id ="rust_toolchain_tools_repository-edition "></ a > edition</ td >< td style ="text-align: left "> The rust edition to be used by default (2015, 2018, or 2021). If absent, every rule is required to specify its< code > edition</ code > attribute.</ td >< td style ="text-align: left "> String</ td >< td style ="text-align: left "> optional</ td >< td style ="text-align: left ">< code > ""</ code ></ td ></ tr > 1525< tr >< td style ="text-align: left ">< a id ="rust_toolchain_tools_repository-exec_triple "></ a > exec_triple</ td >< td style ="text-align: left "> The Rust-style target that this compiler runs on</ td >< td style ="text-align: left "> String</ td >< td style ="text-align: left "> required</ td >< td style ="text-align: left "></ td ></ tr > 1526< tr >< td style ="text-align: left ">< a id ="rust_toolchain_tools_repository-extra_exec_rustc_flags "></ a > extra_exec_rustc_flags</ td >< td style ="text-align: left "> Extra flags to pass to rustc in exec configuration</ td >< td style ="text-align: left "> List of strings</ td >< td style ="text-align: left "> optional</ td >< td style ="text-align: left ">< code > []</ code ></ td ></ tr > 1527< tr >< td style ="text-align: left ">< a id ="rust_toolchain_tools_repository-extra_rustc_flags "></ a > extra_rustc_flags</ td >< td style ="text-align: left "> Extra flags to pass to rustc in non-exec configuration</ td >< td style ="text-align: left "> List of strings</ td >< td style ="text-align: left "> optional</ td >< td style ="text-align: left ">< code > []</ code ></ td ></ tr > 1528< tr >< td style ="text-align: left ">< a id ="rust_toolchain_tools_repository-global_allocator_library "></ a > global_allocator_library</ td >< td style ="text-align: left "> Target that provides allocator functions when a global allocator is used with cc_common.link.</ td >< td style ="text-align: left "> String</ td >< td style ="text-align: left "> optional</ td >< td style ="text-align: left ">< code > "@rules_rust//ffi/cc/global_allocator_library"</ code ></ td ></ tr > 1529< tr >< td style ="text-align: left ">< a id ="rust_toolchain_tools_repository-netrc "></ a > netrc</ td >< td style ="text-align: left "> .netrc file to use for authentication; mirrors the eponymous attribute from http_archive</ td >< td style ="text-align: left "> String</ td >< td style ="text-align: left "> optional</ td >< td style ="text-align: left ">< code > ""</ code ></ td ></ tr > 1530< tr >< td style ="text-align: left ">< a id ="rust_toolchain_tools_repository-opt_level "></ a > opt_level</ td >< td style ="text-align: left "> Rustc optimization levels. For more details see the documentation for< code > rust_toolchain.opt_level</ code > .</ 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 > 1531< tr >< td style ="text-align: left ">< a id ="rust_toolchain_tools_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 > 1532< tr >< td style ="text-align: left ">< a id ="rust_toolchain_tools_repository-rustfmt_version "></ a > rustfmt_version</ td >< td style ="text-align: left "> The version of the tool among "nightly", "beta", or an exact version.</ td >< td style ="text-align: left "> String</ td >< td style ="text-align: left "> optional</ td >< td style ="text-align: left ">< code > ""</ code ></ td ></ tr > 1533< tr >< td style ="text-align: left ">< a id ="rust_toolchain_tools_repository-sha256s "></ a > sha256s</ td >< td style ="text-align: left "> A dict associating tool subdirectories to sha256 hashes. See< a href ="#rust_register_toolchains "> rust_register_toolchains</ a > for more details.</ 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 > 1534< tr >< td style ="text-align: left ">< a id ="rust_toolchain_tools_repository-target_triple "></ a > target_triple</ td >< td style ="text-align: left "> The Rust-style target that this compiler builds for.</ td >< td style ="text-align: left "> String</ td >< td style ="text-align: left "> required</ td >< td style ="text-align: left "></ td ></ tr > 1535< tr >< td style ="text-align: left ">< a id ="rust_toolchain_tools_repository-urls "></ a > urls</ td >< td style ="text-align: left "> A list of mirror urls containing the tools from the Rust-lang static file server. These must contain the '{}' used to substitute the tool being fetched (using .format).</ td >< td style ="text-align: left "> List of strings</ td >< td style ="text-align: left "> optional</ td >< td style ="text-align: left ">< code > ["https://static.rust-lang.org/dist/{}.tar.xz"]</ code ></ td ></ tr > 1536< tr >< td style ="text-align: left ">< a id ="rust_toolchain_tools_repository-version "></ a > version</ td >< td style ="text-align: left "> The version of the tool among "nightly", "beta", or an exact version.</ td >< td style ="text-align: left "> String</ td >< td style ="text-align: left "> required</ td >< td style ="text-align: left "></ td ></ tr > 1537</ tbody ></ table > 1538</ div > 1539</ main > 1540 1541< nav class ="nav-wrapper "aria-label ="Page navigation "> 1542<!-- Mobile navigation buttons --> 1543< a rel ="prev "href ="rust_analyzer.html "class ="mobile-nav-chapters previous "title ="Previous chapter "aria-label ="Previous chapter "aria-keyshortcuts ="Left "> 1544< i class ="fa fa-angle-left "></ i > 1545</ a > 1546 1547< a rel ="next prefetch "href ="external_crates.html "class ="mobile-nav-chapters next "title ="Next chapter "aria-label ="Next chapter "aria-keyshortcuts ="Right "> 1548< i class ="fa fa-angle-right "></ i > 1549</ a > 1550 1551< div style ="clear: both "></ div > 1552</ nav > 1553</ div > 1554</ div > 1555 1556< nav class ="nav-wide-wrapper "aria-label ="Page navigation "> 1557< a rel ="prev "href ="rust_analyzer.html "class ="nav-chapters previous "title ="Previous chapter "aria-label ="Previous chapter "aria-keyshortcuts ="Left "> 1558< i class ="fa fa-angle-left "></ i > 1559</ a > 1560 1561< a rel ="next prefetch "href ="external_crates.html "class ="nav-chapters next "title ="Next chapter "aria-label ="Next chapter "aria-keyshortcuts ="Right "> 1562< i class ="fa fa-angle-right "></ i > 1563</ a > 1564</ nav > 1565 1566</ div > 1567 1568 1569 1570 1571< script > 1572window . playground_copyable = true ; 1573</ script > 1574 1575 1576< script src ="elasticlunr.min.js "></ script > 1577< script src ="mark.min.js "></ script > 1578< script src ="searcher.js "></ script > 1579 1580< script src ="clipboard.min.js "></ script > 1581< script src ="highlight.js "></ script > 1582< script src ="book.js "></ script > 1583 1584<!-- Custom JS scripts --> 1585 1586 1587</ div > 1588</ body > 1589</ html >