|
15 | 15 | import os |
16 | 16 | import shutil |
17 | 17 | import sys |
18 | | -from typing import List |
| 18 | +from typing import List, Optional |
19 | 19 | from pathlib import Path |
20 | 20 | from functools import partial |
21 | 21 |
|
@@ -1094,6 +1094,47 @@ def __update_review_status_config(args): |
1094 | 1094 | os.symlink(args.review_status_config, rs_config_to_send) |
1095 | 1095 |
|
1096 | 1096 |
|
| 1097 | +def __update_analysis_config_files(args): |
| 1098 | + """ |
| 1099 | + Copy analysis related configuration files |
| 1100 | + (e.g. skipfile, review_status_config) to report_dir/conf/. |
| 1101 | + """ |
| 1102 | + conf_dir = os.path.join(args.output_path, "conf") |
| 1103 | + |
| 1104 | + # Remove any config files used during previous analysis |
| 1105 | + if os.path.isdir(conf_dir): |
| 1106 | + shutil.rmtree(conf_dir) |
| 1107 | + |
| 1108 | + # Create a new conf directory |
| 1109 | + os.makedirs(conf_dir) |
| 1110 | + |
| 1111 | + def add_file_to_conf_dir(file_path: str): |
| 1112 | + if not os.path.isfile(file_path): |
| 1113 | + return |
| 1114 | + |
| 1115 | + file_path = os.path.abspath(file_path) |
| 1116 | + filename = os.path.basename(file_path) |
| 1117 | + shutil.copyfile(file_path, os.path.join(conf_dir, filename)) |
| 1118 | + |
| 1119 | + # Add analysis config files e.g., skipfile, review_status_config, etc. |
| 1120 | + if "skipfile" in args: |
| 1121 | + add_file_to_conf_dir(args.skipfile) |
| 1122 | + |
| 1123 | + if "review_status_config" in args: |
| 1124 | + add_file_to_conf_dir(args.review_status_config) |
| 1125 | + |
| 1126 | + if "config_file" in args: |
| 1127 | + add_file_to_conf_dir(args.config_file) |
| 1128 | + |
| 1129 | + # Add cc-verbatim-args-file |
| 1130 | + # |
| 1131 | + # Example: --saargs <filepath>, --tidyargs <filepath>, |
| 1132 | + # --analyzer-config clangsa:cc-verbatim-args-file=<filepath>, etc. |
| 1133 | + for a_conf in args.analyzer_config: |
| 1134 | + if a_conf.option == "cc-verbatim-args-file": |
| 1135 | + add_file_to_conf_dir(a_conf.value) |
| 1136 | + |
| 1137 | + |
1097 | 1138 | def __cleanup_metadata(metadata_prev, metadata): |
1098 | 1139 | """ Cleanup metadata. |
1099 | 1140 |
|
@@ -1455,6 +1496,7 @@ def main(args): |
1455 | 1496 |
|
1456 | 1497 | __update_skip_file(args) |
1457 | 1498 | __update_review_status_config(args) |
| 1499 | + __update_analysis_config_files(args) |
1458 | 1500 |
|
1459 | 1501 | LOG.debug("Cleanup metadata file started.") |
1460 | 1502 | __cleanup_metadata(metadata_prev, metadata) |
|
0 commit comments