mirror of
https://github.com/FWGS/xash3d-fwgs
synced 2024-12-22 08:52:32 +01:00
Alibek Omarov
3d60770b84
On Linux, it uses memfd_create syscall that can be found on Linux 3.17 and higher. By default memfds are executable, so we set MFD_NOEXEC_SEAL flag to prevent execution at creation time.
52 lines
1.6 KiB
Python
52 lines
1.6 KiB
Python
#!/usr/bin/env python
|
|
|
|
MEMFD_CREATE_TEST = '''#define _GNU_SOURCE
|
|
#include <sys/mman.h>
|
|
int main(int argc, char **argv) { return memfd_create(argv[0], 0); }'''
|
|
|
|
def options(opt):
|
|
pass
|
|
|
|
def configure(conf):
|
|
if conf.env.COMPILER_CXX != 'msvc':
|
|
conf.env.append_unique('CXXFLAGS', ['-fno-exceptions'])
|
|
if conf.env.DEST_OS == 'android':
|
|
conf.check_cc(lib='android')
|
|
elif conf.env.cxxshlib_PATTERN.startswith('lib'): # remove lib prefix for other systems than Android
|
|
conf.env.cxxshlib_PATTERN = conf.env.cxxshlib_PATTERN[3:]
|
|
|
|
if conf.check_cc(fragment=MEMFD_CREATE_TEST, msg='Checking for memfd_create', mandatory=False):
|
|
conf.define('HAVE_MEMFD_CREATE', 1)
|
|
|
|
def build(bld):
|
|
bld(name = 'filesystem_includes', export_includes = '.')
|
|
|
|
libs = [ 'filesystem_includes', 'sdk_includes', 'werror' ]
|
|
|
|
# on PSVita do not link any libraries that are already in the main executable, but add the includes target
|
|
if bld.env.DEST_OS != 'psvita':
|
|
libs += [ 'public', 'ANDROID' ]
|
|
|
|
bld.shlib(target = 'filesystem_stdio',
|
|
features = 'seq',
|
|
source = bld.path.ant_glob(['*.c', '*.cpp']),
|
|
use = libs,
|
|
install_path = bld.env.LIBDIR)
|
|
|
|
if bld.env.TESTS:
|
|
# build in same module, so dynamic linking will work
|
|
# for now (until we turn libpublic to shared module lol)
|
|
tests = {
|
|
'interface' : 'tests/interface.cpp',
|
|
'caseinsensitive' : 'tests/caseinsensitive.c',
|
|
'no-init': 'tests/no-init.c'
|
|
}
|
|
|
|
for i in tests:
|
|
bld.program(features = 'test seq',
|
|
source = tests[i],
|
|
target = 'test_%s' % i,
|
|
use = libs + ['DL'],
|
|
rpath = bld.env.DEFAULT_RPATH,
|
|
install_path = None)
|