Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate compilation database using clang++ #42

Open
pinventado opened this issue Jan 1, 2021 · 1 comment
Open

Generate compilation database using clang++ #42

pinventado opened this issue Jan 1, 2021 · 1 comment

Comments

@pinventado
Copy link
Member

https://sarcasm.github.io/notes/dev/compilation-database.html#clang

Replace the shell script for generating the compilation database (gen_ccjs.sh) with the generator from clang++.

Specifically, use the usually clang++ compilation command, but add a -MJ flag passing along a temporary json file. Finally add [ ] to the generated file. For example:

clang++ -std=c++17 -MJ temp.json main.cc -o main
sed -e '1s/^/[\n/' -e '$s/,$/\n]/' temp.json > compile_commands.json
rm temp.json
@pinventado
Copy link
Member Author

It seems like compile_commands.json really just needs the .cc files. It doesn't even seem to check the value of the command attribute. It worked with "cat main.cc". Although clang++ works, does it make sense to just continue using our simpler bash script but removing the header files?

We will need to fix it though because it seems the current version of the script is only able to retrieve one implementation file. A possible solution is to use shift to remove all previous params, then loop through all the remaining strings, which are the .cc files

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant