项目作者: wberrier

项目描述 :
Command Line Interface Project: project command wrapper
高级语言: Python
项目地址: git://github.com/wberrier/clip.git
创建时间: 2020-02-26T18:19:06Z
项目社区:https://github.com/wberrier/clip

开源协议:

下载


clip: CLI Project

This is really just a command wrapper around various commands to run
at a project root level.

Originally it was to build/debug/run c++ stuff from an editor
(emacs!), but there’s no reason it should be tied to c++ or emacs.

Maybe it’s more necessary for c++ since there’s a lack of standard
tooling. In some sense, this project is inspired by rust’s cargo
tool.

Intended Audience

Vim and Emacs support :make / M-x compile but those are rarely used to
build a project. The intent is to provide a cli tool that runs some
high level commands on a project basis that can be easily used from
various editors. The configuration file to capture these commands can
be persisted with the source.

Config File

Here’s a sample configuration file using meson/ninja. This would be
placed at the root of a project as .clip.yaml.

  1. ---
  2. # parameters that will build this project
  3. build:
  4. # Various "profiles"
  5. release:
  6. command: ninja -j@NUM_CORES_TO_USE@
  7. working_dir: build
  8. debug:
  9. command: ninja -j@NUM_CORES_TO_USE@
  10. working_dir: build-debug
  11. cross:
  12. command: ninja -j@NUM_CORES_TO_USE@
  13. working_dir: build-cross
  14. test:
  15. # Can set environment variables when running profiles
  16. env:
  17. BOOST_TESTS_TO_RUN: subset
  18. command: ninja test
  19. working_dir: build-debug
  20. # run the "tests" binary with gdb in the "build-debug" directory
  21. debug:
  22. program: tests
  23. working_dir: build-debug
  24. program_args:
  25. # "env" also supported here
  26. # Process compile_commands.json file[s] in various ways to
  27. # generate a new one to stdout
  28. compile_commands:
  29. working_dir: build-debug
  30. # ignore_args:
  31. # - args to ignore
  32. # additional_args:
  33. # - args to add if missing
  34. # Option to override compilers
  35. compiler_overrides:
  36. gcc: /usr/local/bin/my-special-gcc
  37. g++: /usr/local/bin/my-special-g++
  38. # Filter compile_commands.json
  39. # {directory_,command_,file_,arguments_,output_}filter_regexes
  40. # filter_regexes:
  41. # regex: replacement
  42. # You can specify more than one file that will get merged into one
  43. files:
  44. - compile_commands.json
  45. - compile_commands2.json
  46. # Some options to pass to clangd
  47. clangd:
  48. log_level: verbose
  49. query_driver: /usr/bin/**/clang-*
  50. #extra_args: --pretty
  51. #executable: /usr/local/bin/clangd

NUM_CORES_TO_USE is referenced from the environment in order to cap
parallel jobs to be less than cores+1. Otherwise a machine can be
brought to it’s knees…

Compile Commands

Support was added to this tool in order to cater to the cquery c++
language server. It was easier to provide a script that combined
compile_commands.json than it was to teach cquery to read multiple
files. The regex stuff was added to take compile databases from cross
compiled builds and still run them through cquery.

Similar support was added to start clangd after first generating
compile_commands.json and then passing that directory to clangd.

Usage

  1. ./clip <sub command> <sub command arguments>
  2. Sub commands:
  3. build [profile]
  4. debug
  5. generate-compile-db
  6. start-clangd

TODO

  • clip build --target=profile instead of clip build profile
  • Make “Config” object to handle loading, munging, and accessing
  • tests?
  • more flexible yaml schema for handling debugging targets and tests
  • better schema?
  • give this script some python “love”
    • setup.py?
    • better module layout?