From f57d991e3a73bcc447dc4b87e1689132295c7076 Mon Sep 17 00:00:00 2001 From: Mihai Fufezan Date: Tue, 12 Mar 2024 22:24:09 +0200 Subject: [PATCH] Makefile: remove No longer used. Functionality moved to CMake. --- CMakeLists.txt | 40 +++++++++++++++++++++++--- Makefile | 74 ------------------------------------------------- README.md | 15 ++++++---- nix/default.nix | 35 ++++------------------- 4 files changed, 52 insertions(+), 112 deletions(-) delete mode 100644 Makefile diff --git a/CMakeLists.txt b/CMakeLists.txt index 09bd2d5..05ba13e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -35,6 +35,35 @@ execute_process( # # +find_program(WaylandScanner NAMES wayland-scanner) +message(STATUS "Found WaylandScanner at ${WaylandScanner}") +execute_process( + COMMAND pkg-config --variable=pkgdatadir wayland-protocols + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + OUTPUT_VARIABLE WAYLAND_PROTOCOLS_DIR + OUTPUT_STRIP_TRAILING_WHITESPACE) +message(STATUS "Found wayland-protocols at ${WAYLAND_PROTOCOLS_DIR}") + +function(protocol protoPath protoName external) + if (external) + execute_process( + COMMAND ${WaylandScanner} client-header ${protoPath} ${protoName}-protocol.h + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}) + execute_process( + COMMAND ${WaylandScanner} private-code ${protoPath} ${protoName}-protocol.c + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}) + target_sources(hyprpaper PRIVATE ${protoName}-protocol.h ${protoName}-protocol.c) + else() + execute_process( + COMMAND ${WaylandScanner} client-header ${WAYLAND_PROTOCOLS_DIR}/${protoPath} ${protoName}-protocol.h + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}) + execute_process( + COMMAND ${WaylandScanner} private-code ${WAYLAND_PROTOCOLS_DIR}/${protoPath} ${protoName}-protocol.c + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}) + target_sources(hyprpaper PRIVATE ${protoName}-protocol.h ${protoName}-protocol.c) + endif() +endfunction() + include_directories(.) add_compile_options(-std=c++2b -DWLR_USE_UNSTABLE ) add_compile_options(-Wall -Wextra -Wno-unused-parameter -Wno-unused-value -Wno-missing-field-initializers -Wno-narrowing) @@ -47,6 +76,11 @@ file(GLOB_RECURSE SRCFILES "src/*.cpp") add_executable(hyprpaper ${SRCFILES}) +protocol("protocols/wlr-layer-shell-unstable-v1.xml" "wlr-layer-shell-unstable-v1" true) +protocol("stable/xdg-shell/xdg-shell.xml" "xdg-shell" false) +protocol("stable/viewporter/viewporter.xml" "viewporter" false) +protocol("staging/fractional-scale/fractional-scale-v1.xml" "fractional-scale-v1" false) + target_compile_definitions(hyprpaper PRIVATE "-DGIT_COMMIT_HASH=\"${GIT_COMMIT_HASH}\"") target_compile_definitions(hyprpaper PRIVATE "-DGIT_BRANCH=\"${GIT_BRANCH}\"") target_compile_definitions(hyprpaper PRIVATE "-DGIT_COMMIT_MESSAGE=\"${GIT_COMMIT_MESSAGE}\"") @@ -66,10 +100,6 @@ target_link_libraries(hyprpaper pthread magic ${CMAKE_THREAD_LIBS_INIT} - ${CMAKE_SOURCE_DIR}/wlr-layer-shell-unstable-v1-protocol.o - ${CMAKE_SOURCE_DIR}/xdg-shell-protocol.o - ${CMAKE_SOURCE_DIR}/fractional-scale-v1-protocol.o - ${CMAKE_SOURCE_DIR}/viewporter-protocol.o wayland-cursor ) @@ -78,3 +108,5 @@ IF(CMAKE_BUILD_TYPE MATCHES Debug OR CMAKE_BUILD_TYPE MATCHES DEBUG) SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pg -no-pie -fno-builtin") SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -pg -no-pie -fno-builtin") ENDIF(CMAKE_BUILD_TYPE MATCHES Debug OR CMAKE_BUILD_TYPE MATCHES DEBUG) + +install(TARGETS hyprpaper) diff --git a/Makefile b/Makefile deleted file mode 100644 index 3e02aec..0000000 --- a/Makefile +++ /dev/null @@ -1,74 +0,0 @@ -PREFIX ?= /usr -CFLAGS ?= -g -Wall -Wextra -Werror -Wno-unused-parameter -Wno-sign-compare -Wno-unused-function -Wno-unused-variable -Wno-unused-result -Wdeclaration-after-statement - -CFLAGS += -I. -DWLR_USE_UNSTABLE -std=c99 - -WAYLAND_PROTOCOLS=$(shell pkg-config --variable=pkgdatadir wayland-protocols) -WAYLAND_SCANNER=$(shell pkg-config --variable=wayland_scanner wayland-scanner) - -PKGS = wlroots wayland-server -CFLAGS += $(foreach p,$(PKGS),$(shell pkg-config --cflags $(p))) -LDLIBS += $(foreach p,$(PKGS),$(shell pkg-config --libs $(p))) - -wlr-layer-shell-unstable-v1-protocol.h: - $(WAYLAND_SCANNER) client-header \ - protocols/wlr-layer-shell-unstable-v1.xml $@ - -wlr-layer-shell-unstable-v1-protocol.c: - $(WAYLAND_SCANNER) private-code \ - protocols/wlr-layer-shell-unstable-v1.xml $@ - -wlr-layer-shell-unstable-v1-protocol.o: wlr-layer-shell-unstable-v1-protocol.h - -xdg-shell-protocol.h: - $(WAYLAND_SCANNER) client-header \ - $(WAYLAND_PROTOCOLS)/stable/xdg-shell/xdg-shell.xml $@ - -xdg-shell-protocol.c: - $(WAYLAND_SCANNER) private-code \ - $(WAYLAND_PROTOCOLS)/stable/xdg-shell/xdg-shell.xml $@ - -xdg-shell-protocol.o: xdg-shell-protocol.h - -fractional-scale-v1-protocol.h: - $(WAYLAND_SCANNER) client-header \ - $(WAYLAND_PROTOCOLS)/staging/fractional-scale/fractional-scale-v1.xml $@ - -fractional-scale-v1-protocol.c: - $(WAYLAND_SCANNER) private-code \ - $(WAYLAND_PROTOCOLS)/staging/fractional-scale/fractional-scale-v1.xml $@ - -fractional-scale-v1-protocol.o: fractional-scale-v1-protocol.h - -viewporter-protocol.h: - $(WAYLAND_SCANNER) client-header \ - $(WAYLAND_PROTOCOLS)/stable/viewporter/viewporter.xml $@ - -viewporter-protocol.c: - $(WAYLAND_SCANNER) private-code \ - $(WAYLAND_PROTOCOLS)/stable/viewporter/viewporter.xml $@ - -viewporter-protocol.o: viewporter-protocol.h - -protocols: wlr-layer-shell-unstable-v1-protocol.o xdg-shell-protocol.o fractional-scale-v1-protocol.o viewporter-protocol.o - -clear: - rm -rf build - rm -f *.o *-protocol.h *-protocol.c - -release: - mkdir -p build && cmake --no-warn-unused-cli -DCMAKE_BUILD_TYPE:STRING=Release -H./ -B./build -G Ninja - cmake --build ./build --config Release --target all -j 10 - -debug: - mkdir -p build && cmake --no-warn-unused-cli -DCMAKE_BUILD_TYPE:STRING=Debug -H./ -B./build -G Ninja - cmake --build ./build --config Debug --target all -j 10 - -all: - make clear - make protocols - make release - -install: - make all - cp ./build/hyprpaper $(PREFIX)/bin -f diff --git a/README.md b/README.md index 3a9d68d..47712cf 100644 --- a/README.md +++ b/README.md @@ -49,13 +49,18 @@ sudo zypper install ninja gcc-c++ wayland-protocols-devel Mesa-libGLESv3-devel f ### Building -``` -git clone https://github.com/hyprwm/hyprpaper -cd hyprpaper -make all +Building is done via CMake: + +```sh +cmake --no-warn-unused-cli -DCMAKE_BUILD_TYPE:STRING=Release -DCMAKE_INSTALL_PREFIX:PATH=/usr -S . -B ./build +cmake --build ./build --config Release --target hyprpaper -j`nproc 2>/dev/null || getconf NPROCESSORS_CONF` ``` -*the output binary will be in `./build/`, copy it to your PATH, e.g. `/usr/bin`* +Install with: + +```sh +cmake --install ./build +``` # Usage diff --git a/nix/default.nix b/nix/default.nix index ba84dc6..ab24856 100644 --- a/nix/default.nix +++ b/nix/default.nix @@ -3,7 +3,6 @@ stdenv, pkg-config, cmake, - ninja, cairo, expat, file, @@ -30,11 +29,16 @@ stdenv.mkDerivation { pname = "hyprpaper" + lib.optionalString debug "-debug"; inherit version; + src = ../.; + cmakeBuildType = + if debug + then "Debug" + else "Release"; + nativeBuildInputs = [ cmake - ninja pkg-config ]; @@ -61,33 +65,6 @@ stdenv.mkDerivation { util-linux ]; - configurePhase = '' - runHook preConfigure - - make protocols - - runHook postConfigure - ''; - - buildPhase = '' - runHook preBuild - - make release - - runHook postBuild - ''; - - installPhase = '' - runHook preInstall - - mkdir -p $out/{bin,share/licenses} - - install -Dm755 build/hyprpaper -t $out/bin - install -Dm644 LICENSE -t $out/share/licenses/hyprpaper - - runHook postInstall - ''; - meta = with lib; { homepage = "https://github.com/hyprwm/hyprpaper"; description = "A blazing fast wayland wallpaper utility with IPC controls";