templates.mozbuild 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  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. @template
  6. def Binary():
  7. '''Generic template for target binaries. Meant to be used by other
  8. templates.'''
  9. if CONFIG['MOZ_LIBSTDCXX_TARGET_VERSION']:
  10. USE_LIBS += ['stdc++compat']
  11. # Ideally, we'd support not adding this to the LIB_IS_C_ONLY case,
  12. # but that variable is actually only set in db/sqlite/src, which
  13. # doesn't build a shared library on the relevant platforms anyways.
  14. # Eventually, though, we should detect LIB_IS_C_ONLY based on the
  15. # associated SOURCES (and there might actually be places where we
  16. # haven't set it but should have).
  17. if CONFIG['STLPORT_LIBS']:
  18. OS_LIBS += [CONFIG['STLPORT_LIBS']]
  19. @template
  20. def Program(name):
  21. '''Template for program executables.'''
  22. PROGRAM = name
  23. Binary()
  24. @template
  25. def SimplePrograms(names, ext='.cpp'):
  26. '''Template for simple program executables.
  27. Those have a single source with the same base name as the executable.
  28. '''
  29. SIMPLE_PROGRAMS += names
  30. SOURCES += ['%s%s' % (name, ext) for name in names]
  31. Binary()
  32. @template
  33. def CppUnitTests(names, ext='.cpp'):
  34. '''Template for C++ unit tests.
  35. Those have a single source with the same base name as the executable.
  36. '''
  37. CPP_UNIT_TESTS += names
  38. SOURCES += ['%s%s' % (name, ext) for name in names]
  39. Binary()
  40. @template
  41. def Library(name):
  42. '''Template for libraries.'''
  43. LIBRARY_NAME = name
  44. @template
  45. def SharedLibrary(name):
  46. '''Template for shared libraries.'''
  47. Library(name)
  48. FORCE_SHARED_LIB = True
  49. Binary()
  50. @template
  51. def Framework(name):
  52. '''Template for OSX Frameworks.'''
  53. SharedLibrary(name)
  54. IS_FRAMEWORK = True
  55. @template
  56. def HostStdCppCompat():
  57. '''Template for libstdc++ compatibility for host binaries.'''
  58. if CONFIG['MOZ_LIBSTDCXX_HOST_VERSION']:
  59. HOST_USE_LIBS += ['host_stdc++compat']
  60. @template
  61. def HostProgram(name, c_only=False):
  62. '''Template for build tools executables.'''
  63. HOST_PROGRAM = name
  64. # With context-based templates, this won't be needed anymore, and will
  65. # work better than relying on the caller setting it, but at the moment,
  66. # this is the best we have. And it doesn't matter /that/ much, so there's
  67. # really only one place using this, where it does matter to avoid the
  68. # extra dependency (because it creates a circular one).
  69. if not c_only:
  70. HostStdCppCompat()
  71. @template
  72. def HostSimplePrograms(names, ext='.cpp'):
  73. '''Template for simple build tools executables.
  74. Those have a single source with the same base name as the executable.
  75. '''
  76. HOST_SIMPLE_PROGRAMS += names
  77. HOST_SOURCES += ['%s%s' % (name.replace('host_', ''), ext)
  78. for name in names]
  79. HostStdCppCompat()
  80. @template
  81. def HostLibrary(name):
  82. '''Template for build tools libraries.'''
  83. HOST_LIBRARY_NAME = name
  84. include('gecko_templates.mozbuild')
  85. include('test_templates.mozbuild')