From 60f327c56e87db94ae94186224700f08b8675887 Mon Sep 17 00:00:00 2001 From: falkTX Date: Wed, 8 May 2024 15:22:29 +0200 Subject: [PATCH] Fix macOS build Signed-off-by: falkTX --- .github/workflows/build.yml | 33 +++++++++++++++++++++++++++++++++ Makefile | 6 +++--- src/ui-client.c | 13 +++++++++---- 3 files changed, 45 insertions(+), 7 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index b26b03c..e49c30f 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -49,3 +49,36 @@ jobs: run: | make clean >/dev/null make testxx -j $(nproc) && ./testxx + + macos: + strategy: + matrix: + target: + - macos-12 + runs-on: ${{ matrix.target }} + steps: + - uses: actions/checkout@v4 + - name: Set up dependencies + run: | + brew install gtk+ gtk+3 lilv make pkg-config + - name: Regular build + env: + CFLAGS: -Werror + CXXFLAGS: -Werror + run: | + make clean >/dev/null + make -j $(nproc) + - name: Run tests (C) + env: + CFLAGS: -Werror + CXXFLAGS: -Werror + run: | + make clean >/dev/null + make test -j $(nproc) && ./test + - name: Run tests (C++) + env: + CFLAGS: -Werror + CXXFLAGS: -Werror + run: | + make clean >/dev/null + make testxx -j $(nproc) && ./testxx diff --git a/Makefile b/Makefile index 8411b80..fb97d2f 100644 --- a/Makefile +++ b/Makefile @@ -30,7 +30,7 @@ CXXFLAGS += -mstackrealign LDFLAGS += -static SERVER_FLAGS = -shared -Wl,-no-undefined else -CLIENT_FLAGS = $(shell pkg-config --cflags --libs x11) -ldl +CLIENT_FLAGS = -ldl SERVER_FLAGS = -fPIC -shared -Wl,-no-undefined SHM_LIBS = -lrt endif @@ -50,10 +50,10 @@ lv2-gtk-ui-bridge.lv2/lv2-gtk-ui-bridge.so: src/ui-server.c src/ipc/*.h $(CC) $< $(CFLAGS) $(LDFLAGS) $(LV2_FLAGS) $(SERVER_FLAGS) $(SHM_LIBS) -o $@ lv2-gtk-ui-bridge.lv2/lv2-gtk2-ui-bridge$(APP_EXT): src/ui-client.c src/ipc/*.h - $(CC) $< $(CFLAGS) $(LDFLAGS) $(LV2_FLAGS) $(shell pkg-config --cflags --libs gtk+-2.0 lilv-0) -DUI_GTK2 $(CLIENT_FLAGS) $(SHM_LIBS) -Wno-deprecated-declarations -o $@ + $(CC) $< $(CFLAGS) $(LDFLAGS) $(LV2_FLAGS) $(shell pkg-config --cflags --libs gtk+-2.0 lilv-0 x11) -DUI_GTK2 $(CLIENT_FLAGS) $(SHM_LIBS) -Wno-deprecated-declarations -o $@ lv2-gtk-ui-bridge.lv2/lv2-gtk3-ui-bridge$(APP_EXT): src/ui-client.c src/ipc/*.h - $(CC) $< $(CFLAGS) $(LDFLAGS) $(LV2_FLAGS) $(shell pkg-config --cflags --libs gtk+-3.0 lilv-0) -DUI_GTK3 $(CLIENT_FLAGS) $(SHM_LIBS) -Wno-deprecated-declarations -o $@ + $(CC) $< $(CFLAGS) $(LDFLAGS) $(LV2_FLAGS) $(shell pkg-config --cflags --libs gtk+-3.0 lilv-0 x11) -DUI_GTK3 $(CLIENT_FLAGS) $(SHM_LIBS) -Wno-deprecated-declarations -o $@ # --------------------------------------------------------------------------------------------------------------------- diff --git a/src/ui-client.c b/src/ui-client.c index 8fe7112..2621556 100644 --- a/src/ui-client.c +++ b/src/ui-client.c @@ -373,9 +373,11 @@ int main(int argc, char* argv[]) const long long winId = wid != NULL ? atoll(wid) : 0; // create plug window - GtkWidget* const window = winId != 0 - ? gtk_plug_new(winId) - : gtk_window_new(GTK_WINDOW_TOPLEVEL); + GtkWidget* const window = + #ifndef __APPLE__ + winId != 0 ? gtk_plug_new(winId) : + #endif + gtk_window_new(GTK_WINDOW_TOPLEVEL); if (window == NULL) { @@ -416,6 +418,7 @@ int main(int argc, char* argv[]) // handle any pending events before showing window lv2ui_idle(&bridge); + #ifndef __APPLE__ if (winId != 0) { gtk_widget_show_all(window); @@ -440,7 +443,9 @@ int main(int argc, char* argv[]) ipc_client_commit(bridge.ipc); } } - else if (shm == NULL) + else + #endif + if (shm == NULL) { g_signal_connect(G_OBJECT(window), "destroy", G_CALLBACK(gtk_main_quit), NULL); gtk_widget_show_all(window);