templates: add c++-meson

This commit is contained in:
Bruno BELANYI 2023-04-04 16:21:05 +00:00
parent 9822b034f7
commit b3e75b374a
11 changed files with 217 additions and 0 deletions

View file

@ -0,0 +1,23 @@
# vim: ft=yaml
---
BasedOnStyle: LLVM
IndentWidth: 4
---
Language: Cpp
# Force pointers to the type for C++.
DerivePointerAlignment: false
PointerAlignment: Left
# Short functions should not be on a single line, unless empty
AllowShortFunctionsOnASingleLine: Empty
# Make them level
AccessModifierOffset: -4
# It makes more sense this way
BreakBeforeBinaryOperators: All
BreakBeforeTernaryOperators: true
# Aesthetic
AlignOperands: AlignAfterOperator
---

7
templates/c++-meson/.gitignore vendored Normal file
View file

@ -0,0 +1,7 @@
# CMake build directories
/build
/build-*
# Nix generated files
/.pre-commit-config.yaml
/result

View file

@ -0,0 +1,26 @@
labels:
type: exec
pipeline:
- name: nix flake check
image: bash
commands:
- nix flake check
- name: notifiy
image: bash
secrets:
- source: matrix_homeserver
target: address
- source: matrix_roomid
target: room
- source: matrix_username
target: user
- source: matrix_password
target: pass
commands:
- nix run '.#matrix-notifier'
when:
status:
- failure
- success

View file

@ -0,0 +1,112 @@
{
description = "A C++ project";
inputs = {
futils = {
type = "github";
owner = "numtide";
repo = "flake-utils";
ref = "main";
};
nixpkgs = {
type = "github";
owner = "NixOS";
repo = "nixpkgs";
ref = "nixos-unstable";
};
pre-commit-hooks = {
type = "github";
owner = "cachix";
repo = "pre-commit-hooks.nix";
ref = "master";
inputs = {
flake-utils.follows = "futils";
nixpkgs.follows = "nixpkgs";
};
};
};
outputs = { self, futils, nixpkgs, pre-commit-hooks }:
{
overlays = {
default = final: prev: {
project = with final; stdenv.mkDerivation {
pname = "project";
version = "0.0.0";
src = self;
nativeBuildInputs = with pkgs; [
meson
ninja
pkg-config
];
checkInputs = with pkgs; [
gtest
];
doCheck = true;
meta = with lib; {
description = "A C++ project";
homepage = "https://gitea.belanyi.fr/ambroisie/project";
license = licenses.mit;
maintainers = with maintainers; [ ambroisie ];
platforms = platforms.unix;
};
};
};
};
} // futils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs {
inherit system;
overlays = [
self.overlays.default
];
};
pre-commit = pre-commit-hooks.lib.${system}.run {
src = self;
hooks = {
nixpkgs-fmt = {
enable = true;
};
clang-format = {
enable = true;
};
};
};
in
{
checks = {
inherit (self.packages.${system}) project;
inherit pre-commit;
};
devShells = {
default = pkgs.mkShell {
inputsFrom = with self.packages.${system}; [
project
];
packages = with pkgs; [
clang-tools
];
inherit (pre-commit) shellHook;
};
};
packages = futils.lib.flattenTree {
default = pkgs.project;
inherit (pkgs) project;
};
});
}

View file

@ -0,0 +1,13 @@
project(
'project',
'cpp',
version : '0.0.0',
license: 'MIT',
default_options : [
'cpp_std=c++20',
'warning_level=3',
],
)
subdir('src')
subdir('tests')

View file

@ -0,0 +1,5 @@
#include <iostream>
int main() {
std::cout << "Hello World!\n";
}

View file

@ -0,0 +1,8 @@
sources = files(
'main.cc',
)
executable(
'project',
sources : sources,
)

View file

@ -0,0 +1 @@
subdir('unit')

View file

@ -0,0 +1,5 @@
#include <gtest/gtest.h>
TEST(misc, passing) {
ASSERT_EQ(1, 1);
}

View file

@ -0,0 +1,13 @@
gtest_dep = dependency(
'gtest',
main : true,
required : false,
)
dummy_test = executable(
'dummy_test',
'dummy_test.cc',
dependencies : gtest_dep,
)
test('dummy test', dummy_test)

View file

@ -3,4 +3,8 @@
path = ./c++-cmake; path = ./c++-cmake;
description = "A C++ project using CMake"; description = "A C++ project using CMake";
}; };
"c++-meson" = {
path = ./c++-meson;
description = "A C++ project using CMake";
};
} }