Skip to content

Commit

Permalink
MASSIVE STYLE CHANGES and several environment updates
Browse files Browse the repository at this point in the history
Environment Updates
  • Loading branch information
Mag1str02 authored Nov 22, 2024
2 parents e9274d1 + 8417c8f commit 8fc0096
Show file tree
Hide file tree
Showing 260 changed files with 5,724 additions and 5,842 deletions.
55 changes: 55 additions & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
---

Checks: '-*,cppcoreguidelines-avoid-goto,cppcoreguidelines-pro-type-const-cast, google-runtime-int, modernize-use-nullptr, readability-container-size-empty, readability-redundant-control-flow, readability-identifier-naming, readability-implicit-bool-conversion, google-explicit-constructor'

CheckOptions:
- key: readability-identifier-naming.NamespaceCase
value: CamelCase
- key: readability-identifier-naming.ClassCase
value: CamelCase
- key: readability-identifier-naming.StructCase
value: CamelCase
- key: readability-identifier-naming.TypedefCase
value: CamelCase
- key: readability-identifier-naming.TypeAliasCase
value: CamelCase
- key: readability-identifier-naming.FunctionCase
value: CamelCase
- key: readability-identifier-naming.ParameterCase
value: lower_case
- key: readability-identifier-naming.VariableCase
value: lower_case
- key: readability-identifier-naming.PrivateMemberCase
value: lower_case
- key: readability-identifier-naming.PrivateMemberSuffix
value: '_'
- key: readability-identifier-naming.GlobalConstantCase
value: CamelCase
- key: readability-identifier-naming.GlobalConstantPrefix
value: k
- key: readability-identifier-naming.StaticConstantCase
value: CamelCase
- key: readability-identifier-naming.StaticConstantPrefix
value: k
- key: readability-identifier-naming.ConstexprVariableCase
value: CamelCase
- key: readability-identifier-naming.ConstexprVariablePrefix
value: k
- key: readability-identifier-naming.TypeTemplateParameterCase
value: CamelCase
- key: readability-simplify-boolean-expr.ChainedConditionalReturn
value: '1'
- key: readability-simplify-boolean-expr.ChainedConditionalAssignment
value: '1'
- key: readability-identifier-naming.TypeTemplateParameterIgnoredRegexp
value: expr-type
- key: readability-identifier-naming.StaticVariableCase
value: CamelCase
- key: readability-identifier-naming.StaticVariablePrefix
value: 's'
- key: readability-identifier-naming.GlobalVariableCase
value: CamelCase
- key: readability-identifier-naming.GlobalVariablePrefix
value: 'g'
- key: readability-identifier-naming.PublicMemberCase
value: CamelCase
46 changes: 0 additions & 46 deletions .github/workflows/build.yml

This file was deleted.

27 changes: 0 additions & 27 deletions .github/workflows/code_style.yml

This file was deleted.

114 changes: 114 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
name: Checks

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

jobs:
BuildWindows:
runs-on: windows-latest
name: Build Windows
strategy:
fail-fast: false
matrix:
build_type: [RelWithDebInfo]
steps:
- name: Checkout Repository
uses: actions/checkout@v4
with:
submodules: 'true'
- name: Install clang
uses: msys2/setup-msys2@v2
with:
location: D:\
update: true
install: >-
mingw-w64-clang-x86_64-clang
mingw-w64-clang-x86_64-ninja
- name: Add msys to path
run: |
echo "D:\msys64\clang64\bin\" | Out-File -Append -FilePath $env:GITHUB_PATH -Encoding utf8
- name: Build
uses: threeal/[email protected]
with:
source-dir: ${{ github.workspace }}
build-dir: ${{ github.workspace }}/build
generator: Ninja
cxx-compiler: clang++
c-compiler: clang
build-args: --target DummyEditor --parallel 16 --config ${{ matrix.build_type }}
options: CMAKE_BUILD_TYPE=${{ matrix.build_type }} DE_FORCE_NO_PCH=ON
BuildUbuntu:
runs-on: ubuntu-latest
name: Build Ubuntu
strategy:
fail-fast: false
matrix:
build_type: [RelWithDebInfo]
c_compiler: [clang-19]
cpp_compiler: [clang++-19]
steps:
- name: Install Packages
run: |
sudo apt update
sudo apt install libwayland-dev libxkbcommon-dev libxrandr-dev libxinerama-dev libxcursor-dev libxi-dev libgtk-3-dev ninja-build
wget https://apt.llvm.org/llvm.sh
chmod +x llvm.sh
sudo ./llvm.sh 19 all
- name: Checkout Repository
uses: actions/checkout@v4
with:
submodules: 'true'
- name: Build
uses: threeal/[email protected]
with:
source-dir: ${{ github.workspace }}
build-dir: ${{ github.workspace }}/build
generator: Ninja
cxx-compiler: ${{ matrix.cpp_compiler }}
c-compiler: ${{ matrix.c_compiler }}
build-args: --target DummyEditor --parallel 16 --config ${{ matrix.build_type }}
options: CMAKE_BUILD_TYPE=${{ matrix.build_type }} DE_FORCE_NO_PCH=ON
Linter:
runs-on: ubuntu-latest
name: Clang Tidy
strategy:
fail-fast: false
steps:
- uses: actions/checkout@v4
with:
submodules: 'true'
- name: Install Packages
run: |
sudo apt update
sudo apt install libwayland-dev libxkbcommon-dev libxrandr-dev libxinerama-dev libxcursor-dev libxi-dev libgtk-3-dev
wget https://apt.llvm.org/llvm.sh
chmod +x llvm.sh
sudo ./llvm.sh 19 all
- name: Configure Cmake
uses: threeal/[email protected]
with:
source-dir: ${{ github.workspace }}
build-dir: ${{ github.workspace }}/build
generator: Unix Makefiles
cxx-compiler: clang++-19
c-compiler: clang-19
options: CMAKE_BUILD_TYPE=RelWithDebInfo CMAKE_EXPORT_COMPILE_COMMANDS=ON DE_FORCE_NO_PCH=ON
run-build: false
- uses: cpp-linter/cpp-linter-action@v2
id: linter
with:
style: 'file'
tidy-checks: ''
verbosity: info
version: 18
files-changed-only: false
database: '${{ github.workspace }}/build'
repo-root: '${{ github.workspace }}'
ignore: 'build/**|Examples/**|Sandbox/**|DummyEngine/Platform/**|DummyEditor/Platform/**'
step-summary: true
- name: Check Linter Results
if: steps.linter.outputs.checks-failed > 0
run: exit 1
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ DummyEngine/Presets

Sandbox/imgui.ini
Sandbox/DummyEditor
Sandbox/TestASAN
Sandbox/TestLSAN
Sandbox/TestMSAN
Sandbox/TestTSAN
Sandbox/Logs/**
Sandbox/Cache/**
Sandbox/**.dll
Expand All @@ -20,3 +24,4 @@ Sandbox/**.dylib
Sandbox/**.so**
Sandbox/*.yml

Config.cmake
5 changes: 5 additions & 0 deletions CMake/All.cmake
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
if (EXISTS ${CMAKE_SOURCE_DIR}/Config.cmake)
include(Config.cmake)
endif()

include(CMake/Options.cmake)
include(CMake/Platform.cmake)
include(CMake/Utils.cmake)
include(CMake/Compiler.cmake)
52 changes: 49 additions & 3 deletions CMake/Compiler.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,63 @@ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC -fno-omit-frame-pointer")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/../Sandbox)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/../Sandbox)

# Precompiled headers and libc++
set(ENABLE_PRECOMPILED_HEADERS OFF)

if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
set(ENABLE_PRECOMPILED_HEADERS ON)
endif()
if (${DE_FORCE_NO_PCH})
set(ENABLE_PRECOMPILED_HEADERS OFF)
endif()

# Clang Tidy
if(DE_CLANG_TIDY_RUN_ON_COMPILATION)
find_program(CLANG_TIDY_EXE NAMES "clang-tidy" "clang-tidy-17" "clang-tidy-18" "clang-tidy-19" REQUIRED)
set(CLANG_TIDY_COMMAND "${CLANG_TIDY_EXE}" "-p" "${CMAKE_CURRENT_SOURCE_DIR}/build")
if (DE_CLANG_TIDY_WARNINGS_AS_ERRORS)
set(CLANG_TIDY_COMMAND ${CLANG_TIDY_COMMAND} "--warnings-as-errors=*")
endif()
message(STATUS "CLANG_TIDY_COMMAND: [${CLANG_TIDY_COMMAND}]")
endif()

# Sanitizers https://clang.llvm.org/docs/UsersManual.html#controlling-code-generation
if (DE_ENABLE_ASAN AND DE_ENABLE_TSAN)
message(FATAL_ERROR "ASAN and TSAN cannot be used simultaneously")
endif()
if (DE_ENABLE_ASAN AND DE_ENABLE_MSAN)
message(FATAL_ERROR "ASAN and MSAN cannot be used simultaneously")
endif()
if (DE_ENABLE_TSAN AND DE_ENABLE_MSAN)
message(FATAL_ERROR "TSAN and MSAN cannot be used simultaneously")
endif()
if (DE_ENABLE_UBSAN)
add_compile_options(-fsanitize=undefined)
add_link_options(-fsanitize=undefined)
endif()
if (DE_ENABLE_ASAN)
add_compile_options(-fsanitize=address)
add_link_options(-fsanitize=address)
endif()
if (DE_ENABLE_TSAN)
if (DE_PLATFORM STREQUAL "WINDOWS")
message(FATAL_ERROR "Cannot use TSAN on Windows")
endif()
add_compile_options(-fsanitize=thread)
add_link_options(-fsanitize=thread)
endif()
if (DE_ENABLE_MSAN)
if (DE_PLATFORM STREQUAL "WINDOWS")
message(FATAL_ERROR "Cannot use MSAN on Windows")
endif()
add_compile_options(-fsanitize=memory)
add_link_options(-fsanitize=memory)
endif()

# Warnings
function(add_warnings TARGET)
target_compile_options(${TARGET} PUBLIC -Wall -Wextra -Wpedantic -Wno-extra-semi -Wno-missing-field-initializers -Werror)

if (${ENABLE_PRECOMPILED_HEADERS})
if (ENABLE_PRECOMPILED_HEADERS)
target_compile_options(${TARGET} PUBLIC -Winvalid-pch)
endif()
endfunction(add_warnings)
20 changes: 20 additions & 0 deletions CMake/Options.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
macro(set_option option help value)
option(${option} ${help} ${value})
if(${option})
message(STATUS "${option}: ON")
else()
message(STATUS "${option}: OFF")
endif()
endmacro()


message(STATUS "---Confiring-Project-Options-----------------------------------------------------------------")
set_option(DE_FORMAT_BEFORE_BUILD "Runs clang-format on DummyEngine and DummyEditor before build" OFF)
set_option(DE_CLANG_TIDY_RUN_ON_COMPILATION "Run clang tidy during compilation" OFF)
set_option(DE_CLANG_TIDY_WARNINGS_AS_ERRORS "Set clang warnings as errors" OFF)
set_option(DE_FORCE_NO_PCH "Prevent PCH" OFF)
set_option(DE_ENABLE_UBSAN "Enable UBSAN" OFF)
set_option(DE_ENABLE_ASAN "Enable ASAN" OFF)
set_option(DE_ENABLE_TSAN "Enable TSAN" OFF)
set_option(DE_ENABLE_MSAN "Enable MSAN" OFF)
message(STATUS "---Confired-Project-Options------------------------------------------------------------------")
6 changes: 3 additions & 3 deletions CMake/Platform.cmake
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
if(WIN32)
message(STATUS "Platform WINDOWS")
set(CMAKE_PLATFORM "WINDOWS")
set(DE_PLATFORM "WINDOWS")
add_compile_definitions(DE_PLATFORM_WINDOWS)
endif()
if(UNIX AND NOT APPLE)
message(STATUS "Platform LINUX")
set(CMAKE_PLATFORM "LINUX")
set(DE_PLATFORM "LINUX")
add_compile_definitions(DE_PLATFORM_LINUX)
endif()
if(APPLE)
message(STATUS "Platform MACOS")
set(CMAKE_PLATFORM "MACOS")
set(DE_PLATFORM "MACOS")
add_compile_definitions(DE_PLATFORM_MACOS)
set(CMAKE_OSX_DEPLOYMENT_TARGET "12.0" CACHE STRING "Minimum OS X deployment version")
endif()
Expand Down
4 changes: 4 additions & 0 deletions DummyEditor/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,8 @@ add_dependencies(DummyEditor DummyEditorScripts)

if (${ENABLE_PRECOMPILED_HEADERS})
target_precompile_headers(DummyEditor REUSE_FROM DummyEngineLib)
target_precompile_headers(DummyEditorScripts REUSE_FROM DummyEngineLib)
endif()
if (${DE_CLANG_TIDY_RUN_ON_COMPILATION})
set_target_properties(DummyEditor PROPERTIES CXX_CLANG_TIDY "${CLANG_TIDY_COMMAND}")
endif()
Loading

0 comments on commit 8fc0096

Please sign in to comment.