Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,6 @@ indent_size = 2

[{.bashrc,.profile,.xinitrc}]
indent_size = 2

[{*.mk, Makefile}]
indent_style = tab
6 changes: 6 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[submodule "C/{{ cookiecutter.project_name }}/doxygen-awesome-css"]
path = C/{{ cookiecutter.project_name }}/doxygen-awesome-css
url = https://github.com/jothepro/doxygen-awesome-css.git
[submodule "C/doxygen-awesome-css"]
path = C/doxygen-awesome-css
url = https://github.com/jothepro/doxygen-awesome-css.git
4 changes: 3 additions & 1 deletion C/cookiecutter.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
"flake.nix",
"flake.lock",
"header.html",
"sourcelist.mk"
"sourcelist.mk",
"check_commit_msg.py",
"dockerfile"
]
}
4 changes: 2 additions & 2 deletions C/hooks/post_gen_project.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/sh

cp ../Common/{{ cookiecutter.project_name }}/* .
cp ../Common/{{ cookiecutter.project_name }}/.* .
chmod +w * -R
chmod +w .* -R

mv * ..
mv .* ..
Expand Down
19 changes: 19 additions & 0 deletions C/{{ cookiecutter.project_name }}/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
root = true

[*]
charset = utf-8
end_of_line = lf
trim_trailing_whitespace = true
insert_final_newline = true
max_line_length = 80
indent_style = space
indent_size = 4

[{*.nix, *.lock, *.json, *.toml, *.yml}]
indent_size = 2

[{.bashrc,.profile,.xinitrc}]
indent_size = 2

[{*.mk, Makefile}]
indent_style = tab
2 changes: 2 additions & 0 deletions C/{{ cookiecutter.project_name }}/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
debug
check
{{ cookiecutter.project_name }}
unittests

# nix
result*
Expand All @@ -18,3 +19,4 @@ docs.pdf
.build
*.[aod]
hook.mk
*.gocv.json.gz
4 changes: 1 addition & 3 deletions C/{{ cookiecutter.project_name }}/Doxyfile
Original file line number Diff line number Diff line change
Expand Up @@ -201,8 +201,6 @@ HTML_FILE_EXTENSION = .html
HTML_HEADER = header.html
HTML_FOOTER =
HTML_STYLESHEET =
HTML_EXTRA_STYLESHEET =
HTML_EXTRA_FILES =
HTML_COLORSTYLE = DARK
HTML_COLORSTYLE_HUE = 220
HTML_COLORSTYLE_SAT = 100
Expand All @@ -222,7 +220,7 @@ DOCSET_FEEDNAME = "Doxygen generated docs"
DOCSET_FEEDURL =
DOCSET_BUNDLE_ID = org.doxygen.Project
DOCSET_PUBLISHER_ID = org.doxygen.Publisher
DOCSET_PUBLISHER_NAME = Julien
DOCSET_PUBLISHER_NAME = Gabriel Hosquet
GENERATE_HTMLHELP = NO
CHM_FILE =
HHC_LOCATION =
Expand Down
48 changes: 37 additions & 11 deletions C/{{ cookiecutter.project_name }}/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,17 @@ _start: bundle

include ./makeincludes/mk-recipes.mk

UNIT := unittests

CFLAGS_@main += -DFOO=1

$(eval $(call mk-recipe-binary, release, SRC-OUT, ))
$(eval $(call mk-recipe-binary, {{ cookiecutter.project_name }}, SRC-OUT, ))

test-src := $(filter-out %main.c, $(SRC-OUT))
test-src += $(TST-OUT)
test-flags := -g3 --coverage -fprofile-arcs -iquote tests/include -lcriterion

$(eval $(call mk-recipe-binary, unittests, test-src, $(test-flags)))

debug-flags := -fanalyzer -DDEBUG=1
$(eval $(call mk-recipe-binary, debug, SRC-OUT, $(debug-flags)))
Expand All @@ -46,27 +54,44 @@ check-flags := $(debug-flags) -fsanitize=address,leak,undefined
$(eval $(call mk-recipe-binary, check, SRC-OUT, $(check-flags)))

.PHONY: all #? all: default, build the release binary
all: $(out-release)
all: $(out-{{ cookiecutter.project_name }})

.PHONY: bundle #? bundle: build all binaries
bundle: debug check all

.PHONY: clean
clean: #? clean: removes object files
bundle: debug check all $(UNIT)

.PHONY: tests_run #? tests_run: build and run the unit tests
tests_run: $(UNIT)
$Q ./$(UNIT) -OP:F --full-stats

.PHONY: cov #? cov: run the tests and generate coverage report
cov: tests_run
$Q gcovr . \
--exclude-unreachable-branches \
--exclude tests \
--exclude-directories .direnv
$Q gcovr . \
--exclude-unreachable-branches \
--exclude tests \
--exclude-directories .direnv \
--txt-metric branch

.PHONY: clean #? clean: removes object files
clean:
$Q $(RM) -r $(_clean)

.PHONY: fclean
fclean: clean #? fclean: remove binaries and object files
.PHONY: fclean #? fclean: remove binaries and object files
fclean: clean
$Q $(RM) -r $(_fclean)
$Q $(RM) -r *.gcov.json.gz

.PHONY: mrproper
mrproper: fclean #? mrproper: remove all generated files
.PHONY: mrproper #? mrproper: remove all generated files
mrproper: fclean
$Q $(RM) -r $(BUILD_DIR)

.PHONY: help
help: #? help: Show this help message
@ grep -P "#[?] " $(MAKEFILE_LIST) \
| sed -E 's/.*#\? ([^:]+): (.*)/\1 "\2"/' \
| sed -E 's/.*#\? ([^:]+): (.*)/\1 "\2"/' \
| xargs printf "%-12s: %s\n"

include ./makeincludes/docs.mk
Expand All @@ -75,5 +100,6 @@ include ./makeincludes/docs.mk
.NOTPARALLEL: re
re: fclean all #? re: rebuild the default target


include ./makeincludes/log-helper.mk
-include hook.mk
69 changes: 26 additions & 43 deletions C/{{ cookiecutter.project_name }}/flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions C/{{ cookiecutter.project_name }}/flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,12 @@
valgrind
# tests
criterion
python3Packages.gcovr
gcovr
# docs
doxygen
# compile_commands.json
bear
python3Packages.compiledb
compiledb
# coding style
cs-wrapped
];
Expand Down
4 changes: 4 additions & 0 deletions C/{{ cookiecutter.project_name }}/hook.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
fclean: clean
$Q $(RM) -r $(_fclean)
$Q $(RM) -r *.gcov.json.gz
$Q $(RM) -r $(BUILD_DIR)
3 changes: 3 additions & 0 deletions C/{{ cookiecutter.project_name }}/sourcelist.mk
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,6 @@ VPATH := src
SRC-OUT := main.c
SRC-OUT += local_cflag_demo.c
SRC-OUT += memory_demo.c

VPATH += tests
TST-OUT := test_suite.c
6 changes: 6 additions & 0 deletions C/{{ cookiecutter.project_name }}/tests/test_suite.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#include <criterion/criterion.h>

Test(test_suite, test_case)
{
cr_assert(1 == 1);
}
7 changes: 0 additions & 7 deletions Common/cookiecutter.json

This file was deleted.

18 changes: 18 additions & 0 deletions Cpp/cookiecutter.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"project_name": "Tmp",
"_copy_without_render": [
"includes",
"makeincludes",
"nix",
"src",
"base_flags.txt",
"Doxyfile",
"ecsls.toml",
"flake.nix",
"flake.lock",
"header.html",
"sourcelist.mk",
"check_commit_msg.py",
"dockerfile"
]
}
9 changes: 9 additions & 0 deletions Cpp/hooks/post_gen_project.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/sh

chmod +w * -R
chmod +w .* -R

mv * ..
mv .* ..
rm -rfv ../{{ cookiecutter.project_name }}

Loading