aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild
diff options
context:
space:
mode:
Diffstat (limited to 'mesonbuild')
-rw-r--r--mesonbuild/backend/backends.py4
-rw-r--r--mesonbuild/backend/ninjabackend.py2
-rw-r--r--mesonbuild/build.py17
-rw-r--r--mesonbuild/compilers.py7
-rw-r--r--mesonbuild/environment.py27
-rw-r--r--mesonbuild/mesonlib.py4
-rw-r--r--mesonbuild/scripts/meson_exe.py6
-rw-r--r--mesonbuild/scripts/meson_install.py13
8 files changed, 67 insertions, 13 deletions
diff --git a/mesonbuild/backend/backends.py b/mesonbuild/backend/backends.py
index 5517fbd..80cf0ee 100644
--- a/mesonbuild/backend/backends.py
+++ b/mesonbuild/backend/backends.py
@@ -252,7 +252,7 @@ class Backend:
exe_wrapper = self.environment.cross_info.config['binaries'].get('exe_wrapper', None)
else:
exe_wrapper = None
- if mesonlib.is_windows():
+ if mesonlib.is_windows() or mesonlib.is_cygwin():
extra_paths = self.determine_windows_extra_paths(exe)
else:
extra_paths = []
@@ -481,7 +481,7 @@ class Backend:
exe_wrapper = self.environment.cross_info.config['binaries'].get('exe_wrapper', None)
else:
exe_wrapper = None
- if mesonlib.is_windows():
+ if mesonlib.is_windows() or mesonlib.is_cygwin():
extra_paths = self.determine_windows_extra_paths(exe)
else:
extra_paths = []
diff --git a/mesonbuild/backend/ninjabackend.py b/mesonbuild/backend/ninjabackend.py
index bc51ace..3143970 100644
--- a/mesonbuild/backend/ninjabackend.py
+++ b/mesonbuild/backend/ninjabackend.py
@@ -492,7 +492,7 @@ int dummy;
# the project, we need to set PATH so the DLLs are found. We use
# a serialized executable wrapper for that and check if the
# CustomTarget command needs extra paths first.
- if target.capture or (mesonlib.is_windows() and
+ if target.capture or ((mesonlib.is_windows() or mesonlib.is_cygwin()) and
self.determine_windows_extra_paths(target.command[0])):
exe_data = self.serialise_executable(target.command[0], cmd[1:],
# All targets are built from the build dir
diff --git a/mesonbuild/build.py b/mesonbuild/build.py
index 1246f3e..537c91b 100644
--- a/mesonbuild/build.py
+++ b/mesonbuild/build.py
@@ -21,7 +21,7 @@ from . import mlog
from .mesonlib import File, MesonException
from .mesonlib import flatten, stringlistify, classify_unity_sources
from .mesonlib import get_filenames_templates_dict, substitute_values
-from .environment import for_windows, for_darwin
+from .environment import for_windows, for_darwin, for_cygwin
from .compilers import is_object, clike_langs, sort_clike, lang_suffixes
known_basic_kwargs = {'install': True,
@@ -997,7 +997,8 @@ class Executable(BuildTarget):
self.prefix = ''
if not hasattr(self, 'suffix'):
# Executable for Windows or C#/Mono
- if for_windows(is_cross, environment) or 'cs' in self.compilers:
+ if (for_windows(is_cross, environment) or
+ for_cygwin(is_cross, environment) or 'cs' in self.compilers):
self.suffix = 'exe'
else:
self.suffix = ''
@@ -1120,6 +1121,18 @@ class SharedLibrary(BuildTarget):
self.filename_tpl = '{0.prefix}{0.name}-{0.soversion}.{0.suffix}'
else:
self.filename_tpl = '{0.prefix}{0.name}.{0.suffix}'
+ elif for_cygwin(is_cross, env):
+ suffix = 'dll'
+ self.gcc_import_filename = 'lib{0}.dll.a'.format(self.name)
+ # Shared library is of the form cygfoo.dll
+ # (ld --dll-search-prefix=cyg is the default)
+ prefix = 'cyg'
+ # Import library is called libfoo.dll.a
+ self.import_filename = self.gcc_import_filename
+ if self.soversion:
+ self.filename_tpl = '{0.prefix}{0.name}-{0.soversion}.{0.suffix}'
+ else:
+ self.filename_tpl = '{0.prefix}{0.name}.{0.suffix}'
elif for_darwin(is_cross, env):
prefix = 'lib'
suffix = 'dylib'
diff --git a/mesonbuild/compilers.py b/mesonbuild/compilers.py
index 6f08d98..e6be8b1 100644
--- a/mesonbuild/compilers.py
+++ b/mesonbuild/compilers.py
@@ -2309,6 +2309,7 @@ class VisualStudioCPPCompiler(VisualStudioCCompiler, CPPCompiler):
GCC_STANDARD = 0
GCC_OSX = 1
GCC_MINGW = 2
+GCC_CYGWIN = 3
CLANG_STANDARD = 0
CLANG_OSX = 1
@@ -2324,7 +2325,7 @@ def get_gcc_soname_args(gcc_type, prefix, shlib_name, suffix, path, soversion, i
sostr = ''
else:
sostr = '.' + soversion
- if gcc_type == GCC_STANDARD or gcc_type == GCC_MINGW:
+ if gcc_type in (GCC_STANDARD, GCC_MINGW, GCC_CYGWIN):
# Might not be correct for mingw but seems to work.
return ['-Wl,-soname,%s%s.%s%s' % (prefix, shlib_name, suffix, sostr)]
elif gcc_type == GCC_OSX:
@@ -2398,7 +2399,7 @@ class GnuCompiler:
return self.defines[define]
def get_pic_args(self):
- if self.gcc_type in (GCC_MINGW, GCC_OSX):
+ if self.gcc_type in (GCC_CYGWIN, GCC_MINGW, GCC_OSX):
return [] # On Window and OS X, pic is always on.
return ['-fPIC']
@@ -2796,7 +2797,7 @@ class FortranCompiler(Compiler):
return ' '.join(self.exelist)
def get_pic_args(self):
- if self.gcc_type in (GCC_MINGW, GCC_OSX):
+ if self.gcc_type in (GCC_CYGWIN, GCC_MINGW, GCC_OSX):
return [] # On Window and OS X, pic is always on.
return ['-fPIC']
diff --git a/mesonbuild/environment.py b/mesonbuild/environment.py
index cb62506..7861612 100644
--- a/mesonbuild/environment.py
+++ b/mesonbuild/environment.py
@@ -158,7 +158,10 @@ def detect_cpu(compilers):
return trial
def detect_system():
- return platform.system().lower()
+ system = platform.system().lower()
+ if system.startswith('cygwin'):
+ return 'cygwin'
+ return system
def for_windows(is_cross, env):
@@ -173,6 +176,20 @@ def for_windows(is_cross, env):
return env.cross_info.config['host_machine']['system'] == 'windows'
return False
+
+def for_cygwin(is_cross, env):
+ """
+ Host machine is cygwin?
+
+ Note: 'host' is the machine on which compiled binaries will run
+ """
+ if not is_cross:
+ return mesonlib.is_cygwin()
+ elif env.cross_info.has_host():
+ return env.cross_info.config['host_machine']['system'] == 'cygwin'
+ return False
+
+
def for_darwin(is_cross, env):
"""
Host machine is Darwin (iOS/OS X)?
@@ -257,6 +274,11 @@ class Environment:
self.exe_suffix = 'exe'
self.object_suffix = 'obj'
self.win_libdir_layout = True
+ elif (not cross and mesonlib.is_cygwin()) \
+ or (cross and self.cross_info.has_host() and self.cross_info.config['host_machine']['system'] == 'cygwin'):
+ self.exe_suffix = 'exe'
+ self.object_suffix = 'o'
+ self.win_libdir_layout = True
else:
self.exe_suffix = ''
self.object_suffix = 'o'
@@ -368,7 +390,8 @@ class Environment:
return GCC_OSX
elif '__MINGW32__' in defines or '__MINGW64__' in defines:
return GCC_MINGW
- # We ignore Cygwin for now, and treat it as a standard GCC
+ elif '__CYGWIN__' in defines:
+ return GCC_CYGWIN
return GCC_STANDARD
def _get_compilers(self, lang, evar, want_cross):
diff --git a/mesonbuild/mesonlib.py b/mesonbuild/mesonlib.py
index ba52219..291eb68 100644
--- a/mesonbuild/mesonlib.py
+++ b/mesonbuild/mesonlib.py
@@ -212,6 +212,10 @@ def is_windows():
platname = platform.system().lower()
return platname == 'windows' or 'mingw' in platname
+def is_cygwin():
+ platname = platform.system().lower()
+ return platname.startswith('cygwin')
+
def is_debianlike():
return os.path.isfile('/etc/debian_version')
diff --git a/mesonbuild/scripts/meson_exe.py b/mesonbuild/scripts/meson_exe.py
index 5c5c317..643e1af 100644
--- a/mesonbuild/scripts/meson_exe.py
+++ b/mesonbuild/scripts/meson_exe.py
@@ -29,8 +29,12 @@ def is_windows():
platname = platform.system().lower()
return platname == 'windows' or 'mingw' in platname
+def is_cygwin():
+ platname = platform.system().lower()
+ return 'cygwin' in platname
+
def run_with_mono(fname):
- if fname.endswith('.exe') and not is_windows():
+ if fname.endswith('.exe') and not (is_windows() or is_cygwin()):
return True
return False
diff --git a/mesonbuild/scripts/meson_install.py b/mesonbuild/scripts/meson_install.py
index 8fb9e04..e172032 100644
--- a/mesonbuild/scripts/meson_install.py
+++ b/mesonbuild/scripts/meson_install.py
@@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-import sys, pickle, os, shutil, subprocess, gzip, platform
+import sys, pickle, os, shutil, subprocess, gzip, platform, errno
from glob import glob
from . import depfixer
from . import destdir_join
@@ -34,6 +34,15 @@ def set_mode(path, mode):
except PermissionError as e:
msg = '{!r}: Unable to set owner {!r} and group {!r}: {}, ignoring...'
print(msg.format(path, mode.owner, mode.group, e.strerror))
+ except LookupError as e:
+ msg = '{!r}: Non-existent owner {!r} or group {!r}: ignoring...'
+ print(msg.format(path, mode.owner, mode.group))
+ except OSError as e:
+ if e.errno == errno.EINVAL:
+ msg = '{!r}: Non-existent numeric owner {!r} or group {!r}: ignoring...'
+ print(msg.format(path, mode.owner, mode.group))
+ else:
+ raise
# Must set permissions *after* setting owner/group otherwise the
# setuid/setgid bits will get wiped by chmod
# NOTE: On Windows you can set read/write perms; the rest are ignored
@@ -193,7 +202,7 @@ def run_install_script(d):
def is_elf_platform():
platname = platform.system().lower()
- if platname == 'darwin' or platname == 'windows':
+ if platname == 'darwin' or platname == 'windows' or platname == 'cygwin':
return False
return True