Mirai's Miscellaneous Misadventures
M47 / meson.build
# license: AGPLv3 or later
# copyright 2023 zamfofex
project('mimimi', 'c', default_options: ['c_std=c89', 'warning_level=3'])
sources = [
'core/sprites.c',
'core/controls.c',
'core/cameras.c',
'core/animations.c',
'core/displays.c',
'core/font.c',
'core/text.c',
'core/collisions.c',
'core/video.c',
'core/effects.c',
'core/ground.c',
'core/dialogues.c',
'core/math.c',
'core/mechanics.c',
'models/all.c',
]
possible_engines = ['fbdev', 'minifb', 'sdl2']
if host_machine.cpu() == 'wasm32'
possible_engines = ['wasm']
endif
# note: 'loader' must come last
chapter_names = ['test', 'chapter-I', 'loader']
engine_names = get_option('engines')
foreach engine_name : engine_names
if engine_name not in possible_engines
error('engine ' + engine_name + ' is not allowed for the host machine')
endif
endforeach
c_args_dict = {
'fbdev': [
'-D_XOPEN_SOURCE=500',
],
}
link_args_dict = {
'wasm': [
'-Wl,--stack-first,-z,stack-size=0x100000',
'-Wl,--export=__heap_base,--export=main',
'-Wl,--export-table,--growable-table',
'-Wl,--export=mimimi_wasm_texture',
'-Wl,--export=mimimi_wasm_invalidate',
'-Wl,--export=mimimi_wasm_stamp',
],
}
cc = meson.get_compiler('c')
install_headers('include/mimimi.h')
mimimi = library('mimimi', sources,
include_directories: 'include',
install: true,
)
chapters = []
foreach engine_name : engine_names
c_args = c_args_dict.get(engine_name, [])
link_args = link_args_dict.get(engine_name, [])
dependencies = []
if engine_name == 'minifb'
dependencies = [cc.find_library('minifb', has_headers: 'MiniFB.h'), dependency('x11'), dependency('gl'), dependency('xkbcommon')]
endif
if engine_name == 'sdl2'
dependencies = dependency('sdl2')
endif
engine = library('mimimi-' + engine_name, 'engines' / (engine_name + '.c'),
include_directories: 'include',
c_args: c_args,
install: true,
dependencies: dependencies,
)
if engine_name == 'wasm'
install_data('index.html', install_tag: 'runtime')
endif
foreach chapter_name : chapter_names
name = 'mimimi-' + chapter_name + '-' + engine_name
name_suffix = []
if engine_name == 'wasm'
name_suffix = 'wasm'
name = 'mimimi-' + chapter_name
install_symlink(name + '.wasm',
install_dir: get_option('prefix') / get_option('datadir') / 'mimimi',
pointing_to: get_option('prefix') / get_option('bindir') / (name + '.wasm'),
install_tag: 'runtime',
)
endif
chapter = static_library(name, 'chapters' / chapter_name / 'setup.c',
include_directories: 'include',
link_args: link_args,
install: true,
)
chapter_libraries = []
if chapter_name == 'loader'
chapter_libraries = chapters
else
chapters += chapter
endif
executable(name, 'chapters/main.c',
include_directories: 'include',
c_args: c_args + [
'-DMIMIMI_ENGINE=mimimi_' + engine_name,
'-DMIMIMI_CHAPTER=mimimi_' + chapter_name.replace('-', '_'),
'-DMIMIMI_TICK=mimimi_' + chapter_name.replace('-', '_') + '_tick',
],
link_args: link_args,
link_with: [mimimi, engine, chapter] + chapter_libraries,
name_suffix: name_suffix,
install: true,
dependencies: dependencies,
)
endforeach
endforeach