I'm using VSCode and Docker.
Docker is used for the purpose similar to AppImage - to improve security and workaround incompatible dependencies.
As a base docker image, I'm using registry.gitlab.com/daviddaish/freecad_docker_env:latest
which is apparently being migrated to GitHub: https://github.com/FreeCAD/Docker/pull/1/files
My workspace folders:
- freecad-docker (bash scripts and docker-compose files, workspace files)
- freecad-source (main freecad git repo)
- freecad-build (CMake build directory)
The main challenge was how to make VSCode see header files installed inside a docker image.
So, I've decided to write a script which copies include folders from the docker image to the `freecad-build/include` directory.
For that, I wrote a CMake query.json which generates a log of *.json files from which I grab include paths and copy them.
After that, I'm putting those to the `.vscode/c_cpp_properties.json`
A snippet which copies includes and generates include paths:
Code: Select all
# get includes
INCLUDES_ALL=`cat .cmake/api/v1/reply/target-*.json | jq -r 'select(.compileGroups != null).compileGroups[].includes[].path' | sort | uniq`
INCLUDES_TO_COPY=${for include in $INCLUDES_ALL; do echo "$include" | grep -v mnt; done}
INCLUDES_BUILD=`for include in $INCLUDES_ALL; do echo "$include" | grep 'mnt/build'; done`
INCLUDES_SOURCE=`for include in $INCLUDES_ALL; do echo "$include" | grep 'mnt/source'; done`
# cp includes
mkdir includes
for include in $INCLUDES_TO_COPY; do cp -r -L --parents "$include"/* ./includes; done
cp -r -L --parents "/usr/local/include/" ./includes
# standard location library includes
echo "\"\${workspaceFolder}/../freecad-build/includes/usr/local/include\""
# non-standard location library includes
for include in $INCLUDES_TO_COPY; do echo "\"\${workspaceFolder}/../freecad-build/includes$include\","; done
# generated includes
for include in $INCLUDES_BUILD; do echo "\"\${workspaceFolder}/../freecad-build`sed -E 's/\/mnt\/build//' <<<$include`\","; done
# source includes
for include in $INCLUDES_SOURCE; do echo "\"\${workspaceFolder}/../freecad-source`sed -E 's/\/mnt\/source//' <<<$include`\","; done
If anybody's interested, I can share more.
Maybe you have any thoughts on this setup and how it can be improved.