moz.configure 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262
  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. # /!\ Use js_option() instead of option() in this file. /!\
  6. # =========================================================
  7. @depends(build_project, '--help')
  8. def building_js(build_project, help):
  9. return build_project == 'js'
  10. # Exception to the rule above: JS_STANDALONE is a special option that doesn't
  11. # want the js_option treatment. When we're done merging js/src/configure and
  12. # top-level configure, it can go away, although the JS_STANDALONE config
  13. # will still need to be set depending on building_js above.
  14. option(env='JS_STANDALONE', default=building_js,
  15. help='Reserved for internal use')
  16. @depends('JS_STANDALONE')
  17. def js_standalone(value):
  18. if value:
  19. return True
  20. set_config('JS_STANDALONE', js_standalone)
  21. add_old_configure_assignment('JS_STANDALONE', js_standalone)
  22. js_option('--disable-js-shell', default=building_js,
  23. help='Do not build the JS shell')
  24. @depends('--disable-js-shell')
  25. def js_disable_shell(value):
  26. if not value:
  27. return True
  28. set_config('JS_DISABLE_SHELL', js_disable_shell)
  29. # SpiderMonkey as a shared library, and how its symbols are exported
  30. # ==================================================================
  31. js_option('--disable-shared-js', default=building_js,
  32. help='Do not create a shared library')
  33. js_option('--disable-export-js', default=building_js,
  34. help='Do not mark JS symbols as DLL exported/visible')
  35. @depends('--disable-shared-js', '--disable-export-js')
  36. def shared_js(shared_js, export_js):
  37. if shared_js:
  38. if not export_js:
  39. die('Must export JS symbols when building a shared library.')
  40. return True
  41. set_config('JS_SHARED_LIBRARY', shared_js)
  42. add_old_configure_assignment('JS_SHARED_LIBRARY', shared_js)
  43. @depends('--disable-shared-js', '--disable-export-js')
  44. def exportable_js_api(shared_js, export_js):
  45. if not shared_js and export_js:
  46. return True
  47. set_define('STATIC_EXPORTABLE_JS_API', exportable_js_api)
  48. @depends('--disable-shared-js', '--disable-export-js')
  49. def static_js_api(shared_js, export_js):
  50. if not shared_js and not export_js:
  51. return True
  52. set_define('STATIC_JS_API', static_js_api)
  53. @depends('--disable-shared-js')
  54. def static_js(value):
  55. if not value:
  56. return True
  57. set_define('MOZ_STATIC_JS', static_js)
  58. @deprecated_option(env='DISABLE_SHARED_JS', nargs='?')
  59. def disable_shared_js(value):
  60. # DISABLE_SHARED_JS=1 gets us an empty PositiveOptionValue
  61. if value and not len(value):
  62. suggestion = '--disable-shared-js'
  63. else:
  64. suggestion = '--enable-shared-js'
  65. die('Setting %s is deprecated, use %s instead.',
  66. value.format('DISABLE_SHARED_JS'), suggestion)
  67. @deprecated_option(env='DISABLE_EXPORT_JS', nargs='?')
  68. def disable_export_js(value):
  69. # DISABLE_EXPORT_JS=1 gets us an empty PositiveOptionValue
  70. if value and not len(value):
  71. suggestion = '--disable-export-js'
  72. else:
  73. suggestion = '--enable-export-js'
  74. die('Setting %s is deprecated, use %s instead.',
  75. value.format('DISABLE_EXPORT_JS'), suggestion)
  76. # Profiling
  77. # =======================================================
  78. js_option('--enable-instruments', env='MOZ_INSTRUMENTS',
  79. help='Enable instruments remote profiling')
  80. @depends('--enable-instruments', target)
  81. def instruments(value, target):
  82. if value and target.os != 'OSX':
  83. die('--enable-instruments cannot be used when targeting %s',
  84. target.os)
  85. if value:
  86. return True
  87. set_config('MOZ_INSTRUMENTS', instruments)
  88. set_define('MOZ_INSTRUMENTS', instruments)
  89. add_old_configure_assignment('MOZ_INSTRUMENTS', instruments)
  90. imply_option('--enable-profiling', instruments, reason='--enable-instruments')
  91. js_option('--enable-callgrind', env='MOZ_CALLGRIND',
  92. help='Enable callgrind profiling')
  93. @depends('--enable-callgrind')
  94. def callgrind(value):
  95. if value:
  96. return True
  97. set_define('MOZ_CALLGRIND', callgrind)
  98. imply_option('--enable-profiling', callgrind)
  99. js_option('--enable-profiling', env='MOZ_PROFILING',
  100. help='Set compile flags necessary for using sampling profilers '
  101. '(e.g. shark, perf)')
  102. @depends('--enable-profiling')
  103. def profiling(value):
  104. if value:
  105. return True
  106. add_old_configure_assignment('MOZ_PROFILING', profiling)
  107. @depends(profiling, target)
  108. def imply_vtune(value, target):
  109. if value and (target.kernel == 'WINNT' or (target.kernel == 'Linux' and
  110. target.os == 'GNU')):
  111. return True
  112. set_config('MOZ_PROFILING', profiling)
  113. set_define('MOZ_PROFILING', profiling)
  114. imply_option('--enable-vtune', imply_vtune, reason='--enable-profiling')
  115. js_option('--enable-vtune', env='MOZ_VTUNE', help='Enable vtune profiling')
  116. @depends('--enable-vtune')
  117. def vtune(value):
  118. if value:
  119. return True
  120. set_config('MOZ_VTUNE', vtune)
  121. set_define('MOZ_VTUNE', vtune)
  122. js_option('--enable-gc-trace', env='JS_GC_TRACE',
  123. help='Enable tracing of allocation and finalization')
  124. @depends('--enable-gc-trace')
  125. def gc_trace(value):
  126. if value:
  127. return True
  128. set_define('JS_GC_TRACE', gc_trace)
  129. js_option('--enable-perf', env='JS_ION_PERF',
  130. help='Enable Linux perf integration')
  131. @depends('--enable-perf')
  132. def ion_perf(value):
  133. if value:
  134. return True
  135. set_define('JS_ION_PERF', ion_perf)
  136. js_option('--enable-more-deterministic', env='JS_MORE_DETERMINISTIC',
  137. help='Enable changes that make the shell more deterministic')
  138. @depends('--enable-more-deterministic')
  139. def more_deterministic(value):
  140. if value:
  141. return True
  142. set_define('JS_MORE_DETERMINISTIC', more_deterministic)
  143. # CTypes
  144. # =======================================================
  145. @depends(building_js, '--help')
  146. def ctypes_default(building_js, _):
  147. return not building_js
  148. js_option('--enable-ctypes', help='Enable js-ctypes',
  149. default=ctypes_default)
  150. build_ctypes = depends_if('--enable-ctypes')(lambda _: True)
  151. set_config('BUILD_CTYPES', build_ctypes)
  152. set_define('BUILD_CTYPES', build_ctypes)
  153. add_old_configure_assignment('BUILD_CTYPES', build_ctypes)
  154. @depends(build_ctypes, building_js)
  155. def js_has_ctypes(ctypes, js):
  156. if ctypes and js:
  157. return True
  158. set_config('JS_HAS_CTYPES', js_has_ctypes)
  159. set_define('JS_HAS_CTYPES', js_has_ctypes)
  160. add_old_configure_assignment('JS_HAS_CTYPES', js_has_ctypes)
  161. @depends('--enable-ctypes', '--enable-compile-environment', '--help')
  162. def ctypes_and_compile_environment(ctypes, compile_environment, _):
  163. return ctypes and compile_environment
  164. include('ffi.configure', when=ctypes_and_compile_environment)
  165. # Support various fuzzing options
  166. # ==============================================================
  167. with only_when('--enable-compile-environment'):
  168. option('--enable-fuzzing', help='Enable fuzzing support')
  169. @depends('--enable-fuzzing')
  170. def enable_fuzzing(value):
  171. if value:
  172. return True
  173. @depends(enable_fuzzing,
  174. try_compile(body='__AFL_COMPILER;',
  175. check_msg='for AFL compiler',
  176. when='--enable-fuzzing'))
  177. def enable_libfuzzer(fuzzing, afl):
  178. if fuzzing and not afl:
  179. return True
  180. set_config('FUZZING', enable_fuzzing)
  181. set_define('FUZZING', enable_fuzzing)
  182. set_config('LIBFUZZER', enable_libfuzzer)
  183. set_define('LIBFUZZER', enable_libfuzzer)
  184. # Initial support for new regexp engine
  185. # ==================================================
  186. js_option('--enable-new-regexp', default=False, help='Enable new regexp engine')
  187. @depends('--enable-new-regexp')
  188. def enable_new_regexp(value):
  189. if value:
  190. return True
  191. set_config('JS_NEW_REGEXP', enable_new_regexp)
  192. set_define('JS_NEW_REGEXP', enable_new_regexp)