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