diff options
Diffstat (limited to 'meson/manual tests/4 standalone binaries')
-rw-r--r-- | meson/manual tests/4 standalone binaries/Info.plist | 26 | ||||
-rwxr-xr-x | meson/manual tests/4 standalone binaries/build_linux_package.sh | 12 | ||||
-rwxr-xr-x | meson/manual tests/4 standalone binaries/build_osx_package.sh | 20 | ||||
-rwxr-xr-x | meson/manual tests/4 standalone binaries/build_windows_package.py | 32 | ||||
-rwxr-xr-x | meson/manual tests/4 standalone binaries/linux_bundler.sh | 7 | ||||
-rw-r--r-- | meson/manual tests/4 standalone binaries/meson.build | 38 | ||||
-rw-r--r-- | meson/manual tests/4 standalone binaries/myapp.cpp | 39 | ||||
-rw-r--r-- | meson/manual tests/4 standalone binaries/myapp.icns | bin | 0 -> 1831 bytes | |||
-rw-r--r-- | meson/manual tests/4 standalone binaries/myapp.iss | 18 | ||||
-rwxr-xr-x | meson/manual tests/4 standalone binaries/myapp.sh | 10 | ||||
-rwxr-xr-x | meson/manual tests/4 standalone binaries/osx_bundler.sh | 6 | ||||
-rw-r--r-- | meson/manual tests/4 standalone binaries/readme.txt | 12 | ||||
-rw-r--r-- | meson/manual tests/4 standalone binaries/template.dmg.gz | bin | 0 -> 37311 bytes |
13 files changed, 220 insertions, 0 deletions
diff --git a/meson/manual tests/4 standalone binaries/Info.plist b/meson/manual tests/4 standalone binaries/Info.plist new file mode 100644 index 000000000..0f0c90e49 --- /dev/null +++ b/meson/manual tests/4 standalone binaries/Info.plist @@ -0,0 +1,26 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> +<plist version="1.0"> +<dict> + <key>CFBundleGetInfoString</key> + <string>MyApp</string> + <key>CFBundleExecutable</key> + <string>myapp.sh</string> + <key>CFBundleIdentifier</key> + <string>com.example.me</string> + <key>CFBundleName</key> + <string>myapp</string> + <key>CFBundleIconFile</key> + <string>myapp.icns</string> + <key>CFBundleShortVersionString</key> + <string>1.0</string> + <key>CFBundleInfoDictionaryVersion</key> + <string>6.0</string> + <key>CFBundlePackageType</key> + <string>APPL</string> + <key>IFMajorVersion</key> + <integer>0</integer> + <key>IFMinorVersion</key> + <integer>1</integer> +</dict> +</plist> diff --git a/meson/manual tests/4 standalone binaries/build_linux_package.sh b/meson/manual tests/4 standalone binaries/build_linux_package.sh new file mode 100755 index 000000000..783981ef5 --- /dev/null +++ b/meson/manual tests/4 standalone binaries/build_linux_package.sh @@ -0,0 +1,12 @@ +#!/bin/sh -eu + +curdir=`pwd` +rm -rf buildtmp +mkdir buildtmp +LDFLAGS=-static-libstdc++ ~/meson/meson.py buildtmp --buildtype=release --prefix=/tmp/myapp --libdir=lib --strip +ninja -C buildtmp install +rm -rf buildtmp +cd /tmp/ +tar czf myapp.tar.gz myapp +mv myapp.tar.gz "$curdir" +rm -rf myapp diff --git a/meson/manual tests/4 standalone binaries/build_osx_package.sh b/meson/manual tests/4 standalone binaries/build_osx_package.sh new file mode 100755 index 000000000..8a94ca534 --- /dev/null +++ b/meson/manual tests/4 standalone binaries/build_osx_package.sh @@ -0,0 +1,20 @@ +#!/bin/sh -eu + +rm -rf buildtmp +mkdir buildtmp +~/meson/meson.py buildtmp --buildtype=release --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 +rm -rf mnttmp/myapp.app +mv /tmp/myapp.app mnttmp +# NOTE: output of hdiutil changes every now and then. +# Verify that this is still working. +hdiutil detach $(hdiutil info|grep "mnttmp"|awk '{print $1}') +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/meson/manual tests/4 standalone binaries/build_windows_package.py b/meson/manual tests/4 standalone binaries/build_windows_package.py new file mode 100755 index 000000000..0932eac09 --- /dev/null +++ b/meson/manual tests/4 standalone binaries/build_windows_package.py @@ -0,0 +1,32 @@ +#!/usr/bin/env python3 + +import os, urllib.request, shutil, subprocess +from glob import glob + +sdl_url = 'http://libsdl.org/release/SDL2-devel-2.0.3-VC.zip' +sdl_filename = 'SDL2-devel-2.0.3-VC.zip' +sdl_dir = 'SDL2-2.0.3' + +shutil.rmtree('build', ignore_errors=True) +os.mkdir('build') + +if not os.path.exists(sdl_filename): + response = urllib.request.urlopen(sdl_url, timeout=600.0) + data = response.read() + open(sdl_filename, 'wb').write(data) + +shutil.unpack_archive(sdl_filename, 'build') + +libs = glob(os.path.join('build', sdl_dir, 'lib/x86/*')) +[shutil.copy(x, 'build') for x in libs] + +# Sorry for this hack but this needs to work during development +# when Meson is not in path. +subprocess.check_call(['python3', r'..\..\meson.py', 'build', + '--backend=ninja', '--buildtype=release']) +subprocess.check_call(['ninja'], cwd='build') +shutil.copy('myapp.iss', 'build') +subprocess.check_call([r'\Program Files\Inno Setup 5\ISCC.exe', 'myapp.iss'], + cwd='build') +shutil.copy('build/setup.exe', 'myapp 1.0.exe') +shutil.rmtree('build') diff --git a/meson/manual tests/4 standalone binaries/linux_bundler.sh b/meson/manual tests/4 standalone binaries/linux_bundler.sh new file mode 100755 index 000000000..2a8e907fe --- /dev/null +++ b/meson/manual tests/4 standalone binaries/linux_bundler.sh @@ -0,0 +1,7 @@ +#!/bin/sh -eu + +libdir="${MESON_INSTALL_PREFIX}/lib" +mkdir -p $libdir +sdlfile=`ldd ${MESON_INSTALL_PREFIX}/bin/myapp | grep libSDL | cut -d ' ' -f 3` +cp $sdlfile "${libdir}" +strip "${libdir}/libSDL"* diff --git a/meson/manual tests/4 standalone binaries/meson.build b/meson/manual tests/4 standalone binaries/meson.build new file mode 100644 index 000000000..ad6645f5b --- /dev/null +++ b/meson/manual tests/4 standalone binaries/meson.build @@ -0,0 +1,38 @@ +project('myapp', 'cpp') + +sdl = dependency('sdl2', required : host_machine.system() != 'windows') + +if meson.get_compiler('cpp').get_id() != 'msvc' + add_global_arguments('-std=c++11', language : 'cpp') +endif + +if host_machine.system() == 'darwin' + install_data('myapp.sh', + install_dir : 'Contents/MacOS') + + install_data('myapp.icns', + install_dir : 'Contents/Resources') + + install_data('Info.plist', + install_dir : 'Contents') + + meson.add_install_script('osx_bundler.sh') +endif + +if host_machine.system() == 'linux' + install_data('myapp.sh', install_dir : '.') + meson.add_install_script('linux_bundler.sh') +endif + +extra_link_args = [] + +if host_machine.system() == 'windows' + str = '-I@0@/@1@'.format(meson.current_build_dir(), 'SDL2-2.0.3/include') + add_global_arguments(str, language : 'cpp') + extra_link_args = ['/SUBSYSTEM:CONSOLE', 'SDL2main.lib', 'SDL2.lib'] +endif + +prog = executable('myapp', 'myapp.cpp', +dependencies : sdl, +link_args : extra_link_args, +install : true) diff --git a/meson/manual tests/4 standalone binaries/myapp.cpp b/meson/manual tests/4 standalone binaries/myapp.cpp new file mode 100644 index 000000000..8ddff2736 --- /dev/null +++ b/meson/manual tests/4 standalone binaries/myapp.cpp @@ -0,0 +1,39 @@ +#include<SDL.h> +#include<memory> +#include<iostream> +#include<string> + +int main(void) { + SDL_Surface *screenSurface; + SDL_Event e; + int keepGoing = 1; + std::string message; + + if(SDL_Init( SDL_INIT_VIDEO ) < 0) { + printf( "SDL could not initialize! SDL_Error: %s\n", SDL_GetError() ); + } + atexit(SDL_Quit); + + std::unique_ptr<SDL_Window, void(*)(SDL_Window*)> window(SDL_CreateWindow( "My application", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, 640, 480, SDL_WINDOW_SHOWN), SDL_DestroyWindow); + screenSurface = SDL_GetWindowSurface(window.get()); + + // Use iostream to make sure we have not screwed + // up libstdc++ linking. + message = "Window created."; + message += " Starting main loop."; + std::cout << message << std::endl; + + 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.get()); + SDL_Delay(100); + } + + return 0; +} diff --git a/meson/manual tests/4 standalone binaries/myapp.icns b/meson/manual tests/4 standalone binaries/myapp.icns Binary files differnew file mode 100644 index 000000000..633195454 --- /dev/null +++ b/meson/manual tests/4 standalone binaries/myapp.icns diff --git a/meson/manual tests/4 standalone binaries/myapp.iss b/meson/manual tests/4 standalone binaries/myapp.iss new file mode 100644 index 000000000..2bd441ded --- /dev/null +++ b/meson/manual tests/4 standalone binaries/myapp.iss @@ -0,0 +1,18 @@ +; Innosetup file for My app. + +[Setup] +AppName=My App +AppVersion=1.0 +DefaultDirName={pf}\My App +DefaultGroupName=My App +UninstallDisplayIcon={app}\myapp.exe +Compression=lzma2 +SolidCompression=yes +OutputDir=. + +[Files] +Source: "myapp.exe"; DestDir: "{app}" +Source: "SDL2.dll"; DestDir: "{app}" + +;[Icons] +;Name: "{group}\My App"; Filename: "{app}\myapp.exe" diff --git a/meson/manual tests/4 standalone binaries/myapp.sh b/meson/manual tests/4 standalone binaries/myapp.sh new file mode 100755 index 000000000..319148353 --- /dev/null +++ b/meson/manual tests/4 standalone binaries/myapp.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +cd "${0%/*}" + +if [ `uname` == 'Darwin' ]; then + ./myapp +else + export LD_LIBRARY_PATH="`pwd`/lib" + bin/myapp +fi diff --git a/meson/manual tests/4 standalone binaries/osx_bundler.sh b/meson/manual tests/4 standalone binaries/osx_bundler.sh new file mode 100755 index 000000000..3bad65f76 --- /dev/null +++ b/meson/manual tests/4 standalone binaries/osx_bundler.sh @@ -0,0 +1,6 @@ +#!/bin/sh -eu + +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/meson/manual tests/4 standalone binaries/readme.txt b/meson/manual tests/4 standalone binaries/readme.txt new file mode 100644 index 000000000..991b5c6b8 --- /dev/null +++ b/meson/manual tests/4 standalone binaries/readme.txt @@ -0,0 +1,12 @@ +This directory shows how you can build redistributable binaries. On +OSX this menans building an app bundle and a .dmg installer. On Linux +it means building an archive that bundles its dependencies. On Windows +it means building an .exe installer. + +To build each package you run the corresponding build_ARCH.sh build +script. + +On Linux you must build the package on the oldest distribution you +plan to support (Debian stable/oldstable and old CentOS are the common +choice here). + diff --git a/meson/manual tests/4 standalone binaries/template.dmg.gz b/meson/manual tests/4 standalone binaries/template.dmg.gz Binary files differnew file mode 100644 index 000000000..fcb6d6115 --- /dev/null +++ b/meson/manual tests/4 standalone binaries/template.dmg.gz |