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

YT-CPPAP-1: Repository cleanup and preparation for version 1.1 #42

Merged
merged 6 commits into from
Mar 24, 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
62 changes: 17 additions & 45 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -1,76 +1,48 @@
---
Language: Cpp
Standard: Latest
Standard: c++20
DisableFormat: false


# General
IndentWidth: 4
TabWidth: 4
UseTab: Never
ColumnLimit: 80
ColumnLimit: 100
ContinuationIndentWidth: 4


# Alignment options
AlignAfterOpenBracket: BlockIndent
AlignArrayOfStructures: Right
AlignConsecutiveAssignments:
Enabled: false
AcrossEmptyLines: false
AcrossComments: false
AlignCompound: false
PadOperators: false
AlignConsecutiveBitFields:
Enabled: false
AcrossEmptyLines: false
AcrossComments: false
AlignCompound: false
PadOperators: false
AlignConsecutiveDeclarations:
Enabled: false
AcrossEmptyLines: false
AcrossComments: false
AlignCompound: false
PadOperators: false
AlignConsecutiveMacros:
Enabled: false
AcrossEmptyLines: false
AcrossComments: false
AlignCompound: false
PadOperators: false
AlignConsecutiveAssignments: false
AlignConsecutiveBitFields: false
AlignConsecutiveDeclarations: false
AlignConsecutiveMacros: false
AlignConsecutiveShortCaseStatements:
Enabled: true
AcrossEmptyLines: true
AcrossComments: true
AlignCaseColons: false
Enabled: false
AlignEscapedNewlines: Left
AlignOperands: AlignAfterOperator
AlignTrailingComments:
Kind: Always
OverEmptyLines: 0
AlignTrailingComments: false

AllowAllArgumentsOnNextLine: true
AllowAllParametersOfDeclarationOnNextLine: true
AllowShortBlocksOnASingleLine: Empty
AllowShortCaseLabelsOnASingleLine: false
AllowShortEnumsOnASingleLine: true
AllowShortFunctionsOnASingleLine: Inline
AllowShortFunctionsOnASingleLine: Empty
AllowShortIfStatementsOnASingleLine: Never
AllowShortLambdasOnASingleLine: Inline
AllowShortLambdasOnASingleLine: All
AllowShortLoopsOnASingleLine: false

AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: false
AlwaysBreakTemplateDeclarations: Yes
BreakAfterAttributes: Leave
BreakAfterJavaFieldAnnotations: true
BreakArrays: false
BreakAfterAttributes: Never
BreakBeforeBinaryOperators: NonAssignment
BreakBeforeBraces: Custom
BreakBeforeConceptDeclarations: Always
BreakBeforeInlineASMColon: OnlyMultiline
BreakBeforeTernaryOperators: true
BreakConstructorInitializers: BeforeColon
BreakInheritanceList: BeforeColon
Expand Down Expand Up @@ -123,14 +95,14 @@ ShortNamespaceLines: 0

IndentAccessModifiers: false
AccessModifierOffset: -4
ConstructorInitializerIndentWidth: 4
ConstructorInitializerIndentWidth: 0
EmptyLineAfterAccessModifier: Never
EmptyLineBeforeAccessModifier: LogicalBlock
PackConstructorInitializers: NextLine
SeparateDefinitionBlocks: Leave
SeparateDefinitionBlocks: Always

IndentCaseBlocks: true
IndentCaseLabels: true
IndentCaseBlocks: false
IndentCaseLabels: false

IndentWrappedFunctionNames: false
LambdaBodyIndentation: Signature
Expand All @@ -154,7 +126,7 @@ SpaceAfterLogicalNot: true
SpaceAfterTemplateKeyword: true
SpaceAroundPointerQualifiers: Default
SpaceBeforeAssignmentOperators: true
SpaceBeforeCaseColon: true
SpaceBeforeCaseColon: false
SpaceBeforeCpp11BracedList: false
SpaceBeforeCtorInitializerColon: true
SpaceBeforeParens: Custom
Expand All @@ -164,7 +136,7 @@ SpaceBeforeParensOptions:
AfterFunctionDeclarationName: false
AfterFunctionDefinitionName: false
AfterIfMacros: false
AfterOverloadedOperator: true
AfterOverloadedOperator: false
AfterRequiresInClause: false
AfterRequiresInExpression: false
BeforeNonEmptyParentheses: false
Expand Down
15 changes: 9 additions & 6 deletions .github/workflows/clang.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@ on:
push:
branches:
- '*'
pull_request:
branches:
- master

jobs:
build:
Expand All @@ -16,14 +13,20 @@ jobs:
- name: Checkout
uses: actions/checkout@v2

- name: Prepare
shell: bash
run: |
sudo bash ./scripts/env/install_clang17_toolchain.sh
continue-on-error: false

- name: Build
shell: bash
env:
CC: clang-14
CXX: clang++-14
CC: clang-17
CXX: clang++-17
run: |
cd example
cmake -B build -DCMAKE_CXX_COMPILER=clang++-14
cmake -B build -DCMAKE_CXX_COMPILER=clang++-17 -DCMAKE_C_COMPILER=clang-17
cd build
make
continue-on-error: false
25 changes: 25 additions & 0 deletions .github/workflows/format.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: format
on:
push:
branches:
- '*'

jobs:
build:
name: Test code formatting
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v2

- name: Prepare
shell: bash
run: |
sudo bash ./scripts/env/install_clang17_toolchain.sh
continue-on-error: false

- name: Test formatting
shell: bash
run: |
bash ./scripts/format/unix.sh --check
5 changes: 1 addition & 4 deletions .github/workflows/gpp.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@ on:
push:
branches:
- '*'
pull_request:
branches:
- master

jobs:
build:
Expand All @@ -23,7 +20,7 @@ jobs:
CXX: g++-11
run: |
cd example
cmake -B build -DCMAKE_CXX_COMPILER=g++-11
cmake -B build -DCMAKE_CXX_COMPILER=g++-11 -DCMAKE_C_COMPILER=gcc-11
cd build
make
continue-on-error: false
8 changes: 4 additions & 4 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@ on:
push:
branches:
- '*'
pull_request:
branches:
- master

jobs:
build_and_test:
Expand All @@ -17,9 +14,12 @@ jobs:
uses: actions/checkout@v2

- name: Prepare
env:
CC: gcc-11
CXX: g++-11
run: |
cd test
cmake -B build -DCMAKE_CXX_COMPILER=g++-11
cmake -B build -DCMAKE_CXX_COMPILER=g++-11 -DCMAKE_C_COMPILER=gcc-11
continue-on-error: false

- name: Build test executable
Expand Down
85 changes: 54 additions & 31 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Command-line argument parser for C++20
[![g++](https://github.com/SpectraL519/cpp-ap/actions/workflows/gpp.yaml/badge.svg)](https://github.com/SpectraL519/cpp-ap/actions/workflows/g++)
[![clang++](https://github.com/SpectraL519/cpp-ap/actions/workflows/clang.yaml/badge.svg)](https://github.com/SpectraL519/cpp-ap/actions/workflows/clang++)
[![test](https://github.com/SpectraL519/cpp-ap/actions/workflows/test.yaml/badge.svg)](https://github.com/SpectraL519/cpp-ap/actions/workflows/test)
[![format](https://github.com/SpectraL519/cpp-ap/actions/workflows/format.yaml/badge.svg)](https://github.com/SpectraL519/cpp-ap/actions/workflows/format)

<br />

Expand Down Expand Up @@ -34,11 +35,12 @@ The `CPP-AP` library does not require installing any additional tools or heavy l
* [Parsing arguments](#parsing-arguments)
* [Examples](#examples)
* [Dev notes](#dev-notes)
* [Requirements](#requirements)
* [Building and testing](#building-and-testing)
* [Formatting](#formatting)
* [Documentation](#documentation)
* [Compiler support](#compiler-support)
* [Licence](#licence)
* [Change log](change_log.md)

<br />
<br />
Expand Down Expand Up @@ -410,7 +412,7 @@ Open your terminal in the project's example directory:
cd <project-root>/example
```

The examples' source files are in the `<project-root>/example/src` directory.
The examples' source files are in the `<project-root>/example/source` directory.

> **Note:** Each source file is a sepparate example.

Expand All @@ -437,55 +439,74 @@ The compiled binaries will appear in the `<project-root>/example/build/bin` dire

## Dev notes

#### Requirements:
* Supported compiler (check compiler support [here](#compiler-support))
* clang-format-17 ([ubuntu download tutorial](https://ubuntuhandbook.org/index.php/2023/09/how-to-install-clang-17-or-16-in-ubuntu-22-04-20-04/amp/?fbclid=IwAR1ZfJpoiitjwn8aMlKVWpFdkYmUqtaQwraJBju09v1gtc0jQANTgVeCuMY))
### Building and testing:

<br />
First build the testing executable:

#### Building and testing:
```shell
cd <project-root>/test/
cmake -B build
cd build
make
```

1. Build the testing executable:
or alternatively:

```shell
cd <project-root>/test/
cmake -B build
cd build
make
```
```shell
cd <project-root>/test/
mkdir build && cd build
cmake ..
make
```

or
> **NOTE:** Building on Windows - use the `-G "Unix Makefiles"` option when running CMake to build a GNU Make project instead of a default Visual Studio project.

```shell
cd <project-root>/test/
mkdir build && cd build
cmake ..
make
```
Run the tests:

2. Run tests
> **NOTE:** The test executable is generated in the `<project-root>/test/build` directory.

* All tests:

Run all tests:
```shell
cd <project-root>/test/build
./test
```

Run a single test suite:
* A single test suite:

```shell
./test -ts="<test-suite-name>"
```

> **Note**: Test suites in the project have the same name as the files they're in.

3. Tips and tricks:
<br />

* Changing the CMake generator:
### Formatting

If you wish for CMake to generate a different type of project, use the `-G` option, e.g. (building a Make project on Windows instead of a VS project):
```
cmake -G "Unix Makefiles"
```
> **NOTE:** To ensure new line encoding compatibility the project uses unix new line encoding.
>
> This can be set using the `git config --global core.autocrlf true` command.
> More details can be found [here](https://docs.github.com/en/get-started/getting-started-with-git/configuring-git-to-handle-line-endings)

> **NOTE:** The project uses `clang-format-17`.
>
> To install this tool on ubuntu run `sudo bash ./scripts/env/install_clang17_toolchain.sh`.
>
> On windows you can download the LLVM package from the official LLVM [GitHub release page](https://github.com/llvm/llvm-project/releases/tag/llvmorg-17.0.1)

To format the code use run the following:

```shell
# Unix platforms
./scripts/format/unix.sh
```

```shell
# Windows: powershell
./scripts/format/windows.ps1
```

To run a forrmat check use the scripts mentioned above with a `--check` flag.

<br />
<br />
Expand All @@ -511,6 +532,8 @@ The documentation for this project can be generated using Doxygen:

As of now the project supports the **GNU G++** and **Clang++** compilers with `C++20` support on Linux and Windows.

> **NOTE:** To build the project using clang you will need to install the `clang-17` toolchain using the script or website mentioned in the [Formatting](#formatting) section.

<br />
<br />

Expand Down
Loading
Loading