From b4b2e8d5331878f9b2dcf807c0d277b6dc880959 Mon Sep 17 00:00:00 2001 From: Jussi Pakkanen Date: Tue, 10 Mar 2015 16:45:39 +0200 Subject: Added an example of how to create OSX installers. --- manual tests/3 osx bundle/Info.plist | 26 +++++++++++++++++++ manual tests/3 osx bundle/build_osx_installer.sh | 21 +++++++++++++++ manual tests/3 osx bundle/install_script.sh | 6 +++++ manual tests/3 osx bundle/meson.build | 18 +++++++++++++ manual tests/3 osx bundle/myapp.c | 31 +++++++++++++++++++++++ manual tests/3 osx bundle/myapp.icns | Bin 0 -> 1831 bytes manual tests/3 osx bundle/myapp.sh | 4 +++ manual tests/3 osx bundle/template.dmg.gz | Bin 0 -> 37311 bytes 8 files changed, 106 insertions(+) create mode 100644 manual tests/3 osx bundle/Info.plist create mode 100755 manual tests/3 osx bundle/build_osx_installer.sh create mode 100755 manual tests/3 osx bundle/install_script.sh create mode 100644 manual tests/3 osx bundle/meson.build create mode 100644 manual tests/3 osx bundle/myapp.c create mode 100644 manual tests/3 osx bundle/myapp.icns create mode 100755 manual tests/3 osx bundle/myapp.sh create mode 100644 manual tests/3 osx bundle/template.dmg.gz (limited to 'manual tests') diff --git a/manual tests/3 osx bundle/Info.plist b/manual tests/3 osx bundle/Info.plist new file mode 100644 index 0000000..0f0c90e --- /dev/null +++ b/manual tests/3 osx bundle/Info.plist @@ -0,0 +1,26 @@ + + + + + CFBundleGetInfoString + MyApp + CFBundleExecutable + myapp.sh + CFBundleIdentifier + com.example.me + CFBundleName + myapp + CFBundleIconFile + myapp.icns + CFBundleShortVersionString + 1.0 + CFBundleInfoDictionaryVersion + 6.0 + CFBundlePackageType + APPL + IFMajorVersion + 0 + IFMinorVersion + 1 + + diff --git a/manual tests/3 osx bundle/build_osx_installer.sh b/manual tests/3 osx bundle/build_osx_installer.sh new file mode 100755 index 0000000..9225415 --- /dev/null +++ b/manual tests/3 osx bundle/build_osx_installer.sh @@ -0,0 +1,21 @@ +#!/bin/sh + +rm -rf buildtmp +mkdir buildtmp +~/meson/meson.py buildtmp --prefix=/tmp/myapp.app --bindir=Contents/MacOS +ninja -C buildtmp install +rm -rf buildtmp +mkdir -p mnttmp +rm -f working.dmg +gunzip < template.dmg.gz > working.dmg +hdiutil attach working.dmg -noautoopen -quiet -mountpoint mnttmp +# NOTE: output of hdiutil changes every now and then. +# Verify that this is still working. +DEV=`hdiutil info|tail -1|awk '{print $1}'` +rm -rf mnttmp/myapp.app +mv /tmp/myapp.app mnttmp +hdiutil detach ${DEV} +rm -rf mnttmp +rm -f myapp.dmg +hdiutil convert working.dmg -quiet -format UDZO -imagekey zlib-level=9 -o myapp.dmg +rm -f working.dmg diff --git a/manual tests/3 osx bundle/install_script.sh b/manual tests/3 osx bundle/install_script.sh new file mode 100755 index 0000000..f61187f --- /dev/null +++ b/manual tests/3 osx bundle/install_script.sh @@ -0,0 +1,6 @@ +#!/bin/sh + +mkdir -p ${MESON_INSTALL_PREFIX}/Contents/Frameworks +cp -r /Library/Frameworks/SDL2.framework ${MESON_INSTALL_PREFIX}/Contents/Frameworks + +install_name_tool -change @rpath/SDL2.framework/Versions/A/SDL2 @executable_path/../Frameworks/SDL2.framework/Versions/A/SDL2 ${MESON_INSTALL_PREFIX}/Contents/MacOS/myapp diff --git a/manual tests/3 osx bundle/meson.build b/manual tests/3 osx bundle/meson.build new file mode 100644 index 0000000..13ab29a --- /dev/null +++ b/manual tests/3 osx bundle/meson.build @@ -0,0 +1,18 @@ +project('myapp', 'c') + +sdl = dependency('sdl2') + +prog = executable('myapp', 'myapp.c', +dependencies : sdl, +install : true) + +install_data('myapp.sh', +install_dir : 'Contents/MacOS') + +install_data('myapp.icns', +install_dir : 'Contents/Resources') + +install_data('Info.plist', +install_dir : 'Contents') + +meson.set_install_script('install_script.sh') diff --git a/manual tests/3 osx bundle/myapp.c b/manual tests/3 osx bundle/myapp.c new file mode 100644 index 0000000..83a4e4c --- /dev/null +++ b/manual tests/3 osx bundle/myapp.c @@ -0,0 +1,31 @@ +#include + +int main(int argc, char **argv) { + SDL_Window *window; + SDL_Surface *screenSurface; + SDL_Event e; + int keepGoing = 1; + if(SDL_Init( SDL_INIT_VIDEO ) < 0) { + printf( "SDL could not initialize! SDL_Error: %s\n", SDL_GetError() ); + } + + window = SDL_CreateWindow( "My application", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, 640, 480, SDL_WINDOW_SHOWN ); + + screenSurface = SDL_GetWindowSurface( window ); + + while(keepGoing) { + while(SDL_PollEvent(&e) != 0) { + if(e.type == SDL_QUIT) { + keepGoing = 0; + break; + } + } + SDL_FillRect( screenSurface, NULL, SDL_MapRGB( screenSurface->format, 0xFF, 0x00, 0x00 ) ); + SDL_UpdateWindowSurface( window ); + SDL_Delay(100); + } + + SDL_DestroyWindow(window); + SDL_Quit(); + return 0; +} diff --git a/manual tests/3 osx bundle/myapp.icns b/manual tests/3 osx bundle/myapp.icns new file mode 100644 index 0000000..6331954 Binary files /dev/null and b/manual tests/3 osx bundle/myapp.icns differ diff --git a/manual tests/3 osx bundle/myapp.sh b/manual tests/3 osx bundle/myapp.sh new file mode 100755 index 0000000..2303818 --- /dev/null +++ b/manual tests/3 osx bundle/myapp.sh @@ -0,0 +1,4 @@ +#!/bin/bash + +cd "${0%/*}" +./myapp diff --git a/manual tests/3 osx bundle/template.dmg.gz b/manual tests/3 osx bundle/template.dmg.gz new file mode 100644 index 0000000..fcb6d61 Binary files /dev/null and b/manual tests/3 osx bundle/template.dmg.gz differ -- cgit v1.1