@@ -1355,12 +1355,22 @@ _rust_binary_without_process_wrapper_transition = transition(
13551355 ],
13561356)
13571357
1358+ _RustBuiltWithoutProcessWrapperInfo = provider (
1359+ doc = "A provider identifying the target having been built using a `*_without_process_wrapper` rule variant." ,
1360+ fields = {},
1361+ )
1362+
1363+ def _rust_binary_without_process_wrapper_impl (ctx ):
1364+ providers = _rust_binary_impl (ctx )
1365+ return providers + [_RustBuiltWithoutProcessWrapperInfo ()]
1366+
13581367# Provides an internal rust_{binary,library} to use that we can use to build the process
13591368# wrapper, this breaks the dependency of rust_* on the process wrapper by
13601369# setting it to None, which the functions in rustc detect and build accordingly.
13611370rust_binary_without_process_wrapper = rule (
1362- implementation = _rust_binary_impl ,
1363- provides = COMMON_PROVIDERS ,
1371+ implementation = _rust_binary_without_process_wrapper_impl ,
1372+ doc = "A variant of `rust_binary` that uses a minimal process wrapper for `Rustc` actions." ,
1373+ provides = COMMON_PROVIDERS + [_RustBuiltWithoutProcessWrapperInfo ],
13641374 attrs = _common_attrs_for_binary_without_process_wrapper (_common_attrs | _rust_binary_attrs ),
13651375 cfg = _rust_binary_without_process_wrapper_transition ,
13661376 executable = True ,
@@ -1371,9 +1381,14 @@ rust_binary_without_process_wrapper = rule(
13711381 ],
13721382)
13731383
1384+ def _rust_library_without_process_wrapper_impl (ctx ):
1385+ providers = _rust_library_impl (ctx )
1386+ return providers + [_RustBuiltWithoutProcessWrapperInfo ()]
1387+
13741388rust_library_without_process_wrapper = rule (
1375- implementation = _rust_library_impl ,
1376- provides = COMMON_PROVIDERS ,
1389+ implementation = _rust_library_without_process_wrapper_impl ,
1390+ doc = "A variant of `rust_library` that uses a minimal process wrapper for `Rustc` actions." ,
1391+ provides = COMMON_PROVIDERS + [_RustBuiltWithoutProcessWrapperInfo ],
13771392 attrs = dict (_common_attrs_for_binary_without_process_wrapper (_common_attrs ).items ()),
13781393 fragments = ["cpp" ],
13791394 toolchains = [
@@ -1382,6 +1397,39 @@ rust_library_without_process_wrapper = rule(
13821397 ],
13831398)
13841399
1400+ def _test_attrs_for_binary_without_process_wrapper (attrs ):
1401+ new_attrs = {}
1402+ new_attrs .update (attrs )
1403+
1404+ # Require that `crate` has the correct internal provider.
1405+ new_attrs ["crate" ] = attr .label (
1406+ mandatory = False ,
1407+ providers = [_RustBuiltWithoutProcessWrapperInfo ],
1408+ doc = dedent ("""\
1409+ Target inline tests declared in the given crate
1410+
1411+ These tests are typically those that would be held out under
1412+ `#[cfg(test)]` declarations.
1413+ """ ),
1414+ )
1415+
1416+ return new_attrs
1417+
1418+ rust_test_without_process_wrapper_test = rule (
1419+ implementation = _rust_test_impl ,
1420+ doc = "Unlike other `*_without_process_wrapper` rules, this rule does use the process wrapper but requires it's dependencies were not built with one." ,
1421+ provides = COMMON_PROVIDERS ,
1422+ attrs = _test_attrs_for_binary_without_process_wrapper (_common_attrs | _rust_test_attrs ),
1423+ executable = True ,
1424+ cfg = _rust_binary_without_process_wrapper_transition ,
1425+ fragments = ["cpp" ],
1426+ test = True ,
1427+ toolchains = [
1428+ str (Label ("//rust:toolchain_type" )),
1429+ config_common .toolchain_type ("@bazel_tools//tools/cpp:toolchain_type" , mandatory = False ),
1430+ ],
1431+ )
1432+
13851433def _rust_test_transition_impl (settings , attr ):
13861434 return {
13871435 "//command_line_option:platforms" : str (attr .platform ) if attr .platform else settings ["//command_line_option:platforms" ],
0 commit comments