Ed Tanous | d44b444 | 2017-02-28 11:12:44 -0800 | [diff] [blame^] | 1 | import json |
| 2 | import shlex |
| 3 | import os |
| 4 | import sys |
| 5 | |
| 6 | SCRIPT_DIR = os.path.dirname(os.path.realpath(__file__)) |
| 7 | |
| 8 | VS_CODE_FILE = os.path.join(SCRIPT_DIR, "../.vscode/c_cpp_properties.json") |
| 9 | |
| 10 | def main(): |
| 11 | """ Main function""" |
| 12 | if os.path.exists(VS_CODE_FILE): |
| 13 | unique_includes = list(set(sys.argv[1:])) |
| 14 | |
| 15 | print("Adding {} includes to c_cpp_properties.json".format(len(unique_includes))) |
| 16 | with open(VS_CODE_FILE) as vscodefile: |
| 17 | vscode_data = json.load(vscodefile) |
| 18 | |
| 19 | for config in vscode_data["configurations"]: |
| 20 | if config["name"] in "Linux": |
| 21 | config["includePath"] = unique_includes |
| 22 | |
| 23 | |
| 24 | with open(VS_CODE_FILE, 'w') as vscodefile: |
| 25 | json.dump(vscode_data, vscodefile, sort_keys=True, indent=4) |
| 26 | |
| 27 | if __name__ == "__main__": |
| 28 | main() |