templates: add c++-meson
This commit is contained in:
parent
9822b034f7
commit
b3e75b374a
23
templates/c++-meson/.clang-format
Normal file
23
templates/c++-meson/.clang-format
Normal 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
7
templates/c++-meson/.gitignore
vendored
Normal file
|
@ -0,0 +1,7 @@
|
|||
# CMake build directories
|
||||
/build
|
||||
/build-*
|
||||
|
||||
# Nix generated files
|
||||
/.pre-commit-config.yaml
|
||||
/result
|
26
templates/c++-meson/.woodpecker/check.yml
Normal file
26
templates/c++-meson/.woodpecker/check.yml
Normal 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
|
112
templates/c++-meson/flake.nix
Normal file
112
templates/c++-meson/flake.nix
Normal 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;
|
||||
};
|
||||
});
|
||||
}
|
13
templates/c++-meson/meson.build
Normal file
13
templates/c++-meson/meson.build
Normal 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')
|
5
templates/c++-meson/src/main.cc
Normal file
5
templates/c++-meson/src/main.cc
Normal file
|
@ -0,0 +1,5 @@
|
|||
#include <iostream>
|
||||
|
||||
int main() {
|
||||
std::cout << "Hello World!\n";
|
||||
}
|
8
templates/c++-meson/src/meson.build
Normal file
8
templates/c++-meson/src/meson.build
Normal file
|
@ -0,0 +1,8 @@
|
|||
sources = files(
|
||||
'main.cc',
|
||||
)
|
||||
|
||||
executable(
|
||||
'project',
|
||||
sources : sources,
|
||||
)
|
1
templates/c++-meson/tests/meson.build
Normal file
1
templates/c++-meson/tests/meson.build
Normal file
|
@ -0,0 +1 @@
|
|||
subdir('unit')
|
5
templates/c++-meson/tests/unit/dummy_test.cc
Normal file
5
templates/c++-meson/tests/unit/dummy_test.cc
Normal file
|
@ -0,0 +1,5 @@
|
|||
#include <gtest/gtest.h>
|
||||
|
||||
TEST(misc, passing) {
|
||||
ASSERT_EQ(1, 1);
|
||||
}
|
13
templates/c++-meson/tests/unit/meson.build
Normal file
13
templates/c++-meson/tests/unit/meson.build
Normal 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)
|
|
@ -3,4 +3,8 @@
|
|||
path = ./c++-cmake;
|
||||
description = "A C++ project using CMake";
|
||||
};
|
||||
"c++-meson" = {
|
||||
path = ./c++-meson;
|
||||
description = "A C++ project using CMake";
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue