summaryrefslogtreecommitdiff
path: root/build/templates.mozbuild
blob: 4bf63cfc532ad750b7480395987b05032cee1d24 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

@template
def Binary():
    '''Generic template for target binaries. Meant to be used by other
    templates.'''

    if CONFIG['MOZ_LIBSTDCXX_TARGET_VERSION']:
        USE_LIBS += ['stdc++compat']

    # Ideally, we'd support not adding this to the LIB_IS_C_ONLY case,
    # but that variable is actually only set in db/sqlite/src, which
    # doesn't build a shared library on the relevant platforms anyways.
    # Eventually, though, we should detect LIB_IS_C_ONLY based on the
    # associated SOURCES (and there might actually be places where we
    # haven't set it but should have).
    if CONFIG['STLPORT_LIBS']:
        OS_LIBS += [CONFIG['STLPORT_LIBS']]


@template
def Program(name):
    '''Template for program executables.'''
    PROGRAM = name

    Binary()


@template
def SimplePrograms(names, ext='.cpp'):
    '''Template for simple program executables.

    Those have a single source with the same base name as the executable.
    '''
    SIMPLE_PROGRAMS += names
    SOURCES += ['%s%s' % (name, ext) for name in names]

    Binary()


@template
def CppUnitTests(names, ext='.cpp'):
    '''Template for C++ unit tests.

    Those have a single source with the same base name as the executable.
    '''
    CPP_UNIT_TESTS += names
    SOURCES += ['%s%s' % (name, ext) for name in names]

    Binary()


@template
def Library(name):
    '''Template for libraries.'''
    LIBRARY_NAME = name


@template
def SharedLibrary(name):
    '''Template for shared libraries.'''
    Library(name)

    FORCE_SHARED_LIB = True

    Binary()


@template
def Framework(name):
    '''Template for OSX Frameworks.'''
    SharedLibrary(name)

    IS_FRAMEWORK = True


@template
def HostStdCppCompat():
    '''Template for libstdc++ compatibility for host binaries.'''

    if CONFIG['MOZ_LIBSTDCXX_HOST_VERSION']:
        HOST_USE_LIBS += ['host_stdc++compat']


@template
def HostProgram(name, c_only=False):
    '''Template for build tools executables.'''
    HOST_PROGRAM = name

    # With context-based templates, this won't be needed anymore, and will
    # work better than relying on the caller setting it, but at the moment,
    # this is the best we have. And it doesn't matter /that/ much, so there's
    # really only one place using this, where it does matter to avoid the
    # extra dependency (because it creates a circular one).
    if not c_only:
        HostStdCppCompat()


@template
def HostSimplePrograms(names, ext='.cpp'):
    '''Template for simple build tools executables.

    Those have a single source with the same base name as the executable.
    '''
    HOST_SIMPLE_PROGRAMS += names
    HOST_SOURCES += ['%s%s' % (name.replace('host_', ''), ext)
        for name in names]

    HostStdCppCompat()


@template
def HostLibrary(name):
    '''Template for build tools libraries.'''
    HOST_LIBRARY_NAME = name


include('gecko_templates.mozbuild')
include('test_templates.mozbuild')