2017-11-25 20:45:11 +01:00
|
|
|
project('taisei', 'c',
|
|
|
|
license : 'MIT',
|
2022-12-28 23:15:55 +01:00
|
|
|
# NOTE: See https://github.com/mesonbuild/meson/issues/11163
|
|
|
|
version : run_command([
|
|
|
|
files('scripts/version.py'),
|
|
|
|
'--rootdir', meson.project_source_root(),
|
|
|
|
], check : true).stdout().strip(),
|
|
|
|
meson_version : '>=0.63.0',
|
2017-11-25 20:45:11 +01:00
|
|
|
default_options : [
|
2019-12-14 10:03:04 +01:00
|
|
|
'c_std=gnu11',
|
|
|
|
|
2019-03-17 06:06:47 +01:00
|
|
|
'default_library=static',
|
2022-08-16 07:39:47 +02:00
|
|
|
'cglm:default_library=static',
|
|
|
|
'freetype:default_library=static',
|
|
|
|
'glslang:default_library=static',
|
|
|
|
'libpng:default_library=static',
|
|
|
|
'libwebp:default_library=static',
|
|
|
|
'libzip:default_library=static',
|
|
|
|
'libzstd:default_library=static',
|
|
|
|
'ogg:default_library=static',
|
|
|
|
'opus:default_library=static',
|
|
|
|
'opusfile:default_library=static',
|
|
|
|
'sdl2:default_library=static',
|
|
|
|
'shaderc:default_library=static',
|
|
|
|
'SPIRV-Cross:default_library=static',
|
|
|
|
'vorbis:default_library=static',
|
|
|
|
'zlib:default_library=static',
|
2019-03-17 06:06:47 +01:00
|
|
|
|
2020-03-17 10:00:34 +01:00
|
|
|
'koishi:threadsafe=false',
|
|
|
|
|
2021-04-29 19:15:56 +02:00
|
|
|
'cglm:werror=false',
|
2020-11-08 19:53:17 +01:00
|
|
|
'cglm:install=false',
|
|
|
|
'cglm:build_tests=false',
|
|
|
|
|
2022-02-05 20:27:37 +01:00
|
|
|
'basis_universal:enable_ktx2=false',
|
|
|
|
|
2021-04-13 19:07:35 +02:00
|
|
|
'libzip:bzip2=disabled',
|
|
|
|
'libzip:lzma=disabled',
|
|
|
|
'libzip:zstd=enabled',
|
2020-03-19 08:02:33 +01:00
|
|
|
'libzip:enable_crypto=false',
|
2017-11-25 20:45:11 +01:00
|
|
|
|
2021-03-27 17:29:56 +01:00
|
|
|
'libzstd:install_headers=false',
|
|
|
|
'libzstd:install_libraries=false',
|
|
|
|
'libzstd:install_pkgconfig=false',
|
|
|
|
'libzstd:legacy_level=0',
|
|
|
|
'libzstd:debug_level=0',
|
|
|
|
'libzstd:bin_programs=false',
|
|
|
|
'libzstd:bin_tests=false',
|
|
|
|
'libzstd:bin_contrib=false',
|
|
|
|
'libzstd:zlib=disabled',
|
|
|
|
'libzstd:lzma=disabled',
|
|
|
|
'libzstd:lz4=disabled',
|
|
|
|
'libzstd:multi_thread=disabled',
|
|
|
|
|
2023-07-29 03:25:38 +02:00
|
|
|
'sdl2:test=false',
|
2019-03-20 08:35:29 +01:00
|
|
|
'sdl2:use_haptic=disabled',
|
|
|
|
'sdl2:use_power=disabled',
|
|
|
|
'sdl2:use_render=disabled',
|
|
|
|
'sdl2:use_sensor=disabled',
|
2020-03-19 08:02:33 +01:00
|
|
|
'sdl2:use_video_offscreen=disabled',
|
|
|
|
'sdl2:use_video_vulkan=disabled',
|
2023-07-29 03:25:38 +02:00
|
|
|
'sdl2:with_main=true',
|
2019-03-18 07:05:10 +01:00
|
|
|
|
2023-07-31 03:07:01 +02:00
|
|
|
'freetype:brotli=disabled',
|
|
|
|
'freetype:bzip2=disabled',
|
|
|
|
'freetype:harfbuzz=disabled',
|
|
|
|
'freetype:png=disabled',
|
|
|
|
'freetype:tests=disabled',
|
|
|
|
|
2023-07-31 03:31:57 +02:00
|
|
|
'opus:docs=disabled',
|
|
|
|
'opus:extra-programs=disabled',
|
|
|
|
'opus:tests=disabled',
|
|
|
|
|
2017-11-25 20:45:11 +01:00
|
|
|
# You may want to change these for a debug build dir
|
|
|
|
'buildtype=release',
|
|
|
|
'strip=true',
|
|
|
|
'b_lto=true',
|
2019-01-24 21:21:08 +01:00
|
|
|
'b_ndebug=if-release',
|
2017-11-25 20:45:11 +01:00
|
|
|
]
|
|
|
|
)
|
2017-11-12 01:28:30 +01:00
|
|
|
|
2022-12-28 23:15:55 +01:00
|
|
|
taisei_version_string = meson.project_version()
|
|
|
|
|
2019-05-01 07:18:25 +02:00
|
|
|
is_debug_build = get_option('debug')
|
|
|
|
is_developer_build = (get_option('developer') == 'auto' ? is_debug_build : get_option('developer') == 'true')
|
|
|
|
|
2017-11-12 01:28:30 +01:00
|
|
|
cc = meson.get_compiler('c')
|
2020-12-26 00:40:08 +01:00
|
|
|
python = import('python').find_installation()
|
2017-11-12 01:28:30 +01:00
|
|
|
|
2019-01-24 21:21:08 +01:00
|
|
|
subdir('scripts')
|
2017-11-25 20:45:11 +01:00
|
|
|
|
2019-01-24 21:21:08 +01:00
|
|
|
config = configuration_data()
|
2017-11-12 01:28:30 +01:00
|
|
|
|
2019-02-11 09:30:00 +01:00
|
|
|
taisei_c_args = [
|
2019-01-24 21:21:08 +01:00
|
|
|
'-Wall',
|
2019-04-04 01:43:03 +02:00
|
|
|
|
2019-02-02 12:25:06 +01:00
|
|
|
'-Werror=assume',
|
2019-01-24 21:21:08 +01:00
|
|
|
'-Werror=implicit-function-declaration',
|
2019-04-04 01:43:03 +02:00
|
|
|
'-Werror=incompatible-pointer-types',
|
2021-07-18 10:18:34 +02:00
|
|
|
'-Werror=return-type',
|
2019-01-24 21:21:08 +01:00
|
|
|
|
|
|
|
#
|
|
|
|
# Keep the rest sorted
|
|
|
|
#
|
|
|
|
|
|
|
|
'-Wabsolute-value',
|
|
|
|
'-Wcast-align',
|
|
|
|
'-Wcast-align=strict',
|
Emscripten compatibility (#161)
* Major refactoring of the main loop(s) and control flow (WIP)
run_at_fps() is gone 🦀
Instead of nested blocking event loops, there is now an eventloop API
that manages an explicit stack of scenes. This makes Taisei a lot more
portable to async environments where spinning a loop forever without
yielding control simply is not an option, and that is the entire point
of this change.
A prime example of such an environment is the Web (via emscripten).
Taisei was able to run there through a terrible hack: inserting
emscripten_sleep calls into the loop, which would yield to the browser.
This has several major drawbacks: first of all, every function that
could possibly call emscripten_sleep must be compiled into a special
kind of bytecode, which then has to be interpreted at runtime, *much*
slower than JITed WebAssembly. And that includes *everything* down the
call stack, too! For more information, see
https://emscripten.org/docs/porting/emterpreter.html
Even though that method worked well enough for experimenting, despite
suboptimal performance, there is another obvious drawback:
emscripten_sleep is implemented via setTimeout(), which can be very
imprecise and is generally not reliable for fluid animation. Browsers
actually have an API specifically for that use case:
window.requestAnimationFrame(), but Taisei's original blocking control
flow style is simply not compatible with it. Emscripten exposes this API
with its emscripten_set_main_loop(), which the eventloop backend now
uses on that platform.
Unfortunately, C is still C, with no fancy closures or coroutines.
With blocking calls into menu/scene loops gone, the control flow is
reimplemented via so-called (pun intended) "call chains". That is
basically an euphemism for callback hell. With manual memory management
and zero type-safety. Not that the menu system wasn't shitty enough
already. I'll just keep telling myself that this is all temporary and
will be replaced with scripts in v1.4.
* improve build system for emscripten + various fixes
* squish menu bugs
* improve emscripten event loop; disable EMULATE_FUNCTION_POINTER_CASTS
Note that stock freetype does not work without
EMULATE_FUNCTION_POINTER_CASTS; use a patched version from the
"emscripten" branch here:
https://github.com/taisei-project/freetype2/tree/emscripten
* Enable -Wcast-function-type
Calling functions through incompatible pointers is nasal demons and
doesn't work in WASM.
* webgl: workaround a crash on some browsers
* emscripten improvements:
* Persist state (config, progress, replays, ...) in local IndexDB
* Simpler HTML shell (temporary)
* Enable more optimizations
* fix build if validate_glsl=false
* emscripten: improve asset packaging, with local cache
Note that even though there are rules to build audio bundles, audio
does *not* work yet. It looks like SDL2_mixer can not work without
threads, which is a problem. Yet another reason to write an OpenAL
backend - emscripten supports that natively.
* emscripten: customize the html shell
* emscripten: force "show log" checkbox unchecked initially
* emscripten: remove quit shortcut from main menu (since there's no quit)
* emscripten: log area fixes
* emscripten/webgl: workaround for fullscreen viewport issue
* emscripten: implement frameskip
* emscripter: improve framerate limiter
* align List to at least 8 bytes (shut up warnings)
* fix non-emscripten builds
* improve fullscreen handling, mainly for emscripten
* Workaround to make audio work in chromium
emscripten-core/emscripten#6511
* emscripten: better vsync handling; enable vsync & disable fxaa by default
2019-03-09 20:32:32 +01:00
|
|
|
'-Wcast-function-type',
|
2019-01-24 21:21:08 +01:00
|
|
|
'-Wclobbered',
|
|
|
|
'-Wduplicated-branches',
|
|
|
|
'-Wduplicated-cond',
|
|
|
|
'-Wfor-loop-analysis',
|
|
|
|
'-Wformat-security',
|
|
|
|
'-Wgcc-compat',
|
|
|
|
'-Wignored-qualifiers',
|
|
|
|
'-Winit-self',
|
|
|
|
'-Wlogical-op',
|
|
|
|
'-Wmissing-prototypes',
|
2023-06-20 05:41:22 +02:00
|
|
|
'-Wno-declaration-after-statement',
|
2023-01-08 01:49:34 +01:00
|
|
|
'-Wno-gnu-alignof-expression',
|
2020-03-07 17:47:02 +01:00
|
|
|
'-Wno-gnu-folding-constant',
|
2021-04-21 03:31:26 +02:00
|
|
|
'-Wno-ignored-optimization-argument',
|
2020-04-04 01:23:32 +02:00
|
|
|
'-Wno-implicit-fallthrough',
|
2019-01-24 21:21:08 +01:00
|
|
|
'-Wno-long-long',
|
2019-03-03 12:53:45 +01:00
|
|
|
'-Wno-missing-braces',
|
2023-06-20 05:44:11 +02:00
|
|
|
'-Wno-shadow',
|
2019-02-08 20:12:52 +01:00
|
|
|
'-Wno-typedef-redefinition',
|
2019-01-24 21:21:08 +01:00
|
|
|
'-Wnull-dereference',
|
|
|
|
'-Wparentheses',
|
|
|
|
'-Wsometimes-uninitialized',
|
2020-12-26 00:40:08 +01:00
|
|
|
'-Wstrict-overflow=0',
|
2019-01-24 21:21:08 +01:00
|
|
|
'-Wstrict-prototypes',
|
|
|
|
'-Wtype-limits',
|
Some compatibility fixes for Elbrus compiler (and others based on EDG front end) (#157)
* Reduce alignment to 16 due to stack variables alignment
On some archs (e.g. elbrus) there is no possibility to align
variables on stack by more that 16 bytes.
* Added check for -Wno-typedef-redefinition
In C11, there is legal to redefine typedef with the same type,
but some compilers like elbrus's lcc and, probably, intel's icc
generate a warning about that. So we disable it.
* Typo fix
* Fix __builtin_unreachable() warning on some frontends like EDG
* Added check for __attribute__((designated_init))
It doesn't work for elbrus'c lcc and clang; but clang does not
generate warning by default, but we still disable it just in case.
* A hack to avoid -Wtype-limits for compilers with unsigned enums
* Rewritten unreachable __builtin_unreachable() behavior.
According to https://bugs.llvm.org/show_bug.cgi?id=13910,
old clang versions also suffer from this issue along with lcc.
And also this warning option is removed from gcc since 4.5.0,
and it's likely there is no unreachable code analysis at all:
https://gcc.gnu.org/onlinedocs/gcc-4.5.0/gcc/Warning-Options.html
* Fixed unneeded stray UNREACHABLE which caused warnings
* Removed alignas() which is unneeded after lowering alignment requirements
* Removed a hack of -Wunreachable-code disabling on certain compilers
Actually, there was a wrong opinion that most of unreachable code
warnings are produced by __builtin_unreachable() itself,
not the certain use of it. After commit 36493d3, it is finally
figured out that it wasn't the case.
* Added dummy element to a struct in a test for designated_init
This test will enexpectedly fail when GNU extensions are not available
2019-02-07 09:11:13 +01:00
|
|
|
'-Wunneeded-internal-declaration',
|
2019-02-08 20:12:52 +01:00
|
|
|
'-Wunreachable-code',
|
2019-01-24 21:21:08 +01:00
|
|
|
'-Wunreachable-code-loop-increment',
|
2019-07-22 09:35:21 +02:00
|
|
|
|
|
|
|
'-fexcess-precision=standard',
|
|
|
|
'-fmerge-all-constants',
|
|
|
|
'-fno-math-errno',
|
|
|
|
'-fno-signaling-nans',
|
|
|
|
'-fno-trapping-math',
|
2019-02-11 09:30:00 +01:00
|
|
|
]
|
|
|
|
|
2023-02-16 00:28:09 +01:00
|
|
|
taisei_conversion_c_args = [
|
|
|
|
# These are intended to enable "implicit conversion discards imaginary component" warnings
|
|
|
|
# on clang. Those are gated by `-Wconversion`, which enables a ton of other stuff that we are
|
|
|
|
# not ready for. So we need to undo that. Some of this stuff might be worth enabling later.
|
|
|
|
|
|
|
|
# In GCC, -Wconversion also enables a bunch of stuff that can't be disabled individually, or so
|
|
|
|
# it seems. It also doesn't have the warning we are actually interested in. That's why we test
|
|
|
|
# for all of these flags at once: if the compiler accepts all of them, we assume clang-like
|
|
|
|
# behavior.
|
|
|
|
|
|
|
|
'-Wconversion',
|
|
|
|
'-Wno-enum-conversion',
|
|
|
|
'-Wno-float-conversion',
|
|
|
|
'-Wfloat-overflow-conversion',
|
|
|
|
'-Wno-implicit-int-conversion',
|
|
|
|
'-Wno-implicit-int-float-conversion',
|
|
|
|
'-Wno-implicit-float-conversion',
|
|
|
|
'-Wno-shorten-64-to-32',
|
|
|
|
'-Wno-sign-conversion',
|
|
|
|
'-Wno-string-conversion',
|
|
|
|
]
|
|
|
|
|
2019-10-03 02:22:54 +02:00
|
|
|
deprecation_warnings = get_option('deprecation_warnings')
|
|
|
|
|
|
|
|
if deprecation_warnings == 'error'
|
|
|
|
taisei_c_args += '-Werror=deprecated-declarations'
|
|
|
|
elif deprecation_warnings == 'no-error'
|
|
|
|
taisei_c_args += '-Wno-error=deprecated-declarations'
|
|
|
|
elif deprecation_warnings == 'ignore'
|
|
|
|
taisei_c_args += '-Wno-deprecated-declarations'
|
|
|
|
endif
|
|
|
|
|
2019-02-11 09:30:00 +01:00
|
|
|
taisei_c_args = cc.get_supported_arguments(taisei_c_args)
|
2017-11-25 20:45:11 +01:00
|
|
|
|
2019-02-17 22:25:16 +01:00
|
|
|
foreach arglist : [
|
2023-02-16 00:28:09 +01:00
|
|
|
taisei_conversion_c_args,
|
2019-02-17 22:25:16 +01:00
|
|
|
['-msse', '-mfpmath=sse'],
|
|
|
|
]
|
|
|
|
if cc.has_multi_arguments(arglist)
|
|
|
|
taisei_c_args += arglist
|
|
|
|
endif
|
|
|
|
endforeach
|
|
|
|
|
2022-12-28 23:15:55 +01:00
|
|
|
sm_check = run_command(check_submodules_command, check : false)
|
2019-02-20 03:55:54 +01:00
|
|
|
|
|
|
|
if sm_check.stdout() != ''
|
|
|
|
foreach line : sm_check.stdout().strip().split('\n')
|
|
|
|
warning(line)
|
|
|
|
endforeach
|
|
|
|
endif
|
|
|
|
|
|
|
|
if sm_check.stderr() != ''
|
|
|
|
warning('Submodule check completed with errors:\n@0@'.format(sm_check.stderr()))
|
|
|
|
endif
|
|
|
|
|
2022-12-28 23:15:55 +01:00
|
|
|
opt_vfs_zip = get_option('vfs_zip').require(host_machine.system() != 'emscripten',
|
|
|
|
error_message : 'ZIP packages are not supported on Emscripten')
|
|
|
|
|
2023-09-28 14:58:08 +02:00
|
|
|
opt_gamemode = get_option('gamemode').require(host_machine.system() == 'linux',
|
|
|
|
error_message : 'GameMode is Linux-specific')
|
|
|
|
|
2022-12-28 23:15:55 +01:00
|
|
|
dep_freetype = dependency('freetype2', required : true)
|
|
|
|
dep_png = dependency('libpng', version : '>=1.5', required : true)
|
|
|
|
dep_sdl2 = dependency('sdl2', version : '>=2.0.10',required : true)
|
|
|
|
dep_webp = dependency('libwebp', version : '>=0.5', required : true)
|
|
|
|
dep_webpdecoder = dependency('libwebpdecoder', version : '>=0.5', required : false)
|
|
|
|
dep_zlib = dependency('zlib', required : true)
|
|
|
|
dep_zstd = dependency('libzstd', version : '>=1.4.0', fallback : ['libzstd', 'libzstd_dep'])
|
|
|
|
dep_zip = dependency('libzip', version : '>=1.5.0', required : opt_vfs_zip, allow_fallback : true)
|
|
|
|
dep_cglm = dependency('cglm', version : '>=0.7.8', required : true)
|
|
|
|
dep_crypto = dependency('libcrypto', required : get_option('use_libcrypto'))
|
2023-09-28 14:58:08 +02:00
|
|
|
dep_gamemode = dependency('gamemode', required : opt_gamemode)
|
2018-10-18 23:12:46 +02:00
|
|
|
|
2019-02-08 19:59:36 +01:00
|
|
|
dep_m = cc.find_library('m', required : false)
|
2017-11-12 01:28:30 +01:00
|
|
|
|
2020-08-15 13:51:12 +02:00
|
|
|
dep_basisu_transcoder = subproject('basis_universal').get_variable('basisu_transcoder_dep')
|
2019-06-26 12:09:26 +02:00
|
|
|
dep_koishi = subproject('koishi').get_variable('koishi_dep')
|
2018-06-30 22:11:54 +02:00
|
|
|
|
2023-08-28 15:58:28 +02:00
|
|
|
sub_glad = subproject('glad')
|
|
|
|
dep_glad_gl = sub_glad.get_variable('glad_gl_dep')
|
|
|
|
dep_glad_egl = sub_glad.get_variable('glad_egl_dep')
|
|
|
|
|
2018-04-12 16:08:48 +02:00
|
|
|
taisei_deps = [
|
2020-08-15 13:51:12 +02:00
|
|
|
dep_basisu_transcoder,
|
2018-10-18 23:12:46 +02:00
|
|
|
dep_cglm,
|
2022-12-28 23:15:55 +01:00
|
|
|
dep_crypto,
|
2018-06-29 23:36:51 +02:00
|
|
|
dep_freetype,
|
2020-11-19 00:12:51 +01:00
|
|
|
dep_gamemode,
|
2019-06-26 12:09:26 +02:00
|
|
|
dep_koishi,
|
2018-04-12 16:08:48 +02:00
|
|
|
dep_m,
|
2018-10-18 23:12:46 +02:00
|
|
|
dep_png,
|
|
|
|
dep_sdl2,
|
2022-12-28 23:15:55 +01:00
|
|
|
dep_zip,
|
2018-10-18 23:12:46 +02:00
|
|
|
dep_zlib,
|
2021-03-22 16:43:37 +01:00
|
|
|
dep_zstd,
|
2018-06-30 22:11:54 +02:00
|
|
|
# don't add glad here
|
2018-04-12 16:08:48 +02:00
|
|
|
]
|
2017-11-12 01:28:30 +01:00
|
|
|
|
2022-12-28 23:15:55 +01:00
|
|
|
wrap_mode_forcefallback = (get_option('wrap_mode') == 'forcefallback')
|
2019-09-29 21:02:38 +02:00
|
|
|
|
|
|
|
if dep_webpdecoder.found() and not wrap_mode_forcefallback
|
2019-09-15 09:18:39 +02:00
|
|
|
# distro libwebpdecoder
|
2018-10-19 01:51:59 +02:00
|
|
|
taisei_deps += dep_webpdecoder
|
|
|
|
else
|
2019-09-15 09:18:39 +02:00
|
|
|
# either distro libwebp, or libwebpdecoder from subproject
|
|
|
|
taisei_deps += dep_webp
|
2018-10-19 01:51:59 +02:00
|
|
|
endif
|
|
|
|
|
2017-11-12 01:28:30 +01:00
|
|
|
if host_machine.system() == 'windows'
|
|
|
|
taisei_deps += cc.find_library('shlwapi')
|
|
|
|
endif
|
|
|
|
|
2022-12-28 23:15:55 +01:00
|
|
|
package_data = (
|
|
|
|
get_option('package_data')
|
|
|
|
.require(dep_zip.found(),
|
|
|
|
error_message : 'libzip not found or VFS ZIP support is disabled')
|
|
|
|
.allowed()
|
|
|
|
)
|
2019-01-24 21:21:08 +01:00
|
|
|
|
2022-12-28 23:15:55 +01:00
|
|
|
config.set('TAISEI_BUILDCONF_USE_ZIP', dep_zip.found())
|
2017-11-12 01:28:30 +01:00
|
|
|
|
2019-12-14 10:03:04 +01:00
|
|
|
have_posix = cc.has_header_symbol('unistd.h', '_POSIX_VERSION')
|
|
|
|
|
|
|
|
# Feature test macros _SUCK_!
|
|
|
|
# On some platforms (FreeBSD, macOS, ...), defining _POSIX_C_SOURCE disables C11
|
|
|
|
# symbols, EVEN WHEN COMPILING IN C11 MODE! On macOS you can get around this
|
|
|
|
# with _DARWIN_C_SOURCE; on BSD you're screwed apparently. Some libCs require
|
|
|
|
# _POSIX_C_SOURCE for posix functionality (musl, glibc with __STRICT_ANSI__),
|
|
|
|
# others include everything by default, it's an inconsistent trash fire. So far
|
|
|
|
# the safest option seems to be to compile without strict conformance and only
|
|
|
|
# define _POSIX_C_SOURCE if we have to.
|
|
|
|
if have_posix
|
|
|
|
if not cc.has_header_symbol('stdio.h', 'fileno')
|
|
|
|
# No POSIX stuff by default? Then request it, and assume the libc isn't
|
|
|
|
# braindead enough to hide the standard C11 APIs.
|
|
|
|
# If it is then your system sucks.
|
|
|
|
config.set('_POSIX_C_SOURCE', '200809L')
|
|
|
|
endif
|
|
|
|
|
|
|
|
# For good measure
|
|
|
|
if host_machine.system() == 'darwin'
|
|
|
|
config.set('_DARWIN_C_SOURCE', true)
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
2019-02-22 00:56:48 +01:00
|
|
|
have_vla = not cc.has_header_symbol('stdlib.h', '__STDC_NO_VLA__')
|
|
|
|
have_complex = not cc.has_header_symbol('stdlib.h', '__STDC_NO_COMPLEX__')
|
2019-12-14 10:03:04 +01:00
|
|
|
have_timespec = cc.has_function('timespec_get')
|
2017-11-12 01:28:30 +01:00
|
|
|
|
2019-02-22 00:56:48 +01:00
|
|
|
assert(have_vla and have_complex, 'Your C implementation needs to support complex numbers and variable-length arrays.')
|
2017-11-12 01:28:30 +01:00
|
|
|
|
2018-05-28 10:10:41 +02:00
|
|
|
config.set('TAISEI_BUILDCONF_HAVE_TIMESPEC', have_timespec)
|
2019-01-09 04:25:10 +01:00
|
|
|
config.set('TAISEI_BUILDCONF_HAVE_INT128', cc.sizeof('__int128') == 16)
|
|
|
|
config.set('TAISEI_BUILDCONF_HAVE_LONG_DOUBLE', cc.sizeof('long double') > 8)
|
2019-02-14 22:11:27 +01:00
|
|
|
config.set('TAISEI_BUILDCONF_HAVE_POSIX', have_posix)
|
2019-07-20 15:15:51 +02:00
|
|
|
config.set('TAISEI_BUILDCONF_HAVE_SINCOS', cc.has_function('sincos', dependencies : dep_m))
|
|
|
|
|
2022-02-22 19:55:50 +01:00
|
|
|
use_gnu_funcs = false
|
2022-08-27 01:40:55 +02:00
|
|
|
gnu_funcs = ['sincos', 'strtok_r', 'memrchr', 'memmem']
|
2022-02-22 19:55:50 +01:00
|
|
|
|
|
|
|
foreach f : gnu_funcs
|
|
|
|
have = cc.has_function(f, dependencies : dep_m)
|
|
|
|
config.set('TAISEI_BUILDCONF_HAVE_@0@'.format(f.to_upper()), have)
|
|
|
|
use_gnu_funcs = have or use_gnu_funcs
|
|
|
|
endforeach
|
|
|
|
|
|
|
|
config.set('_GNU_SOURCE', use_gnu_funcs)
|
2019-12-18 14:33:36 +01:00
|
|
|
|
|
|
|
if host_machine.system() == 'emscripten'
|
|
|
|
# Emscripten bug: https://github.com/emscripten-core/emscripten/issues/10072
|
|
|
|
config.set('TAISEI_BUILDCONF_MALLOC_ALIGNMENT', 8)
|
|
|
|
config.set('TAISEI_BUILDCONF_HAVE_MAX_ALIGN_T', false)
|
|
|
|
else
|
|
|
|
malloc_alignment = cc.alignment('max_align_t', prefix : '#include <stddef.h>\n')
|
|
|
|
config.set('TAISEI_BUILDCONF_MALLOC_ALIGNMENT', malloc_alignment)
|
|
|
|
config.set('TAISEI_BUILDCONF_HAVE_MAX_ALIGN_T', malloc_alignment > 0)
|
|
|
|
endif
|
2019-02-22 00:56:48 +01:00
|
|
|
|
2020-08-15 13:51:12 +02:00
|
|
|
config.set('TAISEI_BUILDCONF_HAVE_BUILTIN_POPCOUNTLL', cc.has_function('__builtin_popcountll'))
|
|
|
|
config.set('TAISEI_BUILDCONF_HAVE_BUILTIN_POPCOUNT', cc.has_function('__builtin_popcount'))
|
2021-04-29 19:43:57 +02:00
|
|
|
config.set('TAISEI_BUILDCONF_HAVE_BUILTIN_AVAILABLE', cc.has_function('__builtin_available'))
|
2023-01-09 04:19:31 +01:00
|
|
|
config.set('TAISEI_BUILDCONF_HAVE_ALIGNED_ALLOC', cc.has_function('aligned_alloc'))
|
2023-04-03 01:33:32 +02:00
|
|
|
# XXX: meson thinks posix_memalign exists on Switch
|
|
|
|
config.set('TAISEI_BUILDCONF_HAVE_POSIX_MEMALIGN',
|
|
|
|
host_machine.system() != 'nx' and cc.has_function('posix_memalign'))
|
2023-01-09 04:19:31 +01:00
|
|
|
config.set('TAISEI_BUILDCONF_HAVE_ALIGNED_MALLOC_FREE',
|
|
|
|
cc.has_function('_aligned_malloc') and cc.has_function('_aligned_free'))
|
2020-03-31 21:51:31 +02:00
|
|
|
|
2022-12-28 23:15:55 +01:00
|
|
|
if dep_zip.found()
|
2021-04-20 02:54:52 +02:00
|
|
|
if dep_zip.type_name() == 'internal'
|
|
|
|
have_zip_compression_method_supported = dep_zip.version().version_compare('>=1.7.0')
|
|
|
|
else
|
|
|
|
have_zip_compression_method_supported = cc.has_function('zip_compression_method_supported', dependencies : dep_zip)
|
|
|
|
endif
|
|
|
|
else
|
|
|
|
have_zip_compression_method_supported = false
|
|
|
|
endif
|
|
|
|
|
|
|
|
config.set('TAISEI_BUILDCONF_HAVE_ZIP_COMPRESSION_METHOD_SUPPORTED', have_zip_compression_method_supported)
|
2021-04-19 01:20:42 +02:00
|
|
|
|
2023-01-08 23:54:01 +01:00
|
|
|
config.set('TAISEI_BUILDCONF_HAVE_ATTR_DESIGNATED_INIT', cc.compiles(
|
|
|
|
'struct { int dummy; } __attribute__((designated_init)) x;',
|
|
|
|
name : '__attribute__((designated_init))',
|
|
|
|
args : ['-Wattributes', '-Werror']
|
|
|
|
))
|
|
|
|
|
|
|
|
config.set('TAISEI_BUILDCONF_HAVE_ATTR_MALLOC_WITH_ARGS', cc.compiles(
|
|
|
|
'void myfree(void *p); void *myalloc() __attribute__((malloc(myfree, 1)));',
|
|
|
|
name : '__attribute__((malloc(deallocator, index)))',
|
|
|
|
args : ['-Wattributes', '-Werror']
|
2023-03-26 01:52:41 +01:00
|
|
|
))
|
|
|
|
|
|
|
|
config.set('TAISEI_BUILDCONF_HAVE_STATIC_ASSERT_WITHOUT_MSG', cc.compiles(
|
|
|
|
'''
|
|
|
|
#include <assert.h>
|
|
|
|
static_assert(1, "with message");
|
|
|
|
static_assert(1);
|
|
|
|
''',
|
|
|
|
name : 'static_assert() without message',
|
|
|
|
args : ['-Werror']
|
2023-01-08 23:54:01 +01:00
|
|
|
))
|
|
|
|
|
2019-02-22 00:56:48 +01:00
|
|
|
prefer_relpath_systems = [
|
|
|
|
'windows',
|
Emscripten compatibility (#161)
* Major refactoring of the main loop(s) and control flow (WIP)
run_at_fps() is gone 🦀
Instead of nested blocking event loops, there is now an eventloop API
that manages an explicit stack of scenes. This makes Taisei a lot more
portable to async environments where spinning a loop forever without
yielding control simply is not an option, and that is the entire point
of this change.
A prime example of such an environment is the Web (via emscripten).
Taisei was able to run there through a terrible hack: inserting
emscripten_sleep calls into the loop, which would yield to the browser.
This has several major drawbacks: first of all, every function that
could possibly call emscripten_sleep must be compiled into a special
kind of bytecode, which then has to be interpreted at runtime, *much*
slower than JITed WebAssembly. And that includes *everything* down the
call stack, too! For more information, see
https://emscripten.org/docs/porting/emterpreter.html
Even though that method worked well enough for experimenting, despite
suboptimal performance, there is another obvious drawback:
emscripten_sleep is implemented via setTimeout(), which can be very
imprecise and is generally not reliable for fluid animation. Browsers
actually have an API specifically for that use case:
window.requestAnimationFrame(), but Taisei's original blocking control
flow style is simply not compatible with it. Emscripten exposes this API
with its emscripten_set_main_loop(), which the eventloop backend now
uses on that platform.
Unfortunately, C is still C, with no fancy closures or coroutines.
With blocking calls into menu/scene loops gone, the control flow is
reimplemented via so-called (pun intended) "call chains". That is
basically an euphemism for callback hell. With manual memory management
and zero type-safety. Not that the menu system wasn't shitty enough
already. I'll just keep telling myself that this is all temporary and
will be replaced with scripts in v1.4.
* improve build system for emscripten + various fixes
* squish menu bugs
* improve emscripten event loop; disable EMULATE_FUNCTION_POINTER_CASTS
Note that stock freetype does not work without
EMULATE_FUNCTION_POINTER_CASTS; use a patched version from the
"emscripten" branch here:
https://github.com/taisei-project/freetype2/tree/emscripten
* Enable -Wcast-function-type
Calling functions through incompatible pointers is nasal demons and
doesn't work in WASM.
* webgl: workaround a crash on some browsers
* emscripten improvements:
* Persist state (config, progress, replays, ...) in local IndexDB
* Simpler HTML shell (temporary)
* Enable more optimizations
* fix build if validate_glsl=false
* emscripten: improve asset packaging, with local cache
Note that even though there are rules to build audio bundles, audio
does *not* work yet. It looks like SDL2_mixer can not work without
threads, which is a problem. Yet another reason to write an OpenAL
backend - emscripten supports that natively.
* emscripten: customize the html shell
* emscripten: force "show log" checkbox unchecked initially
* emscripten: remove quit shortcut from main menu (since there's no quit)
* emscripten: log area fixes
* emscripten/webgl: workaround for fullscreen viewport issue
* emscripten: implement frameskip
* emscripter: improve framerate limiter
* align List to at least 8 bytes (shut up warnings)
* fix non-emscripten builds
* improve fullscreen handling, mainly for emscripten
* Workaround to make audio work in chromium
emscripten-core/emscripten#6511
* emscripten: better vsync handling; enable vsync & disable fxaa by default
2019-03-09 20:32:32 +01:00
|
|
|
]
|
|
|
|
|
|
|
|
force_relpath_systems = [
|
2019-02-22 00:56:48 +01:00
|
|
|
'emscripten',
|
2019-08-02 20:38:33 +02:00
|
|
|
'nx'
|
2019-02-22 00:56:48 +01:00
|
|
|
]
|
2018-05-28 10:10:41 +02:00
|
|
|
|
2022-12-28 23:15:55 +01:00
|
|
|
opt_install_macos_bundle = get_option('install_macos_bundle')
|
|
|
|
opt_install_macos_bundle = opt_install_macos_bundle.require(
|
|
|
|
host_machine.system() == 'darwin',
|
|
|
|
error_message : 'only supported on macOS')
|
2020-02-20 23:36:40 +01:00
|
|
|
|
2022-12-28 23:15:55 +01:00
|
|
|
prefer_relocatable = (
|
|
|
|
host_machine.system() in (prefer_relpath_systems + force_relpath_systems) or
|
|
|
|
opt_install_macos_bundle.allowed())
|
2020-02-20 23:36:40 +01:00
|
|
|
|
2022-12-28 23:15:55 +01:00
|
|
|
opt_install_relocatable = get_option('install_relocatable')
|
|
|
|
opt_install_relocatable = opt_install_relocatable.disable_auto_if(
|
|
|
|
not prefer_relocatable)
|
2020-02-20 23:36:40 +01:00
|
|
|
|
2022-12-28 23:15:55 +01:00
|
|
|
opt_install_macos_bundle = opt_install_macos_bundle.require(
|
|
|
|
opt_install_relocatable.allowed(),
|
|
|
|
error_message : 'install_relocatable is required')
|
2017-11-27 14:27:32 +01:00
|
|
|
|
2022-12-28 23:15:55 +01:00
|
|
|
if host_machine.system() in force_relpath_systems and opt_install_relocatable.disabled()
|
|
|
|
error('install_relocatable must be enabled on this platform')
|
|
|
|
endif
|
2017-11-27 14:27:32 +01:00
|
|
|
|
2022-12-28 23:15:55 +01:00
|
|
|
is_relocatable_install = opt_install_relocatable.allowed()
|
|
|
|
macos_app_bundle = opt_install_macos_bundle.allowed()
|
2017-12-21 05:52:25 +01:00
|
|
|
|
2022-12-28 23:15:55 +01:00
|
|
|
opt_install_freedesktop = (
|
|
|
|
get_option('install_freedesktop')
|
|
|
|
.disable_auto_if(is_relocatable_install or host_machine.system() == 'darwin')
|
|
|
|
.require(not macos_app_bundle,
|
|
|
|
error_message : 'installing freedesktop.org stuff into a macOS bundle makes no sense')
|
|
|
|
)
|
2017-11-12 01:28:30 +01:00
|
|
|
|
2022-12-28 23:15:55 +01:00
|
|
|
install_xdg = opt_install_freedesktop.allowed()
|
|
|
|
|
|
|
|
datadir = get_option('datadir')
|
2017-11-28 14:46:28 +01:00
|
|
|
|
2020-02-20 23:36:40 +01:00
|
|
|
if is_relocatable_install
|
2017-11-27 14:27:32 +01:00
|
|
|
data_path = 'data'
|
2019-02-22 00:56:48 +01:00
|
|
|
doc_path = '.' # Meson bug https://github.com/mesonbuild/meson/issues/4295
|
2017-11-28 14:46:28 +01:00
|
|
|
xdg_path = 'freedesktop.org'
|
2020-02-20 23:36:40 +01:00
|
|
|
lib_path = '.'
|
2017-11-12 01:28:30 +01:00
|
|
|
|
2017-12-21 05:52:25 +01:00
|
|
|
if macos_app_bundle
|
2022-12-28 23:15:55 +01:00
|
|
|
bundle_dir = 'Taisei.app'
|
|
|
|
|
|
|
|
bundle_datadir = join_paths('Contents', 'Resources')
|
|
|
|
bundle_bindir = join_paths('Contents', 'MacOS')
|
|
|
|
bundle_libdir = bundle_bindir
|
|
|
|
|
|
|
|
datadir = join_paths(bundle_dir, bundle_datadir)
|
|
|
|
bindir = join_paths(bundle_dir, bundle_bindir)
|
|
|
|
libdir = join_paths(bundle_dir, bundle_libdir)
|
|
|
|
|
|
|
|
meson.add_install_script(
|
2024-01-24 04:53:47 +01:00
|
|
|
macos_install_dylibs_command,
|
2022-12-28 23:15:55 +01:00
|
|
|
':'.join(meson.get_cross_property('macos_lib_path', [])),
|
|
|
|
':'.join(meson.get_cross_property('macos_tool_path', [])),
|
|
|
|
meson.get_cross_property('macos_tool_prefix', ''),
|
|
|
|
)
|
|
|
|
|
2020-02-20 23:36:40 +01:00
|
|
|
# Relative to SDL_GetBasePath() (bundle root)
|
|
|
|
config.set_quoted('TAISEI_BUILDCONF_DATA_PATH', join_paths(bundle_datadir, data_path))
|
|
|
|
config.set_quoted('TAISEI_BUILDCONF_LIB_PATH', join_paths(bundle_libdir))
|
|
|
|
|
|
|
|
# Make paths prefix-relative for installation
|
|
|
|
data_path = join_paths(datadir, data_path)
|
|
|
|
lib_path = libdir
|
|