summaryrefslogtreecommitdiffstats
path: root/config/external/ffi
diff options
context:
space:
mode:
Diffstat (limited to 'config/external/ffi')
-rw-r--r--config/external/ffi/Makefile.in12
-rw-r--r--config/external/ffi/moz.build107
-rw-r--r--config/external/ffi/subst_header.py25
3 files changed, 144 insertions, 0 deletions
diff --git a/config/external/ffi/Makefile.in b/config/external/ffi/Makefile.in
new file mode 100644
index 000000000..717b5d829
--- /dev/null
+++ b/config/external/ffi/Makefile.in
@@ -0,0 +1,12 @@
+# -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
+# vim: set filetype=python:
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+# libffi's assembly files want to be pre-processed, so we still use the libffi
+# wrapper to combine the preprocessor and assembler stages.
+# Bug 1299959 is on file to find a better way to do this in moz.build.
+ifdef _MSC_VER
+AS = $(topsrcdir)/js/src/ctypes/libffi/msvcc.sh
+endif
diff --git a/config/external/ffi/moz.build b/config/external/ffi/moz.build
new file mode 100644
index 000000000..e9ef07de3
--- /dev/null
+++ b/config/external/ffi/moz.build
@@ -0,0 +1,107 @@
+# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
+# vim: set filetype=python:
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+FINAL_LIBRARY = 'js'
+
+if CONFIG['MOZ_SYSTEM_FFI']:
+ OS_LIBS += CONFIG['MOZ_FFI_LIBS']
+else:
+ ALLOW_COMPILER_WARNINGS = True
+ NO_VISIBILITY_FLAGS = True
+
+ CONFIGURE_DEFINE_FILES += [
+ '../../../js/src/ctypes/libffi/fficonfig.h',
+ ]
+ GENERATED_FILES += [
+ '../../../js/src/ctypes/libffi/include/ffi.h',
+ ]
+ ffi_h = GENERATED_FILES['../../../js/src/ctypes/libffi/include/ffi.h']
+ ffi_h.script = 'subst_header.py'
+ ffi_h.inputs = ['../../../js/src/ctypes/libffi/include/ffi.h.in']
+
+ LOCAL_INCLUDES += [
+ '!/js/src/ctypes/libffi',
+ '!/js/src/ctypes/libffi/include',
+ '/js/src/ctypes/libffi/include',
+ '/js/src/ctypes/libffi/src/%s' % CONFIG['FFI_TARGET_DIR'],
+ ]
+
+ DEFINES.update({
+ 'TARGET': CONFIG['FFI_TARGET'],
+ CONFIG['FFI_TARGET']: True,
+ 'FFI_NO_RAW_API': True,
+ 'HAVE_AS_ASCII_PSEUDO_OP': True,
+ 'HAVE_AS_STRING_PSEUDO_OP': True,
+ 'HAVE_AS_X86_64_UNWIND_SECTION_TYPE': True,
+ })
+
+ if CONFIG['MOZ_DEBUG']:
+ DEFINES['FFI_DEBUG'] = True
+ if not CONFIG['MOZ_NO_DEBUG_RTL']:
+ DEFINES['USE_DEBUG_RTL'] = True
+ SOURCES += [
+ '/js/src/ctypes/libffi/src/debug.c',
+ ]
+
+ if CONFIG['OS_TARGET'] not in ('WINNT', 'Darwin'):
+ DEFINES['HAVE_HIDDEN_VISIBILITY_ATTRIBUTE'] = True
+
+ if CONFIG['INTEL_ARCHITECTURE']:
+ DEFINES['HAVE_AS_X86_PCREL'] = True
+
+ # Don't bother setting EH_FRAME_FLAGS on Windows.
+ # Quoted defines confuse msvcc.sh, and the value isn't used there.
+ if CONFIG['OS_TARGET'] != 'WINNT':
+ if CONFIG['FFI_TARGET'] == 'ARM':
+ DEFINES['EH_FRAME_FLAGS'] = '"aw"'
+ else:
+ DEFINES['EH_FRAME_FLAGS'] = '"a"'
+
+ if CONFIG['CLANG_CL']:
+ ASFLAGS += ['-clang-cl']
+
+ # Common source files.
+ SOURCES += [
+ '/js/src/ctypes/libffi/src/closures.c',
+ '/js/src/ctypes/libffi/src/java_raw_api.c',
+ '/js/src/ctypes/libffi/src/prep_cif.c',
+ '/js/src/ctypes/libffi/src/raw_api.c',
+ '/js/src/ctypes/libffi/src/types.c',
+ ]
+
+ # Per-platform sources and flags.
+ ffi_srcs = ()
+ if CONFIG['FFI_TARGET'] == 'ARM':
+ ffi_srcs = ('sysv.S', 'ffi.c')
+ if CONFIG['CLANG_CXX']:
+ ASFLAGS += ['-no-integrated-as']
+ elif CONFIG['FFI_TARGET'] == 'AARCH64':
+ ffi_srcs = ('sysv.S', 'ffi.c')
+ elif CONFIG['FFI_TARGET'] == 'X86':
+ ffi_srcs = ('ffi.c', 'sysv.S', 'win32.S')
+ elif CONFIG['FFI_TARGET'] == 'X86_64':
+ ffi_srcs = ('ffi64.c', 'unix64.S', 'ffi.c', 'sysv.S')
+ elif CONFIG['FFI_TARGET'] == 'X86_WIN32':
+ # MinGW Build for 32 bit
+ if CONFIG['CC_TYPE'] == 'gcc':
+ DEFINES['SYMBOL_UNDERSCORE'] = True
+ ffi_srcs = ('ffi.c', 'win32.S')
+ elif CONFIG['FFI_TARGET'] == 'X86_WIN64':
+ ffi_srcs = ('ffi.c', 'win64.S')
+ ASFLAGS += ['-m64']
+ elif CONFIG['FFI_TARGET'] == 'X86_DARWIN':
+ DEFINES['FFI_MMAP_EXEC_WRIT'] = True
+ if CONFIG['OS_TEST'] != 'x86_64':
+ ffi_srcs = ('ffi.c', 'darwin.S', 'ffi64.c', 'darwin64.S',
+ 'win32.S')
+ DEFINES['SYMBOL_UNDERSCORE'] = True
+ else:
+ ffi_srcs = ('ffi.c', 'darwin.S', 'ffi64.c', 'darwin64.S')
+
+ SOURCES += [
+ '/js/src/ctypes/libffi/src/%s/%s' % (CONFIG['FFI_TARGET_DIR'], s)
+ for s in sorted(ffi_srcs)
+ ]
diff --git a/config/external/ffi/subst_header.py b/config/external/ffi/subst_header.py
new file mode 100644
index 000000000..a138f9020
--- /dev/null
+++ b/config/external/ffi/subst_header.py
@@ -0,0 +1,25 @@
+# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
+# vim: set filetype=python:
+# This Souce Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distibuted with this
+# file, You can obtain one at http://mozilla.og/MPL/2.0/.
+
+import sys
+import buildconfig
+from mozbuild.preprocessor import Preprocessor
+
+def main(output, input_file):
+ pp = Preprocessor()
+ pp.context.update({
+ 'FFI_EXEC_TRAMPOLINE_TABLE': '0',
+ 'HAVE_LONG_DOUBLE': '0',
+ 'TARGET': buildconfig.substs['FFI_TARGET'],
+ 'VERSION': '',
+ })
+ pp.do_filter('substitution')
+ pp.setMarker(None)
+ pp.out = output
+ pp.do_include(input_file)
+
+if __name__ == '__main__':
+ main(*sys.agv[1:])