Skip to content

Commit

Permalink
Update c++ tools page
Browse files Browse the repository at this point in the history
  • Loading branch information
tobiashienzsch committed May 2, 2020
1 parent 452489d commit 2a92e47
Showing 1 changed file with 38 additions and 11 deletions.
49 changes: 38 additions & 11 deletions chapters/cpp/tools.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,23 @@
- cross platform different warnings
- old versions in distros

## clang-tidy
## clang-format

- Visual Studio
- from terminal/python script
Automatic formatting of source code. A must have in my option. It doesn't matter what configuration you pick, the goal is for your complete code base to look as similar as possible.

## clang-format
```sh
# Formats all files with endings .h .hpp .cpp inplace (overrides).
find . -iname '*.h' -o -iname '*.hpp' -o -iname '*.cpp' | xargs clang-format -i
```

- A must
- Pick a standard
- Visual Studio integration
- python script
## clang-tidy

Static analysis tool. Takes a lot of CPU to run, but finds a lot of valid issuses.

## compiler-explorer

[https://godbolt.org](https://godbolt.org/)

Online compiler. Great for testing small code snippets. Does not currently have `JUCE` installed unfortunately.

## coverage
Expand All @@ -30,6 +33,30 @@ Online compiler. Great for testing small code snippets. Does not currently have

## Makefile/Scripts

- Makefile
- Shell scripts
- Projucer python bindings
I usally wrap all the common commands in a Makefile. Just to save some typing.

```make
CONFIG ?= Release
BUILD_DIR ?= build
GENERATOR ?= Ninja

.PHONY: config
config:
cmake -S. -B$(BUILD_DIR) -G$(GENERATOR) -DCMAKE_BUILD_TYPE=$(CONFIG)

.PHONY: build
build:
cmake --build $(BUILD_DIR) --config $(CONFIG)

.PHONY: test
test:
cd $(BUILD_DIR) && ctest -C $(CONFIG)

.PHONY: clean
clean:
rm -rf $(BUILD_DIR)

.PHONY: format
format:
find . -iname '*.h' -o -iname '*.hpp' -o -iname '*.cpp' | xargs clang-format -i
```

0 comments on commit 2a92e47

Please sign in to comment.