basecfg
kernel
- git clone https://github.com/alexlo2000/vscode-linux-kernel.git .vscode
- ./.vscode/generate_compdb.py
application
手动生成 compile_commands.json
gencompilerFile.py
import json, os, sys
import subprocess
cmdlist = [
"find ./drivers/ips -name *.c -o -name *.h",
]
def main(argv):
tmpdic = {}
jsondata = []
with open('compile_commands.json', 'w', encoding='utf8') as wfp:
for itm in cmdlist:
raw = subprocess.Popen(itm,shell=True,stdin=subprocess.PIPE,stdout=subprocess.PIPE).communicate()[0].decode().split()
for sigf in raw:
ttfile = os.path.split(sigf)
tmpdic["directory"] = ttfile[0]
tmpdic["file"] = ttfile[1]
jsondata.append(tmpdic)
json.dump(jsondata, wfp, ensure_ascii=False, indent=4, separators=(',', ': '))
if not os.path.exists(".vscode/setting.json"):
os.mkdir(".vscode")
dica = {}
with open(".vscode/setting.json", 'w', encoding='utf8') as wfp:
dica["C_Cpp.default.compileCommands"] = "compile_commands.json"
json.dump(dica, wfp, ensure_ascii=False, indent=4, separators=(',', ': '))
if __name__ == '__main__':
main(sys.argv)
–end
|