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

Makefile: add clang-format #176

Merged
merged 2 commits into from
Oct 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
---
BasedOnStyle: LLVM
Language: Cpp
Standard: Cpp03
AccessModifierOffset: -2
IndentWidth: 2
TabWidth: 8
ColumnLimit: 100
UseTab: Never
IndentCaseLabels: true
AlignAfterOpenBracket: true
AlignEscapedNewlines: Left
BreakConstructorInitializers: BeforeComma
AllowShortBlocksOnASingleLine: false
DerivePointerAlignment: false
PointerAlignment: Left
BinPackParameters: true
BinPackArguments: true
AllowShortIfStatementsOnASingleLine: true
CompactNamespaces: true
AlignOperands: true
SpacesInContainerLiterals: true
ConstructorInitializerAllOnOneLineOrOnePerLine: false
Cpp11BracedListStyle: false
AlwaysBreakTemplateDeclarations: true
BreakBeforeInheritanceComma: true
...

18 changes: 16 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,12 @@ install-valgrind-if-missing: update-apt-cache-if-needed
sudo snap install valgrind --classic;\
)

install-clang-format-if-missing: update-apt-cache-if-needed
@clang-format --version >/dev/null 2>&1 || (\
echo "clang-format not found in the system, install it.";\
sudo apt install -y clang-format;\
)

install-ccm-if-missing:
@ccm list >/dev/null 2>&1 || (\
echo "CCM not found in the system, install it.";\
Expand Down Expand Up @@ -158,9 +164,17 @@ fix-cargo-fmt: install-cargo-if-missing _update-rust-tooling
@echo "Running \"cargo fmt --verbose --all\" in ./scylla-rust-wrapper"
@cd ${CURRENT_DIR}/scylla-rust-wrapper; cargo fmt --verbose --all

check: check-cargo check-cargo-clippy check-cargo-fmt
check-clang-format: install-clang-format-if-missing
@echo "Running \"clang-format --dry-run\" on all files in ./src"
@find src -regextype posix-egrep -regex '.*\.(cpp|hpp|c|h)' -not -path 'src/third_party/*' | xargs clang-format --dry-run

fix-clang-format: install-clang-format-if-missing
@echo "Running \"clang-format -i\" on all files in ./src"
@find src -regextype posix-egrep -regex '.*\.(cpp|hpp|c|h)' -not -path 'src/third_party/*' | xargs clang-format -i

check: check-clang-format check-cargo check-cargo-clippy check-cargo-fmt

fix: fix-cargo fix-cargo-clippy fix-cargo-fmt
fix: fix-clang-format fix-cargo fix-cargo-clippy fix-cargo-fmt

prepare-integration-test: update-apt-cache-if-needed install-valgrind-if-missing install-cargo-if-missing _update-rust-tooling
@sudo sh -c "echo 2097152 >> /proc/sys/fs/aio-max-nr"
Expand Down
4 changes: 1 addition & 3 deletions src/driver_info.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,7 @@

namespace datastax { namespace internal {

const char* driver_name() {
return "Scylla Shard-Aware C/C++ Driver";
}
const char* driver_name() { return "Scylla Shard-Aware C/C++ Driver"; }

const char* driver_version() {
if (strlen(CASS_VERSION_SUFFIX) == 0) {
Expand Down
2 changes: 1 addition & 1 deletion src/macros.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
STATIC_ASSERT_CONCAT(STATIC_ASSERTION_FAILED_AT_LINE_, __LINE__); \
}; \
typedef StaticAssertTest<sizeof(STATIC_ASSERT_CONCAT(__static_assertion_at_line_, __LINE__))> \
STATIC_ASSERT_CONCAT(__static_assertion_test_at_line_, __LINE__)
STATIC_ASSERT_CONCAT(__static_assertion_test_at_line_, __LINE__)

template <bool>
struct StaticAssert;
Expand Down
Loading