summaryrefslogtreecommitdiffstats
path: root/config/moz.build
blob: 7651bcd111ea6943dce0d3377dc8a81d9d01ea65 (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
# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
# vim: set filetype=python:
# 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/.

with Files("**"):
    BUG_COMPONENT = ("Firefox Build System", "General")

with Files("mozunit/**"):
    BUG_COMPONENT = ("Testing", "Python Test")

DIST_INSTALL = False
# For sanity's sake, we compile nsinstall without the wrapped system
# headers, so that we can use it to set up the wrapped system headers.
NoVisibilityFlags()

CONFIGURE_SUBST_FILES += [
    "tests/src-simple/Makefile",
]

if CONFIG["HOST_OS_ARCH"] != "WINNT":
    HOST_SOURCES += [
        "nsinstall.c",
        "pathsub.c",
    ]
    HostProgram("nsinstall_real")

PYTHON_UNITTEST_MANIFESTS += [
    "tests/python.ini",
]

if CONFIG["CC_TYPE"] in ("clang", "gcc") and CONFIG["MOZ_OPTIMIZE"]:
    CFLAGS += ["-O3"]

HOST_DEFINES["UNICODE"] = True
HOST_DEFINES["_UNICODE"] = True

include("stl-headers.mozbuild")
if CONFIG["WRAP_STL_INCLUDES"]:
    stl_compiler = None
    if CONFIG["OS_TARGET"] == "WINNT":
        stl_compiler = "msvc"
    else:
        stl_compiler = "gcc"

    if stl_compiler:
        # Note that the 'stl_wrappers' folder is known to the build system as
        # containing generated files; if this is changed here then the code in
        # GeneratedFile.__init__ in python/mozbuild/mozbuild/frontend/data.py
        # might need to be updated accordingly as well.
        template_file = SRCDIR + "/%s-stl-wrapper.template.h" % stl_compiler
        output_dir = "/dist/stl_wrappers"
        # We have to use a sentinel file as the first file because the
        # file_generate action will create it for us, but we want to create all
        # the files in gen_wrappers()
        outputs = tuple(
            ["stl.sentinel"] + ["%s/%s" % (output_dir, h) for h in stl_headers]
        )
        GeneratedFile(
            *outputs,
            script="make-stl-wrappers.py",
            entry_point="gen_wrappers",
            flags=[TOPOBJDIR + output_dir, stl_compiler, template_file] + stl_headers
        )

    # Wrap <windows.h> to make it easier to use correctly
    # NOTE: If we aren't wrapping STL includes, we're building part of the browser
    # which won't need this wrapper, such as L10N. Just don't try to generate the
    # wrapper in that case.
    if CONFIG["OS_TARGET"] == "WINNT":
        GeneratedFile(
            "/dist/stl_wrappers/windows.h",
            script="make-windows-h-wrapper.py",
            entry_point="generate",
            inputs=[
                "windows-h-constant.decls.h",
                "windows-h-unicode.decls.h",
                "windows-h-wrapper.template.h",
            ],
            flags=[stl_compiler],
        )

if CONFIG["WRAP_SYSTEM_INCLUDES"]:
    include("system-headers.mozbuild")
    output_dir = "/dist/system_wrappers"
    outputs = tuple(
        ["system-header.sentinel"]
        + ["%s/%s" % (output_dir, h) for h in stl_headers + system_headers]
    )
    GeneratedFile(
        *outputs,
        script="make-system-wrappers.py",
        entry_point="gen_wrappers",
        flags=[TOPOBJDIR + output_dir] + stl_headers + system_headers
    )

if CONFIG["COMPILE_ENVIRONMENT"] and CONFIG["CBINDGEN"]:
    GeneratedFile(
        "cbindgen-metadata.json",
        script="/build/RunCbindgen.py",
        entry_point="generate_metadata",
        inputs=["!/.cargo/config"],
    )