xmake, compile_commands.json, flycheck

Posted on May 6, 2024

cmake/warp등을 써보면서 c/c++ 개발할 때에 빌드도구 갖고 놀다가, 이번에 마음을 열고 xmake을 익혀봄.

마음에 든다. 가볍고 빠르고 좋다.

ccache등도 바로 지원하고, lua으로 스크립팅도 그럭저럭 할만해 보이고, [build.zig](https://ziglang.org/learn/build-system/)스러워서 당연하게도 좋은거 같아.

계속 쓸거 같다.

emacs / flycheck + c/c++ 개발할 때에 단점이, 자동적으로 외부 3rd-party 라이브러리의 include-path을 설정해주지 않아서, [dirs-local](https://www.gnu.org/software/emacs/manual/html_node/emacs/Directory-Variables.html) 같은걸 세팅해주길 기대한다는 점.

그래서 그냥 xmake project -vD -k compile_commands -m debug 같이 compile_commands.json 생성하고,

  1. 이걸 파싱해서 표준출력으로 include-paths https://github.com/ageldama/configs/blob/master/compile_commands_json_incdirs.py
  2. 현재 소스코드 버퍼 기준으로 가장 가까운 compile_commands.json 파일 위치 찾는 elisp 함수 https://github.com/ageldama/configs/blob/master/emacs/elisp/compcmdsjson-tiny.el
  3. 위 (1)+(2)을 조합해서 flycheck을 위한 변수 1 들을 설정하는 elisp 함수 https://github.com/ageldama/configs/blob/master/emacs/elisp/flycheck-compcmdsjson.el
  4. 그리고 위 (3)을 c/c++-mode에 자동적으로 적용하고, 또 단축키도 만드는 elisp 코드 https://github.com/ageldama/configs/blob/master/emacs/feat/flycheck-compcmdsjson.el

…요렇게 만들어서 세팅해서 쓰니 편안.

Footnotes