Skip to content

Commit

Permalink
[Base] Initialize project
Browse files Browse the repository at this point in the history
  • Loading branch information
houchen-li committed Mar 2, 2024
0 parents commit c86978c
Show file tree
Hide file tree
Showing 36 changed files with 4,331 additions and 0 deletions.
19 changes: 19 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
BasedOnStyle: Microsoft
UseTab: Never
IndentWidth: 4
ColumnLimit: 100
---
Language: Cpp
PointerAlignment: Left
DerivePointerAlignment: false
AllowShortFunctionsOnASingleLine: All
AlignAfterOpenBracket: BlockIndent
AlignEscapedNewlines: Left
BreakBeforeBraces: Attach
BreakAfterAttributes: Always
AlwaysBreakTemplateDeclarations: Yes
AlwaysBreakBeforeMultilineStrings: true
SortIncludes: CaseInsensitive
InsertNewlineAtEOF: true
---
39 changes: 39 additions & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
---
Checks: |-
clang-diagnostic-*
clang-analyzer-*,
cppcoreguidelines-*,-cppcoreguidelines-avoid-magic-numbers
modernize-*,
WarningsAsErrors: ''
FormatStyle: file
HeaderFilterRegex: ''
CheckOptions:
- key: cert-dcl16-c.NewSuffixes
value: L;LL;LU;LLU
- key: cert-oop54-cpp.WarnOnlyIfThisHasSuspiciousField
value: 0
- key: cppcoreguidelines-explicit-virtual-functions.IgnoreDestructors
value: 1
- key: cppcoreguidelines-non-private-member-variables-in-classes.IgnoreClassesWithAllMemberVariablesBeingPublic
value: 1
- key: google-readability-braces-around-statements.ShortStatementLines
value: 1
- key: google-readability-function-size.StatementThreshold
value: 800
- key: google-readability-namespace-comments.ShortNamespaceLines
value: 10
- key: google-readability-namespace-comments.SpacesBeforeComments
value: 2
- key: modernize-loop-convert.MaxCopySize
value: 16
- key: modernize-loop-convert.MinConfidence
value: reasonable
- key: modernize-loop-convert.NamingStyle
value: CamelCase
- key: modernize-pass-by-value.IncludeStyle
value: llvm
- key: modernize-replace-auto-ptr.IncludeStyle
value: llvm
- key: modernize-use-nullptr.NullMacros
value: NULL
...
22 changes: 22 additions & 0 deletions .github/ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
## *Who* is the bug affecting?
<!-- Ex. All supervisors, Sally Supervisor, Level 1 CCs -->

## *What* is affected by this bug?
<!-- Ex. supervision, sending messages, texter profiles -->

## *When* does this occur?
<!-- Ex. After ending a conversation, every night at 3pm, when I sign off -->

## *Where* on the platform does it happen?
<!-- Ex. In the a Supervisor chat box, on the conversation profile page, on the two-factor screen -->


## *How* do we replicate the issue?
<!-- Please be specific as possible. Use dashes (-) or numbers (1.) to create a list of steps -->


## Expected behavior (i.e. solution)
<!-- What should have happened? -->


## Other Comments
28 changes: 28 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<!--- Provide a general summary of your changes in the Title above -->

## Description
<!--- Describe your changes in detail -->

## Motivation and Context
<!--- Why is this change required? What problem does it solve? -->
<!--- If it fixes an open issue, please link to the issue here. -->

## How has this been tested?
<!--- Please describe in detail how you tested your changes. -->
<!--- Include details of your testing environment, tests ran to see how -->
<!--- your change affects other areas of the code, etc. -->

## Screenshots (if appropriate):

## Types of changes
<!--- What types of changes does your code introduce? Put an `x` in all the boxes that apply: -->
- [ ] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)

## Checklist:
<!--- Go over all the following points, and put an `x` in all the boxes that apply. -->
<!--- If you're unsure about any of these, don't hesitate to ask. We're here to help! -->
- [ ] My code follows the code style of this project.
- [ ] My change requires a change to the documentation.
- [ ] I have updated the documentation accordingly.
16 changes: 16 additions & 0 deletions .github/workflows/clang-format-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: clang-format Check

on: [push, pull_request]

jobs:
formatting-check:
name: Formatting Check
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Run clang-format style check for C/C++ programs.
uses: jidicula/clang-format-action@v4.11.0
with:
clang-format-version: '16'
48 changes: 48 additions & 0 deletions .github/workflows/gcc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: gcc

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

env:
PLATFORM_NAME: gcc-linux_x64

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Get Date
id: get-date
run: |
echo "date=$(/bin/date -u "+%Y%m%d")" >> $GITHUB_OUTPUT
shell: bash

- name: Install latest CMake and Ninja
id: install-cmake
uses: lukka/get-cmake@latest

- name: Cache Outputs
id: cache-outputs
uses: actions/cache@v4
with:
path: |
${{github.workspace}}/out
${{github.workspace}}/third_party
key: ${{runner.os}}-${{steps.get-date.outputs.date}}
restore-keys: |
${{runner.os}}-
- name: Run CMake consuming CMakePresets.json
uses: lukka/run-cmake@v10
with:
configurePreset: ${{env.PLATFORM_NAME}}
configurePresetAdditionalArgs: "['-DCMAKE_C_COMPILER=gcc-13', '-DCMAKE_CXX_COMPILER=g++-13']"
buildPreset: ${{env.PLATFORM_NAME}}
buildPresetAdditionalArgs: "[]"
testPreset: ${{env.PLATFORM_NAME}}
testPresetAdditionalArgs: "[]"
21 changes: 21 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# CMakePresets.json File
CMakeUserPresets.json

# Build Directory
out/
build/

# third-party dependencies
third_party/

# Vscode Configuration
.vscode/

# Clangd Cache
.cache/

# Youcompleteme Configuration
.ycm_extra_conf.py

# Force Include Conf
!conf/**
58 changes: 58 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
cmake_minimum_required(VERSION 3.26.4)

project(modern-osqp-cpp
LANGUAGES
C
CXX
)

set(CMAKE_C_STANDARD 17)
set(CMAKE_C_STANDARD_REQUIRED True)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED True)

set(CMAKE_C_FLAGS_DEBUG "-Og -g")
set(CMAKE_CXX_FLAGS_DEBUG "-Og -g")

set(CMAKE_C_FLAGS_RELEASE "-O2 -DNDEBUG")
set(CMAKE_CXX_FLAGS_RELEASE "-O2 -DNDEBUG")

set(CMAKE_C_FLAGS_RELWITHDEBINFO "-O2 -g -DNDEBUG")
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -g -DNDEBUG")

set(CMAKE_C_FLAGS_MINSIZEREL "-Os -DNDEBUG")
set(CMAKE_CXX_FLAGS_MINSIZEREL "-Os -DNDEBUG")

set(CMAKE_COMPILE_WARNING_AS_ERROR True)

add_compile_options(
-pipe
-fno-plt
-fexceptions
-fstack-clash-protection
-fcf-protection
-Wall
-Wextra
-Wpedantic
-Wno-unused-parameter
)

set(CPM_SOURCE_CACHE third_party)
set(CPM_USE_LOCAL_PACKAGES True)

add_compile_definitions(
SPDLOG_ACTIVE_LEVEL=SPDLOG_LEVEL_TRACE
DOCTEST_CONFIG_SUPER_FAST_ASSERTS
)

include(CTest)
enable_testing()

include(cmake/CPM.cmake)
include(cmake/third_party.cmake)
include(cmake/utils.cmake)

include_directories(${PROJECT_SOURCE_DIR})

add_subdirectory(src)
add_subdirectory(tests)
104 changes: 104 additions & 0 deletions CMakePresets.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
{
"version": 8,
"configurePresets": [
{
"name": "base_configure",
"displayName": "Base Configure",
"description": "Base configuration for all presets",
"generator": "Ninja",
"binaryDir": "${sourceDir}/out/build/${presetName}",
"installDir": "${sourceDir}/out/install/${presetName}",
"cacheVariables": {
"CMAKE_EXPORT_COMPILE_COMMANDS": true
}
},
{
"name": "gcc-linux_x64",
"displayName": "GCC 13.2.1 x86_64-pc-linux-gnu",
"description": "Using compilers: C = /usr/bin/gcc, CXX = /usr/bin/g++",
"inherits": [
"base_configure"
],
"cacheVariables": {
"CMAKE_C_COMPILER": "/usr/bin/gcc",
"CMAKE_CXX_COMPILER": "/usr/bin/g++",
"CMAKE_C_FLAGS": "-march=native -Wp,-D_FORTIFY_SOURCE=2",
"CMAKE_CXX_FLAGS": "-march=native -Wp,-D_FORTIFY_SOURCE=2",
"CMAKE_BUILD_TYPE": "Release"
}
},
{
"name": "clang-linux_x64",
"displayName": "Clang 16.0.6 x86_64-pc-linux-gnu",
"description": "Using compilers: C = /usr/bin/clang, CXX = /usr/bin/clang++",
"inherits": [
"base_configure"
],
"cacheVariables": {
"CMAKE_C_COMPILER": "/usr/bin/clang",
"CMAKE_CXX_COMPILER": "/usr/bin/clang++",
"CMAKE_C_FLAGS": "-march=native -Wp,-D_FORTIFY_SOURCE=2",
"CMAKE_CXX_FLAGS": "-march=native -Wp,-D_FORTIFY_SOURCE=2",
"CMAKE_BUILD_TYPE": "Release"
}
}
],
"buildPresets": [
{
"name": "base_build",
"displayName": "Base Build",
"configurePreset": "base_configure",
"targets": "all",
"jobs": 0
},
{
"name": "gcc-linux_x64",
"displayName": "GCC 13.2.1 x86_64-pc-linux-gnu",
"configurePreset": "gcc-linux_x64",
"inheritConfigureEnvironment": true,
"inherits": [
"base_build"
]
},
{
"name": "clang-linux_x64",
"displayName": "Clang 16.0.6 x86_64-pc-linux-gnu",
"configurePreset": "clang-linux_x64",
"inheritConfigureEnvironment": true,
"inherits": [
"base_build"
]
}
],
"testPresets": [
{
"name": "base_test",
"displayName": "Base Test",
"configurePreset": "base_configure",
"output": {
"outputOnFailure": true
},
"execution": {
"jobs": 0
}
},
{
"name": "gcc-linux_x64",
"displayName": "GCC 13.2.1 x86_64-pc-linux-gnu",
"configurePreset": "gcc-linux_x64",
"inheritConfigureEnvironment": true,
"inherits": [
"base_test"
]
},
{
"name": "clang-linux_x64",
"displayName": "Clang 16.0.6 x86_64-pc-linux-gnu",
"configurePreset": "clang-linux_x64",
"inheritConfigureEnvironment": true,
"inherits": [
"base_test"
]
}
]
}
28 changes: 28 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
BSD 3-Clause License

Copyright (c) 2024, Houchen Li

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.

3. Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Loading

0 comments on commit c86978c

Please sign in to comment.