|
|
|
@ -1,4 +1,4 @@ |
|
|
|
|
# Copyright © 2020-2022 Intel Corporation |
|
|
|
|
# Copyright © 2020-2023 Intel Corporation |
|
|
|
|
|
|
|
|
|
# Licensed under the Apache License, Version 2.0 (the "License"); |
|
|
|
|
# you may not use this file except in compliance with the License. |
|
|
|
@ -18,15 +18,16 @@ import typing as T |
|
|
|
|
|
|
|
|
|
from . import ExtensionModule, ModuleReturnValue, ModuleInfo |
|
|
|
|
from .. import mlog |
|
|
|
|
from ..build import BothLibraries, BuildTarget, CustomTargetIndex, Executable, ExtractedObjects, GeneratedList, IncludeDirs, CustomTarget, StructuredSources |
|
|
|
|
from ..build import BothLibraries, BuildTarget, CustomTargetIndex, Executable, ExtractedObjects, GeneratedList, IncludeDirs, CustomTarget, InvalidArguments, Jar, StructuredSources |
|
|
|
|
from ..compilers.compilers import are_asserts_disabled |
|
|
|
|
from ..dependencies import Dependency, ExternalLibrary |
|
|
|
|
from ..interpreter.type_checking import DEPENDENCIES_KW, TEST_KWS, OUTPUT_KW, INCLUDE_DIRECTORIES |
|
|
|
|
from ..interpreter.type_checking import DEPENDENCIES_KW, LINK_WITH_KW, TEST_KWS, OUTPUT_KW, INCLUDE_DIRECTORIES |
|
|
|
|
from ..interpreterbase import ContainerTypeInfo, InterpreterException, KwargInfo, typed_kwargs, typed_pos_args, noPosargs |
|
|
|
|
from ..mesonlib import File |
|
|
|
|
|
|
|
|
|
if T.TYPE_CHECKING: |
|
|
|
|
from . import ModuleState |
|
|
|
|
from ..build import LibTypes |
|
|
|
|
from ..interpreter import Interpreter |
|
|
|
|
from ..interpreter import kwargs as _kwargs |
|
|
|
|
from ..interpreter.interpreter import SourceInputs, SourceOutputs |
|
|
|
@ -38,6 +39,7 @@ if T.TYPE_CHECKING: |
|
|
|
|
|
|
|
|
|
dependencies: T.List[T.Union[Dependency, ExternalLibrary]] |
|
|
|
|
is_parallel: bool |
|
|
|
|
link_with: T.List[LibTypes] |
|
|
|
|
|
|
|
|
|
class FuncBindgen(TypedDict): |
|
|
|
|
|
|
|
|
@ -68,6 +70,7 @@ class RustModule(ExtensionModule): |
|
|
|
|
'rust.test', |
|
|
|
|
*TEST_KWS, |
|
|
|
|
DEPENDENCIES_KW, |
|
|
|
|
LINK_WITH_KW.evolve(since='1.2.0'), |
|
|
|
|
KwargInfo('is_parallel', bool, default=False), |
|
|
|
|
) |
|
|
|
|
def test(self, state: ModuleState, args: T.Tuple[str, BuildTarget], kwargs: FuncTest) -> ModuleReturnValue: |
|
|
|
@ -112,6 +115,9 @@ class RustModule(ExtensionModule): |
|
|
|
|
rust.test('rust_lib_test', rust_lib) |
|
|
|
|
``` |
|
|
|
|
""" |
|
|
|
|
if any(isinstance(t, Jar) for t in kwargs.get('link_with', [])): |
|
|
|
|
raise InvalidArguments('Rust tests cannot link with Jar targets') |
|
|
|
|
|
|
|
|
|
name = args[0] |
|
|
|
|
base_target: BuildTarget = args[1] |
|
|
|
|
if not base_target.uses_rust(): |
|
|
|
@ -145,6 +151,7 @@ class RustModule(ExtensionModule): |
|
|
|
|
new_target_kwargs['rust_args'] = new_target_kwargs.get('rust_args', []) + ['--test'] |
|
|
|
|
new_target_kwargs['install'] = False |
|
|
|
|
new_target_kwargs['dependencies'] = new_target_kwargs.get('dependencies', []) + kwargs['dependencies'] |
|
|
|
|
new_target_kwargs['link_with'] = new_target_kwargs.get('link_with', []) + kwargs['link_with'] |
|
|
|
|
|
|
|
|
|
sources = T.cast('T.List[SourceOutputs]', base_target.sources.copy()) |
|
|
|
|
sources.extend(base_target.generated) |
|
|
|
|