Files
cell/meson.build
2025-02-05 17:16:05 -06:00

193 lines
5.6 KiB
Meson

project('prosperon', ['c', 'cpp'], default_options : [ 'cpp_std=c++11'])
libtype = get_option('default_library')
link = []
src = []
if not get_option('editor')
add_project_arguments('-DNEDITOR', language:'c')
endif
# Grab the nearest tag (e.g., "0.6.1")
git_tag_cmd = run_command('git', 'describe', '--tags', '--abbrev=0', check: false)
prosperon_version = 'unknown'
if git_tag_cmd.returncode() == 0
prosperon_version = git_tag_cmd.stdout().strip()
endif
# Grab short commit hash (e.g., "de1c9a1")
git_commit_cmd = run_command('git', 'rev-parse', '--short', 'HEAD', check: false)
prosperon_commit = 'unknown'
if git_commit_cmd.returncode() == 0
prosperon_commit = git_commit_cmd.stdout().strip()
endif
# Important: pass the definitions without double-escaping quotes
add_project_arguments(
'-DPROSPERON_VERSION="' + prosperon_version + '"',
'-DPROSPERON_COMMIT="' + prosperon_commit + '"',
language : 'c'
)
add_project_arguments('-Wno-incompatible-pointer-types', language: 'c')
add_project_arguments('-Wno-narrowing', language: 'cpp')
add_project_arguments('-Wno-missing-braces', language:'c')
add_project_arguments('-Wl,--disable-new-dtags', language:'cpp')
add_project_arguments('-Wl,--disable-new-dtags', language:'c')
deps = []
if host_machine.system() == 'darwin'
add_project_arguments('-x', 'objective-c', language: 'c')
fworks = ['foundation', 'metal', 'audiotoolbox', 'metalkit', 'avfoundation', 'quartzcore', 'cocoa']
foreach fkit : fworks
deps += dependency('appleframeworks', modules: fkit)
endforeach
endif
cc = meson.get_compiler('c')
deps += dependency('sdl3', required:true)
if host_machine.system() == 'darwin'
deps += dependency('appleframeworks', modules: 'accelerate')
add_project_arguments('-DACCELERATE_NEW_LAPACK=1', language:'c')
add_project_arguments('-DACCELERATE_LAPACK_ILP64=1', language:'c')
endif
if host_machine.system() == 'linux'
deps += cc.find_library('asound', required:true)
deps += [dependency('x11'), dependency('xi'), dependency('xcursor'), dependency('egl'), dependency('gl')]
link += '-fuse-ld=mold' # use mold, which is very fast, for debug builds
endif
if host_machine.system() == 'windows'
deps += cc.find_library('d3d11')
# these are for tracy
deps += cc.find_library('ws2_32', required:true)
deps += cc.find_library('dbghelp')
#end
link += '-static' # Required to pack in mingw dlls on cross compilation
endif
if host_machine.system() == 'emscripten'
link += '-sUSE_WEBGPU'
endif
tracy_opts = ['fibers=true', 'on_demand=true']
quickjs_opts = []
src += 'qjs_tracy.c'
add_project_arguments('-DTRACY_ENABLE', language:['c','cpp'])
deps += dependency('tracy', static:true, default_options:tracy_opts)
quickjs_opts += 'default_library=static'
deps += dependency('quickjs', static:true, default_options:quickjs_opts)
storefront = get_option('storefront')
if storefront == 'steam'
deps += dependency('qjs-steam',static:false)
endif
deps += dependency('qjs-layout',static:true)
deps += dependency('qjs-nota',static:true)
deps += dependency('qjs-miniz')
deps += dependency('qjs-soloud',static:true)
deps += dependency('physfs', static:true)
#deps += dependency('opencv4')
#deps += cc.find_library('opencv')
deps += dependency('threads')
if get_option('chipmunk')
deps += dependency('qjs-chipmunk', static:false)
endif
if get_option('enet')
#deps += dependency('qjs-enet', static:false)
endif
sources = []
src += ['anim.c', 'config.c', 'datastream.c','font.c','gameobject.c','HandmadeMath.c','jsffi.c','model.c','render.c','script.c','simplex.c','spline.c', 'timer.c', 'transform.c','prosperon.c', 'wildmatch.c', 'sprite.c', 'quadtree.c', 'aabb.c', 'rtree.c']
imsrc = ['GraphEditor.cpp','ImCurveEdit.cpp','ImGradient.cpp','imgui_draw.cpp','imgui_tables.cpp','imgui_widgets.cpp','imgui.cpp','ImGuizmo.cpp','imnodes.cpp','implot_items.cpp','implot.cpp', 'imgui_impl_sdlrenderer3.cpp', 'imgui_impl_sdl3.cpp', 'imgui_impl_sdlgpu3.cpp']
srceng = 'source'
tp = srceng / 'thirdparty'
includes = [srceng,tp / 'cgltf',tp / 'imgui',tp / 'par',tp / 'stb',tp,tp / 'pl_mpeg/include']
foreach file : src
full_path = join_paths('source', file)
sources += files(full_path)
endforeach
if get_option('editor')
sources += 'source/qjs_imgui.cpp'
foreach imgui : imsrc
sources += tp / 'imgui' / imgui
endforeach
sub_dmon = subproject('qjs-dmon')
dmon_dep = sub_dmon.get_variable('qjs_dmon_dep')
endif
includers = []
foreach inc : includes
includers += include_directories(inc)
endforeach
zip_folders = ['scripts', 'fonts', 'icons', 'shaders']
zip_paths = []
foreach folder: zip_folders
zip_paths += meson.project_source_root() / folder
endforeach
# Now use the hash file as a dependency so that any change in the files causes a rebuild.
core = custom_target('core.zip',
output : 'core.zip',
command : ['sh', '-c',
'cd ' + meson.project_source_root() +
' && echo "Rebuilding core.zip" && rm -f ' + meson.current_build_dir() + '/core.zip && ' +
'zip -r ' + meson.current_build_dir() + '/core.zip scripts fonts icons shaders'
],
build_always_stale: true,
build_by_default: true
)
prosperon_raw = executable('prosperon_raw', sources,
dependencies: deps,
include_directories: includers,
link_args: link,
build_rpath: '$ORIGIN',
install:false
)
if host_machine.system() == 'windows'
exe_ext = '.exe'
else
exe_ext = ''
endif
prosperon = custom_target('prosperon',
output: 'prosperon' + exe_ext,
input: [prosperon_raw, core],
command: [
'sh', '-c',
'cat "$1" "$2" > "$3"',
'concat',
'@INPUT0@',
'@INPUT1@',
'@OUTPUT@'
],
build_always: true,
build_by_default: true
)
prosperon_dep = declare_dependency(
link_with:prosperon
)
test('sanity', prosperon)