chiark / gitweb /
Enable dependency checks for out-of-tree packages
[termux-packages] / scripts / meson-android.patch
1 diff -u -r ../meson-0.41.2/mesonbuild/build.py ./mesonbuild/build.py
2 --- ../meson-0.41.2/mesonbuild/build.py 2017-07-19 11:39:22.000000000 +0200
3 +++ ./mesonbuild/build.py       2017-07-29 00:28:05.082804622 +0200
4 @@ -21,7 +21,7 @@
5  from .mesonlib import File, MesonException
6  from .mesonlib import flatten, typeslistify, stringlistify, classify_unity_sources
7  from .mesonlib import get_filenames_templates_dict, substitute_values
8 -from .environment import for_windows, for_darwin, for_cygwin
9 +from .environment import for_windows, for_darwin, for_cygwin, for_android
10  from .compilers import is_object, clike_langs, sort_clike, lang_suffixes
11  
12  known_basic_kwargs = {'install': True,
13 @@ -1164,6 +1164,7 @@
14          if not hasattr(self, 'suffix'):
15              self.suffix = None
16          self.basic_filename_tpl = '{0.prefix}{0.name}.{0.suffix}'
17 +        self.is_cross = is_cross
18          self.determine_filenames(is_cross, environment)
19  
20      def determine_filenames(self, is_cross, env):
21 @@ -1272,25 +1273,26 @@
22  
23      def process_kwargs(self, kwargs, environment):
24          super().process_kwargs(kwargs, environment)
25 -        # Shared library version
26 -        if 'version' in kwargs:
27 -            self.ltversion = kwargs['version']
28 -            if not isinstance(self.ltversion, str):
29 -                raise InvalidArguments('Shared library version needs to be a string, not ' + type(self.ltversion).__name__)
30 -            if not re.fullmatch(r'[0-9]+(\.[0-9]+){0,2}', self.ltversion):
31 -                raise InvalidArguments('Invalid Shared library version "{0}". Must be of the form X.Y.Z where all three are numbers. Y and Z are optional.'.format(self.ltversion))
32 -        # Try to extract/deduce the soversion
33 -        if 'soversion' in kwargs:
34 -            self.soversion = kwargs['soversion']
35 -            if isinstance(self.soversion, int):
36 -                self.soversion = str(self.soversion)
37 -            if not isinstance(self.soversion, str):
38 -                raise InvalidArguments('Shared library soversion is not a string or integer.')
39 -        elif self.ltversion:
40 -            # library version is defined, get the soversion from that
41 -            # We replicate what Autotools does here and take the first
42 -            # number of the version by default.
43 -            self.soversion = self.ltversion.split('.')[0]
44 +        if not for_android(self.is_cross, environment):
45 +            # Shared library version
46 +            if 'version' in kwargs:
47 +                self.ltversion = kwargs['version']
48 +                if not isinstance(self.ltversion, str):
49 +                    raise InvalidArguments('Shared library version needs to be a string, not ' + type(self.ltversion).__name__)
50 +                if not re.fullmatch(r'[0-9]+(\.[0-9]+){0,2}', self.ltversion):
51 +                    raise InvalidArguments('Invalid Shared library version "{0}". Must be of the form X.Y.Z where all three are numbers. Y and Z are optional.'.format(self.ltversion))
52 +            # Try to extract/deduce the soversion
53 +            if 'soversion' in kwargs:
54 +                self.soversion = kwargs['soversion']
55 +                if isinstance(self.soversion, int):
56 +                    self.soversion = str(self.soversion)
57 +                if not isinstance(self.soversion, str):
58 +                    raise InvalidArguments('Shared library soversion is not a string or integer.')
59 +            elif self.ltversion:
60 +                # library version is defined, get the soversion from that
61 +                # We replicate what Autotools does here and take the first
62 +                # number of the version by default.
63 +                self.soversion = self.ltversion.split('.')[0]
64          # Visual Studio module-definitions file
65          if 'vs_module_defs' in kwargs:
66              path = kwargs['vs_module_defs']
67 diff -u -r ../meson-0.41.2/mesonbuild/environment.py ./mesonbuild/environment.py
68 --- ../meson-0.41.2/mesonbuild/environment.py   2017-07-19 11:39:22.000000000 +0200
69 +++ ./mesonbuild/environment.py 2017-07-29 00:08:12.592115029 +0200
70 @@ -212,6 +212,17 @@
71          return env.cross_info.config['host_machine']['system'] == 'darwin'
72      return False
73  
74 +def for_android(is_cross, env):
75 +    """
76 +    Host machine is Android?
77 +
78 +    Note: 'host' is the machine on which compiled binaries will run
79 +    """
80 +    if not is_cross:
81 +        return mesonlib.is_android()
82 +    elif env.cross_info.has_host():
83 +        return env.cross_info.config['host_machine']['system'] == 'android'
84 +    return False
85  
86  def search_version(text):
87      # Usually of the type 4.1.4 but compiler output may contain
88 diff -u -r ../meson-0.41.2/mesonbuild/mesonlib.py ./mesonbuild/mesonlib.py
89 --- ../meson-0.41.2/mesonbuild/mesonlib.py      2017-07-19 11:39:22.000000000 +0200
90 +++ ./mesonbuild/mesonlib.py    2017-07-29 00:08:27.543948195 +0200
91 @@ -219,6 +219,12 @@
92  def is_linux():
93      return platform.system().lower() == 'linux'
94  
95 +def is_android():
96 +    import sysconfig
97 +    # Taken from Lib/test/support/__init__.py of the python source:
98 +    _ANDROID_API_LEVEL = sysconfig.get_config_var('ANDROID_API_LEVEL')
99 +    return _ANDROID_API_LEVEL is not None and _ANDROID_API_LEVEL > 0
100 +
101  def is_windows():
102      platname = platform.system().lower()
103      return platname == 'windows' or 'mingw' in platname