|  | 
| 18 | 18 |     DEPENDENCIES_KW, LINK_WITH_KW, LINK_WHOLE_KW, SHARED_LIB_KWS, TEST_KWS, TEST_KWS_NO_ARGS, | 
| 19 | 19 |     OUTPUT_KW, INCLUDE_DIRECTORIES, SOURCES_VARARGS, NoneType, in_set_validator | 
| 20 | 20 | ) | 
| 21 |  | -from ..interpreterbase import ContainerTypeInfo, InterpreterException, KwargInfo, typed_kwargs, typed_pos_args, noKwargs, noPosargs, permittedKwargs | 
|  | 21 | +from ..interpreterbase import ContainerTypeInfo, InterpreterException, KwargInfo, typed_kwargs, typed_pos_args, noPosargs, permittedKwargs | 
| 22 | 22 | from ..interpreter.interpreterobjects import Doctest | 
| 23 | 23 | from ..mesonlib import File, MesonException, PerMachine | 
| 24 | 24 | from ..programs import ExternalProgram, NonExistingExternalProgram | 
| @@ -495,13 +495,34 @@ def proc_macro(self, state: ModuleState, args: T.Tuple[str, SourcesVarargsType], | 
| 495 | 495 |         return target | 
| 496 | 496 | 
 | 
| 497 | 497 |     @noPosargs | 
| 498 |  | -    @noKwargs | 
|  | 498 | +    @typed_kwargs( | 
|  | 499 | +        'rust.workspace', | 
|  | 500 | +        KwargInfo('default_features', (bool, NoneType), default=None), | 
|  | 501 | +        KwargInfo( | 
|  | 502 | +            'features', | 
|  | 503 | +            (ContainerTypeInfo(list, str), NoneType), | 
|  | 504 | +            default=None, | 
|  | 505 | +            listify=True, | 
|  | 506 | +        ), | 
|  | 507 | +    ) | 
| 499 | 508 |     def workspace(self, state: ModuleState, args: T.List, kwargs: T.Dict[str, T.Any]) -> RustWorkspace: | 
| 500 | 509 |         """Creates a Rust workspace object, controlling the build of | 
| 501 | 510 |            all the packages in a Cargo.lock file.""" | 
| 502 | 511 |         if self.interpreter.cargo is None: | 
| 503 | 512 |             raise MesonException("rust.workspace() requires a Cargo project (Cargo.toml and Cargo.lock)") | 
| 504 | 513 | 
 | 
|  | 514 | +        default_features = kwargs['default_features'] | 
|  | 515 | +        features = kwargs['features'] | 
|  | 516 | +        if default_features is not None or features is not None: | 
|  | 517 | +            # If custom features are provided, default_features = None should be treated as True | 
|  | 518 | +            if default_features is None: | 
|  | 519 | +                default_features = True | 
|  | 520 | + | 
|  | 521 | +            cargo_features = ['default'] if default_features else [] | 
|  | 522 | +            if features is not None: | 
|  | 523 | +                cargo_features.extend(features) | 
|  | 524 | +            self.interpreter.cargo.features = cargo_features | 
|  | 525 | + | 
| 505 | 526 |         # Check if we already have a cached workspace for this cargo interpreter | 
| 506 | 527 |         ws_obj = self._workspace_cache.get(self.interpreter.cargo) | 
| 507 | 528 |         if ws_obj is None: | 
|  | 
0 commit comments