-
Notifications
You must be signed in to change notification settings - Fork 466
Using VSCode with C Python Tagging
Hanoh Haim edited this page Oct 21, 2020
·
4 revisions
See build clang no need to be root, but you should have latest cmake and gcc > 4.8.5 (I've used 7.4)
clangd requires compile_commands.json. To generate it you should build trex project once
$cd linux_dpdk
$./b clean build
$ll build_dpdk/compile_commands.json
This is the configuration that could work
{
"folders": [
{
"path": "/opt/trex-core"
}
],
"settings": {
"clangd.path": "[path-to-clangd-10]/clangd",
"files.exclude": {
"**/*.pyc": true,
"**/__pycache__": true,
"**/.vscode": true,
"**/compile_commands.json": true,
}
"clangd.arguments": [
"-background-index",
"-compile-commands-dir=linux_dpdk/build_dpdk",
"--clang-tidy",
"--index"
],
}
}
In output/clang window you should see something like this:
I[13:01:33.525] Updating file /auto/srg-sce-swinfra-/trex-core/src/stx/astf/trex_astf_dp_core.cpp with command
[/trex-core/linux_dpdk/build_dpdk]
/usr/local/gcc-7.4/bin/g++ --driver-mode=g++ -DWIN_UCODE_SIM -D_BYTE_ORDER -D_LITTLE_ENDIAN -DLINUX -g -Wno-format -Wno-deprecated-declarations -Wno-error=uninitialized -DRTE_DPDK -D__STDC_LIMIT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_CONSTANT_MACROS -march=corei7 -DUCS_210 -mtune=generic -DRTE_MACHINE_CPUFLAG_SSE -DRTE_COMPILE_TIME_CPUFLAGS=RTE_CPUFLAG_SSE -DTREX_USE_BPFJIT -m64 -O3 -std=c++0x -Wall -Werror -Wno-literal-suffix -Wno-sign-compare -Wno-strict-aliasing -Wno-aligned-new -std=gnu++11 -Isrc/dpdk/lib/librte_eal/common/include/arch/x86 -I../../src/dpdk/lib/librte_eal/common/include/arch/x86 -Isrc -I../../src -Isrc/pal/linux_dpdk -I../../src/pal/linux_dpdk -Isrc/pal/linux_dpdk/dpdk1905_x86_64 -I../../src/pal/linux_dpdk/dpdk1905_x86_64 -Isrc/dpdk/drivers -I../../src/dpdk/drivers -Isrc/dpdk/drivers/net -I../../src/dpdk/drivers/net -Isrc/dpdk/drivers/net/af_packet -I../../src/dpdk/drivers/net/af_packet -Isrc/dpdk/drivers/net/e1000 -I../../src/dpdk/drivers/net/e1000 -Isrc/dpdk/drivers/net/e1000/base -I../../src/dpdk/drivers/net/e1000/base -Isrc/dpdk/drivers/net/enic -I../../src/dpdk/drivers/net/enic -Isrc/dpdk/drivers/net/enic/base -I../../src/dpdk/drivers/net/enic/base -Isrc/dpdk/drivers/net/i40e -I../../src/dpdk/drivers/net/i40e -Isrc/dpdk/drivers/net/i40e/base -I../../src/dpdk/drivers/net/i40e/base -Isrc/dpdk/drivers/net/ixgbe -I../../src/dpdk/drivers/net/ixgbe -Isrc/dpdk/drivers/net/ixgbe/base -I../../src/dpdk/drivers/net/ixgbe/base -Isrc/dpdk/drivers/net/mlx4 -I../../src/dpdk/drivers/net/mlx4 -Isrc/dpdk/drivers/net/mlx5 -I../../src/dpdk/drivers/net/mlx5 -Isrc/dpdk/drivers/net/ntacc -I../../src/dpdk/drivers/net/ntacc -Isrc/dpdk/drivers/net/virtio -I../../src/dpdk/drivers/net/virtio -Isrc/dpdk/drivers/net/virtio/virtio_user -I../../src/dpdk/drivers/net/virtio/virtio_user -Isrc/dpdk/drivers/net/vmxnet3 -I../../src/dpdk/drivers/net/vmxnet3 -Isrc/dpdk/drivers/net/vmxnet3/base -I../../src/dpdk/drivers/net/vmxnet3/base -Isrc/dpdk/drivers/net/ena -I../../src/dpdk/drivers/net/ena -Isrc/dpdk/drivers/net/ena/base -I../../src/dpdk/drivers/net/ena/base -Isrc/dpdk/drivers/net/ena/base/ena_defs -I../../src/dpdk/drivers/net/ena/base/ena_defs -Isrc/dpdk/lib -I../../src/dpdk/lib -Isrc/dpdk/lib/librte_cfgfile -I../../src/dpdk/lib/librte_cfgfile -Isrc/dpdk/lib/librte_compat -I../../src/dpdk/lib/librte_compat -Isrc/dpdk/lib/librte_eal -I../../src/dpdk/lib/librte_eal -Isrc/dpdk/lib/librte_eal/common -I../../src/dpdk/lib/librte_eal/common -Isrc/dpdk/lib/librte_eal/common/include -I../../src/dpdk/lib/librte_eal/common/include -Isrc/dpdk/lib/librte_eal/common/include/arch -I../../src/dpdk/lib/librte_eal/common/include/arch -Isrc/dpdk/lib/librte_eal/common/include/generic -I../../src/dpdk/lib/librte_eal/common/include/generic -Isrc/dpdk/lib/librte_eal/linux -I../../src/dpdk/lib/librte_eal/linux -Isrc/dpdk/lib/librte_eal/linux/eal -I../../src/dpdk/lib/librte_eal/linux/eal -Isrc/dpdk/lib/librte_eal/linux/eal/include -I../../src/dpdk/lib/librte_eal/linux/eal/include -Isrc/dpdk/lib/librte_eal/linux/eal/include/exec-env -I../../src/dpdk/lib/librte_eal/linux/eal/include/exec-env -Isrc/dpdk/lib/librte_ethdev -I../../src/dpdk/lib/librte_ethdev -Isrc/dpdk/lib/librte_hash -I../../src/dpdk/lib/librte_hash -Isrc/dpdk/lib/librte_kvargs -I../../src/dpdk/lib/librte_kvargs -Isrc/dpdk/lib/librte_mbuf -I../../src/dpdk/lib/librte_mbuf -Isrc/dpdk/lib/librte_mempool -I../../src/dpdk/lib/librte_mempool -Isrc/dpdk/lib/librte_meter -I../../src/dpdk/lib/librte_meter -Isrc/dpdk/lib/librte_net -I../../src/dpdk/lib/librte_net -Isrc/dpdk/lib/librte_pci -I../../src/dpdk/lib/librte_pci -Isrc/dpdk/lib/librte_port -I../../src/dpdk/lib/librte_port -Isrc/dpdk/lib/librte_ring -I../../src/dpdk/lib/librte_ring -Isrc/dpdk/lib/librte_timer -I../../src/dpdk/lib/librte_timer -Isrc/dpdk -I../../src/dpdk -Isrc/dpdk/drivers/bus/pci -I../../src/dpdk/drivers/bus/pci -Isrc/dpdk/drivers/bus/vdev -I../../src/dpdk/drivers/bus/vdev -Isrc/dpdk/drivers/bus/pci/linux -I../../src/dpdk/drivers/bus/pci/linux -Isrc/drivers -I../../src/drivers -Isrc/pal/common -I../../src/pal/common -Isrc/stx -I../../src/stx -Isrc/stx/common -I../../src/stx/common -Isrc/utils -I../../src/utils -Isrc/hdrh -I../../src/hdrh -Iexternal_libs/yaml-cpp/include -I../../external_libs/yaml-cpp/include -Iexternal_libs/zmq-x86_64/include -I../../external_libs/zmq-x86_64/include -Iexternal_libs/json -I../../external_libs/json -Iexternal_libs/md5 -I../../external_libs/md5 -Iexternal_libs/bpf -I../../external_libs/bpf -Iexternal_libs/valijson/include -I../../external_libs/valijson/include ../../src/stx/astf/trex_astf_dp_core.cpp -c -o/trex-core/linux_dpdk/build_dpdk/src/stx/astf/trex_astf_dp_core.cpp.28.o -fsyntax-only -resource-dir=/scratch/hhaim/llvm/llvm/build/lib/clang/10.0.0
I[13:01:33.526] <-- textDocument/documentSymbol(55)
first you should build one of the target and make sure you have linux_dpdk/build_dpdk/ compile_commands.json
else build ./b build --target=_t-rex-64
without this file ccls won't work
It works much better as it index the workspace once (a few seconds) and then it is ready and fast!
See how to build ccls (requires clang library, and new gcc7.4>)
.Workspace configuration
"ccls.misc.compilationDatabaseDirectory" :"linux_dpdk/build_dpdk/",
.Global configuration
"ccls.launch.command": "/scratch/ccls",
"ccls.cache.directory": "/ccls_cache/",
"ccls.highlighting.enabled.types": true,
"ccls.highlighting.enabled.freeStandingFunctions": true,
"ccls.highlighting.enabled.memberFunctions": true,
"ccls.highlighting.enabled.freeStandingVariables": true,
"ccls.highlighting.enabled.memberVariables": true,
"ccls.highlighting.enabled.namespaces": true,
"ccls.highlighting.enabled.macros": true,
"ccls.highlighting.enabled.enums": true,
"ccls.highlighting.enabled.typeAliases": true,
"ccls.highlighting.enabled.enumConstants": true,
"ccls.highlighting.enabled.staticMemberFunctions": true,
"ccls.highlighting.enabled.parameters": true,
"ccls.highlighting.enabled.templateParameters": true,
"ccls.highlighting.enabled.staticMemberVariables": true,
"ccls.highlighting.enabled.globalVariables": true,
The file .env in root will make the tagging work
.env
$more .env
# python path
PYTHONPATH="scripts/automation/trex_control_plane/interactive/:scripts/automation/:scripts/external_libs/scapy-2.3.1/python3:scrip
ts/external_libs/dpkt-1.9.1:scripts/external_libs/repoze:scripts/external_libs/simpy-3.0.10"