Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gnome: Added 'executable' method for GTK Android #13800

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
8 changes: 8 additions & 0 deletions docs/markdown/Gnome-module.md
Original file line number Diff line number Diff line change
Expand Up @@ -429,3 +429,11 @@ It takes the following keyword arguments:
MIME types handled by desktop files in `<prefix>/<datadir>/applications`.
- `update_mime_database`: *Since 0.64.0* If set to `true`, update cache of
MIME types in `<prefix>/<datadir>/mime`.

### gnome.executable()

*Since 1.7.0*

Wrapper for executable explicitly targeting applications utilizing GTK. It
takes the same arguments as
[executable](Reference-manual_functions.md#executable).
9 changes: 8 additions & 1 deletion mesonbuild/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -525,6 +525,7 @@ class Target(HoldableObject, metaclass=abc.ABCMeta):
build_always_stale: bool = False
extra_files: T.List[File] = field(default_factory=list)
override_options: InitVar[T.Optional[T.Dict[OptionKey, str]]] = None
introspection_flags: T.Optional[T.List[str]] = None

@abc.abstractproperty
def typename(self) -> str:
Expand Down Expand Up @@ -637,6 +638,12 @@ def construct_id_from_path(subdir: str, name: str, type_suffix: str) -> str:
return subdir_part + '@@' + my_id
return my_id

def add_introspection_flag(self, flag: str) -> None:
if self.introspection_flags is None:
self.introspection_flags = [flag]
else:
self.introspection_flags.append(flag)

def get_id(self) -> str:
name = self.name
if getattr(self, 'name_suffix_set', False):
Expand Down Expand Up @@ -1343,7 +1350,7 @@ def get_pch(self, language: str) -> T.List[str]:
def get_include_dirs(self) -> T.List['IncludeDirs']:
return self.include_dirs

def add_deps(self, deps):
def add_deps(self, deps: T.Sequence[dependencies.Dependency]):
deps = listify(deps)
for dep in deps:
if dep in self.added_deps:
Expand Down
6 changes: 6 additions & 0 deletions mesonbuild/interpreter/interpreter.py
Original file line number Diff line number Diff line change
Expand Up @@ -3362,6 +3362,12 @@ def build_target(self, node: mparser.BaseNode, args: T.Tuple[str, SourcesVarargs
def build_target(self, node: mparser.BaseNode, args: T.Tuple[str, SourcesVarargsType],
kwargs: kwtypes.Jar, targetclass: T.Type[build.Jar]) -> build.Jar: ...

@T.overload
def build_target(self, node: mparser.BaseNode, args: T.Tuple[str, SourcesVarargsType],
kwargs: T.Union[kwtypes.Executable, kwtypes.StaticLibrary, kwtypes.SharedLibrary, kwtypes.SharedModule, kwtypes.Jar],
targetclass: T.Type[T.Union[build.Executable, build.StaticLibrary, build.SharedModule, build.SharedLibrary, build.Jar]]
) -> T.Union[build.Executable, build.StaticLibrary, build.SharedModule, build.SharedLibrary, build.Jar]: ...

def build_target(self, node: mparser.BaseNode, args: T.Tuple[str, SourcesVarargsType],
kwargs: T.Union[kwtypes.Executable, kwtypes.StaticLibrary, kwtypes.SharedLibrary, kwtypes.SharedModule, kwtypes.Jar],
targetclass: T.Type[T.Union[build.Executable, build.StaticLibrary, build.SharedModule, build.SharedLibrary, build.Jar]]
Expand Down
3 changes: 3 additions & 0 deletions mesonbuild/mintro.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,9 @@ def list_targets(builddata: build.Build, installdata: backends.InstallData, back
'depends': [lib.get_id() for lib in getattr(target, 'dependencies', [])]
}

if target.introspection_flags:
t['flags'] = target.introspection_flags

vs_module_defs = getattr(target, 'vs_module_defs', None)
if vs_module_defs is not None:
t['vs_module_defs'] = vs_module_defs.relative_name()
Expand Down
24 changes: 24 additions & 0 deletions mesonbuild/modules/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@
from ..programs import ExternalProgram

if T.TYPE_CHECKING:
from ..interpreter import kwargs as kwtypes
from ..interpreter import Interpreter
from ..interpreter.interpreter import ProgramVersionFunc
from ..interpreter.type_checking import SourcesVarargsType
from ..interpreterbase import TYPE_var, TYPE_kwargs
from ..programs import OverrideProgram
from ..dependencies import Dependency
Expand Down Expand Up @@ -157,6 +159,28 @@ def process_include_dirs(self, dirs: T.Iterable[T.Union[str, IncludeDirs]]) -> T
def add_language(self, lang: str, for_machine: MachineChoice) -> None:
self._interpreter.add_languages([lang], True, for_machine)

@T.overload
def add_target(self, args: T.Tuple[str, SourcesVarargsType],
kwargs: kwtypes.Executable, targetclass: T.Type[build.Executable]) -> build.Executable: ...

@T.overload
def add_target(self, args: T.Tuple[str, SourcesVarargsType],
kwargs: kwtypes.StaticLibrary, targetclass: T.Type[build.StaticLibrary]) -> build.StaticLibrary: ...

@T.overload
def add_target(self, args: T.Tuple[str, SourcesVarargsType],
kwargs: kwtypes.SharedModule, targetclass: T.Type[build.SharedModule]) -> build.SharedModule: ...

@T.overload
def add_target(self, args: T.Tuple[str, SourcesVarargsType],
kwargs: kwtypes.SharedLibrary, targetclass: T.Type[build.SharedLibrary]) -> build.SharedLibrary: ...

def add_target(self, args: T.Tuple[str, SourcesVarargsType],
kwargs: T.Union[kwtypes.Executable, kwtypes.StaticLibrary, kwtypes.SharedLibrary, kwtypes.SharedModule, kwtypes.Jar],
targetclass: T.Type[T.Union[build.Executable, build.StaticLibrary, build.SharedModule, build.SharedLibrary, build.Jar]]
) -> T.Union[build.Executable, build.StaticLibrary, build.SharedModule, build.SharedLibrary, build.Jar]:
return self._interpreter.build_target(self.current_node, args, kwargs, targetclass)

class ModuleObject(HoldableObject):
"""Base class for all objects returned by modules
"""
Expand Down
26 changes: 24 additions & 2 deletions mesonbuild/modules/gnome.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
from ..build import CustomTarget, CustomTargetIndex, Executable, GeneratedList, InvalidArguments
from ..dependencies import Dependency, InternalDependency
from ..dependencies.pkgconfig import PkgConfigDependency, PkgConfigInterface
from ..interpreter.type_checking import DEPENDS_KW, DEPEND_FILES_KW, ENV_KW, INSTALL_DIR_KW, INSTALL_KW, NoneType, DEPENDENCY_SOURCES_KW, in_set_validator
from ..interpreterbase import noPosargs, noKwargs, FeatureNew, FeatureDeprecated
from ..interpreter.type_checking import DEPENDS_KW, DEPEND_FILES_KW, ENV_KW, EXECUTABLE_KWS, INSTALL_DIR_KW, INSTALL_KW, SOURCES_VARARGS, NoneType, DEPENDENCY_SOURCES_KW, in_set_validator
from ..interpreterbase import noPosargs, noKwargs, permittedKwargs, FeatureNew, FeatureDeprecated
from ..interpreterbase import typed_kwargs, KwargInfo, ContainerTypeInfo
from ..interpreterbase.decorators import typed_pos_args
from ..mesonlib import (
Expand All @@ -41,7 +41,9 @@
from . import ModuleState
from ..build import BuildTarget
from ..compilers import Compiler
from ..interpreter import kwargs as kwtypes
from ..interpreter import Interpreter
from ..interpreter.type_checking import SourcesVarargsType
from ..interpreterbase import TYPE_var, TYPE_kwargs
from ..mesonlib import FileOrString
from ..programs import ExternalProgram
Expand Down Expand Up @@ -274,6 +276,7 @@ def __init__(self, interpreter: 'Interpreter') -> None:
'mkenums_simple': self.mkenums_simple,
'genmarshal': self.genmarshal,
'generate_vapi': self.generate_vapi,
'executable': self.executable,
})

def _get_native_glib_version(self, state: 'ModuleState') -> str:
Expand Down Expand Up @@ -2205,6 +2208,25 @@ def generate_vapi(self, state: 'ModuleState', args: T.Tuple[str], kwargs: 'Gener
created_values.append(rv)
return ModuleReturnValue(rv, created_values)

@permittedKwargs(build.known_exe_kwargs)
@typed_pos_args('gnome.executable', str, varargs=SOURCES_VARARGS)
@typed_kwargs('gnome.executable', *EXECUTABLE_KWS, allow_unknown=True)
def executable(self, state: 'ModuleState', args: T.Tuple[str, SourcesVarargsType], kwargs: kwtypes.Executable) -> ModuleReturnValue:
target: T.Union[build.Executable, build.SharedLibrary]
if state.environment.machines.host.is_android():
kwargs["gui_app"] = None
kwargs["win_subsystem"] = None
if T.TYPE_CHECKING:
target = state.add_target(args, T.cast(kwtypes.SharedLibrary, kwargs), build.SharedLibrary)
else:
target = state.add_target(args, kwargs, build.SharedLibrary)
glue = state.dependency('gtk4-android-glue')
target.add_deps([glue])
target.add_introspection_flag('gnome:has-android-glue')
else:
target = state.add_target(args, kwargs, build.Executable)
return ModuleReturnValue(target, [])

def initialize(interp: 'Interpreter') -> GnomeModule:
mod = GnomeModule(interp)
mod.interpreter.append_holder_map(GResourceTarget, interpreter.CustomTargetHolder)
Expand Down
Loading