Skip to content

Commit

Permalink
Clang: Format
Browse files Browse the repository at this point in the history
  • Loading branch information
Iswenzz committed May 26, 2024
1 parent d3df1a0 commit 1bb76b4
Show file tree
Hide file tree
Showing 40 changed files with 5,719 additions and 5,673 deletions.
32 changes: 32 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
BasedOnStyle: Google
ColumnLimit: 120
IndentWidth: 4
TabWidth: 4
UseTab: Always
ReflowComments: false
AccessModifierOffset: -4
IncludeBlocks: Preserve
BreakBeforeBraces: Allman
BreakBeforeTernaryOperators: true
BreakBeforeBinaryOperators: NonAssignment
SpaceInEmptyBlock: true
SpacesBeforeTrailingComments: 1
SpaceAfterTemplateKeyword: true
IndentAccessModifiers: false
IndentRequiresClause: false
IndentCaseLabels: false
IndentPPDirectives: BeforeHash
InsertNewlineAtEOF: true
BinPackArguments: true
BinPackParameters: true
PackConstructorInitializers: BinPack
NamespaceIndentation: All
Cpp11BracedListStyle: false
FixNamespaceComments: false
AlignAfterOpenBracket: DontAlign
AlignOperands: false
AllowShortLoopsOnASingleLine: false
AllowShortBlocksOnASingleLine: Empty
AllowShortFunctionsOnASingleLine: Empty
AllowShortIfStatementsOnASingleLine: Never
AllowAllArgumentsOnNextLine: false
6 changes: 6 additions & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Checks: >
-*
clang-analyzer-*
WarningsAsErrors: "*"
FormatStyle: file
8 changes: 8 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
root = true

[*]
charset = utf-8
indent_style = tab
indent_size = 4
insert_final_newline = true
trim_trailing_whitespace = true
112 changes: 56 additions & 56 deletions .github/workflows/linux.yml
Original file line number Diff line number Diff line change
@@ -1,71 +1,71 @@
name: Linux

on:
push:
branches: [master]
pull_request:
branches: [master]
push:
branches: [master]
pull_request:
branches: [master]

jobs:
build:
runs-on: ubuntu-18.04
steps:
- name: Checkout
uses: actions/checkout@v2
build:
runs-on: ubuntu-18.04
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Vcpkg
uses: lukka/run-vcpkg@v11
with:
vcpkgGitCommitId: 4a600e9fea71bd7872080cbb716797e04d30e6d3
- name: Vcpkg
uses: lukka/run-vcpkg@v11
with:
vcpkgGitCommitId: 4a600e9fea71bd7872080cbb716797e04d30e6d3

- name: NASM
uses: ilammy/setup-nasm@v1
- name: NASM
uses: ilammy/setup-nasm@v1

- name: Dependencies
run: |
sudo apt-get install g++-multilib gcc-multilib
sudo dpkg --add-architecture i386
sudo apt-get install nasm:i386 paxctl:i386 libtommath-dev:i386
- name: Dependencies
run: |
sudo apt-get install g++-multilib gcc-multilib
sudo dpkg --add-architecture i386
sudo apt-get install nasm:i386 paxctl:i386 libtommath-dev:i386
- name: GCC
uses: egor-tensin/setup-gcc@v1
with:
version: 9
platform: x86
- name: GCC
uses: egor-tensin/setup-gcc@v1
with:
version: 9
platform: x86

- name: Plugin Interface
run: |
cd ..
curl -o plugin.zip https://iswenzz.com/github/gsclib/plugin.zip
7z x plugin.zip
- name: Plugin Interface
run: |
cd ..
curl -o plugin.zip https://iswenzz.com/github/gsclib/plugin.zip
7z x plugin.zip
- name: Build
run: |
mkdir build && cd build
cmake .. -DCMAKE_TOOLCHAIN_FILE=".vcpkg/linux.cmake" -DBUILD_TESTING=True
cmake --build .
- name: Build
run: |
mkdir build && cd build
cmake .. --preset linux -DBUILD_TESTING=True
cmake --build .
- name: Artifact
uses: actions/upload-artifact@v2
with:
name: build-artifact
path: build
- name: Artifact
uses: actions/upload-artifact@v2
with:
name: build-artifact
path: build

tests:
runs-on: ubuntu-18.04
needs: [build]
steps:
- name: Checkout
uses: actions/checkout@v2
tests:
runs-on: ubuntu-18.04
needs: [build]
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Artifact
uses: actions/download-artifact@v2
with:
name: build-artifact
path: build
- name: Artifact
uses: actions/download-artifact@v2
with:
name: build-artifact
path: build

- name: Tests
working-directory: build
run: |
chmod +x bin/gsclib.Tests
ctest -C Release
- name: Tests
working-directory: build
run: |
chmod +x bin/gsclib.Tests
ctest -C Release
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ set(CMAKE_STATIC_LIBRARY_PREFIX "")
# CMake
add_definitions(-D_CRT_SECURE_NO_WARNINGS -DWIN32_LEAN_AND_MEAN)
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
include(ClangTools)

# CPack
set(CPACK_PROJECT_NAME ${PROJECT_NAME})
Expand Down
23 changes: 23 additions & 0 deletions CMakePresets.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"version": 7,
"cmakeMinimumRequired": {
"major": 3,
"minor": 27,
"patch": 0
},
"configurePresets": [
{
"name": "windows",
"generator": "MinGW Makefiles",
"cacheVariables": {
"CMAKE_TOOLCHAIN_FILE": ".vcpkg/windows.cmake"
}
},
{
"name": "linux",
"cacheVariables": {
"CMAKE_TOOLCHAIN_FILE": ".vcpkg/linux.cmake"
}
}
]
}
56 changes: 33 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,29 @@
[![CodeFactor](https://img.shields.io/codefactor/grade/github/Iswenzz/gsclib?label=codefactor&logo=codefactor)](https://www.codefactor.io/repository/github/iswenzz/gsclib)
[![License](https://img.shields.io/github/license/Iswenzz/gsclib?color=blue&logo=gitbook&logoColor=white)](https://github.com/Iswenzz/gsclib/blob/master/LICENSE)

``gsclib`` acts as a standard library extension for the Call of Duty 4 scripting language. The features this library provides consists of an FTP/FTPS/SFTP client, an HTTP/HTTPS client, Regular Expression (PCRE2) support, Language Integrated Query (Linq) support, a MySQL connector for databases, casting/type conversion/fmt and other type utilities, ZIP files, async workers, and much more. More detailed information on each feature can be found in the documentation section.
`gsclib` acts as a standard library extension for the Call of Duty 4 scripting language. The features this library provides consists of an FTP/FTPS/SFTP client, an HTTP/HTTPS client, Regular Expression (PCRE2) support, Language Integrated Query (Linq) support, a MySQL connector for databases, casting/type conversion/fmt and other type utilities, ZIP files, async workers, and much more. More detailed information on each feature can be found in the documentation section.

## Features & Documentation
* [HTTP/HTTPS Client](https://github.com/Iswenzz/gsclib/blob/master/docs/http.md)
* [FTP/FTPS/SFTP Client](https://github.com/Iswenzz/gsclib/blob/master/docs/ftp.md)
* [Regular Expression (PCRE2)](https://github.com/Iswenzz/gsclib/blob/master/docs/regex.md)
* [Language Integrated Query (Linq)](https://github.com/Iswenzz/gsclib/blob/master/docs/linq.md)
* [MySQL](https://github.com/Iswenzz/gsclib/blob/master/docs/mysql.md)
* [Critical Sections](https://github.com/Iswenzz/gsclib/blob/master/docs/critical.md)
* [Utilities](https://github.com/Iswenzz/gsclib/blob/master/docs/utility.md)
* [File](https://github.com/Iswenzz/gsclib/blob/master/docs/file.md)
* [System](https://github.com/Iswenzz/gsclib/blob/master/docs/system.md)
* [Zip](https://github.com/Iswenzz/gsclib/blob/master/docs/zip.md)
* [Player](https://github.com/Iswenzz/gsclib/blob/master/docs/player.md)
* [Math](https://github.com/Iswenzz/gsclib/blob/master/docs/math.md)

- [HTTP/HTTPS Client](https://github.com/Iswenzz/gsclib/blob/master/docs/http.md)
- [FTP/FTPS/SFTP Client](https://github.com/Iswenzz/gsclib/blob/master/docs/ftp.md)
- [Regular Expression (PCRE2)](https://github.com/Iswenzz/gsclib/blob/master/docs/regex.md)
- [Language Integrated Query (Linq)](https://github.com/Iswenzz/gsclib/blob/master/docs/linq.md)
- [MySQL](https://github.com/Iswenzz/gsclib/blob/master/docs/mysql.md)
- [Critical Sections](https://github.com/Iswenzz/gsclib/blob/master/docs/critical.md)
- [Utilities](https://github.com/Iswenzz/gsclib/blob/master/docs/utility.md)
- [File](https://github.com/Iswenzz/gsclib/blob/master/docs/file.md)
- [System](https://github.com/Iswenzz/gsclib/blob/master/docs/system.md)
- [Zip](https://github.com/Iswenzz/gsclib/blob/master/docs/zip.md)
- [Player](https://github.com/Iswenzz/gsclib/blob/master/docs/player.md)
- [Math](https://github.com/Iswenzz/gsclib/blob/master/docs/math.md)

## Instructions
In order to use this library, you'll need to compile the binary and place it to the CoD4 ``plugins`` directory.
Then you can simply use ``loadplugin gsclib`` in your ``server.cfg`` or as CLI arguments.

To initialize gsclib library you need to call ``GSCLIB_Init()`` at the start of your mod entry point.
In order to use this library, you'll need to compile the binary and place it to the CoD4 `plugins` directory.
Then you can simply use `loadplugin gsclib` in your `server.cfg` or as CLI arguments.

To initialize gsclib library you need to call `GSCLIB_Init()` at the start of your mod entry point.

```c
main()
Expand All @@ -34,37 +36,45 @@ main()
```

## Server

1. Edit plugin_handler.h then recompile the server with a clean obj directory:

```c
#define MAX_SCRIPTFUNCTIONS 256
```
## Building (Linux)
_Pre-Requisites:_
1. [CGSC](https://github.com/Iswenzz/CGSC) and it's pre-requisites.
2. [CMake](https://cmake.org/) and [vcpkg](https://vcpkg.io/en/).
_Build Command:_
mkdir build && cd build
cmake .. -DCMAKE_TOOLCHAIN_FILE=.vcpkg/linux.cmake
cmake --build .
mkdir build && cd build
cmake .. --preset linux
cmake --build .
## Building (Windows)
_Pre-Requisites:_
1. [CGSC](https://github.com/Iswenzz/CGSC) and it's pre-requisites.
2. [CMake](https://cmake.org/) and [vcpkg](https://vcpkg.io/en/).
_Build Command:_
mkdir build && cd build
cmake .. -G "MinGW Makefiles" -DCMAKE_TOOLCHAIN_FILE=.vcpkg/windows.cmake
cmake --build .
mkdir build && cd build
cmake .. --preset windows
cmake --build .
## [Download](https://github.com/Iswenzz/gsclib/releases)
## Troubleshouting
For resolving missing dependencies you can use the [ldd](https://man7.org/linux/man-pages/man1/ldd.1.html) command for Linux, and [Dependency Walker](https://www.dependencywalker.com/) for Windows.
## Contributors:
***Note:*** If you would like to contribute to this repository, feel free to send a pull request, and I will review your code. Also feel free to post about any problems that may arise in the issues section of the repository.
**_Note:_** If you would like to contribute to this repository, feel free to send a pull request, and I will review your code. Also feel free to post about any problems that may arise in the issues section of the repository.
12 changes: 12 additions & 0 deletions cmake/ClangTools.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

add_custom_target(clang-tidy
COMMAND find . -type f \( -name '*.c' -o -name '*.h' \) -not -path './build/*' -exec clang-tidy --config-file=.clang-tidy {} +
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})

add_custom_target(clang-format
COMMAND find . -type f \( -name '*.c' -o -name '*.h' \) -not -path './build/*' -exec clang-format -style=file -i --verbose {} +
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})

set_target_properties(clang-tidy PROPERTIES FOLDER Clang)
set_target_properties(clang-format PROPERTIES FOLDER Clang)
34 changes: 17 additions & 17 deletions src/__test__/main.test.c
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
#include <greatest.h>
GREATEST_MAIN_DEFS();

extern SUITE(Suite_data_regex);
extern SUITE(Suite_data_zip);
extern SUITE(Suite_utils_vsnprintf);

int main(int argc, char** argv)
{
GREATEST_MAIN_BEGIN();

RUN_SUITE(Suite_data_regex);
RUN_SUITE(Suite_data_zip);
RUN_SUITE(Suite_utils_vsnprintf);

GREATEST_MAIN_END();
}
#include <greatest.h>
GREATEST_MAIN_DEFS();

extern SUITE(Suite_data_regex);
extern SUITE(Suite_data_zip);
extern SUITE(Suite_utils_vsnprintf);

int main(int argc, char** argv)
{
GREATEST_MAIN_BEGIN();

RUN_SUITE(Suite_data_regex);
RUN_SUITE(Suite_data_zip);
RUN_SUITE(Suite_utils_vsnprintf);

GREATEST_MAIN_END();
}
Loading

0 comments on commit 1bb76b4

Please sign in to comment.