project('cell', ['c', 'cpp'], version: '0.9.3', meson_version: '>=1.4', default_options : [ 'cpp_std=c++11', 'default_library=static']) libtype = get_option('default_library') link = [] src = [] add_project_arguments('-Wno-gnu-label-as-value', language: ['c']) git_tag_cmd = run_command('git', 'describe', '--tags', '--abbrev=0', check: false) cell_version = 'unknown' if git_tag_cmd.returncode() == 0 cell_version = git_tag_cmd.stdout().strip() endif git_commit_cmd = run_command('git', 'rev-parse', '--short', 'HEAD', check: false) cell_commit = 'unknown' if git_commit_cmd.returncode() == 0 cell_commit = git_commit_cmd.stdout().strip() endif # Important: pass the definitions without double-escaping quotes add_project_arguments( '-DCELL_VERSION="' + cell_version + '"', '-DCELL_COMMIT="' + cell_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('-Wno-strict-prototypes', language:'c') add_project_arguments('-Wno-unused-command-line-argument', language: 'c') add_project_arguments('-Wno-unused-command-line-argument', language: 'cpp') deps = [] if host_machine.system() == 'darwin' add_project_arguments('-x', 'objective-c', language: 'c') fworks = [ 'foundation', 'metal', 'audiotoolbox', 'metalkit', 'avfoundation', 'quartzcore', 'cocoa', 'coreaudio', 'coremedia', 'gamecontroller', 'forcefeedback', 'iokit', 'corefoundation', 'corehaptics', 'carbon', 'uniformtypeidentifiers' ] foreach fkit : fworks deps += dependency('appleframeworks', modules: fkit) endforeach endif cmake = import('cmake') cc = meson.get_compiler('c') if host_machine.system() == 'linux' deps += cc.find_library('asound', required:true) deps += [dependency('x11'), dependency('xi'), dependency('xcursor'), dependency('egl'), dependency('gl')] endif if host_machine.system() == 'windows' deps += cc.find_library('d3d11') deps += cc.find_library('ws2_32', required:true) deps += cc.find_library('dbghelp') deps += cc.find_library('winmm') deps += cc.find_library('setupapi') deps += cc.find_library('imm32') deps += cc.find_library('version') deps += cc.find_library('cfgmgr32') deps += cc.find_library('bcrypt') link += ['-static', '-static-libgcc', '-static-libstdc++'] add_project_link_arguments('-static-libgcc', '-static-libstdc++', language: ['c', 'cpp']) endif miniz_dep = dependency('miniz', static: true, required: false) if not miniz_dep.found() message('⚙ System miniz not found, building subproject...') deps += dependency('miniz', static:true) else deps += miniz_dep endif deps += dependency('threads') # Try to find system-installed curl first curl_dep = dependency('libcurl', static: true, required: false) if not curl_dep.found() message('⚙ System curl not found, building subproject...') deps += dependency('libcurl', static:true) else deps += curl_dep endif if host_machine.system() != 'emscripten' # Try to find system-installed enet first enet_dep = dependency('enet', static: true, required: false) if not enet_dep.found() message('⚙ System enet not found, building subproject...') deps += dependency('enet', static:true) else deps += enet_dep endif mimalloc_enabled = get_option('mimalloc') if mimalloc_enabled message('⚙ Using mimalloc subproject for static linking...') deps += dependency('mimalloc', static:true) add_project_arguments('-DHAVE_MIMALLOC', language: ['c', 'cpp']) else message('⚙ Mimalloc support disabled') endif tracy_enabled = get_option('tracy') if tracy_enabled message('⚙ Tracy profiling enabled') tracy_opts = ['fibers=true', 'no_exit=true', 'on_demand=true'] add_project_arguments('-DTRACY_ENABLE', language:['c','cpp']) # Try to find system-installed tracy first tracy_dep = dependency('tracy', static: true, required: false) if not tracy_dep.found() message('⚙ System tracy not found, building subproject...') deps += dependency('tracy', static:true, default_options:tracy_opts) else deps += tracy_dep endif else message('⚙ Tracy profiling disabled') endif endif link_args = link sources = [] src += [ # core 'qjs_blob.c', 'monocypher.c', 'cell.c', 'wildmatch.c', 'qjs_actor.c', 'qjs_wota.c', 'scheduler_threaded.c', ] src += ['quickjs.c', 'libregexp.c', 'libunicode.c', 'cutils.c', 'dtoa.c'] scripts = [ 'nota.c', 'js.c', 'qop.c', 'wildstar.c', 'fit.c', 'crypto.c', 'text.c', 'utf8.c', 'kim.c', 'time.c', 'miniz.c', 'nota.c', 'debug.c', 'os.c', 'fd.c', 'socket.c', 'http.c', 'enet.c', 'wildstar.c', ] foreach file: scripts full_path = join_paths('scripts', file) sources += files(full_path) endforeach srceng = 'source' includes = [srceng] foreach file : src full_path = join_paths(srceng, file) sources += files(full_path) endforeach includers = [] foreach inc : includes includers += include_directories(inc) endforeach if host_machine.system() == 'windows' exe_ext = '.exe' link += '-Wl,--export-all-symbols' else exe_ext = '' link += '-Wl,-export_dynamic' endif cell_bin = executable('cell_bin', sources, dependencies: deps, include_directories: includers, link_args: link, build_rpath: '$ORIGIN', install: false ) cell_dep = declare_dependency( link_with: cell_bin ) cell_so = both_libraries( 'cell', sources, include_directories: includers, dependencies: deps, install : true, ) # Create core.zip from scripts folder qop_target = custom_target('core.qop', output: 'core.qop', command: ['sh', '-c', ' qopconv -d ' + meson.project_source_root() / 'scripts . core.qop'], build_by_default: true, build_always_stale: true ) # Create final cell executable by appending core.zip to cell_bin cell = custom_target('cell', input: [cell_bin, qop_target], output: 'cell' + exe_ext, command: [ 'sh', '-c', 'cp "$1" "$3" && cat "$2" >> "$3" && chmod +x "$3"', 'cell-cat', '@INPUT0@', '@INPUT1@', '@OUTPUT@' ], build_by_default: true, install: true, install_dir: get_option('bindir') ) # Install headers for building dynamic libraries using Cell install_headers('source/cell.h') install_headers('source/quickjs.h') install_headers('source/wota.h') tests = [ 'spawn_actor', 'empty', 'nota', 'wota', 'portalspawner', 'overling', 'send', 'delay' ] foreach file : tests test(file, cell, args:['tests/' + file]) endforeach