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