158 lines
3.3 KiB
Meson
158 lines
3.3 KiB
Meson
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-incompatible-pointer-types',
|
|
'-Wno-missing-braces',
|
|
'-Wno-strict-prototypes',
|
|
'-Wno-unused-function',
|
|
'-Wno-int-conversion',
|
|
language: 'c'
|
|
)
|
|
add_project_arguments('-Wno-narrowing', language: 'cpp')
|
|
|
|
deps = []
|
|
|
|
if host_machine.system() == 'darwin'
|
|
add_project_arguments('-x', 'objective-c', language: 'c')
|
|
fworks = [
|
|
'CoreFoundation',
|
|
'CFNetwork',
|
|
]
|
|
foreach fkit : fworks
|
|
deps += dependency('appleframeworks', modules: fkit)
|
|
endforeach
|
|
endif
|
|
|
|
if host_machine.system() == 'playdate'
|
|
add_project_arguments('-DTARGET_PLAYDATE', language: 'c')
|
|
endif
|
|
|
|
link_args = link
|
|
sources = []
|
|
src += [ # core
|
|
'qjs_blob.c',
|
|
'monocypher.c',
|
|
'cell.c',
|
|
'wildmatch.c',
|
|
'qjs_actor.c',
|
|
'qjs_wota.c',
|
|
'miniz.c',
|
|
'quickjs.c',
|
|
'libregexp.c', 'libunicode.c', 'cutils.c', 'dtoa.c'
|
|
]
|
|
|
|
src += ['scheduler.c']
|
|
|
|
scripts = [
|
|
'nota.c',
|
|
'js.c',
|
|
'qop.c',
|
|
'wildstar.c',
|
|
'fit.c',
|
|
'crypto.c',
|
|
'text.c',
|
|
'utf8.c',
|
|
'kim.c',
|
|
'time.c',
|
|
'nota.c',
|
|
'debug.c',
|
|
'os.c',
|
|
'fd.c',
|
|
'http.c',
|
|
'enet.c',
|
|
'wildstar.c',
|
|
'miniz.c',
|
|
'json.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_so = shared_library(
|
|
'cell_runtime',
|
|
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
|
|
)
|
|
|
|
# Determine RPATH based on OS
|
|
# MacOS uses @loader_path, Linux uses $ORIGIN
|
|
# We include both the current directory (for build) and ../lib (for install)
|
|
rpath_dirs = []
|
|
if host_machine.system() == 'darwin'
|
|
rpath_dirs += ['@loader_path', '@loader_path/../lib']
|
|
elif host_machine.system() == 'linux'
|
|
rpath_dirs += ['$ORIGIN', '$ORIGIN/../lib']
|
|
endif
|
|
|
|
# Create main executable linked against the cell library
|
|
cell_exe = executable('cell_exe',
|
|
'source/main.c',
|
|
dependencies: deps,
|
|
include_directories: includers,
|
|
link_with: cell_so,
|
|
link_args: link,
|
|
build_rpath: ':'.join(rpath_dirs),
|
|
install: false
|
|
)
|
|
|
|
# Create final cell executable by appending core.zip to cell_exe
|
|
cell = custom_target('cell',
|
|
input: [cell_exe, 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')
|