chore: init project

This commit is contained in:
mandlm 2024-03-18 12:12:08 +01:00
commit ebf50df679
Signed by: mandlm
GPG Key ID: 4AA25D647AA54CC7
11 changed files with 184 additions and 0 deletions

9
.envrc Normal file
View File

@ -0,0 +1,9 @@
use flake .nix
dotenv_if_exists
if on_git_branch; then
echo
git status --short --branch
echo
git fetch
fi

4
.gitignore vendored Normal file
View File

@ -0,0 +1,4 @@
.build/
.cache/
bin/
compile_commands.json

61
.nix/flake.lock Normal file
View File

@ -0,0 +1,61 @@
{
"nodes": {
"flake-utils": {
"inputs": {
"systems": "systems"
},
"locked": {
"lastModified": 1710146030,
"narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1710734606,
"narHash": "sha256-rFJl+WXfksu2NkWJWKGd5Km17ZGEjFg9hOQNwstsoU8=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "79bb4155141a5e68f2bdee2bf6af35b1d27d3a1d",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixpkgs-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"flake-utils": "flake-utils",
"nixpkgs": "nixpkgs"
}
},
"systems": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
}
},
"root": "root",
"version": 7
}

32
.nix/flake.nix Normal file
View File

@ -0,0 +1,32 @@
{
description = "A basic flake with a shell";
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
inputs.flake-utils.url = "github:numtide/flake-utils";
outputs = { self, nixpkgs, flake-utils }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = nixpkgs.legacyPackages.${system};
in
{
devShell = pkgs.mkShell {
nativeBuildInputs = [ pkgs.bashInteractive ];
buildInputs = with pkgs; [
# building
gcc
cmake
ninja
sccache
# pre-commit
pre-commit
commitizen
];
shellHook = ''
pre-commit install --allow-missing-config --hook-type pre-commit --hook-type commit-msg
'';
};
}
);
}

29
.pre-commit-config.yaml Normal file
View File

@ -0,0 +1,29 @@
repos:
- repo: https://github.com/commitizen-tools/commitizen
rev: v3.15.0
hooks:
- id: commitizen
stages: [commit-msg]
- repo: https://github.com/pre-commit/mirrors-prettier
rev: v4.0.0-alpha.8
hooks:
- id: prettier
name: check markdown/yaml formatting
types_or:
- markdown
- yaml
args: [--no-config]
exclude: CHANGELOG.md
- repo: https://github.com/pocc/pre-commit-hooks
rev: v1.3.5
hooks:
- id: clang-format
- id: clang-tidy
- repo: https://github.com/cheshirekow/cmake-format-precommit
rev: v0.6.13
hooks:
- id: cmake-format
- id: cmake-lint

21
CMakeLists.txt Normal file
View File

@ -0,0 +1,21 @@
cmake_minimum_required(VERSION 3.20)
project(
VectorSearch
VERSION 0.1.0
LANGUAGES CXX)
list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake")
include(ExportCompileCommands)
include(sccache)
add_executable(VectorSearch main.cpp)
target_compile_features(VectorSearch PUBLIC cxx_std_20)
set_target_properties(
VectorSearch
PROPERTIES ARCHIVE_OUTPUT_DIRECTORY "${PROJECT_SOURCE_DIR}/bin"
RUNTIME_OUTPUT_DIRECTORY "${PROJECT_SOURCE_DIR}/bin"
RUNTIME_OUTPUT_DIRECTORY "${PROJECT_SOURCE_DIR}/bin")

View File

@ -0,0 +1,8 @@
set(CMAKE_EXPORT_COMPILE_COMMANDS
ON
CACHE BOOL "Export compile commands database")
if(CMAKE_EXPORT_COMPILE_COMMANDS)
set(CMAKE_CXX_STANDARD_INCLUDE_DIRECTORIES
${CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES})
endif()

6
cmake/sccache.cmake Normal file
View File

@ -0,0 +1,6 @@
find_program(SCCACHE_FOUND sccache)
if(SCCACHE_FOUND)
set(CMAKE_C_COMPILER_LAUNCHER sccache)
set(CMAKE_CXX_COMPILER_LAUNCHER sccache)
endif()

7
main.cpp Normal file
View File

@ -0,0 +1,7 @@
#include <iostream>
int main(int argc, char *argv[]) {
std::cout << "VectorSearch" << std::endl;
return 0;
}

4
scripts/bootstrap.sh Executable file
View File

@ -0,0 +1,4 @@
#!/usr/bin/env sh
cmake -S . -B .build -G Ninja -D CMAKE_EXPORT_COMPILE_COMMANDS=ON
ln --symbolic --force .build/compile_commands.json

3
scripts/build.sh Executable file
View File

@ -0,0 +1,3 @@
#!/usr/bin/env sh
cmake --build .build