diff --git a/.gersemirc b/.gersemirc new file mode 100644 index 00000000..c6d6ef6c --- /dev/null +++ b/.gersemirc @@ -0,0 +1,5 @@ +# yamllint disable-line rule:line-length +# yaml-language-server: $schema=https://raw.githubusercontent.com/BlankSpruce/gersemi/master/gersemi/configuration.schema.json + +line_length: 100 +list_expansion: "favour-expansion" diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 00000000..5ba1b194 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,4 @@ +cmake_minimum_required(VERSION 3.16.3) +project(YSTDLIB_CPP LANGUAGES CXX) + +set(YSTDLIB_CPP_VERSION "0.0.1" CACHE STRING "Project version.") diff --git a/lint-requirements.txt b/lint-requirements.txt index 993e8b4f..425a18eb 100644 --- a/lint-requirements.txt +++ b/lint-requirements.txt @@ -1 +1,3 @@ +colorama>=0.4.6 +gersemi>=0.16.2 yamllint>=1.35.1 diff --git a/taskfiles/lint-cmake.yaml b/taskfiles/lint-cmake.yaml new file mode 100644 index 00000000..87af4ba8 --- /dev/null +++ b/taskfiles/lint-cmake.yaml @@ -0,0 +1,46 @@ +version: "3" + +tasks: + cmake-check: + desc: "Runs the CMake linters." + sources: &cmake_format_src_files + - "{{.ROOT_DIR}}/**/*.cmake" + - "{{.ROOT_DIR}}/**/*.cmake.in" + - "{{.ROOT_DIR}}/**/CMakeLists.txt" + - "{{.TASKFILE}}" + - exclude: "{{.ROOT_DIR}}/**/build/*" + - exclude: "{{.ROOT_DIR}}/**/submodules/*" + - exclude: "{{.ROOT_DIR}}/**/tools/*" + cmds: + - task: "gersemi" + vars: + FLAGS: "--diff --color" + - task: "gersemi" + silent: true + vars: + FLAGS: "--check" + + cmake-fix: + desc: "Runs the CMake linters and fixes all violations." + sources: *cmake_format_src_files + cmds: + - task: "gersemi" + vars: + FLAGS: "--in-place" + + gersemi: + internal: true + requires: + vars: + - "FLAGS" + dir: "{{.ROOT_DIR}}" + deps: + - "venv" + cmds: + - |- + . "{{.G_LINT_VENV_DIR}}/bin/activate" + find . \ + \( -path '**/build' -o -path '**/submodules' -o -path '**/tools' \) -prune -o \ + \( -iname "CMakeLists.txt" -o -iname "*.cmake" -o -iname "*.cmake.in" \) \ + -print0 | \ + xargs -0 --no-run-if-empty gersemi {{.FLAGS}} diff --git a/taskfiles/lint.yaml b/taskfiles/lint.yaml index 3d1833cb..eef45a19 100644 --- a/taskfiles/lint.yaml +++ b/taskfiles/lint.yaml @@ -1,6 +1,9 @@ version: "3" includes: + cmake: + flatten: true + taskfile: "./lint-cmake.yaml" yaml: flatten: true taskfile: "./lint-yaml.yaml" @@ -13,11 +16,13 @@ tasks: check: desc: "Runs the full suite of linters to identify warnings and violations." cmds: + - task: "cmake-check" - task: "yaml-check" fix: desc: "Runs the full suite of linters and fixes some violations." cmds: + - task: "cmake-fix" - task: "yaml-fix" venv: @@ -31,6 +36,7 @@ tasks: - "lint-requirements.txt" generates: - "{{.CHECKSUM_FILE}}" + run: "once" deps: - ":init" - task: ":utils:validate-checksum"