From 1228eb57f9debd35811f0ade43bef5eaa09aab42 Mon Sep 17 00:00:00 2001 From: Jan Beich Date: Sun, 7 May 2023 14:38:50 +0000 Subject: [PATCH] Unbreak build on FreeBSD (#23) * make: unhardcode pixman-1 and libdrm include cflags On BSDs /usr/include only contains headers from base system. $ pkg-config --cflags pixman-1 -I/usr/local/include/pixman-1 $ pkg-config --cflags libdrm -I/usr/local/include -I/usr/local/include/libdrm * make: drop GCC dependencies /bin/sh: g++: not found c++: error: unsupported option '--no-gnu-unique' error: invalid value 'c++23' in '-std=c++23' * make: drop GNU make extensions Makefile is evaluated by both GNU make and BSD make but their extensions are not compatible. Instead of renaming Makefile to GNUmakefile support both. - GNU $(shell ...) is BSD ${:!...!} or POSIX sh `...` or $$(...) - GNU $^ is BSD $> for target rule prerequisites * hyprbars: silence Clang -Wc++11-narrowing like Hyprland barDeco.cpp:73:47: error: non-constant-expression cannot be narrowed from type 'int64_t' (aka 'long') to 'double' in initializer list [-Wc++11-narrowing] const auto BARBUF = Vector2D{(int)m_vLastWindowSize.x + 2 * *PBORDERSIZE, *PHEIGHT}; ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ barDeco.cpp:73:47: note: insert an explicit cast to silence this issue const auto BARBUF = Vector2D{(int)m_vLastWindowSize.x + 2 * *PBORDERSIZE, *PHEIGHT}; ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ static_cast( ) barDeco.cpp:73:92: error: non-constant-expression cannot be narrowed from type 'int64_t' (aka 'long') to 'double' in initializer list [-Wc++11-narrowing] const auto BARBUF = Vector2D{(int)m_vLastWindowSize.x + 2 * *PBORDERSIZE, *PHEIGHT}; ^~~~~~~~ barDeco.cpp:73:92: note: insert an explicit cast to silence this issue const auto BARBUF = Vector2D{(int)m_vLastWindowSize.x + 2 * *PBORDERSIZE, *PHEIGHT}; ^~~~~~~~ static_cast( ) barDeco.cpp:249:24: error: non-constant-expression cannot be narrowed from type 'int64_t' (aka 'long') to 'double' in initializer list [-Wc++11-narrowing] m_seExtents = {{0, *PHEIGHT + 1}, {}}; ^~~~~~~~~~~~ barDeco.cpp:249:24: note: insert an explicit cast to silence this issue m_seExtents = {{0, *PHEIGHT + 1}, {}}; ^~~~~~~~~~~~ static_cast( ) barDeco.cpp:251:34: error: non-constant-expression cannot be narrowed from type 'int64_t' (aka 'long') to 'double' in initializer list [-Wc++11-narrowing] const auto BARBUF = Vector2D{(int)m_vLastWindowSize.x + 2 * *PBORDERSIZE, *PHEIGHT} * pMonitor->scale; ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ barDeco.cpp:251:34: note: insert an explicit cast to silence this issue const auto BARBUF = Vector2D{(int)m_vLastWindowSize.x + 2 * *PBORDERSIZE, *PHEIGHT} * pMonitor->scale; ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ static_cast( ) barDeco.cpp:251:79: error: non-constant-expression cannot be narrowed from type 'int64_t' (aka 'long') to 'double' in initializer list [-Wc++11-narrowing] const auto BARBUF = Vector2D{(int)m_vLastWindowSize.x + 2 * *PBORDERSIZE, *PHEIGHT} * pMonitor->scale; ^~~~~~~~ barDeco.cpp:251:79: note: insert an explicit cast to silence this issue const auto BARBUF = Vector2D{(int)m_vLastWindowSize.x + 2 * *PBORDERSIZE, *PHEIGHT} * pMonitor->scale; ^~~~~~~~ static_cast( ) barDeco.cpp:253:31: error: type 'double' cannot be narrowed to 'int' in initializer list [-Wc++11-narrowing] wlr_box titleBarBox = {(int)m_vLastWindowPos.x - *PBORDERSIZE - pMonitor->vecPosition.x, (int)m_vLastWindowPos.y - *PBORDERSIZE - *PHEIGHT - pMonitor->vecPosition.y, ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ barDeco.cpp:253:31: note: insert an explicit cast to silence this issue wlr_box titleBarBox = {(int)m_vLastWindowPos.x - *PBORDERSIZE - pMonitor->vecPosition.x, (int)m_vLastWindowPos.y - *PBORDERSIZE - *PHEIGHT - pMonitor->vecPosition.y, ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ static_cast( ) barDeco.cpp:253:97: error: type 'double' cannot be narrowed to 'int' in initializer list [-Wc++11-narrowing] wlr_box titleBarBox = {(int)m_vLastWindowPos.x - *PBORDERSIZE - pMonitor->vecPosition.x, (int)m_vLastWindowPos.y - *PBORDERSIZE - *PHEIGHT - pMonitor->vecPosition.y, ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ barDeco.cpp:253:97: note: insert an explicit cast to silence this issue wlr_box titleBarBox = {(int)m_vLastWindowPos.x - *PBORDERSIZE - pMonitor->vecPosition.x, (int)m_vLastWindowPos.y - *PBORDERSIZE - *PHEIGHT - pMonitor->vecPosition.y, ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ static_cast( ) barDeco.cpp:254:31: error: non-constant-expression cannot be narrowed from type 'int64_t' (aka 'long') to 'int' in initializer list [-Wc++11-narrowing] (int)m_vLastWindowSize.x + 2 * *PBORDERSIZE, *PHEIGHT + *PROUNDING * 3 /* to fill the bottom cuz we can't disable rounding there */}; ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ barDeco.cpp:254:31: note: insert an explicit cast to silence this issue (int)m_vLastWindowSize.x + 2 * *PBORDERSIZE, *PHEIGHT + *PROUNDING * 3 /* to fill the bottom cuz we can't disable rounding there */}; ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ static_cast( ) barDeco.cpp:254:76: error: non-constant-expression cannot be narrowed from type 'int64_t' (aka 'long') to 'int' in initializer list [-Wc++11-narrowing] (int)m_vLastWindowSize.x + 2 * *PBORDERSIZE, *PHEIGHT + *PROUNDING * 3 /* to fill the bottom cuz we can't disable rounding there */}; ^~~~~~~~~~~~~~~~~~~~~~~~~ barDeco.cpp:254:76: note: insert an explicit cast to silence this issue (int)m_vLastWindowSize.x + 2 * *PBORDERSIZE, *PHEIGHT + *PROUNDING * 3 /* to fill the bottom cuz we can't disable rounding there */}; ^~~~~~~~~~~~~~~~~~~~~~~~~ static_cast( ) barDeco.cpp:273:30: error: type 'double' cannot be narrowed to 'int' in initializer list [-Wc++11-narrowing] wlr_box windowBox = {(int)m_vLastWindowPos.x + offset.x - pMonitor->vecPosition.x, (int)m_vLastWindowPos.y + offset.y - pMonitor->vecPosition.y, (int)m_vLastWindowSize.x, ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ barDeco.cpp:273:30: note: insert an explicit cast to silence this issue wlr_box windowBox = {(int)m_vLastWindowPos.x + offset.x - pMonitor->vecPosition.x, (int)m_vLastWindowPos.y + offset.y - pMonitor->vecPosition.y, (int)m_vLastWindowSize.x, ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ static_cast( ) barDeco.cpp:273:92: error: type 'double' cannot be narrowed to 'int' in initializer list [-Wc++11-narrowing] wlr_box windowBox = {(int)m_vLastWindowPos.x + offset.x - pMonitor->vecPosition.x, (int)m_vLastWindowPos.y + offset.y - pMonitor->vecPosition.y, (int)m_vLastWindowSize.x, ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ barDeco.cpp:273:92: note: insert an explicit cast to silence this issue wlr_box windowBox = {(int)m_vLastWindowPos.x + offset.x - pMonitor->vecPosition.x, (int)m_vLastWindowPos.y + offset.y - pMonitor->vecPosition.y, (int)m_vLastWindowSize.x, ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ static_cast( ) barDeco.cpp:338:41: error: non-constant-expression cannot be narrowed from type 'int64_t' (aka 'long') to 'double' in initializer list [- Wc++11-narrowing] return SWindowDecorationExtents{{0, *PHEIGHT}, {}}; ^~~~~~~~ barDeco.cpp:338:41: note: insert an explicit cast to silence this issue return SWindowDecorationExtents{{0, *PHEIGHT}, {}}; ^~~~~~~~ static_cast( ) barDeco.cpp:344:100: error: non-constant-expression cannot be narrowed from type 'int64_t' (aka 'long') to 'double' in initializer list [-Wc++11-narrowing] return g_pInputManager->getMouseCoordsInternal() - m_pWindow->m_vRealPosition.vec() + Vector2D{*PBORDER, *PHEIGHT + *PBORDER}; ^~~~~~~~ barDeco.cpp:344:100: note: insert an explicit cast to silence this issue return g_pInputManager->getMouseCoordsInternal() - m_pWindow->m_vRealPosition.vec() + Vector2D{*PBORDER, *PHEIGHT + *PBORDER}; ^~~~~~~~ static_cast( ) barDeco.cpp:344:110: error: non-constant-expression cannot be narrowed from type 'int64_t' (aka 'long') to 'double' in initializer list [-Wc++11-narrowing] return g_pInputManager->getMouseCoordsInternal() - m_pWindow->m_vRealPosition.vec() + Vector2D{*PBORDER, *PHEIGHT + *PBORDER}; ^~~~~~~~~~~~~~~~~~~ barDeco.cpp:344:110: note: insert an explicit cast to silence this issue return g_pInputManager->getMouseCoordsInternal() - m_pWindow->m_vRealPosition.vec() + Vector2D{*PBORDER, *PHEIGHT + *PBORDER}; ^~~~~~~~~~~~~~~~~~~ static_cast( ) Based on https://github.com/hyprwm/Hyprland/commit/9ee14eb4452e --- borders-plus-plus/Makefile | 2 +- csgo-vulkan-fix/Makefile | 2 +- hyprbars/Makefile | 9 ++++----- hyprbars/meson.build | 6 ++++++ 4 files changed, 12 insertions(+), 7 deletions(-) diff --git a/borders-plus-plus/Makefile b/borders-plus-plus/Makefile index fe890ca..3baa44a 100644 --- a/borders-plus-plus/Makefile +++ b/borders-plus-plus/Makefile @@ -1,4 +1,4 @@ all: - g++ -shared -fPIC --no-gnu-unique main.cpp borderDeco.cpp -o borders-plus-plus.so -g -I "/usr/include/pixman-1" -I "/usr/include/libdrm" $(shell pkg-config --cflags hyprland) -std=c++23 + $(CXX) -shared -fPIC -Wl,--no-gnu-unique main.cpp borderDeco.cpp -o borders-plus-plus.so -g `pkg-config --cflags pixman-1 libdrm hyprland` -std=c++2b clean: rm ./borders-plus-plus.so diff --git a/csgo-vulkan-fix/Makefile b/csgo-vulkan-fix/Makefile index f90327c..2242516 100644 --- a/csgo-vulkan-fix/Makefile +++ b/csgo-vulkan-fix/Makefile @@ -1,4 +1,4 @@ all: - g++ -shared -fPIC --no-gnu-unique main.cpp -o csgo-vulkan-fix.so -g -I "/usr/include/pixman-1" -I "/usr/include/libdrm" $(shell pkg-config --cflags hyprland) -std=c++23 + $(CXX) -shared -fPIC -Wl,--no-gnu-unique main.cpp -o csgo-vulkan-fix.so -g `pkg-config --cflags pixman-1 libdrm hyprland` -std=c++2b clean: rm ./csgo-vulkan-fix.so diff --git a/hyprbars/Makefile b/hyprbars/Makefile index f157c65..2709b85 100644 --- a/hyprbars/Makefile +++ b/hyprbars/Makefile @@ -1,7 +1,6 @@ -CXX = g++ -CXXFLAGS = -shared -fPIC --no-gnu-unique -g -std=c++23 -INCLUDES = -I "/usr/include/pixman-1" -I "/usr/include/libdrm" $(shell pkg-config --cflags hyprland pangocairo) -LIBS = $(shell pkg-config --libs pangocairo) +CXXFLAGS = -shared -fPIC -Wl,--no-gnu-unique -g -std=c++2b -Wno-c++11-narrowing +INCLUDES = `pkg-config --cflags pixman-1 libdrm hyprland pangocairo` +LIBS = `pkg-config --libs pangocairo` SRC = main.cpp barDeco.cpp TARGET = hyprbars.so @@ -9,7 +8,7 @@ TARGET = hyprbars.so all: $(TARGET) $(TARGET): $(SRC) - $(CXX) $(CXXFLAGS) $(INCLUDES) $^ -o $@ $(LIBS) + $(CXX) $(CXXFLAGS) $(INCLUDES) $^ $> -o $@ $(LIBS) clean: rm ./$(TARGET) diff --git a/hyprbars/meson.build b/hyprbars/meson.build index 7a06ff4..e6c4981 100644 --- a/hyprbars/meson.build +++ b/hyprbars/meson.build @@ -12,6 +12,12 @@ else error('Could not configure current C++ compiler (' + cpp_compiler.get_id() + ' ' + cpp_compiler.version() + ') with required C++ standard (C++23)') endif +add_project_arguments( + [ + '-Wno-narrowing', + ], + language: 'cpp') + globber = run_command('find', '.', '-name', '*.cpp', check: true) src = globber.stdout().strip().split('\n')