Merge pull request #2745 from dcbaker/submit/haiku
small fixes for haiku
This commit is contained in:
commit
cbefb57ffe
|
@ -56,6 +56,7 @@ These are provided by the `.system()` method call.
|
|||
| darwin | Either OSX or iOS |
|
||||
| windows | Any version of Windows |
|
||||
| cygwin | The Cygwin environment for Windows |
|
||||
| haiku | |
|
||||
|
||||
Any string not listed above is not guaranteed to remain stable in
|
||||
future releases.
|
||||
future releases.
|
||||
|
|
|
@ -511,7 +511,7 @@ class Backend:
|
|||
# For 'automagic' deps: Boost and GTest. Also dependency('threads').
|
||||
# pkg-config puts the thread flags itself via `Cflags:`
|
||||
if dep.need_threads():
|
||||
commands += compiler.thread_flags()
|
||||
commands += compiler.thread_flags(self.environment)
|
||||
# Fortran requires extra include directives.
|
||||
if compiler.language == 'fortran':
|
||||
for lt in target.link_targets:
|
||||
|
|
|
@ -2438,7 +2438,7 @@ rule FORTRAN_DEP_HACK
|
|||
# pkg-config puts the thread flags itself via `Cflags:`
|
||||
for d in target.external_deps:
|
||||
if d.need_threads():
|
||||
commands += linker.thread_link_flags()
|
||||
commands += linker.thread_link_flags(self.environment)
|
||||
# Only non-static built targets need link args and link dependencies
|
||||
if not isinstance(target, build.StaticLibrary):
|
||||
commands += target.link_args
|
||||
|
|
|
@ -16,9 +16,11 @@ import subprocess, os.path, tempfile
|
|||
|
||||
from .. import mlog
|
||||
from .. import coredata
|
||||
from ..mesonlib import EnvironmentException, version_compare, Popen_safe, listify
|
||||
from ..mesonlib import for_windows, for_darwin, for_cygwin
|
||||
from . import compilers
|
||||
from ..mesonlib import (
|
||||
EnvironmentException, version_compare, Popen_safe, listify,
|
||||
for_windows, for_darwin, for_cygwin, for_haiku,
|
||||
)
|
||||
|
||||
from .compilers import (
|
||||
GCC_MINGW,
|
||||
|
@ -281,12 +283,12 @@ class CCompiler(Compiler):
|
|||
# Add compile flags needed by dependencies
|
||||
args += d.get_compile_args()
|
||||
if d.need_threads():
|
||||
args += self.thread_flags()
|
||||
args += self.thread_flags(env)
|
||||
if mode == 'link':
|
||||
# Add link flags needed to find dependencies
|
||||
args += d.get_link_args()
|
||||
if d.need_threads():
|
||||
args += self.thread_link_flags()
|
||||
args += self.thread_link_flags(env)
|
||||
# Select a CRT if needed since we're linking
|
||||
if mode == 'link':
|
||||
args += self.get_linker_debug_crt_args()
|
||||
|
@ -781,10 +783,14 @@ class CCompiler(Compiler):
|
|||
return [trial]
|
||||
return None
|
||||
|
||||
def thread_flags(self):
|
||||
def thread_flags(self, env):
|
||||
if for_haiku(self.is_cross, env):
|
||||
return []
|
||||
return ['-pthread']
|
||||
|
||||
def thread_link_flags(self):
|
||||
def thread_link_flags(self, env):
|
||||
if for_haiku(self.is_cross, env):
|
||||
return []
|
||||
return ['-pthread']
|
||||
|
||||
def has_multi_arguments(self, args, env):
|
||||
|
@ -1005,10 +1011,10 @@ class VisualStudioCCompiler(CCompiler):
|
|||
return []
|
||||
|
||||
# FIXME, no idea what these should be.
|
||||
def thread_flags(self):
|
||||
def thread_flags(self, env):
|
||||
return []
|
||||
|
||||
def thread_link_flags(self):
|
||||
def thread_link_flags(self, env):
|
||||
return []
|
||||
|
||||
def get_options(self):
|
||||
|
|
|
@ -634,9 +634,20 @@ class ExternalProgram:
|
|||
# Windows does not ship python3.exe, but we know the path to it
|
||||
if len(commands) > 0 and commands[0] == 'python3':
|
||||
commands = mesonlib.python_command + commands[1:]
|
||||
elif mesonlib.is_haiku():
|
||||
# Haiku does not have /usr, but a lot of scripts assume that
|
||||
# /usr/bin/env always exists. Detect that case and run the
|
||||
# script with the interpreter after it.
|
||||
if commands[0] == '/usr/bin/env':
|
||||
commands = commands[1:]
|
||||
# We know what python3 is, we're running on it
|
||||
if len(commands) > 0 and commands[0] == 'python3':
|
||||
commands = mesonlib.python_command + commands[1:]
|
||||
return commands + [script]
|
||||
except Exception:
|
||||
except Exception as e:
|
||||
mlog.debug(e)
|
||||
pass
|
||||
mlog.debug('Unusable script {!r}'.format(script))
|
||||
return False
|
||||
|
||||
def _is_executable(self, path):
|
||||
|
@ -667,21 +678,17 @@ class ExternalProgram:
|
|||
return [trial_ext]
|
||||
return False
|
||||
|
||||
def _search(self, name, search_dir):
|
||||
def _search_windows_special_cases(self, name, command):
|
||||
'''
|
||||
Search in the specified dir for the specified executable by name
|
||||
and if not found search in PATH
|
||||
Lots of weird Windows quirks:
|
||||
1. PATH search for @name returns files with extensions from PATHEXT,
|
||||
but only self.windows_exts are executable without an interpreter.
|
||||
2. @name might be an absolute path to an executable, but without the
|
||||
extension. This works inside MinGW so people use it a lot.
|
||||
3. The script is specified without an extension, in which case we have
|
||||
to manually search in PATH.
|
||||
4. More special-casing for the shebang inside the script.
|
||||
'''
|
||||
commands = self._search_dir(name, search_dir)
|
||||
if commands:
|
||||
return commands
|
||||
# Do a standard search in PATH
|
||||
command = shutil.which(name)
|
||||
if not mesonlib.is_windows():
|
||||
# On UNIX-like platforms, shutil.which() is enough to find
|
||||
# all executables whether in PATH or with an absolute path
|
||||
return [command]
|
||||
# HERE BEGINS THE TERROR OF WINDOWS
|
||||
if command:
|
||||
# On Windows, even if the PATH search returned a full path, we can't be
|
||||
# sure that it can be run directly if it's not a native executable.
|
||||
|
@ -695,25 +702,41 @@ class ExternalProgram:
|
|||
commands = self._shebang_to_cmd(command)
|
||||
if commands:
|
||||
return commands
|
||||
else:
|
||||
# Maybe the name is an absolute path to a native Windows
|
||||
# executable, but without the extension. This is technically wrong,
|
||||
# but many people do it because it works in the MinGW shell.
|
||||
if os.path.isabs(name):
|
||||
for ext in self.windows_exts:
|
||||
command = '{}.{}'.format(name, ext)
|
||||
if os.path.exists(command):
|
||||
return [command]
|
||||
# On Windows, interpreted scripts must have an extension otherwise they
|
||||
# cannot be found by a standard PATH search. So we do a custom search
|
||||
# where we manually search for a script with a shebang in PATH.
|
||||
search_dirs = os.environ.get('PATH', '').split(';')
|
||||
for search_dir in search_dirs:
|
||||
commands = self._search_dir(name, search_dir)
|
||||
if commands:
|
||||
return commands
|
||||
return [None]
|
||||
# Maybe the name is an absolute path to a native Windows
|
||||
# executable, but without the extension. This is technically wrong,
|
||||
# but many people do it because it works in the MinGW shell.
|
||||
if os.path.isabs(name):
|
||||
for ext in self.windows_exts:
|
||||
command = '{}.{}'.format(name, ext)
|
||||
if os.path.exists(command):
|
||||
return [command]
|
||||
# On Windows, interpreted scripts must have an extension otherwise they
|
||||
# cannot be found by a standard PATH search. So we do a custom search
|
||||
# where we manually search for a script with a shebang in PATH.
|
||||
search_dirs = os.environ.get('PATH', '').split(';')
|
||||
for search_dir in search_dirs:
|
||||
commands = self._search_dir(name, search_dir)
|
||||
if commands:
|
||||
return commands
|
||||
return [None]
|
||||
|
||||
def _search(self, name, search_dir):
|
||||
'''
|
||||
Search in the specified dir for the specified executable by name
|
||||
and if not found search in PATH
|
||||
'''
|
||||
commands = self._search_dir(name, search_dir)
|
||||
if commands:
|
||||
return commands
|
||||
# Do a standard search in PATH
|
||||
command = shutil.which(name)
|
||||
if mesonlib.is_windows():
|
||||
return self._search_windows_special_cases(name, command)
|
||||
# On UNIX-like platforms, shutil.which() is enough to find
|
||||
# all executables whether in PATH or with an absolute path
|
||||
return [command]
|
||||
|
||||
def found(self):
|
||||
return self.command[0] is not None
|
||||
|
||||
|
|
|
@ -48,7 +48,7 @@ class VisualStudioLinker(StaticLinker):
|
|||
def build_rpath_args(self, build_dir, from_dir, rpath_paths, build_rpath, install_rpath):
|
||||
return []
|
||||
|
||||
def thread_link_flags(self):
|
||||
def thread_link_flags(self, env):
|
||||
return []
|
||||
|
||||
def get_option_link_args(self, options):
|
||||
|
@ -100,7 +100,7 @@ class ArLinker(StaticLinker):
|
|||
def get_always_args(self):
|
||||
return []
|
||||
|
||||
def thread_link_flags(self):
|
||||
def thread_link_flags(self, env):
|
||||
return []
|
||||
|
||||
def get_option_link_args(self, options):
|
||||
|
|
|
@ -292,6 +292,18 @@ def for_darwin(is_cross, env):
|
|||
return env.cross_info.config['host_machine']['system'] == 'darwin'
|
||||
return False
|
||||
|
||||
def for_haiku(is_cross, env):
|
||||
"""
|
||||
Host machine is Haiku?
|
||||
|
||||
Note: 'host' is the machine on which compiled binaries will run
|
||||
"""
|
||||
if not is_cross:
|
||||
return is_haiku()
|
||||
elif env.cross_info.has_host():
|
||||
return env.cross_info.config['host_machine']['system'] == 'haiku'
|
||||
return False
|
||||
|
||||
def exe_exists(arglist):
|
||||
try:
|
||||
p = subprocess.Popen(arglist, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||
|
|
|
@ -16,6 +16,9 @@ foreach lang : ['c', 'cpp']
|
|||
elif host_system == 'cygwin'
|
||||
d = cc.get_define('__CYGWIN__')
|
||||
assert(d == '1', '__CYGWIN__ value is @0@ instead of 1'.format(d))
|
||||
elif host_system == 'haiku'
|
||||
d = cc.get_define('__HAIKU__')
|
||||
assert(d == '1', '__HAIKU__ value is @0@ instead of 1'.format(d))
|
||||
else
|
||||
error('Please report a bug and help us improve support for this platform')
|
||||
endif
|
||||
|
|
Loading…
Reference in New Issue