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 <dirk@hohndel.org>
This commit is contained in:
Dirk Hohndel 2012-10-16 21:24:02 -07:00
parent 0d89d511bb
commit 04c5e65b8c
5 changed files with 42 additions and 24 deletions

View file

@ -102,14 +102,16 @@ else ifeq ($(UNAME), darwin)
OSSUPPORT_CFLAGS = $(GTK2CFLAGS) OSSUPPORT_CFLAGS = $(GTK2CFLAGS)
MACOSXINSTALL = /Applications/Subsurface.app MACOSXINSTALL = /Applications/Subsurface.app
MACOSXFILES = packaging/macosx MACOSXFILES = packaging/macosx
MACOSXSTAGING = $(MACOSXFILES)/Subsurface.app
EXTRALIBS = $(shell $(PKGCONFIG) --libs gtk-mac-integration) -framework CoreFoundation EXTRALIBS = $(shell $(PKGCONFIG) --libs gtk-mac-integration) -framework CoreFoundation
CFLAGS += $(shell $(PKGCONFIG) --cflags gtk-mac-integration) CFLAGS += $(shell $(PKGCONFIG) --cflags gtk-mac-integration)
LDFLAGS += -headerpad_max_install_names LDFLAGS += -headerpad_max_install_names
GTK_MAC_BUNDLER = ~/.local/bin/gtk-mac-bundler
else else
OSSUPPORT = windows OSSUPPORT = windows
OSSUPPORT_CFLAGS = $(GTK2CFLAGS) OSSUPPORT_CFLAGS = $(GTK2CFLAGS)
WINDOWSSTAGING = ./packaging/windows 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 endif
ifneq ($(strip $(LIBXSLT)),) ifneq ($(strip $(LIBXSLT)),)
@ -122,7 +124,7 @@ endif
LIBS = $(LIBXML2) $(LIBXSLT) $(LIBGTK) $(LIBGCONF2) $(LIBDIVECOMPUTER) $(EXTRALIBS) $(LIBZIP) -lpthread -lm LIBS = $(LIBXML2) $(LIBXSLT) $(LIBGTK) $(LIBGCONF2) $(LIBDIVECOMPUTER) $(EXTRALIBS) $(LIBZIP) -lpthread -lm
MSGLANGS=$(notdir $(wildcard po/*po)) 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 \ 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 \ 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) $(MACOSXFILES)/Info.plist $(MACOSXINSTALL)/Contents/
$(INSTALL) $(ICONFILE) $(MACOSXINSTALL)/Contents/Resources/ $(INSTALL) $(ICONFILE) $(MACOSXINSTALL)/Contents/Resources/
$(INSTALL) $(MACOSXFILES)/Subsurface.icns $(MACOSXINSTALL)/Contents/Resources/ $(INSTALL) $(MACOSXFILES)/Subsurface.icns $(MACOSXINSTALL)/Contents/Resources/
for LOC in $(wildcard locale/*/LC_MESSAGES); do \ for LOC in $(wildcard share/locale/*/LC_MESSAGES); do \
$(INSTALL) -d -m 755 $(MACOSXINSTALL)/Contents/Resources/share/$$LOC; \ $(INSTALL) -d -m 755 $(MACOSXINSTALL)/Contents/Resources/$$LOC; \
$(INSTALL) $$LOC/subsurface.mo $(MACOSXINSTALL)/Contents/Resources/share/$$LOC/subsurface.mo; \ $(INSTALL) $$LOC/subsurface.mo $(MACOSXINSTALL)/Contents/Resources/$$LOC/subsurface.mo; \
done 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-cross-windows: $(NAME)
$(INSTALL) -d -m 755 $(WINDOWSSTAGING)/share/locale $(INSTALL) -d -m 755 $(WINDOWSSTAGING)/share/locale
for MSG in $(WINMSGDIRS); do\ for MSG in $(WINMSGDIRS); do\
$(INSTALL) -d -m 755 $(WINDOWSSTAGING)/share/$$MSG;\ $(INSTALL) -d -m 755 $(WINDOWSSTAGING)/$$MSG;\
$(INSTALL) $(CROSS_LOCALE_PATH)/$$MSG/* $(WINDOWSSTAGING)/share/$$MSG;\ $(INSTALL) $(CROSS_LOCALE_PATH)/$$MSG/* $(WINDOWSSTAGING)/$$MSG;\
done done
for MSG in $(MSGOBJS); do\ for MSG in $(MSGOBJS); do\
$(INSTALL) -d -m 755 $$(dirname $(WINDOWSSTAGING)/share/$$MSG);\ $(INSTALL) -d -m 755 $$(dirname $(WINDOWSSTAGING)/$$MSG);\
$(INSTALL) $$MSG $(WINDOWSSTAGING)/share/$$MSG;\ $(INSTALL) $$MSG $(WINDOWSSTAGING)/$$MSG;\
done done
file.o: file.c dive.h file.h 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 $(OSSUPPORT).o: $(OSSUPPORT).c display-gtk.h
$(CC) $(CFLAGS) $(OSSUPPORT_CFLAGS) -c $(OSSUPPORT).c $(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 $@) mkdir -p $(dir $@)
msgfmt -c -o $@ po/$*.po msgfmt -c -o $@ po/$*.po
@-if test -s po/$*.aliases; then \ @-if test -s po/$*.aliases; then \
for ALIAS in `cat po/$*.aliases`; do \ for ALIAS in `cat po/$*.aliases`; do \
mkdir -p locale/$$ALIAS/LC_MESSAGES; \ mkdir -p share/locale/$$ALIAS/LC_MESSAGES; \
cp $@ locale/$$ALIAS/LC_MESSAGES; \ cp $@ share/locale/$$ALIAS/LC_MESSAGES; \
done; \ done; \
fi fi
@ -247,4 +263,4 @@ doc:
clean: clean:
rm -f $(OBJS) *~ $(NAME) $(NAME).exe rm -f $(OBJS) *~ $(NAME) $(NAME).exe
rm -rf locale rm -rf share

View file

@ -86,7 +86,7 @@ const char *subsurface_default_filename()
const char *subsurface_gettext_domainpath() const char *subsurface_gettext_domainpath()
{ {
return "./locale"; return "./share/locale";
} }
void subsurface_ui_setup(GtkSettings *settings, GtkWidget *menubar, void subsurface_ui_setup(GtkSettings *settings, GtkWidget *menubar,

14
macos.c
View file

@ -106,15 +106,13 @@ const char *subsurface_default_filename()
const char *subsurface_gettext_domainpath() const char *subsurface_gettext_domainpath()
{ {
CFBundleRef mainBundle = CFBundleGetMainBundle(); static char buffer[256];
CFURLRef localeURL = CFBundleCopyResourceURL(mainBundle, CFSTR("share/locale"), CFSTR(""), NULL); const char *resource_path = quartz_application_get_resource_path();
if (localeURL) { if (resource_path) {
CFStringRef localePath = CFURLCopyFileSystemPath(localeURL, kCFURLPOSIXPathStyle); snprintf(buffer, sizeof(buffer), "%s/share/locale", resource_path);
CFStringEncoding encodingMethod = CFStringGetSystemEncoding(); return buffer;
const char *path = CFStringGetCStringPtr(localePath, encodingMethod);
return path;
} }
return "./locale"; return "./share/locale";
} }
static void show_main_window(GtkWidget *w, gpointer data) static void show_main_window(GtkWidget *w, gpointer data)

View file

@ -86,6 +86,9 @@
${prefix}/share/locale ${prefix}/share/locale
</translations> </translations>
<data dest="${bundle}/Contents/Resources/share/locale">
${project}/Subsurface.app/Contents/Resources/share/locale
</data>
<!-- Data to copy in, usually Glade/UI files, images, sounds files <!-- Data to copy in, usually Glade/UI files, images, sounds files
etc. The destination inside the bundle can be specified if the etc. The destination inside the bundle can be specified if the

View file

@ -34,7 +34,8 @@ export GTK_IM_MODULE_FILE="$bundle_etc/gtk-2.0/gtk.immodules"
export GDK_PIXBUF_MODULE_FILE="$bundle_etc/gtk-2.0/gdk-pixbuf.loaders" export GDK_PIXBUF_MODULE_FILE="$bundle_etc/gtk-2.0/gdk-pixbuf.loaders"
export PANGO_RC_FILE="$bundle_etc/pango/pangorc" export PANGO_RC_FILE="$bundle_etc/pango/pangorc"
APP=name APP=$name
APPlower=`echo $APP | tr '[:upper:]' '[:lower:]'`
I18NDIR="$bundle_data/locale" I18NDIR="$bundle_data/locale"
# Set the locale-related variables appropriately: # Set the locale-related variables appropriately:
unset LANG LC_MESSAGES LC_MONETARY LC_COLLATE unset LANG LC_MESSAGES LC_MONETARY LC_COLLATE
@ -48,7 +49,7 @@ if test "$APPLELANGUAGES"; then
# Test, item per item, to see whether there is an corresponding locale. # Test, item per item, to see whether there is an corresponding locale.
for L in $APPLELANGUAGES; do for L in $APPLELANGUAGES; do
#test for exact matches: #test for exact matches:
if test -f "$I18NDIR/${L}/LC_MESSAGES/$APP.mo"; then if test -f "$I18NDIR/${L}/LC_MESSAGES/${APPlower}.mo"; then
export LANG=$L export LANG=$L
break break
fi fi