Bug 1662123 - Normalize input paths from the metric index file. r=chutten

Differential Revision: https://phabricator.services.mozilla.com/D91007
This commit is contained in:
Jan-Erik Rediger 2020-09-28 10:09:15 +00:00
Родитель 4d6447d396
Коммит 375f13589a
1 изменённых файлов: 17 добавлений и 2 удалений

Просмотреть файл

@ -4,6 +4,7 @@
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
import os
import re
import rust
import sys
@ -26,7 +27,15 @@ def get_parser_options(moz_app_version):
}
def main(output_fd, metrics_index_path, which_array, moz_app_version):
def input_files_from_index(metrics_index_path, which_array):
"""
Get the paths to all input files to look at.
This select the input files to use by loading the index
and selecting the appropriate array.
It then normalizes relatives paths into absolute paths
based on the `TOPSRCDIR` environment variable.
"""
# Source the list of input files from `metrics_index.py`
sys.path.append(str(Path(metrics_index_path).parent))
@ -39,9 +48,15 @@ def main(output_fd, metrics_index_path, which_array, moz_app_version):
print("Build system's asking for unknown array {}".format(which_array))
sys.exit(1)
topsrcdir = Path(os.environ.get("TOPSRCDIR", "."))
return [topsrcdir / Path(x) for x in input_files]
def main(output_fd, metrics_index_path, which_array, moz_app_version):
input_files = input_files_from_index(metrics_index_path, which_array)
# Derived heavily from glean_parser.translate.translate.
# Adapted to how mozbuild sends us a fd, and to expire on versions not dates.
input_files = [Path(x) for x in input_files]
options = get_parser_options(moz_app_version)
all_objs = parser.parse_objects(input_files, options)