Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion mesonbuild/backend/ninjabackend.py
Original file line number Diff line number Diff line change
Expand Up @@ -3210,7 +3210,8 @@ def generate_single_compile(self, target: build.BuildTarget, src,
compiler_name = self.compiler_to_rule_name(compiler)
else:
compiler_name = self.compiler_to_rule_name(compiler)
extra_deps = []
extra_deps: T.List[str] = []
extra_deps.extend(self.get_target_depend_files(target))
if compiler.get_language() == 'fortran':
# Can't read source file to scan for deps if it's generated later
# at build-time. Skip scanning for deps, and just set the module
Expand Down
38 changes: 16 additions & 22 deletions mesonbuild/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
from .linkers.linkers import StaticLinker
from .mesonlib import ExecutableSerialisation, FileMode, FileOrString
from .mparser import BaseNode
from .options import ElementaryOptionValues

GeneratedTypes: TypeAlias = T.Union['CustomTarget', 'CustomTargetIndex', 'GeneratedList']
LibTypes: TypeAlias = T.Union['SharedLibrary', 'StaticLibrary', 'CustomTarget', 'CustomTargetIndex']
Expand All @@ -70,13 +71,15 @@ class BuildTargetKeywordArguments(TypedDict, total=False):

build_by_default: bool
build_rpath: str
build_subdir: str
c_pch: T.Optional[T.Tuple[str, T.Optional[str]]]
cpp_pch: T.Optional[T.Tuple[str, T.Optional[str]]]
d_debug: T.List[T.Union[str, int]]
d_import_dirs: T.List[IncludeDirs]
d_module_versions: T.List[T.Union[str, int]]
d_unittest: bool
dependencies: T.List[dependencies.Dependency]
depend_files: T.List[File]
extra_files: T.List[File]
gnu_symbol_visibility: Literal['default', 'internal', 'hidden', 'protected', 'inlineshidden', '']
implicit_include_directories: bool
Expand All @@ -88,14 +91,14 @@ class BuildTargetKeywordArguments(TypedDict, total=False):
install_tag: T.List[T.Optional[str]]
language_args: T.DefaultDict[Language, T.List[str]]
link_args: T.List[str]
link_depends: T.List[T.Union[str, File, CustomTarget, CustomTargetIndex]]
link_depends: T.List[T.Union[File, BuildTargetTypes]]
link_language: Language
link_whole: T.List[StaticTargetTypes]
link_with: T.List[BuildTargetTypes]
name_prefix: T.Optional[str]
name_suffix: T.Optional[str]
native: MachineChoice
override_options: T.Dict[OptionKey, str]
override_options: T.Dict[str, ElementaryOptionValues]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The commit message says dict[str, str] but this is dict[str, ElementaryOptionValues]

resources: T.List[str]
swift_interoperability_mode: Literal['c', 'cpp']
swift_module_name: str
Expand All @@ -104,7 +107,6 @@ class BuildTargetKeywordArguments(TypedDict, total=False):
vala_gir: T.Optional[str]
vala_header: T.Optional[str]
vala_vapi: T.Optional[str]
win_subsystem: str

_allow_no_sources: bool

Expand All @@ -115,6 +117,7 @@ class ExecutableKeywordArguments(BuildTargetKeywordArguments, total=False):
export_dynamic: bool
pie: bool
vs_module_defs: T.Union[str, File, CustomTarget, CustomTargetIndex]
win_subsystem: str

class SharedModuleKeywordArguments(BuildTargetKeywordArguments, total=False):

Expand All @@ -132,6 +135,13 @@ class StaticLibraryKeywordArguments(BuildTargetKeywordArguments, total=False):
pic: bool
prelink: bool

class JarKeywordArguments(BuildTargetKeywordArguments, total=False):

java_args: T.List[str]
java_resources: T.Optional[StructuredSources]
main_class: str


_T = T.TypeVar('_T')

DEFAULT_STATIC_LIBRARY_NAMES: T.Mapping[str, T.Tuple[str, str]] = {
Expand Down Expand Up @@ -788,7 +798,7 @@ def id(self) -> str:
def get_id(self) -> str:
return self.id

def get_override(self, name: str) -> T.Optional[str]:
def get_override(self, name: str) -> T.Optional[ElementaryOptionValues]:
return self.raw_overrides.get(name, None)

def is_linkable_target(self) -> bool:
Expand Down Expand Up @@ -837,7 +847,7 @@ def __init__(
self.link_language: T.Optional[Language] = kwargs.get('link_language')
self.link_targets: T.List[BuildTargetTypes] = []
self.link_whole_targets: T.List[StaticTargetTypes] = []
self.depend_files: T.List[File] = []
self.depend_files = kwargs.get('depend_files', [])
self.link_depends: T.List[T.Union[File, BuildTargetTypes]] = []
self.added_deps = set()
self.name_prefix_set = False
Expand Down Expand Up @@ -896,7 +906,6 @@ def __init__(
mlog.warning(f'Build target {name} has no sources. '
'This was never supposed to be allowed but did because of a bug, '
'support will be removed in a future release of Meson')
self.check_unknown_kwargs(kwargs)
self.validate_install()
self.check_module_linking()

Expand Down Expand Up @@ -952,21 +961,6 @@ def validate_install(self):
else:
mlog.warning('Installing target build for the build machine. This will fail in a cross build.')

def check_unknown_kwargs(self, kwargs: BuildTargetKeywordArguments) -> None:
# Override this method in derived classes that have more
# keywords.
self.check_unknown_kwargs_int(kwargs, self.known_kwargs)

def check_unknown_kwargs_int(self, kwargs: BuildTargetKeywordArguments, known_kwargs: T.Set[str]) -> None:
unknowns = []
for k in kwargs:
if k == 'language_args':
continue
if k not in known_kwargs:
unknowns.append(k)
if len(unknowns) > 0:
mlog.warning('Unknown keyword argument(s) in target {}: {}.'.format(self.name, ', '.join(unknowns)))

def process_objectlist(self, objects):
assert isinstance(objects, list)
deprecated_non_objects = []
Expand Down Expand Up @@ -3187,7 +3181,7 @@ class Jar(BuildTarget):
def __init__(self, name: str, subdir: str, subproject: str, for_machine: MachineChoice,
sources: T.List[SourceOutputs], structured_sources: T.Optional['StructuredSources'],
objects, environment: Environment, compilers: CompilerDict,
kwargs):
kwargs: JarKeywordArguments):
super().__init__(name, subdir, subproject, for_machine, sources, structured_sources, objects,
environment, compilers, kwargs)
for s in self.sources:
Expand Down
Loading
Loading