2023-01-07 21:04:16 +00:00
|
|
|
# Copyright (c) 2023 Calvin Rose and contributors
|
2019-03-22 22:07:10 +00:00
|
|
|
#
|
|
|
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
# of this software and associated documentation files (the "Software"), to
|
|
|
|
# deal in the Software without restriction, including without limitation the
|
|
|
|
# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
|
|
|
# sell copies of the Software, and to permit persons to whom the Software is
|
|
|
|
# furnished to do so, subject to the following conditions:
|
|
|
|
#
|
|
|
|
# The above copyright notice and this permission notice shall be included in
|
|
|
|
# all copies or substantial portions of the Software.
|
|
|
|
#
|
|
|
|
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
|
|
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
|
|
|
# IN THE SOFTWARE.
|
|
|
|
|
2019-06-20 20:33:28 +00:00
|
|
|
project('janet', 'c',
|
2021-03-10 06:57:53 +00:00
|
|
|
default_options : ['c_std=c99', 'build.c_std=c99', 'b_lundef=false', 'default_library=both'],
|
2023-10-15 19:33:43 +00:00
|
|
|
version : '1.32.1')
|
2019-03-22 22:07:10 +00:00
|
|
|
|
2019-03-23 17:50:50 +00:00
|
|
|
# Global settings
|
|
|
|
janet_path = join_paths(get_option('prefix'), get_option('libdir'), 'janet')
|
2019-05-15 14:49:16 +00:00
|
|
|
header_path = join_paths(get_option('prefix'), get_option('includedir'), 'janet')
|
2019-03-23 17:50:50 +00:00
|
|
|
|
2019-03-22 22:07:10 +00:00
|
|
|
# Link math library on all systems
|
|
|
|
cc = meson.get_compiler('c')
|
|
|
|
m_dep = cc.find_library('m', required : false)
|
|
|
|
dl_dep = cc.find_library('dl', required : false)
|
2021-10-16 02:39:03 +00:00
|
|
|
android_spawn_dep = cc.find_library('android-spawn', required : false)
|
2019-11-27 20:52:20 +00:00
|
|
|
thread_dep = dependency('threads')
|
2019-03-22 22:07:10 +00:00
|
|
|
|
2019-06-20 20:33:28 +00:00
|
|
|
# Link options
|
2021-03-12 07:46:05 +00:00
|
|
|
if get_option('default_library') != 'static' and build_machine.system() != 'windows'
|
2019-06-20 21:28:22 +00:00
|
|
|
add_project_link_arguments('-rdynamic', language : 'c')
|
|
|
|
endif
|
2019-03-22 22:07:10 +00:00
|
|
|
|
2019-06-20 20:33:28 +00:00
|
|
|
# Generate custom janetconf.h
|
|
|
|
conf = configuration_data()
|
|
|
|
version_parts = meson.project_version().split('.')
|
|
|
|
last_parts = version_parts[2].split('-')
|
|
|
|
if last_parts.length() > 1
|
|
|
|
conf.set_quoted('JANET_VERSION_EXTRA', '-' + last_parts[1])
|
|
|
|
else
|
|
|
|
conf.set_quoted('JANET_VERSION_EXTRA', '')
|
|
|
|
endif
|
|
|
|
conf.set('JANET_VERSION_MAJOR', version_parts[0].to_int())
|
|
|
|
conf.set('JANET_VERSION_MINOR', version_parts[1].to_int())
|
|
|
|
conf.set('JANET_VERSION_PATCH', last_parts[0].to_int())
|
|
|
|
conf.set_quoted('JANET_VERSION', meson.project_version())
|
|
|
|
# Use options
|
2019-06-20 21:28:22 +00:00
|
|
|
conf.set_quoted('JANET_BUILD', get_option('git_hash'))
|
2019-06-20 20:33:28 +00:00
|
|
|
conf.set('JANET_NO_NANBOX', not get_option('nanbox'))
|
2019-10-06 01:35:11 +00:00
|
|
|
conf.set('JANET_SINGLE_THREADED', get_option('single_threaded'))
|
2019-06-20 20:33:28 +00:00
|
|
|
conf.set('JANET_NO_DYNAMIC_MODULES', not get_option('dynamic_modules'))
|
|
|
|
conf.set('JANET_NO_DOCSTRINGS', not get_option('docstrings'))
|
|
|
|
conf.set('JANET_NO_SOURCEMAPS', not get_option('sourcemaps'))
|
|
|
|
conf.set('JANET_NO_ASSEMBLER', not get_option('assembler'))
|
|
|
|
conf.set('JANET_NO_PEG', not get_option('peg'))
|
2020-02-02 02:39:54 +00:00
|
|
|
conf.set('JANET_NO_NET', not get_option('net'))
|
2023-11-02 13:51:42 +00:00
|
|
|
conf.set('JANET_NO_IPV6', not get_option('ipv6'))
|
2021-03-18 08:00:23 +00:00
|
|
|
conf.set('JANET_NO_EV', not get_option('ev') or get_option('single_threaded'))
|
2019-06-24 13:40:19 +00:00
|
|
|
conf.set('JANET_REDUCED_OS', get_option('reduced_os'))
|
2019-06-20 20:33:28 +00:00
|
|
|
conf.set('JANET_NO_INT_TYPES', not get_option('int_types'))
|
2020-07-25 18:34:40 +00:00
|
|
|
conf.set('JANET_PRF', get_option('prf'))
|
2019-06-20 20:33:28 +00:00
|
|
|
conf.set('JANET_RECURSION_GUARD', get_option('recursion_guard'))
|
|
|
|
conf.set('JANET_MAX_PROTO_DEPTH', get_option('max_proto_depth'))
|
|
|
|
conf.set('JANET_MAX_MACRO_EXPAND', get_option('max_macro_expand'))
|
|
|
|
conf.set('JANET_STACK_MAX', get_option('stack_max'))
|
2020-05-12 14:04:38 +00:00
|
|
|
conf.set('JANET_NO_UMASK', not get_option('umask'))
|
|
|
|
conf.set('JANET_NO_REALPATH', not get_option('realpath'))
|
|
|
|
conf.set('JANET_NO_PROCESSES', not get_option('processes'))
|
2020-09-07 20:28:46 +00:00
|
|
|
conf.set('JANET_SIMPLE_GETLINE', get_option('simple_getline'))
|
2021-07-22 02:46:26 +00:00
|
|
|
conf.set('JANET_EV_NO_EPOLL', not get_option('epoll'))
|
2021-09-03 20:48:31 +00:00
|
|
|
conf.set('JANET_EV_NO_KQUEUE', not get_option('kqueue'))
|
2021-07-24 20:14:37 +00:00
|
|
|
conf.set('JANET_NO_INTERPRETER_INTERRUPT', not get_option('interpreter_interrupt'))
|
2022-06-06 23:54:17 +00:00
|
|
|
conf.set('JANET_NO_FFI', not get_option('ffi'))
|
2022-12-03 17:26:23 +00:00
|
|
|
conf.set('JANET_NO_FFI_JIT', not get_option('ffi_jit'))
|
2023-11-02 13:51:42 +00:00
|
|
|
conf.set('JANET_NO_CRYPTORAND', not get_option('cryptorand'))
|
2019-08-18 15:00:04 +00:00
|
|
|
if get_option('os_name') != ''
|
|
|
|
conf.set('JANET_OS_NAME', get_option('os_name'))
|
|
|
|
endif
|
|
|
|
if get_option('arch_name') != ''
|
|
|
|
conf.set('JANET_ARCH_NAME', get_option('arch_name'))
|
|
|
|
endif
|
2019-06-20 20:33:28 +00:00
|
|
|
jconf = configure_file(output : 'janetconf.h',
|
|
|
|
configuration : conf)
|
|
|
|
|
2019-03-22 22:07:10 +00:00
|
|
|
# Include directories
|
2019-06-20 20:33:28 +00:00
|
|
|
incdir = include_directories(['src/include', '.'])
|
2019-03-22 22:07:10 +00:00
|
|
|
|
2019-03-23 17:50:50 +00:00
|
|
|
# Order is important here, as some headers
|
|
|
|
# depend on other headers for the amalg target
|
|
|
|
core_headers = [
|
2019-12-31 00:06:15 +00:00
|
|
|
'src/core/features.h',
|
2019-03-23 17:50:50 +00:00
|
|
|
'src/core/util.h',
|
|
|
|
'src/core/state.h',
|
|
|
|
'src/core/gc.h',
|
|
|
|
'src/core/vector.h',
|
|
|
|
'src/core/fiber.h',
|
|
|
|
'src/core/regalloc.h',
|
|
|
|
'src/core/compile.h',
|
|
|
|
'src/core/emit.h',
|
|
|
|
'src/core/symcache.h'
|
|
|
|
]
|
|
|
|
|
2019-03-22 22:07:10 +00:00
|
|
|
core_src = [
|
|
|
|
'src/core/abstract.c',
|
|
|
|
'src/core/array.c',
|
|
|
|
'src/core/asm.c',
|
|
|
|
'src/core/buffer.c',
|
|
|
|
'src/core/bytecode.c',
|
|
|
|
'src/core/capi.c',
|
|
|
|
'src/core/cfuns.c',
|
|
|
|
'src/core/compile.c',
|
|
|
|
'src/core/corelib.c',
|
|
|
|
'src/core/debug.c',
|
|
|
|
'src/core/emit.c',
|
2020-05-28 15:39:40 +00:00
|
|
|
'src/core/ev.c',
|
2022-06-06 23:54:17 +00:00
|
|
|
'src/core/ffi.c',
|
2019-03-22 22:07:10 +00:00
|
|
|
'src/core/fiber.c',
|
|
|
|
'src/core/gc.c',
|
|
|
|
'src/core/inttypes.c',
|
|
|
|
'src/core/io.c',
|
|
|
|
'src/core/marsh.c',
|
|
|
|
'src/core/math.c',
|
2020-02-02 02:39:54 +00:00
|
|
|
'src/core/net.c',
|
2019-03-22 22:07:10 +00:00
|
|
|
'src/core/os.c',
|
|
|
|
'src/core/parse.c',
|
|
|
|
'src/core/peg.c',
|
|
|
|
'src/core/pp.c',
|
|
|
|
'src/core/regalloc.c',
|
|
|
|
'src/core/run.c',
|
|
|
|
'src/core/specials.c',
|
2021-07-17 01:59:03 +00:00
|
|
|
'src/core/state.c',
|
2019-03-22 22:07:10 +00:00
|
|
|
'src/core/string.c',
|
|
|
|
'src/core/strtod.c',
|
|
|
|
'src/core/struct.c',
|
|
|
|
'src/core/symcache.c',
|
|
|
|
'src/core/table.c',
|
|
|
|
'src/core/tuple.c',
|
|
|
|
'src/core/util.c',
|
|
|
|
'src/core/value.c',
|
|
|
|
'src/core/vector.c',
|
|
|
|
'src/core/vm.c',
|
|
|
|
'src/core/wrap.c'
|
|
|
|
]
|
|
|
|
|
|
|
|
boot_src = [
|
|
|
|
'src/boot/array_test.c',
|
|
|
|
'src/boot/boot.c',
|
|
|
|
'src/boot/buffer_test.c',
|
|
|
|
'src/boot/number_test.c',
|
|
|
|
'src/boot/system_test.c',
|
|
|
|
'src/boot/table_test.c',
|
|
|
|
]
|
|
|
|
|
|
|
|
mainclient_src = [
|
2020-01-29 05:38:52 +00:00
|
|
|
'src/mainclient/shell.c'
|
2019-03-22 22:07:10 +00:00
|
|
|
]
|
|
|
|
|
|
|
|
# Build boot binary
|
2020-01-29 05:38:52 +00:00
|
|
|
janet_boot = executable('janet-boot', core_src, boot_src,
|
2019-03-23 19:02:59 +00:00
|
|
|
include_directories : incdir,
|
2019-03-22 22:07:10 +00:00
|
|
|
c_args : '-DJANET_BOOTSTRAP',
|
2021-10-16 02:39:03 +00:00
|
|
|
dependencies : [m_dep, dl_dep, thread_dep, android_spawn_dep],
|
2019-06-02 21:05:17 +00:00
|
|
|
native : true)
|
2019-03-22 22:07:10 +00:00
|
|
|
|
2020-01-29 05:38:52 +00:00
|
|
|
# Build janet.c
|
|
|
|
janetc = custom_target('janetc',
|
2023-09-23 21:16:13 +00:00
|
|
|
input : [janet_boot, 'src/boot/boot.janet'],
|
2020-01-29 05:38:52 +00:00
|
|
|
output : 'janet.c',
|
|
|
|
capture : true,
|
|
|
|
command : [
|
2020-03-18 23:36:41 +00:00
|
|
|
janet_boot, meson.current_source_dir(),
|
2021-08-29 15:43:58 +00:00
|
|
|
'JANET_PATH', janet_path
|
2020-01-29 05:38:52 +00:00
|
|
|
])
|
2019-03-22 22:07:10 +00:00
|
|
|
|
2021-10-16 02:39:03 +00:00
|
|
|
janet_dependencies = [m_dep, dl_dep, android_spawn_dep]
|
2021-03-18 08:00:23 +00:00
|
|
|
if not get_option('single_threaded')
|
|
|
|
janet_dependencies += thread_dep
|
|
|
|
endif
|
|
|
|
|
2023-11-02 13:51:42 +00:00
|
|
|
# Allow building with no shared library
|
2023-09-23 15:50:44 +00:00
|
|
|
if cc.has_argument('-fvisibility=hidden')
|
|
|
|
lib_cflags = ['-fvisibility=hidden']
|
|
|
|
else
|
|
|
|
lib_cflags = []
|
|
|
|
endif
|
2023-11-02 13:51:42 +00:00
|
|
|
if get_option('shared')
|
|
|
|
libjanet = library('janet', janetc,
|
|
|
|
include_directories : incdir,
|
|
|
|
dependencies : janet_dependencies,
|
|
|
|
version: meson.project_version(),
|
|
|
|
soversion: version_parts[0] + '.' + version_parts[1],
|
|
|
|
c_args : lib_cflags,
|
|
|
|
install : true)
|
2019-10-05 15:38:58 +00:00
|
|
|
# Extra c flags - adding -fvisibility=hidden matches the Makefile and
|
|
|
|
# shaves off about 10k on linux x64, likely similar on other platforms.
|
2023-11-02 13:51:42 +00:00
|
|
|
if cc.has_argument('-fvisibility=hidden')
|
|
|
|
extra_cflags = ['-fvisibility=hidden', '-DJANET_DLL_IMPORT']
|
|
|
|
else
|
|
|
|
extra_cflags = ['-DJANET_DLL_IMPORT']
|
|
|
|
endif
|
|
|
|
janet_mainclient = executable('janet', mainclient_src,
|
|
|
|
include_directories : incdir,
|
|
|
|
dependencies : janet_dependencies,
|
|
|
|
link_with: [libjanet],
|
|
|
|
c_args : extra_cflags,
|
|
|
|
install : true)
|
2019-10-05 15:38:58 +00:00
|
|
|
else
|
2023-11-02 13:51:42 +00:00
|
|
|
# No shared library
|
|
|
|
janet_mainclient = executable('janet', mainclient_src, janetc,
|
|
|
|
include_directories : incdir,
|
|
|
|
dependencies : janet_dependencies,
|
|
|
|
c_args : lib_cflags,
|
|
|
|
install : true)
|
2019-10-05 15:38:58 +00:00
|
|
|
endif
|
2019-03-22 22:07:10 +00:00
|
|
|
|
2019-06-02 21:05:17 +00:00
|
|
|
if meson.is_cross_build()
|
2020-08-07 01:44:14 +00:00
|
|
|
native_cc = meson.get_compiler('c', native: true)
|
|
|
|
if native_cc.has_argument('-fvisibility=hidden')
|
|
|
|
extra_native_cflags = ['-fvisibility=hidden']
|
|
|
|
else
|
|
|
|
extra_native_cflags = []
|
|
|
|
endif
|
2020-01-29 05:38:52 +00:00
|
|
|
janet_nativeclient = executable('janet-native', janetc, mainclient_src,
|
2019-06-02 21:05:17 +00:00
|
|
|
include_directories : incdir,
|
2021-03-18 08:00:23 +00:00
|
|
|
dependencies : janet_dependencies,
|
2020-08-07 01:44:14 +00:00
|
|
|
c_args : extra_native_cflags,
|
2019-06-02 21:05:17 +00:00
|
|
|
native : true)
|
|
|
|
else
|
|
|
|
janet_nativeclient = janet_mainclient
|
|
|
|
endif
|
|
|
|
|
2019-03-23 17:50:50 +00:00
|
|
|
# Documentation
|
|
|
|
docs = custom_target('docs',
|
|
|
|
input : ['tools/gendoc.janet'],
|
|
|
|
output : ['doc.html'],
|
|
|
|
capture : true,
|
2019-06-02 21:05:17 +00:00
|
|
|
command : [janet_nativeclient, '@INPUT@'])
|
2019-03-23 17:50:50 +00:00
|
|
|
|
2019-03-22 22:07:10 +00:00
|
|
|
# Tests
|
|
|
|
test_files = [
|
2023-06-03 18:55:49 +00:00
|
|
|
'test/suite-array.janet',
|
|
|
|
'test/suite-asm.janet',
|
|
|
|
'test/suite-boot.janet',
|
|
|
|
'test/suite-buffer.janet',
|
|
|
|
'test/suite-capi.janet',
|
|
|
|
'test/suite-cfuns.janet',
|
|
|
|
'test/suite-compile.janet',
|
|
|
|
'test/suite-corelib.janet',
|
|
|
|
'test/suite-debug.janet',
|
|
|
|
'test/suite-ev.janet',
|
|
|
|
'test/suite-ffi.janet',
|
|
|
|
'test/suite-inttypes.janet',
|
|
|
|
'test/suite-io.janet',
|
|
|
|
'test/suite-marsh.janet',
|
|
|
|
'test/suite-math.janet',
|
|
|
|
'test/suite-os.janet',
|
|
|
|
'test/suite-parse.janet',
|
|
|
|
'test/suite-peg.janet',
|
|
|
|
'test/suite-pp.janet',
|
|
|
|
'test/suite-specials.janet',
|
|
|
|
'test/suite-string.janet',
|
|
|
|
'test/suite-strtod.janet',
|
|
|
|
'test/suite-struct.janet',
|
|
|
|
'test/suite-symcache.janet',
|
|
|
|
'test/suite-table.janet',
|
|
|
|
'test/suite-unknown.janet',
|
|
|
|
'test/suite-value.janet',
|
|
|
|
'test/suite-vm.janet'
|
2019-03-22 22:07:10 +00:00
|
|
|
]
|
|
|
|
foreach t : test_files
|
2019-06-02 21:05:17 +00:00
|
|
|
test(t, janet_nativeclient, args : files([t]), workdir : meson.current_source_dir())
|
2019-03-22 22:07:10 +00:00
|
|
|
endforeach
|
|
|
|
|
|
|
|
# Repl
|
2019-06-02 21:05:17 +00:00
|
|
|
run_target('repl', command : [janet_nativeclient])
|
2019-03-22 22:07:10 +00:00
|
|
|
|
2019-06-08 02:42:09 +00:00
|
|
|
# For use as meson subproject (wrap)
|
2023-11-02 13:51:42 +00:00
|
|
|
if get_option('shared')
|
|
|
|
janet_dep = declare_dependency(include_directories : incdir,
|
|
|
|
link_with : libjanet)
|
2020-03-04 13:35:57 +00:00
|
|
|
# pkgconfig
|
2023-11-02 13:51:42 +00:00
|
|
|
pkg = import('pkgconfig')
|
|
|
|
pkg.generate(libjanet,
|
|
|
|
subdirs: 'janet',
|
|
|
|
description: 'Library for the Janet programming language.')
|
|
|
|
endif
|
2020-03-04 13:35:57 +00:00
|
|
|
|
2019-03-22 22:07:10 +00:00
|
|
|
# Installation
|
|
|
|
install_man('janet.1')
|
2020-01-05 15:26:21 +00:00
|
|
|
install_data(sources : ['tools/.keep'], install_dir : join_paths(get_option('libdir'), 'janet'))
|
2020-11-17 15:48:31 +00:00
|
|
|
patched_janet = custom_target('patched-janeth',
|
|
|
|
input : ['tools/patch-header.janet', 'src/include/janet.h', jconf],
|
|
|
|
install : true,
|
|
|
|
install_dir : join_paths(get_option('includedir'), 'janet'),
|
|
|
|
build_by_default : true,
|
2023-09-23 21:16:13 +00:00
|
|
|
output : ['janet_' + meson.project_version() + '.h'],
|
2020-11-17 15:48:31 +00:00
|
|
|
command : [janet_nativeclient, '@INPUT@', '@OUTPUT@'])
|
2022-04-23 03:29:12 +00:00
|
|
|
|
|
|
|
# Create a version of the janet.h header that matches what jpm often expects
|
2022-05-14 15:26:46 +00:00
|
|
|
if meson.version().version_compare('>=0.61')
|
2023-09-29 01:32:14 +00:00
|
|
|
install_symlink('janet.h', pointing_to: 'janet/janet_' + meson.project_version() + '.h', install_dir: get_option('includedir'))
|
2023-09-27 05:19:35 +00:00
|
|
|
install_symlink('janet.h', pointing_to: 'janet_' + meson.project_version() + '.h', install_dir: join_paths(get_option('includedir'), 'janet'))
|
2022-05-14 15:26:46 +00:00
|
|
|
endif
|
|
|
|
|