Move memfd existence test to glfw.py

This commit is contained in:
Kovid Goyal
2018-10-03 11:02:51 +05:30
parent 7750a461aa
commit 98864091ff
2 changed files with 10 additions and 10 deletions

View File

@@ -22,7 +22,7 @@ def wayland_protocol_file_name(base, ext='c'):
return 'wayland-{}-client-protocol.{}'.format(base, ext) return 'wayland-{}-client-protocol.{}'.format(base, ext)
def init_env(env, pkg_config, at_least_version, module='x11'): def init_env(env, pkg_config, at_least_version, test_compile, module='x11'):
ans = env.copy() ans = env.copy()
ans.cflags = [ ans.cflags = [
x for x in ans.cflags x for x in ans.cflags
@@ -76,6 +76,14 @@ def init_env(env, pkg_config, at_least_version, module='x11'):
for dep in 'wayland-egl wayland-client wayland-cursor xkbcommon dbus-1'.split(): for dep in 'wayland-egl wayland-client wayland-cursor xkbcommon dbus-1'.split():
ans.cflags.extend(pkg_config(dep, '--cflags-only-I')) ans.cflags.extend(pkg_config(dep, '--cflags-only-I'))
ans.ldpaths.extend(pkg_config(dep, '--libs')) ans.ldpaths.extend(pkg_config(dep, '--libs'))
has_memfd_create = test_compile(env.cc, '-Werror', src='''#define _GNU_SOURCE
#include <unistd.h>
#include <sys/syscall.h>
int main(void) {
return syscall(__NR_memfd_create, "test", 0);
}''')
if has_memfd_create:
ans.cppflags.append('-DHAS_MEMFD_CREATE')
return ans return ans

View File

@@ -169,12 +169,6 @@ def init_env(
cc, ccver = cc_version() cc, ccver = cc_version()
print('CC:', cc, ccver) print('CC:', cc, ccver)
stack_protector = first_successful_compile(cc, '-fstack-protector-strong', '-fstack-protector') stack_protector = first_successful_compile(cc, '-fstack-protector-strong', '-fstack-protector')
has_memfd_create = test_compile(cc, '-Werror', src='''#define _GNU_SOURCE
#include <unistd.h>
#include <sys/syscall.h>
int main(void) {
return syscall(__NR_memfd_create, "test", 0);
}''')
missing_braces = '' missing_braces = ''
if ccver < (5, 2) and cc == 'gcc': if ccver < (5, 2) and cc == 'gcc':
missing_braces = '-Wno-missing-braces' missing_braces = '-Wno-missing-braces'
@@ -224,8 +218,6 @@ int main(void) {
cflags.append('-g3') cflags.append('-g3')
ldflags.append('-lprofiler') ldflags.append('-lprofiler')
ldpaths = [] ldpaths = []
if has_memfd_create:
cppflags.append('-DHAS_MEMFD_CREATE')
return Env(cc, cppflags, cflags, ldflags, ldpaths=ldpaths) return Env(cc, cppflags, cflags, ldflags, ldpaths=ldpaths)
@@ -429,7 +421,7 @@ def compile_glfw(incremental, compilation_database, all_keys):
modules = 'cocoa' if is_macos else 'x11 wayland' modules = 'cocoa' if is_macos else 'x11 wayland'
for module in modules.split(): for module in modules.split():
try: try:
genv = glfw.init_env(env, pkg_config, at_least_version, module) genv = glfw.init_env(env, pkg_config, at_least_version, test_compile, module)
except SystemExit as err: except SystemExit as err:
if module != 'wayland': if module != 'wayland':
raise raise