meson: intel intrinsics, various improvements

This commit is contained in:
Andrei Alexeyev 2017-11-25 21:45:11 +02:00 committed by Martin Herkt
parent 406b8c8ba6
commit 29acd5f58a
221 changed files with 501 additions and 117 deletions

View file

@ -1,12 +1,25 @@
project('taisei', 'c', license : 'MIT', version : 'v1.1.0-9999',
meson_version : '>=0.38.0',
default_options : ['c_std=c11', 'b_lto=true'])
project('taisei', 'c',
license : 'MIT',
version : 'v1.1.0-9999',
meson_version : '>=0.38.0',
default_options : [
'c_std=c11',
# You may want to change these for a debug build dir
'buildtype=release',
'strip=true',
'b_lto=true',
'b_ndebug=true',
]
)
config = configuration_data()
cc = meson.get_compiler('c')
taisei_c_warnargs = []
taisei_c_args = []
foreach flag : [
'-Wpedantic',
'-Wparentheses',
@ -25,20 +38,24 @@ foreach flag : [
'-Wunneeded-internal-declaration',
'-Wunreachable-code',
'-Wunreachable-code-loop-increment',
'-Wgnu'
'-Wgnu',
]
if cc.has_argument(flag)
taisei_c_args += flag
taisei_c_warnargs += flag
endif
endforeach
taisei_c_args += taisei_c_warnargs
static = get_option('static')
dep_sdl2 = dependency('sdl2', version : '>=2.0.5', required : true, static : static)
dep_sdl2_ttf = dependency('SDL2_ttf', required : true, static: static)
dep_zlib = dependency('zlib', required : true, static: static)
dep_png = dependency('libpng', version : '>=1.5', required : true, static: static)
dep_m = cc.find_library('m', required : false)
dep_sdl2 = dependency('sdl2', version : '>=2.0.5', required : true, static : static)
dep_sdl2_ttf = dependency('SDL2_ttf', required : true, static : static)
dep_sdl2_mixer = dependency('SDL2_mixer', required : false, static : static)
dep_zlib = dependency('zlib', required : true, static : static)
dep_png = dependency('libpng', version : '>=1.5', required : true, static : static)
dep_zip = dependency('libzip', version : '>=1.0', required : false, static : static)
dep_m = cc.find_library('m', required : false)
taisei_deps = [dep_sdl2, dep_sdl2_ttf, dep_zlib, dep_png, dep_m]
@ -46,26 +63,24 @@ if host_machine.system() == 'windows'
taisei_deps += cc.find_library('shlwapi')
endif
dep_sdl2_mixer = dependency('SDL2_mixer', required : false, static: static)
if dep_sdl2_mixer.found() and get_option('enable_audio') != 'false'
taisei_deps += dep_sdl2_mixer
elif get_option('enable_audio') == 'true'
error('Audio support enabled but SDL2_mixer not found')
endif
dep_zip = dependency('libzip', version : '>=1.0', required : false, static: static)
if dep_zip.found() and get_option('package_data') != 'false'
taisei_deps += dep_zip
elif get_option('package_data') == 'true'
error('Data packaging enabled but libzip not found')
endif
config.set('DISABLE_ZIP', not taisei_deps.contains(dep_zip))
config.set('TAISEI_BUILDCONF_USE_ZIP', taisei_deps.contains(dep_zip))
have_posix = cc.has_header_symbol('unistd.h', '_POSIX_VERSION')
have_vla = not cc.has_header_symbol('unistd.h', '__STDC_NO_VLA__')
have_complex = not cc.has_header_symbol('unistd.h', '__STDC_NO_COMPLEX__')
have_backtrace = cc.has_header_symbol('execinfo.h', 'backtrace')
have_posix = cc.has_header_symbol('unistd.h', '_POSIX_VERSION')
have_vla = not cc.has_header_symbol('unistd.h', '__STDC_NO_VLA__')
have_complex = not cc.has_header_symbol('unistd.h', '__STDC_NO_COMPLEX__')
have_backtrace = cc.has_header_symbol('execinfo.h', 'backtrace')
if not (have_vla and have_complex)
error('Your C implementation needs to support complex numbers and variable-length arrays.')
@ -73,15 +88,15 @@ endif
if get_option('install_relative') == 'auto'
config.set('TAISEI_RELATIVE', host_machine.system() == 'windows' or host_machine.system() == 'darwin')
config.set('TAISEI_BUILDCONF_RELATIVE_DATA_PATH', host_machine.system() == 'windows' or host_machine.system() == 'darwin')
else
config.set('TAISEI_RELATIVE', get_option('install_relative') == 'true')
config.set('TAISEI_BUILDCONF_RELATIVE_DATA_PATH', get_option('install_relative') == 'true')
endif
if config.get('TAISEI_RELATIVE')
if config.get('TAISEI_BUILDCONF_RELATIVE_DATA_PATH')
if host_machine.system() == 'darwin'
data_path = join_paths(get_option('datadir'), 'data')
config.set('DATA_PATH', '"@0@"'.format(join_paths('../..', data_path)))
config.set('TAISEI_BUILDCONF_DATA_PATH', '"@0@"'.format(join_paths('../..', data_path)))
else
data_path = 'data'
@ -94,27 +109,27 @@ if config.get('TAISEI_RELATIVE')
endforeach
rel_dpath += data_path
config.set('DATA_PATH', '"@0@"'.format(join_paths(rel_dpath)))
config.set('TAISEI_BUILDCONF_DATA_PATH', '"@0@"'.format(join_paths(rel_dpath)))
endif
doc_path = ''
else
data_path = join_paths(get_option('datadir'), 'taisei')
config.set('DATA_PATH', '"@0@"'.format(join_paths(get_option('prefix'), data_path)))
config.set('TAISEI_BUILDCONF_DATA_PATH', '"@0@"'.format(join_paths(get_option('prefix'), data_path)))
doc_path = join_paths(get_option('datadir'), 'doc', 'taisei')
endif
systype = have_posix ? 'POSIX' : host_machine.system()
systype = (have_posix ? 'POSIX (@0@)' : '@0@').format(host_machine.system())
if get_option('buildtype').startswith('debug')
add_global_arguments('-DDEBUG', language: 'c')
config.set('TAISEI_BUILDCONF_DEBUG', true)
if have_backtrace
add_global_arguments('-DLOG_ENABLE_BACKTRACE', language : 'c')
config.set('TAISEI_BUILDCONF_LOG_ENABLE_BACKTRACE', true)
endif
endif
if host_machine.system() == 'windows' or host_machine.system() == 'darwin'
add_global_arguments('-DLOG_FATAL_MSGBOX', language : 'c')
config.set('TAISEI_BUILDCONF_LOG_FATAL_MSGBOX')
endif
if host_machine.system() == 'windows'
@ -129,22 +144,22 @@ endif
summary = '''
Summary:
System type: @0@
Audio enabled: @1@
Package data: @2@
System type: @0@
Audio enabled: @1@
Package data: @2@
Relative install paths: @3@
Prefix: @4@
Executables: @5@
Data: @6@
Documentation: @7@
Prefix: @4@
Executables: @5@
Data: @6@
Documentation: @7@
Build type: @8@
Build type: @8@
'''.format(
systype,
taisei_deps.contains(dep_sdl2_mixer),
taisei_deps.contains(dep_zip),
config.get('TAISEI_RELATIVE'),
config.get('TAISEI_BUILDCONF_RELATIVE_DATA_PATH'),
get_option('prefix'),
get_option('bindir'),
data_path,
@ -152,10 +167,10 @@ Summary:
get_option('buildtype')
)
message(summary)
subdir('src')
subdir('resources')
subdir('misc')
subdir('doc')
subdir('xdg')
message(summary)

View file

@ -4,3 +4,4 @@ option('package_data', type : 'combo', choices : ['auto', 'true', 'false'], desc
option('install_relative', type : 'combo', choices : ['auto', 'true', 'false'], description : 'Use only relative paths to the executable and install everything in the same directory')
option('win_console', type : 'boolean', value : false, description : 'Use the console subsystem on Windows')
option('static', type : 'boolean', value : false, description : 'Build statically linked executable')
option('intel_intrin', type : 'boolean', value : true, description : 'Use some x86-specific intrinsics for optimizations where appropriate (if possible). Note that this is not equivalent to e.g. supplying -march in CFLAGS')

View file

@ -1,4 +1,4 @@
dirs = ['bgm', 'gfx', 'models', 'sfx', 'shader']
dirs = ['bgm', 'gfx', 'models', 'sfx', 'shader', 'fonts']
if taisei_deps.contains(dep_zip)
archive = '00-taisei.zip'

View file

@ -7,7 +7,7 @@ if __name__ == '__main__':
inpath = sys.argv[1]
outpath = sys.argv[2]
except IndexError:
sys.stdout.write("Usage: %s infile outfile\n")
sys.stdout.write("Usage: %s infile outfile\n" % sys.argv[0])
exit(1)
# This would have been a one-liner with pathlib available...

View file

@ -9,10 +9,12 @@ header = r"""\1/*
* Copyright (c) 2011-2017, Lukas Weber <laochailan@web.de>.
* Copyright (c) 2012-2017, Andrei Alexeyev <akari@alienslab.net>.
*/
\2\3
#include "taisei.h"
"""
header_regex = re.compile(r'^(#if 0.*?\s#endif\s*)?(\s*/\*.*?\*/)?\s*', re.MULTILINE | re.DOTALL)
header_regex = re.compile(r'^(#if 0.*?\s#endif\s*)?(?:\s*?/\*.*?\*/)?(?:\s*?(\n#pragma once))?(?:\s*?#include "taisei.h")?(?:\s*?(\n#pragma once))?\s*', re.MULTILINE | re.DOTALL)
if __name__ == '__main__':
for path in itertools.chain(*((pathlib.Path(__file__).parent.parent / 'src').glob(p) for p in ('**/*.[ch]', '**/*.[ch].in'))):

View file

@ -6,6 +6,8 @@
* Copyright (c) 2012-2017, Andrei Alexeyev <akari@alienslab.net>.
*/
#include "taisei.h"
#include "aniplayer.h"
#include "list.h"
#include "global.h"

View file

@ -7,6 +7,7 @@
*/
#pragma once
#include "taisei.h"
/*
* This is a helper to play animations. It saves the state of the animation and

View file

@ -6,4 +6,6 @@
* Copyright (c) 2012-2017, Andrei Alexeyev <akari@alienslab.net>.
*/
#include "taisei.h"
#error Do not include assert.h, Taisei provides its own implementation.

View file

@ -7,6 +7,7 @@
*/
#pragma once
#include "taisei.h"
#include "resource/sfx.h"
#include "resource/bgm.h"

View file

@ -6,6 +6,8 @@
* Copyright (c) 2012-2017, Andrei Alexeyev <akari@alienslab.net>.
*/
#include "taisei.h"
#include <string.h>
#include <stdio.h>

View file

@ -6,6 +6,8 @@
* Copyright (c) 2012-2017, Andrei Alexeyev <akari@alienslab.net>.
*/
#include "taisei.h"
#include <SDL_mixer.h>
#include "audio.h"

View file

@ -7,6 +7,7 @@
*/
#pragma once
#include "taisei.h"
#include <SDL_mixer.h>
#include <stdbool.h>

View file

@ -6,6 +6,8 @@
* Copyright (c) 2012-2017, Andrei Alexeyev <akari@alienslab.net>.
*/
#include "taisei.h"
#include "audio.h"
void audio_backend_init(void) {}

View file

@ -6,6 +6,8 @@
* Copyright (c) 2012-2017, Andrei Alexeyev <akari@alienslab.net>.
*/
#include "taisei.h"
#include "boss.h"
#include "global.h"
#include "stage.h"

View file

@ -7,6 +7,7 @@
*/
#pragma once
#include "taisei.h"
#include "util.h"
#include "difficulty.h"

View file

@ -6,6 +6,8 @@
* Copyright (c) 2012-2017, Andrei Alexeyev <akari@alienslab.net>.
*/
#include "taisei.h"
#include "cli.h"
#include <getopt.h>
#include <string.h>

View file

@ -7,6 +7,7 @@
*/
#pragma once
#include "taisei.h"
#include "plrmodes.h"

View file

@ -6,6 +6,8 @@
* Copyright (c) 2012-2017, Andrei Alexeyev <akari@alienslab.net>.
*/
#include "taisei.h"
#include <stdio.h>
#include "color.h"

View file

@ -7,6 +7,7 @@
*/
#pragma once
#include "taisei.h"
#include <stdint.h>
#include "taiseigl.h"

View file

@ -7,6 +7,7 @@
*/
#pragma once
#include "taisei.h"
#ifndef __GNUC__ // clang defines this too
#define __attribute__(...)

View file

@ -6,6 +6,8 @@
* Copyright (c) 2012-2017, Andrei Alexeyev <akari@alienslab.net>.
*/
#include "taisei.h"
#include <string.h>
#include "config.h"

View file

@ -7,6 +7,7 @@
*/
#pragma once
#include "taisei.h"
#include <SDL_keycode.h>
#include <stdbool.h>

View file

@ -6,6 +6,8 @@
* Copyright (c) 2012-2017, Andrei Alexeyev <akari@alienslab.net>.
*/
#include "taisei.h"
#include "credits.h"
#include "global.h"
#include "stages/stage6.h"

View file

@ -7,6 +7,7 @@
*/
#pragma once
#include "taisei.h"
void credits_loop(void);
void credits_add(char*, int);

View file

@ -6,6 +6,8 @@
* Copyright (c) 2012-2017, Andrei Alexeyev <akari@alienslab.net>.
*/
#include "taisei.h"
#include "dialog.h"
#include "global.h"
#include <stdlib.h>

View file

@ -7,6 +7,7 @@
*/
#pragma once
#include "taisei.h"
#include <stdbool.h>
#include "resource/texture.h"

View file

@ -6,6 +6,8 @@
* Copyright (c) 2012-2017, Andrei Alexeyev <akari@alienslab.net>.
*/
#include "taisei.h"
#include "difficulty.h"
#include "resource/resource.h"

View file

@ -7,6 +7,7 @@
*/
#pragma once
#include "taisei.h"
#include "color.h"

View file

@ -6,6 +6,8 @@
* Copyright (c) 2012-2017, Andrei Alexeyev <akari@alienslab.net>.
*/
#include "taisei.h"
#include "ending.h"
#include "global.h"
#include "video.h"

View file

@ -7,6 +7,7 @@
*/
#pragma once
#include "taisei.h"
#include "resource/texture.h"

View file

@ -6,6 +6,8 @@
* Copyright (c) 2012-2017, Andrei Alexeyev <akari@alienslab.net>.
*/
#include "taisei.h"
#include "enemy.h"
#include <stdlib.h>

View file

@ -7,6 +7,7 @@
*/
#pragma once
#include "taisei.h"
#include "util.h"
#include "projectile.h"

View file

@ -6,6 +6,8 @@
* Copyright (c) 2012-2017, Andrei Alexeyev <akari@alienslab.net>.
*/
#include "taisei.h"
#include "events.h"
#include "config.h"
#include "global.h"

View file

@ -7,6 +7,7 @@
*/
#pragma once
#include "taisei.h"
#include "util.h"

View file

@ -6,6 +6,8 @@
* Copyright (c) 2012-2017, Andrei Alexeyev <akari@alienslab.net>.
*/
#include "taisei.h"
#include "fbo.h"
#include "global.h"
#include "util.h"

View file

@ -7,6 +7,7 @@
*/
#pragma once
#include "taisei.h"
#include "taiseigl.h"

View file

@ -6,6 +6,8 @@
* Copyright (c) 2012-2017, Andrei Alexeyev <akari@alienslab.net>.
*/
#include "taisei.h"
#include "gamepad.h"
#include "config.h"
#include "events.h"

View file

@ -7,6 +7,7 @@
*/
#pragma once
#include "taisei.h"
#include <SDL.h>
#include <stdbool.h>

View file

@ -6,6 +6,8 @@
* Copyright (c) 2012-2017, Andrei Alexeyev <akari@alienslab.net>.
*/
#include "taisei.h"
#include "global.h"
Global global;

View file

@ -7,6 +7,7 @@
*/
#pragma once
#include "taisei.h"
#include <SDL.h>
#include <SDL_platform.h>

View file

@ -6,6 +6,8 @@
* Copyright (c) 2012-2017, Andrei Alexeyev <akari@alienslab.net>.
*/
#include "taisei.h"
#include "hashtable.h"
#include "list.h"
#include "util.h"

View file

@ -7,6 +7,7 @@
*/
#pragma once
#include "taisei.h"
#include <stdbool.h>
#include <stdint.h>

View file

@ -6,6 +6,8 @@
* Copyright (c) 2012-2017, Andrei Alexeyev <akari@alienslab.net>.
*/
#include "taisei.h"
#include "util.h"
#include "hirestime.h"

View file

@ -7,6 +7,7 @@
*/
#pragma once
#include "taisei.h"
typedef long double hrtime_t;

View file

@ -6,6 +6,8 @@
* Copyright (c) 2012-2017, Andrei Alexeyev <akari@alienslab.net>.
*/
#include "taisei.h"
#include "item.h"
#include "global.h"
#include "list.h"

View file

@ -7,6 +7,7 @@
*/
#pragma once
#include "taisei.h"
#include "util.h"
#include "resource/texture.h"

View file

@ -6,6 +6,8 @@
* Copyright (c) 2012-2017, Andrei Alexeyev <akari@alienslab.net>.
*/
#include "taisei.h"
#include "laser.h"
#include "global.h"
#include "list.h"

View file

@ -7,6 +7,7 @@
*/
#pragma once
#include "taisei.h"
#include "util.h"
#include "projectile.h"

View file

@ -6,6 +6,8 @@
* Copyright (c) 2012-2017, Andrei Alexeyev <akari@alienslab.net>.
*/
#include "taisei.h"
#include <stdlib.h>
#include <stdio.h>

View file

@ -7,6 +7,7 @@
*/
#pragma once
#include "taisei.h"
typedef struct List {
struct List *next;

View file

@ -6,6 +6,8 @@
* Copyright (c) 2012-2017, Andrei Alexeyev <akari@alienslab.net>.
*/
#include "taisei.h"
#include <SDL_bits.h>
#include <SDL_mutex.h>

View file

@ -7,6 +7,7 @@
*/
#pragma once
#include "taisei.h"
#include <stdnoreturn.h>
#include <stdbool.h>

View file

@ -6,6 +6,8 @@
* Copyright (c) 2012-2017, Andrei Alexeyev <akari@alienslab.net>.
*/
#include "taisei.h"
#include <locale.h>
#include "global.h"

View file

@ -6,6 +6,8 @@
* Copyright (c) 2012-2017, Andrei Alexeyev <akari@alienslab.net>.
*/
#include "taisei.h"
#include <string.h>
#include "global.h"

View file

@ -7,6 +7,7 @@
*/
#pragma once
#include "taisei.h"
typedef float Matrix[4][4];

View file

@ -6,6 +6,8 @@
* Copyright (c) 2012-2017, Andrei Alexeyev <akari@alienslab.net>.
*/
#include "taisei.h"
#include "menu.h"
#include "options.h"
#include "common.h"

View file

@ -7,6 +7,7 @@
*/
#pragma once
#include "taisei.h"
#include "menu.h"

View file

@ -6,6 +6,8 @@
* Copyright (c) 2012-2017, Andrei Alexeyev <akari@alienslab.net>.
*/
#include "taisei.h"
#include "global.h"
#include "menu.h"
#include "savereplay.h"

View file

@ -7,6 +7,7 @@
*/
#pragma once
#include "taisei.h"
#include "menu.h"

View file

@ -6,6 +6,8 @@
* Copyright (c) 2012-2017, Andrei Alexeyev <akari@alienslab.net>.
*/
#include "taisei.h"
#include "difficulty.h"
#include "difficultyselect.h"
#include "options.h"

View file

@ -7,6 +7,7 @@
*/
#pragma once
#include "taisei.h"
#include "menu.h"

View file

@ -6,6 +6,8 @@
* Copyright (c) 2012-2017, Andrei Alexeyev <akari@alienslab.net>.
*/
#include "taisei.h"
#include "menu.h"
#include "gameovermenu.h"
#include "ingamemenu.h"

View file

@ -7,6 +7,7 @@
*/
#pragma once
#include "taisei.h"
#include "menu.h"

View file

@ -6,6 +6,8 @@
* Copyright (c) 2012-2017, Andrei Alexeyev <akari@alienslab.net>.
*/
#include "taisei.h"
#include "menu.h"
#include "common.h"
#include "ingamemenu.h"

View file

@ -7,6 +7,7 @@
*/
#pragma once
#include "taisei.h"
#include "menu.h"

View file

@ -6,6 +6,8 @@
* Copyright (c) 2012-2017, Andrei Alexeyev <akari@alienslab.net>.
*/
#include "taisei.h"
#include "mainmenu.h"
#include "menu.h"
#include "submenus.h"

View file

@ -7,6 +7,7 @@
*/
#pragma once
#include "taisei.h"
#include "menu.h"

View file

@ -6,6 +6,8 @@
* Copyright (c) 2012-2017, Andrei Alexeyev <akari@alienslab.net>.
*/
#include "taisei.h"
#include "menu.h"
#include "global.h"
#include "video.h"

View file

@ -7,6 +7,7 @@
*/
#pragma once
#include "taisei.h"
#include <stdbool.h>
#include "transition.h"

View file

@ -6,6 +6,8 @@
* Copyright (c) 2012-2017, Andrei Alexeyev <akari@alienslab.net>.
*/
#include "taisei.h"
#include <stdio.h>
#include "menu.h"
#include "common.h"

View file

@ -7,6 +7,7 @@
*/
#pragma once
#include "taisei.h"
#include "menu.h"

View file

@ -6,6 +6,8 @@
* Copyright (c) 2012-2017, Andrei Alexeyev <akari@alienslab.net>.
*/
#include "taisei.h"
#include <time.h>
#include "global.h"
#include "menu.h"

View file

@ -7,6 +7,7 @@
*/
#pragma once
#include "taisei.h"
#include "menu.h"

View file

@ -6,6 +6,8 @@
* Copyright (c) 2012-2017, Andrei Alexeyev <akari@alienslab.net>.
*/
#include "taisei.h"
#include <time.h>
#include "savereplay.h"
#include "options.h"

View file

@ -7,6 +7,7 @@
*/
#pragma once
#include "taisei.h"
#include "menu.h"

View file

@ -6,6 +6,8 @@
* Copyright (c) 2012-2017, Andrei Alexeyev <akari@alienslab.net>.
*/
#include "taisei.h"
#include "spellpractice.h"
#include "common.h"
#include "options.h"

View file

@ -7,6 +7,7 @@
*/
#pragma once
#include "taisei.h"
#include "menu.h"

View file

@ -6,6 +6,8 @@
* Copyright (c) 2012-2017, Andrei Alexeyev <akari@alienslab.net>.
*/
#include "taisei.h"
#include "stagepractice.h"
#include "common.h"
#include "options.h"

View file

@ -7,6 +7,7 @@
*/
#pragma once
#include "taisei.h"
#include "menu.h"
#include "difficulty.h"

View file

@ -6,6 +6,8 @@
* Copyright (c) 2012-2017, Andrei Alexeyev <akari@alienslab.net>.
*/
#include "taisei.h"
#include "global.h"
#include "menu.h"
#include "options.h"