Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Install files using CMake, use CMake for Nix #5667

Merged
merged 3 commits into from
May 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions .github/workflows/nix-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,13 @@ jobs:
uses: actions/checkout@v3
with:
ref: ${{ github.ref }}
submodules: recursive

- uses: cachix/install-nix-action@v25
- uses: cachix/install-nix-action@v26
- uses: DeterminateSystems/magic-nix-cache-action@main
- uses: cachix/cachix-action@v12
with:
name: hyprland
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'

- run: nix build .#${{ matrix.package }} --extra-substituters "https://hyprland.cachix.org" -L
- run: nix build '.?submodules=1#${{ matrix.package }}' -L --extra-substituters "https://hyprland.cachix.org"
7 changes: 3 additions & 4 deletions .github/workflows/nix-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@ name: Nix
on: [push, pull_request, workflow_dispatch]

jobs:
wlroots:
if: github.event_name != 'pull_request'
uses: ./.github/workflows/nix-update-wlroots.yml
update-inputs:
uses: ./.github/workflows/nix-update-inputs.yml
secrets: inherit

build:
if: always() && !cancelled() && !contains(needs.*.result, 'failure')
needs: wlroots
needs: update-inputs
uses: ./.github/workflows/nix-build.yml
secrets: inherit
11 changes: 4 additions & 7 deletions .github/workflows/nix-update-inputs.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
name: Nix

on:
schedule:
- cron: '0 0 * * *' # check daily
workflow_call:
secrets:
PAT:
required: true

jobs:
update:
Expand All @@ -22,8 +24,3 @@ jobs:
uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: "[gha] Nix: update inputs"

update-build:
needs: update
uses: ./.github/workflows/nix-build.yml
secrets: inherit
26 changes: 0 additions & 26 deletions .github/workflows/nix-update-wlroots.yml

This file was deleted.

71 changes: 66 additions & 5 deletions CMakeLists.txt
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
cmake_minimum_required(VERSION 3.27)

include(CheckIncludeFile)
include(ExternalProject)
include(GNUInstallDirs)

# Get version
file(READ ${CMAKE_CURRENT_SOURCE_DIR}/props.json PROPS)
Expand All @@ -12,6 +15,7 @@ project(Hyprland

set(HYPRLAND_VERSION ${VER})
set(PREFIX ${CMAKE_INSTALL_PREFIX})
set(INCLUDEDIR ${CMAKE_INSTALL_INCLUDEDIR})
configure_file(hyprland.pc.in hyprland.pc @ONLY)

set(CMAKE_MESSAGE_LOG_LEVEL "STATUS")
Expand All @@ -23,17 +27,13 @@ message(STATUS "Gathering git info")
execute_process(
COMMAND ./scripts/generateVersion.sh
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
#
#

# udis
add_subdirectory("subprojects/udis86")

# wlroots
message(STATUS "Setting up wlroots")

include(ExternalProject)

if(CMAKE_BUILD_TYPE)
string(TOLOWER ${CMAKE_BUILD_TYPE} BUILDTYPE_LOWER)
if(BUILDTYPE_LOWER STREQUAL "release")
Expand Down Expand Up @@ -112,7 +112,7 @@ pkg_check_modules(deps REQUIRED IMPORTED_TARGET
hyprwayland-scanner>=0.3.4 hyprlang>=0.3.2 hyprcursor>=0.1.7
)

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

set(TRACY_CPP_FILES "")
if(USE_TRACY)
Expand Down Expand Up @@ -287,3 +287,64 @@ protocolNew("staging/ext-session-lock/ext-session-lock-v1.xml" "ext-session-lock
# tools
add_subdirectory(hyprctl)
add_subdirectory(hyprpm)

# binary and symlink
install(TARGETS Hyprland)

install(CODE "execute_process( \
COMMAND ${CMAKE_COMMAND} -E create_symlink \
${CMAKE_INSTALL_BINDIR}/Hyprland \
${CMAKE_INSTALL_BINDIR}/hyprland
)"
)

# session file
install(FILES ${CMAKE_SOURCE_DIR}/example/hyprland.desktop
DESTINATION ${CMAKE_INSTALL_DATADIR}/wayland-sessions)

# wallpapers
file(GLOB_RECURSE WALLPAPERS "assets/wall*")
install(FILES ${WALLPAPERS}
DESTINATION ${CMAKE_INSTALL_DATADIR}/hyprland)

# default config
install(FILES ${CMAKE_SOURCE_DIR}/example/hyprland.conf
DESTINATION ${CMAKE_INSTALL_DATADIR}/hyprland)

# portal config
install(FILES ${CMAKE_SOURCE_DIR}/assets/hyprland-portals.conf
DESTINATION ${CMAKE_INSTALL_DATADIR}/xdg-desktop-portal)

# man pages
file(GLOB_RECURSE MANPAGES "docs/*.1")
install(FILES ${MANPAGES}
DESTINATION ${CMAKE_INSTALL_MANDIR}/man1)


# pkgconfig entry
install(FILES ${CMAKE_BINARY_DIR}/hyprland.pc
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/pkgconfig)

# wlroots headers
set(HEADERS_WLR "${CMAKE_CURRENT_SOURCE_DIR}/subprojects/wlroots-hyprland/include/wlr")
install(DIRECTORY ${HEADERS_WLR}
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/hyprland
FILES_MATCHING PATTERN "*.h")

# config.h and version.h
set(HEADERS_WLR_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/subprojects/wlroots-hyprland/build/include/wlr")
install(DIRECTORY ${HEADERS_WLR_ROOT}/
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/hyprland/wlr
FILES_MATCHING PATTERN "*.h")

# protocol headers
set(HEADERS_PROTO "${CMAKE_CURRENT_SOURCE_DIR}/protocols")
install(DIRECTORY ${HEADERS_PROTO}
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/hyprland
FILES_MATCHING PATTERN "*.h*")

# hyprland headers
set(HEADERS_SRC "${CMAKE_CURRENT_SOURCE_DIR}/src")
install(DIRECTORY ${HEADERS_SRC}
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/hyprland
FILES_MATCHING PATTERN "*.h*")
63 changes: 9 additions & 54 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,86 +2,42 @@ PREFIX = /usr/local

legacyrenderer:
cmake --no-warn-unused-cli -DCMAKE_BUILD_TYPE:STRING=Release -DCMAKE_INSTALL_PREFIX:STRING=${PREFIX} -DLEGACY_RENDERER:BOOL=true -S . -B ./build -G Ninja
cmake --build ./build --config Release --target all -j`nproc 2>/dev/null || getconf NPROCESSORS_CONF`
cmake --build ./build --config Release --target all
chmod -R 777 ./build

legacyrendererdebug:
cmake --no-warn-unused-cli -DCMAKE_BUILD_TYPE:STRING=Debug -DCMAKE_INSTALL_PREFIX:STRING=${PREFIX} -DLEGACY_RENDERER:BOOL=true -S . -B ./build -G Ninja
cmake --build ./build --config Release --target all -j`nproc 2>/dev/null || getconf NPROCESSORS_CONF`
cmake --build ./build --config Release --target all
chmod -R 777 ./build

release:
cmake --no-warn-unused-cli -DCMAKE_BUILD_TYPE:STRING=Release -DCMAKE_INSTALL_PREFIX:STRING=${PREFIX} -S . -B ./build -G Ninja
cmake --build ./build --config Release --target all -j`nproc 2>/dev/null || getconf NPROCESSORS_CONF`
cmake --build ./build --config Release --target all
chmod -R 777 ./build

debug:
cmake --no-warn-unused-cli -DCMAKE_BUILD_TYPE:STRING=Debug -DCMAKE_INSTALL_PREFIX:STRING=${PREFIX} -S . -B ./build -G Ninja
cmake --build ./build --config Debug --target all -j`nproc 2>/dev/null || getconf NPROCESSORS_CONF`
cmake --build ./build --config Debug --target all
chmod -R 777 ./build

nopch:
cmake --no-warn-unused-cli -DCMAKE_BUILD_TYPE:STRING=Release -DCMAKE_INSTALL_PREFIX:STRING=${PREFIX} -DCMAKE_DISABLE_PRECOMPILE_HEADERS=ON -S . -B ./build -G Ninja
cmake --build ./build --config Release --target all -j`nproc 2>/dev/null || getconf NPROCESSORS_CONF`
cmake --build ./build --config Release --target all

clear:
rm -rf build
rm -f ./protocols/*.h ./protocols/*.c ./protocols/*.cpp ./protocols/*.hpp
rm -rf ./subprojects/wlroots-hyprland/build

all:
@if [[ "$EUID" = 0 ]]; then echo -en "Avoid running $(MAKE) all as sudo.\n"; fi
$(MAKE) clear
$(MAKE) release

install:
@if [ ! -f ./build/Hyprland ]; then echo -en "You need to run $(MAKE) all first.\n" && exit 1; fi
@echo -en "!NOTE: Please note make install does not compile Hyprland and only installs the already built files."

mkdir -p ${PREFIX}/share/wayland-sessions
mkdir -p ${PREFIX}/bin
mkdir -p ${PREFIX}/share/hyprland
mkdir -p ${PREFIX}/share/bash-completion/completions
mkdir -p ${PREFIX}/share/fish/vendor_completions.d
mkdir -p ${PREFIX}/share/zsh/site-functions
cp -f ./build/Hyprland ${PREFIX}/bin
cp -f ./build/hyprctl/hyprctl ${PREFIX}/bin
cp -f ./build/hyprpm/hyprpm ${PREFIX}/bin
cp -f ./hyprctl/hyprctl.bash ${PREFIX}/share/bash-completion/completions/hyprctl
cp -f ./hyprctl/hyprctl.fish ${PREFIX}/share/fish/vendor_completions.d/hyprctl.fish
cp -f ./hyprctl/hyprctl.zsh ${PREFIX}/share/zsh/site-functions/_hyprctl
cp -f ./hyprpm/hyprpm.bash ${PREFIX}/share/bash-completion/completions/hyprpm
cp -f ./hyprpm/hyprpm.fish ${PREFIX}/share/fish/vendor_completions.d/hyprpm.fish
cp -f ./hyprpm/hyprpm.zsh ${PREFIX}/share/zsh/site-functions/_hyprpm
chmod 755 ${PREFIX}/bin/Hyprland
chmod 755 ${PREFIX}/bin/hyprctl
chmod 755 ${PREFIX}/bin/hyprpm
cd ${PREFIX}/bin && ln -sf Hyprland hyprland
if [ ! -f ${PREFIX}/share/wayland-sessions/hyprland.desktop ]; then cp ./example/hyprland.desktop ${PREFIX}/share/wayland-sessions; fi
cp ./assets/wall* ${PREFIX}/share/hyprland
mkdir -p ${PREFIX}/share/xdg-desktop-portal
cp ./assets/hyprland-portals.conf ${PREFIX}/share/xdg-desktop-portal

mkdir -p ${PREFIX}/share/man/man1
install -m644 ./docs/*.1 ${PREFIX}/share/man/man1

$(MAKE) installheaders
cmake --install ./build

uninstall:
rm -f ${PREFIX}/share/wayland-sessions/hyprland.desktop
rm -f ${PREFIX}/bin/Hyprland
rm -f ${PREFIX}/bin/hyprland
rm -f ${PREFIX}/bin/hyprctl
rm -f ${PREFIX}/bin/hyprpm
rm -rf ${PREFIX}/share/hyprland
rm -f ${PREFIX}/share/man/man1/Hyprland.1
rm -f ${PREFIX}/share/man/man1/hyprctl.1
rm -f ${PREFIX}/share/bash-completion/completions/hyprctl
rm -f ${PREFIX}/share/fish/vendor_completions.d/hyprctl.fish
rm -f ${PREFIX}/share/zsh/site-functions/_hyprctl
rm -f ${PREFIX}/share/bash-completion/completions/hyprpm
rm -f ${PREFIX}/share/fish/vendor_completions.d/hyprpm.fish
rm -f ${PREFIX}/share/zsh/site-functions/_hyprpm
xargs rm < ./build/install_manifest.txt

pluginenv:
@echo -en "$(MAKE) pluginenv has been deprecated.\nPlease run $(MAKE) all && sudo $(MAKE) installheaders\n"
Expand All @@ -95,7 +51,7 @@ installheaders:
mkdir -p ${PREFIX}/include/hyprland/protocols
mkdir -p ${PREFIX}/include/hyprland/wlroots-hyprland
mkdir -p ${PREFIX}/share/pkgconfig

find src -name '*.h*' -print0 | cpio --quiet -0dump ${PREFIX}/include/hyprland
cd subprojects/wlroots-hyprland/include && find . -name '*.h*' -print0 | cpio --quiet -0dump ${PREFIX}/include/hyprland/wlroots-hyprland && cd ../../..
cd subprojects/wlroots-hyprland/build/include && find . -name '*.h*' -print0 | cpio --quiet -0dump ${PREFIX}/include/hyprland/wlroots-hyprland && cd ../../../..
Expand Down Expand Up @@ -143,8 +99,7 @@ asan:

patch -p1 < ./scripts/hyprlandStaticAsan.diff
cmake --no-warn-unused-cli -DCMAKE_BUILD_TYPE:STRING=Debug -DWITH_ASAN:STRING=True -DUSE_TRACY:STRING=False -DUSE_TRACY_GPU:STRING=False -S . -B ./build -G Ninja
cmake --build ./build --config Debug --target all -j`nproc 2>/dev/null || getconf NPROCESSORS_CONF`
cmake --build ./build --config Debug --target all
@echo "Hyprland done"

ASAN_OPTIONS="detect_odr_violation=0,log_path=asan.log" HYPRLAND_NO_CRASHREPORTER=1 ./build/Hyprland -c ~/.config/hypr/hyprland.conf

25 changes: 3 additions & 22 deletions flake.lock

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

Loading
Loading