summaryrefslogtreecommitdiffstats
path: root/manual tests/4 standalone binaries
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-29 04:41:38 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-29 04:41:38 +0000
commit7b6e527f440cd7e6f8be2b07cee320ee6ca18786 (patch)
tree4a2738d69fa2814659fdadddf5826282e73d81f4 /manual tests/4 standalone binaries
parentInitial commit. (diff)
downloadmeson-upstream.tar.xz
meson-upstream.zip
Adding upstream version 1.0.1.upstream/1.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'manual tests/4 standalone binaries')
-rw-r--r--manual tests/4 standalone binaries/Info.plist26
-rwxr-xr-xmanual tests/4 standalone binaries/build_linux_package.sh12
-rwxr-xr-xmanual tests/4 standalone binaries/build_osx_package.sh20
-rwxr-xr-xmanual tests/4 standalone binaries/build_windows_package.py32
-rwxr-xr-xmanual tests/4 standalone binaries/linux_bundler.sh7
-rw-r--r--manual tests/4 standalone binaries/meson.build38
-rw-r--r--manual tests/4 standalone binaries/myapp.cpp39
-rw-r--r--manual tests/4 standalone binaries/myapp.icnsbin0 -> 1831 bytes
-rw-r--r--manual tests/4 standalone binaries/myapp.iss18
-rwxr-xr-xmanual tests/4 standalone binaries/myapp.sh10
-rwxr-xr-xmanual tests/4 standalone binaries/osx_bundler.sh6
-rw-r--r--manual tests/4 standalone binaries/readme.txt11
-rw-r--r--manual tests/4 standalone binaries/template.dmg.gzbin0 -> 37311 bytes
13 files changed, 219 insertions, 0 deletions
diff --git a/manual tests/4 standalone binaries/Info.plist b/manual tests/4 standalone binaries/Info.plist
new file mode 100644
index 0000000..0f0c90e
--- /dev/null
+++ b/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/manual tests/4 standalone binaries/build_linux_package.sh b/manual tests/4 standalone binaries/build_linux_package.sh
new file mode 100755
index 0000000..783981e
--- /dev/null
+++ b/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/manual tests/4 standalone binaries/build_osx_package.sh b/manual tests/4 standalone binaries/build_osx_package.sh
new file mode 100755
index 0000000..8a94ca5
--- /dev/null
+++ b/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/manual tests/4 standalone binaries/build_windows_package.py b/manual tests/4 standalone binaries/build_windows_package.py
new file mode 100755
index 0000000..0932eac
--- /dev/null
+++ b/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/manual tests/4 standalone binaries/linux_bundler.sh b/manual tests/4 standalone binaries/linux_bundler.sh
new file mode 100755
index 0000000..2a8e907
--- /dev/null
+++ b/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/manual tests/4 standalone binaries/meson.build b/manual tests/4 standalone binaries/meson.build
new file mode 100644
index 0000000..ad6645f
--- /dev/null
+++ b/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/manual tests/4 standalone binaries/myapp.cpp b/manual tests/4 standalone binaries/myapp.cpp
new file mode 100644
index 0000000..8ddff27
--- /dev/null
+++ b/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/manual tests/4 standalone binaries/myapp.icns b/manual tests/4 standalone binaries/myapp.icns
new file mode 100644
index 0000000..6331954
--- /dev/null
+++ b/manual tests/4 standalone binaries/myapp.icns
Binary files differ
diff --git a/manual tests/4 standalone binaries/myapp.iss b/manual tests/4 standalone binaries/myapp.iss
new file mode 100644
index 0000000..2bd441d
--- /dev/null
+++ b/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/manual tests/4 standalone binaries/myapp.sh b/manual tests/4 standalone binaries/myapp.sh
new file mode 100755
index 0000000..3191483
--- /dev/null
+++ b/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/manual tests/4 standalone binaries/osx_bundler.sh b/manual tests/4 standalone binaries/osx_bundler.sh
new file mode 100755
index 0000000..3bad65f
--- /dev/null
+++ b/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/manual tests/4 standalone binaries/readme.txt b/manual tests/4 standalone binaries/readme.txt
new file mode 100644
index 0000000..b689779
--- /dev/null
+++ b/manual tests/4 standalone binaries/readme.txt
@@ -0,0 +1,11 @@
+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/manual tests/4 standalone binaries/template.dmg.gz b/manual tests/4 standalone binaries/template.dmg.gz
new file mode 100644
index 0000000..fcb6d61
--- /dev/null
+++ b/manual tests/4 standalone binaries/template.dmg.gz
Binary files differ