1 # -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
2 # vim: set filetype=python:
3 # This Source Code Form is subject to the terms of the Mozilla Public
4 # License, v. 2.0. If a copy of the MPL was not distributed with this
5 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 def force_system_ffi(target):
10 # Pre-emptively move to system ffi for non-tier one platforms.
11 if target.cpu not in ("x86", "x86_64", "arm", "aarch64"):
15 imply_option("--with-system-ffi", force_system_ffi, "target")
19 help="Use system libffi (located with pkgconfig)",
23 use_system_ffi = depends_if("--with-system-ffi", when=use_pkg_config)(lambda _: True)
25 system_ffi = pkg_check_modules("MOZ_FFI", "libffi > 3.0.9", when=use_system_ffi)
27 building_ffi = depends(system_ffi)(lambda v: v is None)
29 set_config("MOZ_SYSTEM_FFI", depends_if(system_ffi)(lambda _: True))
32 # Target selection, based on ffi/configure.ac.
33 @depends(target, when=building_ffi)
34 def ffi_target(target):
35 if target.cpu not in ("x86", "x86_64", "arm", "aarch64"):
37 "Building libffi from the tree is not supported on this platform. "
38 "Use --with-system-ffi instead."
41 if target.cpu == "x86_64":
45 }.get(target.kernel, "X86_64")
47 elif target.cpu == "x86":
51 "Darwin": "X86_DARWIN",
52 "FreeBSD": "X86_FREEBSD",
53 "OpenBSD": "X86_FREEBSD",
54 }.get(target.kernel, "X86")
56 elif target.cpu == "aarch64":
57 target_dir = "aarch64"
60 }.get(target.kernel, "AARCH64")
62 elif target.cpu == "arm":
66 return namespace(name=target_name, dir=target_dir)
69 set_config("FFI_TARGET", ffi_target.name)
70 set_config("FFI_TARGET_DIR", ffi_target.dir)