From 3031290ba049b76e7ca41d301110ab30cf8f8854 Mon Sep 17 00:00:00 2001 From: Jayden Grubb Date: Sun, 2 Feb 2025 14:43:08 +1000 Subject: [PATCH] Initial commit --- .clang-format | 102 +++++++++++++++++++++++++++++++++++++++++++++++ .editorconfig | 15 +++++++ .gitignore | 42 +++++++++++++++++++ CMakeLists.txt | 44 ++++++++++++++++++++ include/.gitkeep | 0 src/main.cpp | 12 ++++++ 6 files changed, 215 insertions(+) create mode 100644 .clang-format create mode 100644 .editorconfig create mode 100644 .gitignore create mode 100644 CMakeLists.txt create mode 100644 include/.gitkeep create mode 100644 src/main.cpp diff --git a/.clang-format b/.clang-format new file mode 100644 index 0000000..623404b --- /dev/null +++ b/.clang-format @@ -0,0 +1,102 @@ +# Based on https://gist.github.com/YodaEmbedding/c2c77dc693d11f3734d78489f9a6eea4 +# Attempts to format C++ similar to rustfmt, with some modifications + +AccessModifierOffset: -2 +AlignAfterOpenBracket: BlockIndent +AlignConsecutiveMacros: false +AlignConsecutiveAssignments: false +AlignConsecutiveDeclarations: false +AlignEscapedNewlines: DontAlign +AlignOperands: false +AlignTrailingComments: false +AllowAllArgumentsOnNextLine: false +AllowAllParametersOfDeclarationOnNextLine: false +AllowShortBlocksOnASingleLine: Empty +AllowShortCaseLabelsOnASingleLine: false +AllowShortFunctionsOnASingleLine: Empty +AllowShortIfStatementsOnASingleLine: Never +AllowShortLambdasOnASingleLine: All +AllowShortLoopsOnASingleLine: false +AlwaysBreakAfterReturnType: None +AlwaysBreakBeforeMultilineStrings: true +AlwaysBreakTemplateDeclarations: Yes +BinPackArguments: false +BinPackParameters: false +BreakBeforeBinaryOperators: NonAssignment +BreakBeforeBraces: Attach +BreakBeforeTernaryOperators: true +BreakConstructorInitializers: AfterColon +BreakInheritanceList: AfterColon +BreakStringLiterals: false +CompactNamespaces: false +ConstructorInitializerIndentWidth: 4 +ContinuationIndentWidth: 4 +Cpp11BracedListStyle: true +DerivePointerAlignment: false +FixNamespaceComments: true +IncludeBlocks: Regroup +IncludeCategories: + - Regex: '^' + Priority: 0 + CaseSensitive: false + - Regex: '^<.*\.(hpp|hh)>' + Priority: 1 + CaseSensitive: false + - Regex: '^<.*\.h>' + Priority: 2 + CaseSensitive: false + - Regex: '^<.*>' + Priority: 3 + CaseSensitive: false + - Regex: '^".*\.(hpp|hh)"' + Priority: 4 + CaseSensitive: false + - Regex: '^".*\.h"' + Priority: 5 + CaseSensitive: false +IncludeIsMainRegex: '^$' +IndentCaseLabels: true +IndentPPDirectives: BeforeHash +IndentWidth: 4 +IndentWrappedFunctionNames: false +KeepEmptyLinesAtTheStartOfBlocks: false +MaxEmptyLinesToKeep: 1 +NamespaceIndentation: None +PackConstructorInitializers: CurrentLine +PointerAlignment: Left +ReferenceAlignment: Left +ReflowComments: false +SeparateDefinitionBlocks: Leave +SortIncludes: true +SortUsingDeclarations: true +SpaceAfterCStyleCast: false +SpaceAfterLogicalNot: false +SpaceAfterTemplateKeyword: false +SpaceBeforeAssignmentOperators: true +SpaceBeforeCpp11BracedList: true +SpaceBeforeCtorInitializerColon: true +SpaceBeforeInheritanceColon: true +SpaceBeforeParens: ControlStatements +SpaceBeforeRangeBasedForLoopColon: true +SpaceInEmptyParentheses: false +SpacesBeforeTrailingComments: 1 +SpacesInAngles: false +SpacesInCStyleCastParentheses: false +SpacesInContainerLiterals: false +SpacesInParentheses: false +SpacesInSquareBrackets: false +Standard: c++20 +TabWidth: 4 +UseTab: Always +ColumnLimit: 120 +PenaltyBreakAssignment: 50 +PenaltyBreakBeforeFirstCallParameter: 40 +PenaltyBreakComment: 10 +PenaltyBreakFirstLessLess: 100 +PenaltyBreakOpenParenthesis: 50 +PenaltyBreakScopeResolution: 80 +PenaltyBreakString: 100 +PenaltyBreakTemplateDeclaration: 100 +PenaltyExcessCharacter: 100 +PenaltyIndentedWhitespace: 50 +PenaltyReturnTypeOnItsOwnLine: 70 diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..fff7dda --- /dev/null +++ b/.editorconfig @@ -0,0 +1,15 @@ +# EditorConfig is awesome: https://EditorConfig.org + +# top-most EditorConfig file +root = true + +[*] +indent_style = tab +indent_size = 4 +end_of_line = lf +charset = utf-8 +trim_trailing_whitespace = false +insert_final_newline = true + +[*.{c,cpp,h,hpp}] +clang-format-style = file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ccdd3f2 --- /dev/null +++ b/.gitignore @@ -0,0 +1,42 @@ +# Prerequisites +*.d + +# Compiled Object files +*.slo +*.lo +*.o +*.obj + +# Precompiled Headers +*.gch +*.pch + +# Compiled Dynamic libraries +*.so +*.dylib +*.dll + +# Fortran module files +*.mod +*.smod + +# Compiled Static libraries +*.lai +*.la +*.a +*.lib + +# Executables +*.exe +*.out +*.app + +# Build directory +build/ + +# Cache directory +.cache/ + +# Editor directories +.vscode/ +.idea/ diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..5d79f52 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,44 @@ +cmake_minimum_required(VERSION 3.20) +set(CMAKE_EXPORT_COMPILE_COMMANDS ON CACHE INTERNAL "") + +project(Example) +enable_language(CXX) +set(CMAKE_CXX_STANDARD 23) +set(CMAKE_CXX_STANDARD_REQUIRED ON) + +add_compile_options( + -Wall + -Wextra + -Wpedantic + -Wold-style-cast +) + +add_executable( + ${PROJECT_NAME} + src/main.cpp +) + +# find_package(Example REQUIRED) + +include_directories( + ${CMAKE_CURRENT_SOURCE_DIR}/include + # ${Example_INCLUDE_DIRS} +) + +target_link_libraries( + ${PROJECT_NAME} + # ${Example_LIBRARIES} +) + +if (CMAKE_IMPORT_LIBRARY_SUFFIX) + add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy $ $ + COMMAND_EXPAND_LISTS + ) +endif () + +add_custom_target(run + COMMAND ${PROJECT_NAME} + DEPENDS ${PROJECT_NAME} + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} +) diff --git a/include/.gitkeep b/include/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/src/main.cpp b/src/main.cpp new file mode 100644 index 0000000..37f97e0 --- /dev/null +++ b/src/main.cpp @@ -0,0 +1,12 @@ +#include +#include + +int main(int argc, char** argv) { + std::println("Hello, World!"); + + for (int i = 0; i < argc; i++) { + std::println("argv[{}] = {}", i, argv[i]); + } + + return EXIT_SUCCESS; +}