aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEugene Triguba <eugenetriguba@gmail.com>2024-07-04 10:37:02 -0400
committerEugene Triguba <eugenetriguba@gmail.com>2024-07-04 10:37:02 -0400
commit8194817305017008119714e8badc851db3bb0b0a (patch)
treee813a3719a3086a4b43b3784e73e47e1b6145f22
parentInitial Commit (diff)
downloadcli-8194817305017008119714e8badc851db3bb0b0a.zip
Add cmake and clang format
-rw-r--r--.clang-format135
-rw-r--r--.gitignore4
-rw-r--r--CMakeLists.txt19
-rw-r--r--Dockerfile18
-rw-r--r--Makefile22
-rw-r--r--docker-compose.yml1
6 files changed, 169 insertions, 30 deletions
diff --git a/.clang-format b/.clang-format
new file mode 100644
index 0000000..52ba178
--- /dev/null
+++ b/.clang-format
@@ -0,0 +1,135 @@
+---
+Language: Cpp
+# BasedOnStyle: LLVM
+AccessModifierOffset: -2
+AlignAfterOpenBracket: Align
+AlignConsecutiveMacros: false
+AlignConsecutiveAssignments: false
+AlignConsecutiveDeclarations: false
+AlignEscapedNewlines: Right
+AlignOperands: true
+AlignTrailingComments: true
+AllowAllArgumentsOnNextLine: true
+AllowAllConstructorInitializersOnNextLine: true
+AllowAllParametersOfDeclarationOnNextLine: true
+AllowShortBlocksOnASingleLine: Never
+AllowShortCaseLabelsOnASingleLine: false
+AllowShortFunctionsOnASingleLine: All
+AllowShortLambdasOnASingleLine: All
+AllowShortIfStatementsOnASingleLine: Never
+AllowShortLoopsOnASingleLine: false
+AlwaysBreakAfterDefinitionReturnType: None
+AlwaysBreakAfterReturnType: None
+AlwaysBreakBeforeMultilineStrings: false
+AlwaysBreakTemplateDeclarations: MultiLine
+BinPackArguments: true
+BinPackParameters: true
+BraceWrapping:
+ AfterCaseLabel: false
+ AfterClass: false
+ AfterControlStatement: false
+ AfterEnum: false
+ AfterFunction: false
+ AfterNamespace: false
+ AfterObjCDeclaration: false
+ AfterStruct: false
+ AfterUnion: false
+ AfterExternBlock: false
+ BeforeCatch: false
+ BeforeElse: false
+ IndentBraces: false
+ SplitEmptyFunction: true
+ SplitEmptyRecord: true
+ SplitEmptyNamespace: true
+BreakBeforeBinaryOperators: None
+BreakBeforeBraces: Attach
+BreakBeforeInheritanceComma: false
+BreakInheritanceList: BeforeColon
+BreakBeforeTernaryOperators: true
+BreakConstructorInitializersBeforeComma: false
+BreakConstructorInitializers: BeforeColon
+BreakAfterJavaFieldAnnotations: false
+BreakStringLiterals: true
+ColumnLimit: 90
+CommentPragmas: "^ IWYU pragma:"
+CompactNamespaces: false
+ConstructorInitializerAllOnOneLineOrOnePerLine: false
+ConstructorInitializerIndentWidth: 4
+ContinuationIndentWidth: 4
+Cpp11BracedListStyle: true
+DeriveLineEnding: true
+DerivePointerAlignment: false
+DisableFormat: false
+ExperimentalAutoDetectBinPacking: false
+FixNamespaceComments: true
+ForEachMacros:
+ - foreach
+ - Q_FOREACH
+ - BOOST_FOREACH
+IncludeBlocks: Preserve
+IncludeCategories:
+ - Regex: '^"(llvm|llvm-c|clang|clang-c)/'
+ Priority: 2
+ SortPriority: 0
+ - Regex: '^(<|"(gtest|gmock|isl|json)/)'
+ Priority: 3
+ SortPriority: 0
+ - Regex: ".*"
+ Priority: 1
+ SortPriority: 0
+IncludeIsMainRegex: "(Test)?$"
+IncludeIsMainSourceRegex: ""
+IndentCaseLabels: false
+IndentGotoLabels: true
+IndentPPDirectives: None
+IndentWidth: 4
+IndentWrappedFunctionNames: false
+JavaScriptQuotes: Leave
+JavaScriptWrapImports: true
+KeepEmptyLinesAtTheStartOfBlocks: true
+MacroBlockBegin: ""
+MacroBlockEnd: ""
+MaxEmptyLinesToKeep: 1
+NamespaceIndentation: None
+ObjCBinPackProtocolList: Auto
+ObjCBlockIndentWidth: 2
+ObjCSpaceAfterProperty: false
+ObjCSpaceBeforeProtocolList: true
+PenaltyBreakAssignment: 2
+PenaltyBreakBeforeFirstCallParameter: 19
+PenaltyBreakComment: 300
+PenaltyBreakFirstLessLess: 120
+PenaltyBreakString: 1000
+PenaltyBreakTemplateDeclaration: 10
+PenaltyExcessCharacter: 1000000
+PenaltyReturnTypeOnItsOwnLine: 60
+PointerAlignment: Right
+ReflowComments: true
+SortIncludes: true
+SortUsingDeclarations: true
+SpaceAfterCStyleCast: false
+SpaceAfterLogicalNot: false
+SpaceAfterTemplateKeyword: true
+SpaceBeforeAssignmentOperators: true
+SpaceBeforeCpp11BracedList: false
+SpaceBeforeCtorInitializerColon: true
+SpaceBeforeInheritanceColon: true
+SpaceBeforeParens: ControlStatements
+SpaceBeforeRangeBasedForLoopColon: true
+SpaceInEmptyBlock: false
+SpaceInEmptyParentheses: false
+SpacesBeforeTrailingComments: 1
+SpacesInAngles: false
+SpacesInConditionalStatement: false
+SpacesInContainerLiterals: true
+SpacesInCStyleCastParentheses: false
+SpacesInParentheses: false
+SpacesInSquareBrackets: false
+SpaceBeforeSquareBrackets: false
+Standard: Latest
+StatementMacros:
+ - Q_UNUSED
+ - QT_REQUIRE_VERSION
+TabWidth: 8
+UseCRLF: false
+UseTab: Never
diff --git a/.gitignore b/.gitignore
index 9360af8..c1b5a79 100644
--- a/.gitignore
+++ b/.gitignore
@@ -3,3 +3,7 @@
# Build
/justify
+/build
+
+# Editors
+.vscode
diff --git a/CMakeLists.txt b/CMakeLists.txt
new file mode 100644
index 0000000..f5724e8
--- /dev/null
+++ b/CMakeLists.txt
@@ -0,0 +1,19 @@
+cmake_minimum_required(VERSION 3.29)
+project(justify VERSION 0.1.0)
+
+set(CMAKE_C_STANDARD 11)
+set(CMAKE_C_STANDARD_REQUIRED True)
+
+set(CMAKE_C_COMPILER clang)
+set(CMAKE_CXX_COMPILER clang++)
+if (CMAKE_C_COMPILER_ID STREQUAL "Clang")
+ add_compile_options(-Wall -Wextra -ansi)
+endif()
+
+set(SRC_FILES
+ src/linebuffer.c
+ src/word.c
+ src/main.c
+)
+include_directories(src)
+add_executable(justify ${SRC_FILES})
diff --git a/Dockerfile b/Dockerfile
index 7b54f5a..33568a0 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -1,18 +1,22 @@
FROM alpine:3.20.1
RUN apk update && \
- apk upgrade && \
- apk add --no-cache \
+ apk upgrade && \
+ apk add --no-cache \
build-base \
- gdb \
- gcc \
- make \
+ lldb \
+ clang \
+ cmake \
valgrind \
- bash
+ bash \
+ vim
WORKDIR /app
COPY . /app
-RUN make
+RUN mkdir build \
+ && cd build \
+ && cmake .. \
+ && cmake --build .
ENTRYPOINT ["/bin/bash"]
diff --git a/Makefile b/Makefile
deleted file mode 100644
index 7a1ef44..0000000
--- a/Makefile
+++ /dev/null
@@ -1,22 +0,0 @@
-CC = gcc
-OPTIMIZATION_FLAG = -O0
-CC_FLAGS = -Wall -Wextra -pedantic $(OPTIMIZATION_FLAG) -std=c11
-
-SRC_ENTRY_FILE = src/main.c
-SRC_FILES = src/linebuffer.c src/word.c
-
-BUILD_OUTFILE = justify
-
-build: $(SRC_ENTRY_FILE) $(SRC_FILES)
- $(CC) $(SRC_ENTRY_FILE) $(SRC_FILES) -o $(BUILD_OUTFILE) $(CC_FLAGS)
-
-build_optimized: $(SRC_ENTRY_FILE) $(SRC_FILES)
- $(MAKE) OPTIMIZATION_FLAG=-O3 build
-
-memcheck:
- $(MAKE) build
- valgrind --leak-check=full --show-leak-kinds=all --track-origins=yes --verbose ./$(BUILD_OUTFILE)
-
-clean:
- rm -f $(BUILD_OUTFILE) $(TEST_OUTFILE)
-
diff --git a/docker-compose.yml b/docker-compose.yml
index 7679ddf..3df5441 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -7,4 +7,3 @@ services:
volumes:
- .:/app
tty: true
-