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/.
18 if not buildconfig
.substs
.get("MOZ_CODE_COVERAGE") or not buildconfig
.substs
.get(
24 "GRCOV_PATH" in os
.environ
25 ), "The environment variable GRCOV_PATH should contain a path to grcov"
26 grcov_path
= os
.environ
["GRCOV_PATH"]
27 assert os
.path
.exists(grcov_path
), "grcov should exist"
34 buildconfig
.topsrcdir
,
35 buildconfig
.topobjdir
,
38 if buildconfig
.substs
["OS_TARGET"] == "Linux":
39 gcc_dir
= os
.path
.join(os
.environ
["MOZ_FETCHES_DIR"], "gcc")
40 if "LD_LIBRARY_PATH" in os
.environ
:
41 os
.environ
["LD_LIBRARY_PATH"] = "{}/lib64/:{}".format(
42 gcc_dir
, os
.environ
["LD_LIBRARY_PATH"]
45 os
.environ
["LD_LIBRARY_PATH"] = "{}/lib64/".format(gcc_dir
)
47 os
.environ
["PATH"] = "{}/bin/{}{}".format(
48 gcc_dir
, os
.pathsep
, os
.environ
["PATH"]
51 grcov_output
= subprocess
.check_output(grcov_command
)
53 grcov_zip_path
= os
.path
.join(buildconfig
.topobjdir
, "code-coverage-grcov.zip")
54 with zipfile
.ZipFile(grcov_zip_path
, "a", zipfile
.ZIP_DEFLATED
) as z
:
55 z
.writestr("grcov_lcov_output.info", grcov_output
)
58 if __name__
== "__main__":