set up project files and build system
This commit is contained in:
186
.clang-format
Normal file
186
.clang-format
Normal file
@@ -0,0 +1,186 @@
|
||||
---
|
||||
# ---------------------------
|
||||
# general style settings
|
||||
# ---------------------------
|
||||
BasedOnStyle: GNU
|
||||
Standard: Auto
|
||||
ColumnLimit: 0
|
||||
LineEnding: LF
|
||||
UseTab: ForContinuationAndIndentation
|
||||
TabWidth: 8
|
||||
IndentWidth: 8
|
||||
ContinuationIndentWidth: 8
|
||||
AccessModifierOffset: -4
|
||||
|
||||
# ---------------------------
|
||||
# alignment options
|
||||
# ---------------------------
|
||||
AlignAfterOpenBracket: DontAlign
|
||||
AlignOperands: DontAlign
|
||||
AlignTrailingComments: true
|
||||
AlignConsecutiveMacros: AcrossEmptyLines
|
||||
AlignEscapedNewlines: Left
|
||||
AlignArrayOfStructures: Left
|
||||
AlignConsecutiveAssignments: None
|
||||
AlignConsecutiveBitFields: AcrossEmptyLines
|
||||
AlignConsecutiveDeclarations: None
|
||||
AlignConsecutiveShortCaseStatements:
|
||||
Enabled: true
|
||||
|
||||
# ---------------------------
|
||||
# short constructs on a single line
|
||||
# ---------------------------
|
||||
AllowShortBlocksOnASingleLine: Always
|
||||
AllowShortFunctionsOnASingleLine: All
|
||||
AllowShortLambdasOnASingleLine: All
|
||||
AllowShortIfStatementsOnASingleLine: AllIfsAndElse
|
||||
AllowShortCaseLabelsOnASingleLine: true
|
||||
AllowShortEnumsOnASingleLine: true
|
||||
AllowShortLoopsOnASingleLine: true
|
||||
|
||||
# ---------------------------
|
||||
# break and wrapping options
|
||||
# ---------------------------
|
||||
AlwaysBreakBeforeMultilineStrings: false
|
||||
AlwaysBreakAfterReturnType: Automatic
|
||||
BreakTemplateDeclarations: false
|
||||
BreakBeforeBinaryOperators: None
|
||||
BreakBeforeConceptDeclarations: Never
|
||||
BreakBeforeBraces: Custom
|
||||
BreakBeforeTernaryOperators: false
|
||||
BreakStringLiterals: false
|
||||
|
||||
# ---------------------------
|
||||
# brace wrapping configuration
|
||||
# ---------------------------
|
||||
BraceWrapping:
|
||||
AfterControlStatement: Never
|
||||
AfterCaseLabel: false
|
||||
AfterClass: false
|
||||
AfterEnum: false
|
||||
AfterFunction: false
|
||||
AfterNamespace: false
|
||||
AfterObjCDeclaration: false
|
||||
AfterStruct: false
|
||||
AfterUnion: false
|
||||
AfterExternBlock: false
|
||||
BeforeCatch: false
|
||||
BeforeElse: false
|
||||
BeforeLambdaBody: false
|
||||
BeforeWhile: false
|
||||
IndentBraces: false
|
||||
SplitEmptyFunction: true
|
||||
SplitEmptyRecord: true
|
||||
SplitEmptyNamespace: true
|
||||
|
||||
# ---------------------------
|
||||
# constructor initializer and parameter packing options
|
||||
# ---------------------------
|
||||
ConstructorInitializerIndentWidth: 8
|
||||
PackConstructorInitializers: NextLine
|
||||
BinPackParameters: true
|
||||
BinPackArguments: true
|
||||
|
||||
# ---------------------------
|
||||
# pointer alignment
|
||||
# ---------------------------
|
||||
DerivePointerAlignment: false
|
||||
PointerAlignment: Right
|
||||
ReferenceAlignment: Pointer
|
||||
QualifierAlignment: Left
|
||||
|
||||
# ---------------------------
|
||||
# include settings and sorting
|
||||
# ---------------------------
|
||||
IncludeIsMainSourceRegex: ''
|
||||
IncludeIsMainRegex: '([-_](test|unittest))?$'
|
||||
IncludeBlocks: Regroup
|
||||
IncludeCategories:
|
||||
- Regex: '^<glad/gl\.h>'
|
||||
Priority: 1
|
||||
SortPriority: 0
|
||||
CaseSensitive: true
|
||||
- Regex: '^<.*\.h>'
|
||||
Priority: 2
|
||||
SortPriority: 0
|
||||
CaseSensitive: true
|
||||
- Regex: '^".*'
|
||||
Priority: 3
|
||||
SortPriority: 0
|
||||
CaseSensitive: true
|
||||
|
||||
# ---------------------------
|
||||
# additional formatting and sorting details
|
||||
# ---------------------------
|
||||
FixNamespaceComments: false
|
||||
MaxEmptyLinesToKeep: 2
|
||||
ReflowComments: true
|
||||
RemoveBracesLLVM: false
|
||||
AllowAllArgumentsOnNextLine: false
|
||||
AllowAllParametersOfDeclarationOnNextLine: false
|
||||
EmptyLineAfterAccessModifier: Never
|
||||
EmptyLineBeforeAccessModifier: LogicalBlock
|
||||
ExperimentalAutoDetectBinPacking: false
|
||||
SeparateDefinitionBlocks: Leave
|
||||
ShortNamespaceLines: 1
|
||||
SortIncludes: CaseSensitive
|
||||
SortJavaStaticImport: Before
|
||||
SortUsingDeclarations: false
|
||||
|
||||
# ---------------------------
|
||||
# spacing options
|
||||
# ---------------------------
|
||||
SpaceAfterCStyleCast: false
|
||||
SpaceAfterLogicalNot: false
|
||||
SpaceAfterTemplateKeyword: true
|
||||
SpaceBeforeAssignmentOperators: true
|
||||
SpaceBeforeCaseColon: false
|
||||
Cpp11BracedListStyle: true
|
||||
SpaceBeforeCpp11BracedList: false
|
||||
SpaceBeforeCtorInitializerColon: true
|
||||
SpaceBeforeInheritanceColon: true
|
||||
SpaceBeforeParens: ControlStatements
|
||||
SpaceBeforeRangeBasedForLoopColon: true
|
||||
SpaceInEmptyBlock: true
|
||||
SpacesInParens: Custom
|
||||
SpacesInParensOptions:
|
||||
ExceptDoubleParentheses: false
|
||||
InConditionalStatements: false
|
||||
InCStyleCasts: false
|
||||
Other: false
|
||||
SpacesBeforeTrailingComments: 1
|
||||
SpacesInAngles: Never
|
||||
SpacesInConditionalStatement: false
|
||||
SpacesInContainerLiterals: false
|
||||
SpacesInCStyleCastParentheses: false
|
||||
SpacesInLineCommentPrefix:
|
||||
Minimum: 1
|
||||
Maximum: 1
|
||||
SpacesInParentheses: false
|
||||
SpacesInSquareBrackets: false
|
||||
SpaceBeforeSquareBrackets: false
|
||||
BitFieldColonSpacing: Both
|
||||
|
||||
# ---------------------------
|
||||
# penalty settings
|
||||
# ---------------------------
|
||||
PenaltyBreakAssignment: 10
|
||||
PenaltyBreakBeforeFirstCallParameter: 30
|
||||
PenaltyBreakComment: 10
|
||||
PenaltyBreakFirstLessLess: 0
|
||||
PenaltyBreakString: 10
|
||||
PenaltyExcessCharacter: 100
|
||||
PenaltyReturnTypeOnItsOwnLine: 60
|
||||
|
||||
# ---------------------------
|
||||
# indentation details
|
||||
# ---------------------------
|
||||
IndentAccessModifiers: false
|
||||
IndentCaseLabels: false
|
||||
IndentCaseBlocks: false
|
||||
IndentGotoLabels: false
|
||||
IndentExternBlock: AfterExternBlock
|
||||
IndentRequiresClause: false
|
||||
IndentPPDirectives: None
|
||||
PPIndentWidth: 1
|
||||
...
|
||||
19
.editorconfig
Normal file
19
.editorconfig
Normal file
@@ -0,0 +1,19 @@
|
||||
# Copyright (c) 2025 Quinn
|
||||
# Licensed under the MIT Licence. See LICENSE for details
|
||||
[*]
|
||||
charset = utf-8
|
||||
end_of_line = lf
|
||||
insert_final_newline = true
|
||||
trim_trailing_whitespace = true
|
||||
|
||||
[*.{c,h}]
|
||||
indent_style = tab
|
||||
indent_size = tab
|
||||
|
||||
[{makefile}]
|
||||
indent_style = tab
|
||||
indent_size = tab
|
||||
|
||||
[*.{yaml,json}]
|
||||
indent_style = space
|
||||
intent_size = 2
|
||||
22
.gitignore
vendored
Normal file
22
.gitignore
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
# Copyright (c) 2025 Quinn
|
||||
# Licensed under the MIT Licence. See LICENSE for details
|
||||
|
||||
# ignore all dotfiles by default
|
||||
.*
|
||||
|
||||
# unhide dotfiles we want to keep
|
||||
!.gitignore
|
||||
!.editorconfig
|
||||
!.clang-format
|
||||
!/.github/
|
||||
|
||||
# hide output files
|
||||
*.o
|
||||
*.d
|
||||
*.out
|
||||
/bin/
|
||||
/obj/
|
||||
/test/bin/
|
||||
/test/obj/
|
||||
*.lock
|
||||
compile_commands.json
|
||||
21
LICENSE
Normal file
21
LICENSE
Normal file
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2025 Quinn
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
81
makefile
Normal file
81
makefile
Normal file
@@ -0,0 +1,81 @@
|
||||
# Copyright (c) 2025 Quinn
|
||||
# Licensed under the MIT Licence. See LICENSE for details
|
||||
|
||||
# dependencies:
|
||||
# - make
|
||||
# - C compiler
|
||||
# - glfw3 (install glfw3:x64-mingw-dynamic via vcpkg for cross compilation)
|
||||
# - xxd (tinyxxd recommended; faster)
|
||||
# - (windows) git bash (recommended)
|
||||
|
||||
# build configuration, information about the current build process
|
||||
NAME := sudoku-algo
|
||||
DEBUG ?= 0
|
||||
CC ?= cc
|
||||
LD ?= ld
|
||||
CFLAGS += -c -std=gnu99 -Wall -Wextra -Wpedantic -Ilib -MMD -MP
|
||||
LDFLAGS += -flto -lm
|
||||
|
||||
# profiles
|
||||
ifeq ($(DEBUG),1) # check whether we're debugging
|
||||
CFLAGS += -UNDEBUG -Og -g
|
||||
PROF := dbg
|
||||
else # otherwise, assume release
|
||||
CFLAGS += -DNDEBUG -O2
|
||||
PROF := rel
|
||||
endif
|
||||
|
||||
# build directory structure
|
||||
DIR_BIN := bin/$(PROF)
|
||||
DIR_OBJ := obj/$(PROF)
|
||||
|
||||
# get source files
|
||||
SRC := $(shell find src/ -name '*.c')
|
||||
|
||||
# output files
|
||||
BIN := $(DIR_BIN)/$(NAME)
|
||||
OBJ := $(SRC:%.c=$(DIR_OBJ)/%.o) $(RES:%=$(DIR_OBJ)/%.o)
|
||||
DEP := $(OBJ:.o=.d)
|
||||
|
||||
COMPILE_COMMANDS := $(DIR_OBJ)/compile_commands.json
|
||||
|
||||
.PHONY: run compile echo
|
||||
run: echo compile_commands $(BIN); $(BIN)
|
||||
compile: echo compile_commands $(BIN)
|
||||
echo:
|
||||
$(info $(shell printf "\033[36m")using compiler: $(CC)$(shell printf "\033[0m"))
|
||||
|
||||
# creates the binary (linking step)
|
||||
$(BIN): $(OBJ)
|
||||
@mkdir -p $(@D)
|
||||
$(CC) -o $@ $^ $(LDFLAGS)
|
||||
|
||||
# compilation rule
|
||||
$(DIR_OBJ)/%.o: %.c
|
||||
@mkdir -p $(@D)
|
||||
$(CC) $(CFLAGS) -o $@ $<
|
||||
|
||||
.PHONY .NOTPARALLEL:
|
||||
clean:
|
||||
rm -rf obj bin compile_commands.json
|
||||
|
||||
# update compile commands if the makefile has been updated (for linting)
|
||||
compile_commands: # default, empty rule
|
||||
ifneq ($(shell which bear),)
|
||||
ifneq ($(COMPILE_COMMANDS),)
|
||||
ifeq ($(NOCMDS),)
|
||||
.PHONY .NOTPARALLEL:
|
||||
compile_commands: $(COMPILE_COMMANDS)
|
||||
ln -sf $< compile_commands.json
|
||||
|
||||
.NOTPARALLEL:
|
||||
$(COMPILE_COMMANDS): makefile
|
||||
@$(warning regenerating compile_commands.json thus recompiling.)
|
||||
@mkdir -p ${@D} # ensure the target directory exists
|
||||
@touch $@ # create the file so it isn't retriggered (will just change modification time if already exists)
|
||||
@bear --output $@ -- make -B compile NOCMDS=1 # rebuild the current target using bear, to create the compile commands
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
-include $(DEP)
|
||||
10
src/main.c
Normal file
10
src/main.c
Normal file
@@ -0,0 +1,10 @@
|
||||
// Copyright (c) 2025 Quinn
|
||||
// Licensed under the MIT Licence. See LICENSE for details
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
(void)argc, (void)argv;
|
||||
printf("%s\n", "Hello, World!");
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
Reference in New Issue
Block a user