Build windows installer for SDL2 sample app.

pull/96/head
Jussi Pakkanen 10 years ago
parent e46c1743ce
commit d0d2508562
  1. 8
      dependencies.py
  2. 32
      manual tests/4 standalone binaries/build_windows_package.py
  3. 10
      manual tests/4 standalone binaries/meson.build
  4. 2
      manual tests/4 standalone binaries/myapp.cpp
  5. 18
      manual tests/4 standalone binaries/myapp.iss
  6. 10
      manual tests/4 standalone binaries/readme.txt

@ -73,9 +73,13 @@ class PkgConfigDependency(Dependency):
if PkgConfigDependency.pkgconfig_found is None:
self.check_pkgconfig()
if not PkgConfigDependency.pkgconfig_found:
raise DependencyException('Pkg-config not found.')
self.is_found = False
if not PkgConfigDependency.pkgconfig_found:
if required:
raise DependencyException('Pkg-config not found.')
self.cargs = []
self.libs = []
return
p = subprocess.Popen(['pkg-config', '--modversion', name], stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
out = p.communicate()[0]

@ -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)
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')

@ -1,6 +1,6 @@
project('myapp', 'cpp')
sdl = dependency('sdl2')
sdl = dependency('sdl2', required : host.name() != 'windows')
if meson.get_compiler('cpp').get_id() != 'msvc'
add_global_arguments('-std=c++11', language : 'cpp')
@ -24,7 +24,15 @@ if host.name() == 'linux'
meson.set_install_script('linux_bundler.sh')
endif
extra_link_args = []
if host.name() == '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)

@ -3,7 +3,7 @@
#include<iostream>
#include<string>
int main(int argc, char **argv) {
int main(int argc, char *argv[]) {
SDL_Surface *screenSurface;
SDL_Event e;
int keepGoing = 1;

@ -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"

@ -1,12 +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 a binary that bundles its dependencies. On Windows
it means probably building an .exe installer or something (not done
yet).
it means building an .exe installer.
To build each package you run the corresponding build_ARCH.sh build script.
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 usually
the choice here).
plan to support (Debian stable/oldstable and old CentOS are the common
choice here).

Loading…
Cancel
Save