mirror of
https://github.com/mesonbuild/meson.git
synced 2026-11-06 05:16:42 +00:00
Build windows installer for SDL2 sample app.
This commit is contained in:
1 parent
e46c1743ce
commit
d0d2508562
6 files changed
+71
-9
No files matched your search
+6
-2
@@ -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).
|
||||
|
||||
Reference in new issue
Block a user