Update configs. IGNORE BROKEN CHANGESETS CLOSED TREE NO BUG a=release ba=release
[gecko.git] / js / ffi.configure
bloba8a7ca1c7b9bc5e8769ef35dc23e573c9c4512dc
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/.
8 @depends(target)
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"):
12         return True
15 imply_option("--with-system-ffi", force_system_ffi, "target")
17 system_lib_option(
18     "--with-system-ffi", help="Use system libffi (located with pkgconfig)"
21 use_system_ffi = depends_if("--with-system-ffi")(lambda _: True)
23 system_ffi = pkg_check_modules("MOZ_FFI", "libffi > 3.0.9", when=use_system_ffi)
25 building_ffi = depends(system_ffi)(lambda v: v is None)
27 set_config("MOZ_SYSTEM_FFI", depends_if(system_ffi)(lambda _: True))
30 # Target selection, based on ffi/configure.ac.
31 @depends(target, when=building_ffi)
32 def ffi_target(target):
33     if target.cpu not in ("x86", "x86_64", "arm", "aarch64"):
34         die(
35             "Building libffi from the tree is not supported on this platform. "
36             "Use --with-system-ffi instead."
37         )
39     if target.cpu == "x86_64":
40         target_dir = "x86"
41         target_name = {
42             "WINNT": "X86_WIN64",
43         }.get(target.kernel, "X86_64")
45     elif target.cpu == "x86":
46         target_dir = "x86"
47         target_name = {
48             "WINNT": "X86_WIN32",
49             "Darwin": "X86_DARWIN",
50             "FreeBSD": "X86_FREEBSD",
51             "OpenBSD": "X86_FREEBSD",
52         }.get(target.kernel, "X86")
54     elif target.cpu == "aarch64":
55         target_dir = "aarch64"
56         target_name = {
57             "WINNT": "ARM_WIN64",
58         }.get(target.kernel, "AARCH64")
60     elif target.cpu == "arm":
61         target_dir = "arm"
62         target_name = "ARM"
64     return namespace(name=target_name, dir=target_dir)
67 set_config("FFI_TARGET", ffi_target.name)
68 set_config("FFI_TARGET_DIR", ffi_target.dir)