From 04c5e65b8cd52bf10d49375d22ba0908efbaa985 Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Tue, 16 Oct 2012 21:24:02 -0700 Subject: [PATCH] Redoing the Mac bundling With the right tools in place you can now create a bundle from the Makefile by calling "make create-macos-bundle" In the process of this I also moved the locale directory where we stage our .mo files to share/locale (which is much more logical). Signed-off-by: Dirk Hohndel --- Makefile | 42 +++++++++++++++++++++--------- linux.c | 2 +- macos.c | 14 +++++----- packaging/macosx/subsurface.bundle | 3 +++ packaging/macosx/subsurface.sh | 5 ++-- 5 files changed, 42 insertions(+), 24 deletions(-) diff --git a/Makefile b/Makefile index 34247e79f..1fcb9e310 100644 --- a/Makefile +++ b/Makefile @@ -102,14 +102,16 @@ else ifeq ($(UNAME), darwin) OSSUPPORT_CFLAGS = $(GTK2CFLAGS) MACOSXINSTALL = /Applications/Subsurface.app MACOSXFILES = packaging/macosx + MACOSXSTAGING = $(MACOSXFILES)/Subsurface.app EXTRALIBS = $(shell $(PKGCONFIG) --libs gtk-mac-integration) -framework CoreFoundation CFLAGS += $(shell $(PKGCONFIG) --cflags gtk-mac-integration) LDFLAGS += -headerpad_max_install_names + GTK_MAC_BUNDLER = ~/.local/bin/gtk-mac-bundler else OSSUPPORT = windows OSSUPPORT_CFLAGS = $(GTK2CFLAGS) WINDOWSSTAGING = ./packaging/windows - WINMSGDIRS=$(addprefix locale/,$(shell ls po/*.po | sed -e 's/po\/\(..\)_.*/\1\/LC_MESSAGES/')) + WINMSGDIRS=$(addprefix share/locale/,$(shell ls po/*.po | sed -e 's/po\/\(..\)_.*/\1\/LC_MESSAGES/')) endif ifneq ($(strip $(LIBXSLT)),) @@ -122,7 +124,7 @@ endif LIBS = $(LIBXML2) $(LIBXSLT) $(LIBGTK) $(LIBGCONF2) $(LIBDIVECOMPUTER) $(EXTRALIBS) $(LIBZIP) -lpthread -lm MSGLANGS=$(notdir $(wildcard po/*po)) -MSGOBJS=$(addprefix locale/,$(MSGLANGS:.po=.UTF-8/LC_MESSAGES/subsurface.mo)) +MSGOBJS=$(addprefix share/locale/,$(MSGLANGS:.po=.UTF-8/LC_MESSAGES/subsurface.mo)) OBJS = main.o dive.o time.o profile.o info.o equipment.o divelist.o \ parse-xml.o save-xml.o libdivecomputer.o print.o uemis.o uemis-downloader.o \ @@ -157,20 +159,34 @@ install-macosx: $(NAME) $(INSTALL) $(MACOSXFILES)/Info.plist $(MACOSXINSTALL)/Contents/ $(INSTALL) $(ICONFILE) $(MACOSXINSTALL)/Contents/Resources/ $(INSTALL) $(MACOSXFILES)/Subsurface.icns $(MACOSXINSTALL)/Contents/Resources/ - for LOC in $(wildcard locale/*/LC_MESSAGES); do \ - $(INSTALL) -d -m 755 $(MACOSXINSTALL)/Contents/Resources/share/$$LOC; \ - $(INSTALL) $$LOC/subsurface.mo $(MACOSXINSTALL)/Contents/Resources/share/$$LOC/subsurface.mo; \ + for LOC in $(wildcard share/locale/*/LC_MESSAGES); do \ + $(INSTALL) -d -m 755 $(MACOSXINSTALL)/Contents/Resources/$$LOC; \ + $(INSTALL) $$LOC/subsurface.mo $(MACOSXINSTALL)/Contents/Resources/$$LOC/subsurface.mo; \ done +create-macosx-bundle: $(NAME) + $(INSTALL) -d -m 755 $(MACOSXSTAGING)/Contents/Resources + $(INSTALL) -d -m 755 $(MACOSXSTAGING)/Contents/MacOS + $(INSTALL) $(NAME) $(MACOSXSTAGING)/Contents/MacOS/ + $(INSTALL) $(MACOSXFILES)/PkgInfo $(MACOSXSTAGING)/Contents/ + $(INSTALL) $(MACOSXFILES)/Info.plist $(MACOSXSTAGING)/Contents/ + $(INSTALL) $(ICONFILE) $(MACOSXSTAGING)/Contents/Resources/ + $(INSTALL) $(MACOSXFILES)/Subsurface.icns $(MACOSXSTAGING)/Contents/Resources/ + for LOC in $(wildcard share/locale/*/LC_MESSAGES); do \ + $(INSTALL) -d -m 755 $(MACOSXSTAGING)/Contents/Resources/$$LOC; \ + $(INSTALL) $$LOC/subsurface.mo $(MACOSXSTAGING)/Contents/Resources/$$LOC/subsurface.mo; \ + done + $(GTK_MAC_BUNDLER) packaging/macos/subsurface.bundle + install-cross-windows: $(NAME) $(INSTALL) -d -m 755 $(WINDOWSSTAGING)/share/locale for MSG in $(WINMSGDIRS); do\ - $(INSTALL) -d -m 755 $(WINDOWSSTAGING)/share/$$MSG;\ - $(INSTALL) $(CROSS_LOCALE_PATH)/$$MSG/* $(WINDOWSSTAGING)/share/$$MSG;\ + $(INSTALL) -d -m 755 $(WINDOWSSTAGING)/$$MSG;\ + $(INSTALL) $(CROSS_LOCALE_PATH)/$$MSG/* $(WINDOWSSTAGING)/$$MSG;\ done for MSG in $(MSGOBJS); do\ - $(INSTALL) -d -m 755 $$(dirname $(WINDOWSSTAGING)/share/$$MSG);\ - $(INSTALL) $$MSG $(WINDOWSSTAGING)/share/$$MSG;\ + $(INSTALL) -d -m 755 $$(dirname $(WINDOWSSTAGING)/$$MSG);\ + $(INSTALL) $$MSG $(WINDOWSSTAGING)/$$MSG;\ done file.o: file.c dive.h file.h @@ -232,13 +248,13 @@ uemis-downloader.o: uemis-downloader.c dive.h uemis.h $(OSSUPPORT).o: $(OSSUPPORT).c display-gtk.h $(CC) $(CFLAGS) $(OSSUPPORT_CFLAGS) -c $(OSSUPPORT).c -locale/%.UTF-8/LC_MESSAGES/subsurface.mo: po/%.po +share/locale/%.UTF-8/LC_MESSAGES/subsurface.mo: po/%.po mkdir -p $(dir $@) msgfmt -c -o $@ po/$*.po @-if test -s po/$*.aliases; then \ for ALIAS in `cat po/$*.aliases`; do \ - mkdir -p locale/$$ALIAS/LC_MESSAGES; \ - cp $@ locale/$$ALIAS/LC_MESSAGES; \ + mkdir -p share/locale/$$ALIAS/LC_MESSAGES; \ + cp $@ share/locale/$$ALIAS/LC_MESSAGES; \ done; \ fi @@ -247,4 +263,4 @@ doc: clean: rm -f $(OBJS) *~ $(NAME) $(NAME).exe - rm -rf locale + rm -rf share diff --git a/linux.c b/linux.c index b97e54f27..5861411ee 100644 --- a/linux.c +++ b/linux.c @@ -86,7 +86,7 @@ const char *subsurface_default_filename() const char *subsurface_gettext_domainpath() { - return "./locale"; + return "./share/locale"; } void subsurface_ui_setup(GtkSettings *settings, GtkWidget *menubar, diff --git a/macos.c b/macos.c index bb10baa3c..585e879b0 100644 --- a/macos.c +++ b/macos.c @@ -106,15 +106,13 @@ const char *subsurface_default_filename() const char *subsurface_gettext_domainpath() { - CFBundleRef mainBundle = CFBundleGetMainBundle(); - CFURLRef localeURL = CFBundleCopyResourceURL(mainBundle, CFSTR("share/locale"), CFSTR(""), NULL); - if (localeURL) { - CFStringRef localePath = CFURLCopyFileSystemPath(localeURL, kCFURLPOSIXPathStyle); - CFStringEncoding encodingMethod = CFStringGetSystemEncoding(); - const char *path = CFStringGetCStringPtr(localePath, encodingMethod); - return path; + static char buffer[256]; + const char *resource_path = quartz_application_get_resource_path(); + if (resource_path) { + snprintf(buffer, sizeof(buffer), "%s/share/locale", resource_path); + return buffer; } - return "./locale"; + return "./share/locale"; } static void show_main_window(GtkWidget *w, gpointer data) diff --git a/packaging/macosx/subsurface.bundle b/packaging/macosx/subsurface.bundle index fcfd4f7f1..bff9c962e 100644 --- a/packaging/macosx/subsurface.bundle +++ b/packaging/macosx/subsurface.bundle @@ -86,6 +86,9 @@ ${prefix}/share/locale + + ${project}/Subsurface.app/Contents/Resources/share/locale +