tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

moz.build (6729B)


      1 # -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
      2 # vim: set filetype=python:
      3 # This Source Code Form is subject to the terms of the Mozilla Public
      4 # License, v. 2.0. If a copy of the MPL was not distributed with this
      5 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
      6 
      7 with Files("**"):
      8     BUG_COMPONENT = ("Core", "Security: PSM")
      9 
     10 DIRS += [
     11     "/security/mls",
     12 ]
     13 
     14 with Files("generate*.py"):
     15     BUG_COMPONENT = ("Firefox Build System", "General")
     16 
     17 with Files("nss/**"):
     18     BUG_COMPONENT = ("NSS", "Libraries")
     19 
     20 with Files("nss.symbols"):
     21     BUG_COMPONENT = ("NSS", "Libraries")
     22 
     23 if CONFIG["MOZ_SYSTEM_NSS"]:
     24     Library("nss")
     25     OS_LIBS += CONFIG["NSS_LIBS"]
     26 
     27 include("/build/gyp_base.mozbuild")
     28 if CONFIG["MOZ_FOLD_LIBS"]:
     29     GeckoSharedLibrary("nss")
     30     # TODO: The library name can be changed when bug 845217 is fixed.
     31     SHARED_LIBRARY_NAME = "nss3"
     32 
     33     USE_LIBS += [
     34         "nspr4",
     35         "nss3_static",
     36         "nssutil",
     37         "plc4",
     38         "plds4",
     39         "smime3_static",
     40         "ssl",
     41     ]
     42 
     43     OS_LIBS += CONFIG["REALTIME_LIBS"]
     44 
     45     SYMBOLS_FILE = "nss.symbols"
     46     # This changes the default targets in the NSS build, among
     47     # other things.
     48     gyp_vars["moz_fold_libs"] = 1
     49     # Some things in NSS need to link against nssutil, which
     50     # gets folded, so this tells them what to link against.
     51     gyp_vars["moz_folded_library_name"] = "nss"
     52     # Force things in NSS that want to link against NSPR to link
     53     # against the folded library.
     54     gyp_vars["nspr_libs"] = "nss"
     55 elif not CONFIG["MOZ_SYSTEM_NSS"]:
     56     Library("nss")
     57     USE_LIBS += [
     58         "nss3",
     59         "nssutil3",
     60         "smime3",
     61         "sqlite",
     62         "ssl3",
     63     ]
     64     gyp_vars["nspr_libs"] = "nspr"
     65 else:
     66     gyp_vars["nspr_libs"] = "nspr"
     67     # Bug 1805371: We need a static copy of NSS for the tlsserver test
     68     # binaries even when building with system NSS. But there's no good
     69     # way to build NSS that does not pollute dist/bin with shared
     70     # object files. For now, we have to build mozpkix only and disable
     71     # the affected tests.
     72     gyp_vars["mozpkix_only"] = 1
     73 
     74 # This disables building some NSS tools.
     75 gyp_vars["mozilla_client"] = 1
     76 
     77 # This builds NSS tools in COMM applications that Firefox doesn't build.
     78 if CONFIG["MOZ_BUILD_APP"].startswith("comm/"):
     79     gyp_vars["comm_client"] = 1
     80 
     81 # We run shlibsign as part of packaging, not build.
     82 gyp_vars["sign_libs"] = 0
     83 gyp_vars["python"] = CONFIG["PYTHON3"]
     84 # The NSS gyp files do not have a default for this.
     85 gyp_vars["nss_dist_dir"] = "$PRODUCT_DIR/dist"
     86 # NSS wants to put public headers in $nss_dist_dir/public/nss by default,
     87 # which would wind up being mapped to dist/include/public/nss (by
     88 # gyp_reader's `handle_copies`).
     89 # This forces it to put them in dist/include/nss.
     90 gyp_vars["nss_public_dist_dir"] = "$PRODUCT_DIR/dist"
     91 gyp_vars["nss_dist_obj_dir"] = "$PRODUCT_DIR/dist/bin"
     92 # We don't currently build NSS tests.
     93 gyp_vars["disable_tests"] = 1
     94 gyp_vars["disable_dbm"] = 1
     95 gyp_vars["disable_libpkix"] = 1
     96 # tor-browser#18885, tor-browser#21849
     97 gyp_vars["enable_sslkeylogfile"] = 0
     98 # Whether we're using system NSS or Rust nssckbi, we don't need
     99 # to build C nssckbi
    100 gyp_vars["disable_ckbi"] = 1
    101 # pkg-config won't reliably find zlib on our builders, so just force it.
    102 # System zlib is only used for modutil and signtool unless
    103 # SSL zlib is enabled, which we are disabling immediately below this.
    104 gyp_vars["zlib_libs"] = "-lz"
    105 gyp_vars["ssl_enable_zlib"] = 0
    106 # System sqlite here is the in-tree mozsqlite.
    107 gyp_vars["use_system_sqlite"] = 1
    108 gyp_vars["sqlite_libs"] = "sqlite"
    109 gyp_vars["enable_draft_hpke"] = 1
    110 # This makes a block in security/nss/coreconf/config.gypi happy, but it
    111 # doesn't actually matter because it's for xcode settings, which the
    112 # build system ignores.
    113 gyp_vars["iphone_deployment_target"] = "doesntmatter"
    114 # The definition of CK_PKCS5_PBKD2_PARAMS in PKCS#11 v2.4 has a bug which was
    115 # fixed, by the introduction of CK_PKCS5_PBKD2_PARAMS2, in v3.0. Starting in
    116 # NSS 3.114 (Bug 1836559), softoken uses an unsafe heuristic to choose which of
    117 # the two structs is intended. We don't need our copy of softoken to support
    118 # CK_PKCS5_PBKD2_PARAMS at all, so we avoid the unsafe heuristic by disabling
    119 # it.
    120 gyp_vars["use_pkcs5_pbkd2_params2_only"] = 1
    121 
    122 # Clang can build NSS with its integrated assembler since version 9.
    123 if (
    124     CONFIG["TARGET_CPU"] == "x86_64"
    125     and CONFIG["CC_TYPE"] == "clang"
    126     and int(CONFIG["CC_VERSION"].split(".")[0]) >= 9
    127 ):
    128     gyp_vars["force_integrated_as"] = 1
    129 
    130 
    131 if CONFIG["MOZ_SYSTEM_NSPR"]:
    132     gyp_vars["nspr_include_dir"] = "%" + CONFIG["NSPR_INCLUDE_DIR"]
    133     gyp_vars["nspr_lib_dir"] = "%" + CONFIG["NSPR_LIB_DIR"]
    134 else:
    135     gyp_vars["nspr_include_dir"] = "!/dist/include/nspr"
    136     gyp_vars["nspr_lib_dir"] = ""  # gyp wants a value, but we don't need
    137     # it to be valid.
    138 
    139 # The Python scripts that detect clang need it to be set as CC
    140 # in the environment, which isn't true here. I don't know that
    141 # setting that would be harmful, but we already have this information
    142 # anyway.
    143 if CONFIG["CC_TYPE"] in ("clang", "clang-cl"):
    144     gyp_vars["cc_is_clang"] = 1
    145 if CONFIG["GCC_USE_GNU_LD"]:
    146     gyp_vars["cc_use_gnu_ld"] = 1
    147 
    148 GYP_DIRS += ["nss"]
    149 GYP_DIRS["nss"].input = "nss/nss.gyp"
    150 GYP_DIRS["nss"].variables = gyp_vars
    151 
    152 sandbox_vars = {
    153     # NSS explicitly exports its public symbols
    154     # with linker scripts.
    155     "COMPILE_FLAGS": {
    156         "VISIBILITY": [],
    157         "WARNINGS_CFLAGS": [
    158             f for f in CONFIG["WARNINGS_CFLAGS"] if f != "-Wsign-compare"
    159         ],
    160     },
    161     # NSS' build system doesn't currently build NSS with PGO.
    162     # We could probably do so, but not without a lot of
    163     # careful consideration.
    164     "NO_PGO": True,
    165 }
    166 if CONFIG["OS_TARGET"] == "WINNT":
    167     # We want to remove XP_WIN32 eventually. See bug 1535219 for details.
    168     sandbox_vars["CFLAGS"] = [
    169         "-DXP_WIN32",
    170         "-Wno-error=unused-function",  # bug 1856445
    171     ]
    172     if CONFIG["TARGET_CPU"] == "x86":
    173         # This should really be the default.
    174         sandbox_vars["ASFLAGS"] = ["-safeseh"]
    175 
    176     DELAYLOAD_DLLS += [
    177         "winmm.dll",
    178     ]
    179 
    180 if CONFIG["MOZ_SYSTEM_NSS"]:
    181     sandbox_vars["CXXFLAGS"] = CONFIG["NSS_CFLAGS"]
    182 GYP_DIRS["nss"].sandbox_vars = sandbox_vars
    183 GYP_DIRS["nss"].no_chromium = True
    184 GYP_DIRS["nss"].no_unified = True
    185 # This maps action names from gyp files to
    186 # Python scripts that can be used in moz.build GENERATED_FILES.
    187 GYP_DIRS["nss"].action_overrides = {
    188     "generate_mapfile": "generate_mapfile.py",
    189 }
    190 
    191 if CONFIG["NSS_EXTRA_SYMBOLS_FILE"]:
    192     DEFINES["NSS_EXTRA_SYMBOLS_FILE"] = CONFIG["NSS_EXTRA_SYMBOLS_FILE"]
    193 
    194 SPHINX_TREES["nss"] = "nss/doc/rst"
    195 
    196 with Files("nss/doc/rst/**"):
    197     SCHEDULES.exclusive = ["nss"]