Ejemplo n.º 1
0
def dependentlibs_readelf(lib):
    """Returns the list of dependencies declared in the given ELF .so"""
    proc = subprocess.Popen(
        [substs.get("TOOLCHAIN_PREFIX", "") + "readelf", "-d", lib],
        stdout=subprocess.PIPE,
        universal_newlines=True,
    )
    deps = []
    for line in proc.stdout:
        # Each line has the following format:
        #  tag (TYPE)          value
        # or with BSD readelf:
        #  tag TYPE            value
        # Looking for NEEDED type entries
        tmp = line.split(" ", 3)
        if len(tmp) > 3 and "NEEDED" in tmp[2]:
            # NEEDED lines look like:
            # 0x00000001 (NEEDED)             Shared library: [libname]
            # or with BSD readelf:
            # 0x00000001 NEEDED               Shared library: [libname]
            match = re.search("\[(.*)\]", tmp[3])
            if match:
                deps.append(match.group(1))
    proc.wait()
    return deps
Ejemplo n.º 2
0
def xz_compress(path):
    """
    Execute xz to compress the given path.
    """
    if open(path, "rb").read(5)[1:] == "7zXZ":
        print("%s is already compressed" % path)
        return

    from buildconfig import substs

    xz = substs.get("XZ")
    cmd = [xz, "-zkf", path]

    # For now, the mozglue XZStream ELF loader can only support xz files
    # with a single stream that contains a single block. In xz, there is no
    # explicit option to set the max block count. Instead, we force xz to use
    # single thread mode, which results in a single block.
    cmd.extend(["--threads=1"])

    bcj = None
    if substs.get("MOZ_THUMB2"):
        bcj = "--armthumb"
    elif substs.get("CPU_ARCH") == "arm":
        bcj = "--arm"
    elif substs.get("CPU_ARCH") == "x86":
        bcj = "--x86"

    if bcj:
        cmd.extend([bcj])

    # We need to explicitly specify the LZMA filter chain to ensure consistent builds
    # across platforms. Note that the dict size must be less then 16MiB per the hardcoded
    # value in mozglue/linker/XZStream.cpp. This is the default LZMA filter chain for for
    # xz-utils version 5.0. See:
    # https://github.com/xz-mirror/xz/blob/v5.0.0/src/liblzma/lzma/lzma_encoder_presets.c
    # https://github.com/xz-mirror/xz/blob/v5.0.0/src/liblzma/api/lzma/container.h#L31
    cmd.extend([
        "--lzma2=dict=8MiB,lc=3,lp=0,pb=2,mode=normal,nice=64,mf=bt4,depth=0"
    ])
    print("xz-compressing %s with %s" % (path, " ".join(cmd)))

    if subprocess.call(cmd) != 0:
        errors.fatal("Error executing " + " ".join(cmd))
        return

    os.rename(path + ".xz", path)
Ejemplo n.º 3
0
def strip(path):
    '''
    Execute the STRIP command with STRIP_FLAGS on the given path.
    '''
    from buildconfig import substs
    strip = substs['STRIP']
    flags = substs.get('STRIP_FLAGS', [])
    cmd = [strip] + flags + [path]
    if subprocess.call(cmd) != 0:
        errors.fatal('Error executing ' + ' '.join(cmd))
Ejemplo n.º 4
0
    def __init__(self, source, omnijar_name=None, unpack_xpi=True):
        if isinstance(source, BaseFinder):
            self._finder = source
        else:
            self._finder = FileFinder(source)
        self.base = self._finder.base
        self.files = FileRegistry()
        self.kind = "flat"
        if omnijar_name:
            self.omnijar = omnijar_name
        else:
            # Can't include globally because of bootstrapping issues.
            from buildconfig import substs

            self.omnijar = substs.get("OMNIJAR_NAME", "omni.ja")
        self.jarlogs = {}
        self.compressed = False
        self._unpack_xpi = unpack_xpi

        jars = set()

        for p, f in self._finder.find("*"):
            # Skip the precomplete file, which is generated at packaging time.
            if p == "precomplete":
                continue
            base = mozpath.dirname(p)
            # If the file matches the omnijar pattern, it is an omnijar.
            # All the files it contains go in the directory containing the full
            # pattern. Manifests are merged if there is a corresponding manifest
            # in the directory.
            if self._maybe_zip(f) and mozpath.match(p, "**/%s" % self.omnijar):
                jar = self._open_jar(p, f)
                if "chrome.manifest" in jar:
                    self.kind = "omni"
                    self._fill_with_jar(p[: -len(self.omnijar) - 1], jar)
                    continue
            # If the file is a manifest, scan its entries for some referencing
            # jar: urls. If there are some, the files contained in the jar they
            # point to, go under a directory named after the jar.
            if is_manifest(p):
                m = self.files[p] if self.files.contains(p) else ManifestFile(base)
                for e in parse_manifest(
                    self.base, p, codecs.getreader("utf-8")(f.open())
                ):
                    m.add(self._handle_manifest_entry(e, jars))
                if self.files.contains(p):
                    continue
                f = m
            # If we're unpacking packed addons and the file is a packed addon,
            # unpack it under a directory named after the xpi.
            if self._unpack_xpi and p.endswith(".xpi") and self._maybe_zip(f):
                self._fill_with_jar(p[:-4], self._open_jar(p, f))
                continue
            if p not in jars:
                self.files.add(p, f)
Ejemplo n.º 5
0
def may_strip(path):
    '''
    Return whether strip() should be called
    '''
    from buildconfig import substs
    # Bug 1658632: clang-11-based strip complains about d3dcompiler_47.dll.
    # It's not clear why this happens, but as a quick fix just avoid stripping
    # this DLL. It's not from our build anyway.
    if 'd3dcompiler' in path:
        return False
    return bool(substs.get('PKG_STRIP'))
Ejemplo n.º 6
0
def strip(path):
    """
    Execute the STRIP command with STRIP_FLAGS on the given path.
    """
    from buildconfig import substs

    strip = substs["STRIP"]
    flags = substs.get("STRIP_FLAGS", [])
    cmd = [strip] + flags + [path]
    if subprocess.call(cmd) != 0:
        errors.fatal("Error executing " + " ".join(cmd))
Ejemplo n.º 7
0
def get_clang_format_binary():
    """
    Returns the path of the first clang-format binary available
    if not found returns None
    """
    binary = os.environ.get("CLANG_FORMAT")
    if binary:
        return binary

    clang_tools_path = os.path.join(get_tools_dir(), "clang-tools")
    bin_path = os.path.join(clang_tools_path, "clang-tidy", "bin")
    return os.path.join(bin_path, "clang-format" + substs.get("HOST_BIN_SUFFIX", ""))
Ejemplo n.º 8
0
    def testCrashLogging(self):
        """
        Test that a crashing test process logs a failure.
        """
        self.writeFile("test_crashes.js", TEST_CRASHING)
        self.writeManifest(["test_crashes.js"])

        self.assertTestResult(False)
        self.assertEquals(1, self.x.testCount)
        self.assertEquals(0, self.x.passCount)
        self.assertEquals(1, self.x.failCount)
        if substs.get('MOZ_CRASHREPORTER'):
            self.assertInLog("\nPROCESS-CRASH")
Ejemplo n.º 9
0
    def testUncaughtRejection(self):
        """
        Ensure a simple test with an uncaught rejection is reported.
        """
        self.writeFile("test_simple_uncaught_rejection.js", SIMPLE_UNCAUGHT_REJECTION_TEST)
        self.writeManifest(["test_simple_uncaught_rejection.js"])

        self.assertTestResult(False)
        self.assertInLog(TEST_FAIL_STRING)
        if not substs.get('RELEASE_OR_BETA'):
          # async stacks are currently not enabled in release builds.
          self.assertInLog("test_simple_uncaught_rejection.js:3:3")
        self.assertInLog("Test rejection.")
        self.assertEquals(1, self.x.testCount)
        self.assertEquals(0, self.x.passCount)
        self.assertEquals(1, self.x.failCount)
Ejemplo n.º 10
0
def dependentlibs_readelf(lib):
    '''Returns the list of dependencies declared in the given ELF .so'''
    proc = subprocess.Popen([substs.get('TOOLCHAIN_PREFIX', '') + 'readelf', '-d', lib], stdout = subprocess.PIPE)
    deps = []
    for line in proc.stdout:
        # Each line has the following format:
        #  tag (TYPE)          value
        # Looking for NEEDED type entries
        tmp = line.split(' ', 3)
        if len(tmp) > 3 and tmp[2] == '(NEEDED)':
            # NEEDED lines look like:
            # 0x00000001 (NEEDED)             Shared library: [libname]
            match = re.search('\[(.*)\]', tmp[3])
            if match:
                deps.append(match.group(1))
    proc.wait()
    return deps
Ejemplo n.º 11
0
def dependentlibs_readelf(lib):
    '''Returns the list of dependencies declared in the given ELF .so'''
    proc = subprocess.Popen(
        [substs.get('TOOLCHAIN_PREFIX', '') + 'readelf', '-d', lib],
        stdout=subprocess.PIPE)
    deps = []
    for line in proc.stdout:
        # Each line has the following format:
        #  tag (TYPE)          value
        # Looking for NEEDED type entries
        tmp = line.split(' ', 3)
        if len(tmp) > 3 and tmp[2] == '(NEEDED)':
            # NEEDED lines look like:
            # 0x00000001 (NEEDED)             Shared library: [libname]
            match = re.search('\[(.*)\]', tmp[3])
            if match:
                deps.append(match.group(1))
    proc.wait()
    return deps
Ejemplo n.º 12
0
                v = v.format(**interpolation)
            prefs[k] = Preferences.cast(v)

        profile = FirefoxProfile(profile=profilePath,
                                 preferences=prefs,
                                 addons=[os.path.join(
                                     build.topsrcdir, 'tools', 'quitter',
                                     '*****@*****.**')],
                                 locations=locations)

        env = os.environ.copy()
        env["MOZ_CRASHREPORTER_NO_REPORT"] = "1"
        env["XPCOM_DEBUG_BREAK"] = "warn"

        # For VC12+, make sure we can find the right bitness of pgort1x0.dll
        if not substs.get('HAVE_64BIT_BUILD'):
            for e in ('VS140COMNTOOLS', 'VS120COMNTOOLS'):
                if e not in env:
                    continue

                vcdir = os.path.abspath(os.path.join(env[e], '../../VC/bin'))
                if os.path.exists(vcdir):
                    env['PATH'] = '%s;%s' % (vcdir, env['PATH'])
                    break

        # Run Firefox a first time to initialize its profile
        runner = FirefoxRunner(profile=profile,
                               binary=binary,
                               cmdargs=['data:text/html,<script>Quitter.quit()</script>'],
                               env=env)
        runner.start()
Ejemplo n.º 13
0
 def brotli_tool():
     from buildconfig import topobjdir, substs
     return os.path.join(topobjdir, 'dist', 'host', 'bin',
                         'bro' + substs.get('BIN_SUFFIX', ''))
Ejemplo n.º 14
0
def may_strip(path):
    '''
    Return whether strip() should be called
    '''
    from buildconfig import substs
    return bool(substs.get('PKG_STRIP'))
Ejemplo n.º 15
0
    def brotli_tool():
        from buildconfig import topobjdir, substs

        return os.path.join(topobjdir, "dist", "host", "bin",
                            "bro" + substs.get("BIN_SUFFIX", ""))
Ejemplo n.º 16
0
 def brotli_tool():
         from buildconfig import topobjdir, substs
         return os.path.join(topobjdir, 'dist', 'host', 'bin',
                            'bro' + substs.get('BIN_SUFFIX', ''))