brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.3 KiB · 5177a01 Raw
43 lines · python
1"""2DTLTO Mock Distributor.3 4This script acts as a mock distributor for Distributed ThinLTO (DTLTO). It is5used for testing DTLTO when a Clang binary is not be available to invoke to6perform the backend compilation jobs.7 8Usage:9    python mock.py <input_file1> <input_file2> ... <json_file>10 11Arguments:12    - <input_file1>, <input_file2>, ...  : Input files to be copied.13    - <json_file>                        : JSON file describing the DTLTO jobs.14 15The script performs the following:16    1. Reads the JSON file containing job descriptions.17    2. For each job copies the corresponding input file to the output location18       specified for that job.19    3. Validates the JSON format using the `validate` module.20"""21 22import sys23import json24import shutil25from pathlib import Path26import validate27 28if __name__ == "__main__":29    json_arg = sys.argv[-1]30    input_files = sys.argv[1:-1]31 32    # Load the DTLTO information from the input JSON file.33    with Path(json_arg).open() as f:34        data = json.load(f)35 36    # Iterate over the jobs and create the output37    # files by copying over the supplied input files.38    for job_index, job in enumerate(data["jobs"]):39        shutil.copy(input_files[job_index], job["outputs"][0])40 41    # Check the format of the JSON.42    validate.validate(data)43