core: project setup

This commit is contained in:
outfoxxed 2024-10-17 22:24:58 -07:00
commit bd99baf876
No known key found for this signature in database
GPG key ID: 4C88A185FB89301E
13 changed files with 376 additions and 0 deletions

65
.clang-format Normal file
View file

@ -0,0 +1,65 @@
---
Language: Cpp
BasedOnStyle: LLVM
AccessModifierOffset: -2
AlignAfterOpenBracket: Align
AlignConsecutiveMacros: true
AlignConsecutiveAssignments: true
AlignEscapedNewlines: Right
AlignOperands: false
AlignTrailingComments: true
AllowAllArgumentsOnNextLine: true
AllowAllConstructorInitializersOnNextLine: true
AllowAllParametersOfDeclarationOnNextLine: true
AllowShortBlocksOnASingleLine: true
AllowShortCaseLabelsOnASingleLine: true
AllowShortFunctionsOnASingleLine: Empty
AllowShortIfStatementsOnASingleLine: Never
AllowShortLambdasOnASingleLine: All
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: false
AlwaysBreakTemplateDeclarations: Yes
BreakBeforeBraces: Attach
BreakBeforeTernaryOperators: false
BreakConstructorInitializers: AfterColon
ColumnLimit: 100
CompactNamespaces: false
ConstructorInitializerAllOnOneLineOrOnePerLine: false
ExperimentalAutoDetectBinPacking: false
FixNamespaceComments: false
IncludeBlocks: Preserve
IndentCaseLabels: true
IndentWidth: 4
PointerAlignment: Left
ReflowComments: false
SortIncludes: false
SortUsingDeclarations: false
SpaceAfterCStyleCast: false
SpaceAfterLogicalNot: false
SpaceAfterTemplateKeyword: true
SpaceBeforeCtorInitializerColon: true
SpaceBeforeInheritanceColon: true
SpaceBeforeParens: ControlStatements
SpaceBeforeRangeBasedForLoopColon: true
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 1
SpacesInAngles: false
SpacesInCStyleCastParentheses: false
SpacesInContainerLiterals: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
Standard: Auto
TabWidth: 4
UseTab: Never
AllowShortEnumsOnASingleLine: false
BraceWrapping:
AfterEnum: false
AlignConsecutiveDeclarations: AcrossEmptyLines
NamespaceIndentation: All

57
.clang-tidy Normal file
View file

@ -0,0 +1,57 @@
WarningsAsErrors: '*'
HeaderFilterRegex: '.*\.hpp'
FormatStyle: file
Checks: >
-*,
bugprone-*,
-bugprone-easily-swappable-parameters,
-bugprone-forward-declararion-namespace,
concurrency-*,
cppcoreguidelines-*,
-cppcoreguidelines-owning-memory,
-cppcoreguidelines-avoid-magic-numbers,
-cppcoreguidelines-pro-bounds-constant-array-index,
-cppcoreguidelines-avoid-const-or-ref-data-members,
-cppcoreguidelines-non-private-member-variables-in-classes,
-cppcoreguidelines-pro-bounds-array-to-pointer-decay,
-cppcoreguidelines-avoid-do-while,
google-build-using-namespace.
google-explicit-constructor,
google-global-names-in-headers,
google-readability-casting,
google-runtime-int,
google-runtime-operator,
misc-*,
-misc-no-recursion,
-misc-non-private-member-variables-in-classes,
modernize-*,
-modernize-return-braced-init-list,
-modernize-use-trailing-return-type,
performance-*,
portability-std-allocator-const,
readability-*,
-readability-function-cognitive-complexity,
-readability-function-size,
-readability-identifier-length,
-readability-magic-numbers,
-readability-uppercase-literal-suffix,
-readability-braces-around-statements,
-readability-redundant-access-specifiers,
-readability-else-after-return,
-readability-container-data-pointer,
-readability-implicit-bool-conversion,
tidyfox-*,
CheckOptions:
performance-for-range-copy.WarnOnAllAutoCopies: true
performance-inefficient-string-concatenation.StrictMode: true
readability-identifier-naming.ClassCase: CamelCase
readability-identifier-naming.ConstantCase: UPPER_CASE
readability-identifier-naming.EnumCase: CamelCase
readability-identifier-naming.EnumConstantCase: CamelCase
readability-identifier-naming.FunctionCase: camelBack
readability-identifier-naming.MemberCase: camelBack
readability-identifier-naming.NamespaceCase: lower_case
readability-identifier-naming.LocalConstantCase: camelBack
readability-identifier-naming.MethodCase: camelBack
readability-identifier-naming.ParameterCase: camelBack
readability-identifier-naming.VariableCase: camelBack

14
.editorconfig Normal file
View file

@ -0,0 +1,14 @@
root = true
[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
indent_style = space
indent_size = 4
[*.qml,*.nix]
indent_size = 2
[Makefile]
indent_style = tab

8
.gitignore vendored Normal file
View file

@ -0,0 +1,8 @@
# build
/build
/result
compile_commands.json
# direnv
/.direnv
/.envrc

16
CMakeLists.txt Normal file
View file

@ -0,0 +1,16 @@
cmake_minimum_required(VERSION 3.20)
include(GNUInstallDirs)
# Get version
file(READ "${CMAKE_SOURCE_DIR}/VERSION" VER_RAW)
string(STRIP ${VER_RAW} VER)
project(hyprland-qt-support VERSION ${VER} LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
find_package(Qt6 6.6 REQUIRED COMPONENTS Qml Quick QuickControls2)
qt_standard_project_setup(REQUIRES 6.6)
set(QT_QML_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/qml)

28
LICENSE Normal file
View file

@ -0,0 +1,28 @@
BSD 3-Clause License
Copyright (c) 2024, Hypr Development
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

24
Makefile Normal file
View file

@ -0,0 +1,24 @@
.PHONY: all
all: build
cmake --build build
build:
cmake -GNinja -B build -DCMAKE_BUILD_TYPE=RelWithDebInfo
.PHONY: dev
dev:
CMAKE_EXPORT_COMPILE_COMMANDS=1 cmake -GNinja -B build -DCMAKE_BUILD_TYPE=Debug
ln -sf build/compile_commands.json .
.PHONY: fmt
fmt:
find src -type f \( -name "*.cpp" -o -name "*.hpp" \) -print0 | xargs -0 clang-format -i
.PHONY: lint
lint:
find src -type f -name "*.cpp" -print0 | parallel -q0 --eta clang-tidy
.PHONY: clean
clean:
rm -rf build
rm -f compile_commands.json

1
VERSION Normal file
View file

@ -0,0 +1 @@
0.0.1

43
flake.lock Normal file
View file

@ -0,0 +1,43 @@
{
"nodes": {
"nixpkgs": {
"locked": {
"lastModified": 1728888510,
"narHash": "sha256-nsNdSldaAyu6PE3YUA+YQLqUDJh+gRbBooMMekZJwvI=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "a3c0b3b21515f74fd2665903d4ce6bc4dc81c77c",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"nixpkgs": "nixpkgs",
"systems": "systems"
}
},
"systems": {
"locked": {
"lastModified": 1689347949,
"narHash": "sha256-12tWmuL2zgBgZkdoB6qXZsgJEH9LR3oUgpaQq2RbI80=",
"owner": "nix-systems",
"repo": "default-linux",
"rev": "31732fcf5e8fea42e59c2488ad31a0e651500f68",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default-linux",
"type": "github"
}
}
},
"root": "root",
"version": 7
}

39
flake.nix Normal file
View file

@ -0,0 +1,39 @@
{
description = "extra qt support libraries for the hyprland ecosystem";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
systems.url = "github:nix-systems/default-linux";
};
outputs = {
self,
nixpkgs,
systems,
...
} @ inputs: let
inherit (nixpkgs) lib;
eachSystem = lib.genAttrs (import systems);
pkgsFor = eachSystem (
system:
import nixpkgs {
localSystem = system;
overlays = [self.overlays.default];
}
);
in {
overlays = import ./nix/overlays.nix { inherit inputs self lib; };
packages = eachSystem (system: {
default = self.packages.${system}.hyprland-qt-support;
inherit (pkgsFor.${system}) hyprland-qt-support;
});
devShells = eachSystem (system: {
default = import ./nix/shell.nix {
pkgs = pkgsFor.${system};
inherit (pkgsFor.${system}) hyprland-qt-support;
};
});
};
}

37
nix/default.nix Normal file
View file

@ -0,0 +1,37 @@
{
lib,
nix-gitignore,
stdenv,
cmake,
ninja,
qt6,
version ? "0",
}: let
inherit (lib.strings) makeBinPath;
in stdenv.mkDerivation {
pname = "hyprland-qt-support";
inherit version;
src = nix-gitignore.gitignoreSource [] ./..;
nativeBuildInputs = [
cmake
ninja
qt6.wrapQtAppsHook
];
buildInputs = [
qt6.qtbase
qt6.qtdeclarative
qt6.qtsvg
qt6.qtwayland
];
meta = {
description = "hyprland-qt-support";
homepage = "https://github.com/hyprwm/hyprland-qt-support";
license = lib.licenses.bsd3;
platforms = lib.platforms.linux;
};
}

23
nix/overlays.nix Normal file
View file

@ -0,0 +1,23 @@
{
inputs,
self,
lib,
}: let
mkDate = longDate: (lib.concatStringsSep "-" [
(builtins.substring 0 4 longDate)
(builtins.substring 4 2 longDate)
(builtins.substring 6 2 longDate)
]);
date = mkDate (self.lastModifiedDate or "19700101");
version = lib.removeSuffix "\n" (builtins.readFile ../VERSION);
in {
default = self.overlays.hyprland-qt-support;
hyprland-qt-support = lib.composeManyExtensions [
(final: prev: {
hyprland-qt-support = final.callPackage ./. {
version = "${version}+date=${date}_${self.shortRev or "dirty"}";
};
})
];
}

21
nix/shell.nix Normal file
View file

@ -0,0 +1,21 @@
{
pkgs ? import <nixpkgs> {},
hyprland-qt-support ? pkgs.callPackage ./default.nix {},
...
}: pkgs.mkShell {
inputsFrom = [ hyprland-qt-support ];
nativeBuildInputs = [ pkgs.clang-tools pkgs.parallel ];
shellHook = let
inherit (pkgs.lib.strings) concatMapStringsSep;
qtLibPath = f: concatMapStringsSep ":" f (with pkgs.qt6; [
qtbase
qtdeclarative
qtwayland
]);
in ''
# Add Qt-related environment variables.
export QT_PLUGIN_PATH=${qtLibPath (p: "${p}/lib/qt-6/plugins")}
export QML2_IMPORT_PATH=${qtLibPath (p: "${p}/lib/qt-6/qml")}
'';
}