Skip to content

Instantly share code, notes, and snippets.

@Junch
Last active October 23, 2018 01:58
Show Gist options
  • Select an option

  • Save Junch/e80d98b7618a6cd023d17b36916d68f6 to your computer and use it in GitHub Desktop.

Select an option

Save Junch/e80d98b7618a6cd023d17b36916d68f6 to your computer and use it in GitHub Desktop.
Script to generate the compile_commands.json
#!/bin/bash
# Refer to
# 1. http://blog.51cto.com/liveforlinux/689382
# 2. https://sarcasm.github.io/notes/dev/compilation-database.html
# 3. https://unix.stackexchange.com/questions/38172/switching-to-zsh-are-all-bash-scripts-compatible-with-zsh/38173
# 在scons文件中,添加 env.Append(CCFLAGS=['-MJ', '${TARGET}.json'])
find ./out/macosx-10.13-x86_64-rel/obj-static/src/ -name "*.o.json" | xargs sed -e '1s/^/[\'$'\n/' -e '$s/,$/\'$'\n]/' > compile_commands.json
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment