Skip to content

Commit

Permalink
core: Move to hyprutils for util functions (#48)
Browse files Browse the repository at this point in the history
* move to hyprutils

* Nix: add hyprutils dep

---------

Co-authored-by: Mihai Fufezan <[email protected]>
  • Loading branch information
vaxerski and fufexan committed Jun 8, 2024
1 parent 87d5d98 commit ec6938c
Show file tree
Hide file tree
Showing 8 changed files with 102 additions and 242 deletions.
57 changes: 20 additions & 37 deletions .github/workflows/arch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,39 +2,6 @@ name: Build & Test (Arch)

on: [push, pull_request, workflow_dispatch]
jobs:
gcc:
name: "gcc build / clang test"
runs-on: ubuntu-latest
container:
image: archlinux
steps:
- name: Checkout repository actions
uses: actions/checkout@v4
with:
sparse-checkout: .github/actions

- name: Get required pkgs
run: |
sed -i 's/SigLevel = Required DatabaseOptional/SigLevel = Optional TrustAll/' /etc/pacman.conf
pacman --noconfirm --noprogressbar -Syyu
pacman --noconfirm --noprogressbar -Sy gcc base-devel cmake clang libc++
- name: Build hyprlang with gcc
run: |
CC="/usr/bin/gcc" CXX="/usr/bin/g++" cmake --no-warn-unused-cli -DCMAKE_BUILD_TYPE:STRING=Release -DCMAKE_INSTALL_PREFIX:PATH=/usr -S . -B ./build
CC="/usr/bin/gcc" CXX="/usr/bin/g++" cmake --build ./build --config Release --target hyprlang -j`nproc 2>/dev/null || getconf NPROCESSORS_CONF`
cmake --install ./build
- name: Build tests with clang
run: |
rm -rf ./build
CC="/usr/bin/clang" CXX="/usr/bin/clang++" cmake --no-warn-unused-cli -DCMAKE_BUILD_TYPE:STRING=Release -DCMAKE_INSTALL_PREFIX:PATH=/usr -DCMAKE_CXX_FLAGS="-stdlib=libc++" -S . -B ./build
CC="/usr/bin/clang" CXX="/usr/bin/clang++" cmake --build ./build --config Release --target tests -j`nproc 2>/dev/null || getconf NPROCESSORS_CONF`
- name: Run tests
run: |
cd ./build && ctest --output-on-failure
asan:
name: "gcc build / ASan tests"
runs-on: ubuntu-latest
Expand All @@ -50,7 +17,11 @@ jobs:
run: |
sed -i 's/SigLevel = Required DatabaseOptional/SigLevel = Optional TrustAll/' /etc/pacman.conf
pacman --noconfirm --noprogressbar -Syyu
pacman --noconfirm --noprogressbar -Sy gcc base-devel cmake clang
pacman --noconfirm --noprogressbar -Sy gcc base-devel cmake clang git
- name: Get hyprutils-git
run: |
git clone https://github.com/hyprwm/hyprutils && cd hyprutils && cmake -DCMAKE_BUILD_TYPE:STRING=Release -DCMAKE_INSTALL_PREFIX:PATH=/usr -B build && cmake --build build --target hyprutils && cmake --install build
- name: Build with gcc
run: |
Expand All @@ -77,7 +48,11 @@ jobs:
run: |
sed -i 's/SigLevel = Required DatabaseOptional/SigLevel = Optional TrustAll/' /etc/pacman.conf
pacman --noconfirm --noprogressbar -Syyu
pacman --noconfirm --noprogressbar -Sy gcc base-devel cmake clang
pacman --noconfirm --noprogressbar -Sy gcc base-devel cmake clang git
- name: Get hyprutils-git
run: |
git clone https://github.com/hyprwm/hyprutils && cd hyprutils && cmake -DCMAKE_BUILD_TYPE:STRING=Release -DCMAKE_INSTALL_PREFIX:PATH=/usr -B build && cmake --build build --target hyprutils && cmake --install build
- name: Build with gcc
run: |
Expand All @@ -104,7 +79,11 @@ jobs:
run: |
sed -i 's/SigLevel = Required DatabaseOptional/SigLevel = Optional TrustAll/' /etc/pacman.conf
pacman --noconfirm --noprogressbar -Syyu
pacman --noconfirm --noprogressbar -Sy gcc base-devel cmake clang
pacman --noconfirm --noprogressbar -Sy gcc base-devel cmake clang git
- name: Get hyprutils-git
run: |
git clone https://github.com/hyprwm/hyprutils && cd hyprutils && cmake -DCMAKE_BUILD_TYPE:STRING=Release -DCMAKE_INSTALL_PREFIX:PATH=/usr -B build && cmake --build build --target hyprutils && cmake --install build
- name: Build with gcc
run: |
Expand All @@ -131,7 +110,11 @@ jobs:
run: |
sed -i 's/SigLevel = Required DatabaseOptional/SigLevel = Optional TrustAll/' /etc/pacman.conf
pacman --noconfirm --noprogressbar -Syyu
pacman --noconfirm --noprogressbar -Sy gcc base-devel cmake clang libc++
pacman --noconfirm --noprogressbar -Sy gcc base-devel cmake clang libc++ git
- name: Get hyprutils-git
run: |
git clone https://github.com/hyprwm/hyprutils && cd hyprutils && cmake -DCMAKE_BUILD_TYPE:STRING=Release -DCMAKE_INSTALL_PREFIX:PATH=/usr -B build && cmake --build build --target hyprutils && cmake --install build
- name: Build hyprlang with clang
run: |
Expand Down
11 changes: 9 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ add_compile_definitions(HYPRLANG_INTERNAL)

set(CMAKE_CXX_STANDARD 23)

find_package(PkgConfig REQUIRED)
pkg_check_modules(deps REQUIRED IMPORTED_TARGET
hyprutils>=0.1.1
)

file(GLOB_RECURSE SRCFILES CONFIGURE_DEPENDS "src/*.cpp" "include/hyprlang.hpp")

add_library(hyprlang SHARED ${SRCFILES})
Expand All @@ -40,6 +45,8 @@ set_target_properties(hyprlang PROPERTIES
SOVERSION 2
PUBLIC_HEADER include/hyprlang.hpp)

target_link_libraries(hyprlang PkgConfig::deps)

if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
# for std::expected.
# probably evil. Arch's clang is very outdated tho...
Expand All @@ -55,12 +62,12 @@ install(TARGETS hyprlang)
add_custom_target(tests)

add_executable(hyprlang_test "tests/parse/main.cpp")
target_link_libraries(hyprlang_test PRIVATE hyprlang)
target_link_libraries(hyprlang_test PRIVATE hyprlang hyprutils)
add_test(NAME "Parsing" WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/tests COMMAND hyprlang_test "parse")
add_dependencies(tests hyprlang_test)

add_executable(hyprlang_fuzz "tests/fuzz/main.cpp")
target_link_libraries(hyprlang_fuzz PRIVATE hyprlang)
target_link_libraries(hyprlang_fuzz PRIVATE hyprlang hyprutils)
add_test(NAME "Fuzz" WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/tests COMMAND hyprlang_fuzz "fuzz")
add_dependencies(tests hyprlang_fuzz)

Expand Down
30 changes: 27 additions & 3 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 18 additions & 8 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,20 @@
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
systems.url = "github:nix-systems/default-linux";

hyprutils = {
url = "github:hyprwm/hyprutils";
inputs.nixpkgs.follows = "nixpkgs";
inputs.systems.follows = "systems";
};
};

outputs = {
self,
nixpkgs,
systems,
}: let
...
} @ inputs: let
inherit (nixpkgs) lib;
eachSystem = lib.genAttrs (import systems);
pkgsFor = eachSystem (system:
Expand All @@ -26,13 +33,16 @@
in {
overlays = {
default = self.overlays.hyprlang;
hyprlang = final: prev: {
hyprlang = final.callPackage ./nix/default.nix {
stdenv = final.gcc13Stdenv;
version = "0.pre" + "+date=" + (mkDate (self.lastModifiedDate or "19700101")) + "_" + (self.shortRev or "dirty");
};
hyprlang-with-tests = final.hyprlang.override {doCheck = true;};
};
hyprlang = lib.composeManyExtensions [
inputs.hyprutils.overlays.default
(final: prev: {
hyprlang = final.callPackage ./nix/default.nix {
stdenv = final.gcc13Stdenv;
version = "0.pre" + "+date=" + (mkDate (self.lastModifiedDate or "19700101")) + "_" + (self.shortRev or "dirty");
};
hyprlang-with-tests = final.hyprlang.override {doCheck = true;};
})
];
};

packages = eachSystem (system: {
Expand Down
9 changes: 8 additions & 1 deletion nix/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
lib,
stdenv,
cmake,
hyprutils,
pkg-config,
version ? "git",
doCheck ? false,
}:
Expand All @@ -10,7 +12,12 @@ stdenv.mkDerivation {
inherit version doCheck;
src = ../.;

nativeBuildInputs = [cmake];
nativeBuildInputs = [
cmake
pkg-config
];

buildInputs = [hyprutils];

outputs = ["out" "dev"];

Expand Down
55 changes: 0 additions & 55 deletions src/VarList.cpp

This file was deleted.

63 changes: 0 additions & 63 deletions src/VarList.hpp

This file was deleted.

Loading

0 comments on commit ec6938c

Please sign in to comment.