Last active
October 16, 2025 15:04
-
-
Save donn/4c0fa8d6e29f08b23b3fe8aebdc48fe9 to your computer and use it in GitHub Desktop.
yosys vscode cpp properties script thing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # To be run from within `nix develop github:fossi-foundation/nix-eda/yosys_pybind11#yosys` from your yosys | |
| # repository | |
| # | |
| # currently mac-only | |
| # | |
| # https://unlicense.org | |
| import os | |
| import sys | |
| import json | |
| import shlex | |
| import shutil | |
| import platform | |
| import pybind11 | |
| import sysconfig | |
| def get_python_includes(): | |
| dirs = [ | |
| sysconfig.get_path("include"), | |
| sysconfig.get_path("platinclude"), | |
| pybind11.get_include(), | |
| ] | |
| # Make unique but preserve order | |
| unique_dirs = [] | |
| for d in dirs: | |
| if d and d not in unique_dirs: | |
| unique_dirs.append(d) | |
| return unique_dirs | |
| top = {"configurations": [], "version": 4} | |
| arch_string = "x64" | |
| match platform.machine(): | |
| # add other architectures here | |
| case "arm64": | |
| arch_string = "arm64" | |
| case "aarch64": | |
| arch_string = "arm64" | |
| if platform.system() == "Darwin": | |
| clang = shutil.which("clang") | |
| top["configurations"].append( | |
| { | |
| "name": "Nix Config (macOS)", | |
| "macFrameworkPath": ["/System/Library/Frameworks", "/Library/Frameworks"], | |
| "intelliSenseMode": f"macos-clang-{arch_string}", | |
| "compilerPath": clang, | |
| "includePath": ["${workspaceFolder}", *get_python_includes()], | |
| "compilerArgs": [*shlex.split(os.environ["NIX_CFLAGS_COMPILE"]), "-DYOSYS_ENABLE_PYTHON", "-D_YOSYS_", "-DYOSYS_ENABLE_PLUGINS", "-DYOSYS_ENABLE_TCL"], | |
| } | |
| ) | |
| else: | |
| print("Script not implemented for your platform yet.", file=sys.stderr) | |
| exit(-1) | |
| with open(".vscode/c_cpp_properties.json", "w") as f: | |
| json.dump(top, fp=f, indent=2) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment