Skip to content
Snippets Groups Projects
Commit 81da0ecd authored by recallmenot's avatar recallmenot
Browse files

added clangd support, build scripts in seperate dir

parent 9aebd4de
No related branches found
No related tags found
No related merge requests found
......@@ -8,3 +8,4 @@
*.map
minichlink/minichlink
minichlink/minichlink.so
compile_commands.json
......@@ -139,6 +139,12 @@ This project can also be built, uploaded and debugged with VSCode and the Platfo
See [here](https://github.com/Community-PIO-CH32V/platform-ch32v) for further details.
## clangd
If the C/C++ language server clangd is unable to find `ch32v003fun.h`, the example will have to be wiped `make clean` and built once with `bear -- make build`, which will generate a `compile_commands.json`, which clangd uses to find the include paths specified in the makefiles.
`make clangd` does this in one step.
`build_all_clangd.sh` does in `build scripts` does this for all examples.
## Quick Reference
* Needed for programming/debugging: `SWIO` is on `PD1`
* Optional (not needed, can be configured as output if fuse set): `NRST` is on `PD7`
......
Scripts serve to build / clean all examples at once.
`build_all_clangd.sh` uses bear to additionally generate a `compile_commands.yaml` for each example so the C/C++ language server clangd can be aware of the paths in the makefiles.
......@@ -4,4 +4,8 @@ setlocal
set TARGET=%1
if [%1]==[] set TARGET=build
cd ..\examples
for /d %%i in (*) do make --directory=%%i %TARGET%
cd ..\build_scripts
#!/bin/bash
echo "this will build all examples"
sleep 2
cd ../examples
for dir in */; do
if [ -f "${dir}Makefile" ]; then
echo "running 'make build' in ${dir}"
(cd "${dir}" && make build)
else
echo "no Makefile in ${dir}"
fi
done
cd ../build_scripts
#!/bin/bash
echo "this will build all examples with 'bear' to generate 'compile_commands.json'"
echo "'clangd' relies on these files to find the include paths"
sleep 2
cd ../examples
if ! command -v bear --help &> /dev/null
then
echo "'bear' could not be found"
echo "please install it from your package manager"
exit
fi
for dir in */; do
if [ -f "${dir}Makefile" ]; then
echo "running 'bear -- make' in ${dir}"
(cd "${dir}" && make clean && make clangd_clean && make clangd)
else
echo "no Makefile in ${dir}"
fi
done
cd ../build_scripts
#!/bin/bash
echo "this will clean all examples"
sleep 2
cd ../examples
for dir in */; do
if [ -f "${dir}Makefile" ]; then
echo "running 'make clean' in ${dir}"
(cd "${dir}" && make clean)
else
echo "no Makefile in ${dir}"
fi
done
cd ../build_scripts
#!/bin/bash
echo "this will clean all examples and their 'compile_commands.json'"
echo "'clangd' relies on these files to find the include paths"
sleep 2
cd ../examples
for dir in */; do
if [ -f "${dir}Makefile" ]; then
echo "running 'make clean' and 'make clangd_clean' in ${dir}"
(cd "${dir}" && make clean && make clangd_clean)
else
echo "no Makefile in ${dir}"
fi
done
cd ../build_scripts
......@@ -46,6 +46,13 @@ monitor :
gdbserver :
-$(MINICHLINK)/minichlink -baG
clangd :
make clean
bear -- make build
clangd_clean :
rm -f compile_commands.json
cv_flash : $(TARGET).bin
make -C $(MINICHLINK) all
$(MINICHLINK)/minichlink -w $< flash -b
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment