ffi.configure 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. # -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
  2. # This Source Code Form is subject to the terms of the Mozilla Public
  3. # License, v. 2.0. If a copy of the MPL was not distributed with this
  4. # file, You can obtain one at http://mozilla.org/MPL/2.0/.
  5. @depends(target)
  6. def force_system_ffi(target):
  7. # Pre-emptively move to system ffi for non-tier one platforms.
  8. if target.cpu not in ('x86', 'x86_64', 'arm', 'aarch64'):
  9. return True
  10. imply_option('--with-system-ffi', force_system_ffi, "target")
  11. js_option('--with-system-ffi',
  12. help='Use system libffi (located with pkgconfig)')
  13. use_system_ffi = depends_if('--with-system-ffi')(lambda _: True)
  14. system_ffi = pkg_check_modules('MOZ_FFI', 'libffi > 3.0.9',
  15. when=use_system_ffi)
  16. building_ffi = depends(system_ffi)(lambda v: v is None)
  17. set_config('MOZ_SYSTEM_FFI', depends_if(system_ffi)(lambda _: True))
  18. add_old_configure_assignment('MOZ_SYSTEM_FFI', depends_if(system_ffi)(lambda _: True))
  19. # Target selection, based on ffi/configure.ac.
  20. @depends_when(target, when=building_ffi)
  21. def ffi_target(target):
  22. if target.cpu not in ('x86', 'x86_64', 'arm', 'aarch64'):
  23. die('Building libffi from the tree is not supported on this platform. '
  24. 'Use --with-system-ffi instead.')
  25. if target.os == 'WINNT':
  26. target_dir = 'x86'
  27. if target.cpu == 'x86_64':
  28. target_name = 'X86_WIN64'
  29. else:
  30. target_name = 'X86_WIN32'
  31. elif target.os == 'OSX':
  32. target_dir = 'x86'
  33. target_name = 'X86_DARWIN'
  34. elif target.cpu == 'arm':
  35. target_dir = 'arm'
  36. target_name = 'ARM'
  37. elif target.cpu == 'aarch64':
  38. target_dir = 'aarch64'
  39. target_name = 'AARCH64'
  40. else:
  41. target_dir = 'x86'
  42. target_name = target.cpu.upper()
  43. return namespace(
  44. name=target_name,
  45. dir=target_dir
  46. )
  47. set_config('FFI_TARGET', delayed_getattr(ffi_target, 'name'))
  48. set_config('FFI_TARGET_DIR', delayed_getattr(ffi_target, 'dir'))