diff --git a/.gersemirc b/.gersemirc new file mode 100644 index 0000000..c6d6ef6 --- /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 0000000..ccefcf6 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,38 @@ +# CMake 3.22.1 is the default on Ubuntu 22.04 +cmake_minimum_required(VERSION 3.22.1) + +project( + spider + LANGUAGES + C + CXX + VERSION 0.1.0 +) + +# Enable exporting compile commands +set(CMAKE_EXPORT_COMPILE_COMMANDS + ON + CACHE BOOL + "Enable/Disable output of compile commands during generation." + FORCE +) + +# Set the default build type to Release if not specified +if(NOT CMAKE_BUILD_TYPE) + set(SPIDER_DEFAULT_BUILD_TYPE "Release") + message(STATUS "No build type specified. Setting to '${SPIDER_DEFAULT_BUILD_TYPE}'.") + set(CMAKE_BUILD_TYPE + "${SPIDER_DEFAULT_BUILD_TYPE}" + CACHE STRING + "Choose the type of build." + FORCE + ) +endif() + +add_executable(spider) +target_compile_features(spider PRIVATE cxx_std_20) + +set(SPIDER_SOURCES src/spider/spider.cpp) +target_sources(spider PRIVATE ${SPIDER_SOURCES}) + +target_include_directories(spider PRIVATE src/) diff --git a/README.md b/README.md index 61b5c7e..14ab9d2 100644 --- a/README.md +++ b/README.md @@ -30,9 +30,11 @@ The commands above run all linting checks, but for performance you may want to r if you only changed C++ files, you don't need to run the YAML linting checks) using one of the tasks in the table below. -| Task | Description | -|-------------------------|----------------------------------------------------------| -| `lint:yml-check` | Runs the YAML linters. | -| `lint:yml-fix` | Runs the YAML linters and fixes some violations. | +| Task | Description | +|--------------------|--------------------------------------------------| +| `lint:cmake-check` | Runs the CMake linters. | +| `lint:cmake-fix` | Runs the CMake linters and fixes any violations. | +| `lint:yml-check` | Runs the YAML linters. | +| `lint:yml-fix` | Runs the YAML linters and fixes some violations. | [Task]: https://taskfile.dev diff --git a/lint-requirements.txt b/lint-requirements.txt index 993e8b4..2c40fe3 100644 --- a/lint-requirements.txt +++ b/lint-requirements.txt @@ -1 +1,2 @@ +gersemi>=0.16.2 yamllint>=1.35.1 diff --git a/lint-tasks.yaml b/lint-tasks.yaml index 1c5f153..2f4fbb2 100644 --- a/lint-tasks.yaml +++ b/lint-tasks.yaml @@ -6,12 +6,28 @@ vars: tasks: check: cmds: + - task: "cmake-check" - task: "yml-check" fix: cmds: + - task: "cmake-fix" - task: "yml-fix" + cmake-check: + deps: ["venv"] + cmds: + - task: "cmake" + vars: + FLAGS: "--check" + + cmake-fix: + deps: ["venv"] + cmds: + - task: "cmake" + vars: + FLAGS: "--in-place" + yml: aliases: - "yml-check" @@ -22,6 +38,18 @@ tasks: . "{{.G_LINT_VENV_DIR}}/bin/activate" yamllint --strict . + cmake: + internal: true + requires: + vars: ["FLAGS"] + cmd: |- + . "{{.G_LINT_VENV_DIR}}/bin/activate" + find . \ + -path ./build -prune \ + -o -name CMakeLists.txt \ + -print0 | \ + xargs -0 --no-run-if-empty gersemi {{.FLAGS}} + venv: internal: true vars: @@ -32,6 +60,7 @@ tasks: - "{{.TASKFILE}}" - "lint-requirements.txt" generates: ["{{.CHECKSUM_FILE}}"] + run: "once" deps: - ":init" - task: ":utils:validate-checksum" diff --git a/src/spider/spider.cpp b/src/spider/spider.cpp new file mode 100644 index 0000000..54e47ec --- /dev/null +++ b/src/spider/spider.cpp @@ -0,0 +1,6 @@ +#include + +int main() { + std::cout << "Hello, world!" << std::endl; + return 0; +}