tor-browser

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

nss.configure (1888B)


      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 
      8 @imports(_from="__builtin__", _import="open")
      9 @imports("os")
     10 def get_nss_version():
     11     nss_version = [0, 0]
     12     topsrcdir = os.path.realpath(os.path.join(os.path.dirname(__file__), "..", ".."))
     13     with open(
     14         os.path.join(topsrcdir, "security", "nss", "lib", "nss", "nss.h"), "r"
     15     ) as f:
     16         for line in f:
     17             if "NSS_VMAJOR" in line:
     18                 nss_version[0] = line.split()[-1]
     19             if "NSS_VMINOR" in line:
     20                 nss_version[1] = line.split()[-1]
     21             if "NSS_VPATCH" in line:
     22                 patch = line.split()[-1]
     23                 if patch != "0":
     24                     nss_version.append(line.split()[-1])
     25     return ".".join(nss_version)
     26 
     27 
     28 system_lib_option(
     29     "--with-system-nss",
     30     help="Use system NSS",
     31     when=use_pkg_config,
     32 )
     33 
     34 imply_option("--with-system-nspr", True, when="--with-system-nss")
     35 
     36 nss_pkg = pkg_check_modules(
     37     "NSS", "nss >= " + get_nss_version(), when="--with-system-nss", config=False
     38 )
     39 
     40 set_config("MOZ_SYSTEM_NSS", True, when="--with-system-nss")
     41 
     42 
     43 @depends(nss_pkg, build_environment)
     44 def nss_config(nss_pkg, build_env):
     45     cflags = ["-I%s" % os.path.join(build_env.dist, "include", "nss")]
     46     libs = None
     47     if nss_pkg:
     48         cflags = list(nss_pkg.cflags) + cflags
     49         libs = nss_pkg.libs
     50     return namespace(cflags=cflags, libs=libs)
     51 
     52 
     53 set_config("NSS_CFLAGS", nss_config.cflags)
     54 set_config("NSS_LIBS", nss_config.libs)
     55 
     56 # Used specifically by Thunderbird
     57 project_flag(
     58     env="NSS_EXTRA_SYMBOLS_FILE",
     59     nargs=1,
     60     help="Path to a file containing extra symbols to export from NSS",
     61 )