Skip to content

Commit

Permalink
Fix macOS build
Browse files Browse the repository at this point in the history
Signed-off-by: falkTX <[email protected]>
  • Loading branch information
falkTX committed May 8, 2024
1 parent 08d11f6 commit ae316c8
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 7 deletions.
35 changes: 35 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,38 @@ jobs:
run: |
make clean >/dev/null
make testxx -j $(nproc) && ./testxx
macos:
strategy:
matrix:
target:
- macos-12
- macos-13
- macos-14
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 $(sysctl -n hw.logicalcpu)
- name: Run tests (C)
env:
CFLAGS: -Werror
CXXFLAGS: -Werror
run: |
make clean >/dev/null
make test -j $(sysctl -n hw.logicalcpu) && ./test
- name: Run tests (C++)
env:
CFLAGS: -Werror
CXXFLAGS: -Werror
run: |
make clean >/dev/null
make testxx -j $(sysctl -n hw.logicalcpu) && ./testxx
8 changes: 5 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ endif
TARGET_MACHINE := $(shell $(CC) -dumpmachine)

ifneq (,$(findstring apple,$(TARGET_MACHINE)))
CFLAGS += -Wno-deprecated-declarations
CXXFLAGS += -Wno-deprecated -Wno-deprecated-declarations
SERVER_FLAGS = -fPIC -dynamiclib
else ifneq (,$(findstring mingw,$(TARGET_MACHINE)))
APP_EXT = .exe
Expand All @@ -30,7 +32,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
Expand All @@ -50,10 +52,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 $@

# ---------------------------------------------------------------------------------------------------------------------

Expand Down
13 changes: 9 additions & 4 deletions src/ui-client.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand Down

0 comments on commit ae316c8

Please sign in to comment.