shithub: femtolisp

ref: 1fa5ecb395cf9771300fae5da9e38b69e3aa48a9
dir: /meson.build/

View raw version
project(
	'femtolisp',
	'c',
	version: '0.999',
	meson_version: '>=1.1.0',
	default_options: [
		'c_std=c2x',
		'warning_level=3',
		'buildtype=debugoptimized',
		'b_ndebug=if-release'
		#'b_coverage=true',
	],
)

add_project_arguments(
	#'-Wconversion',
	#'-Wsign-conversion',
	'-Wmissing-prototypes',
	'-Werror=odr',
	'-Werror=strict-aliasing',
	'-Wno-parentheses',
	'-Wno-overlength-strings',
	'-D_DEFAULT_SOURCE',
	'-DCOMPUTED_GOTO',
	language: 'c',
)

utf = [
	'3rd/utf/rune.c',
	'3rd/utf/runeistype.c',
	'3rd/utf/runetotype.c',
	'3rd/utf/utfnlen.c',
]

src = [
	'3rd/mt19937-64.c',
	'3rd/spooky.c',
	'bitvector.c',
	'builtins.c',
	'cvalues.c',
	'equal.c',
	'equalhash.c',
	'flisp.c',
	'flmain.c',
	'hashing.c',
	'htable.c',
	'ios.c',
	'iostream.c',
	'main_posix.c',
	'operators.c',
	'print.c',
	'ptrhash.c',
	'random.c',
	'read.c',
	'string.c',
	'table.c',
	'terminal_posix.c',
	'time_posix.c',
	'types.c',
	'utf8.c',
]

cc = meson.get_compiler('c')

if cc.get_id() == 'clang'
	add_project_arguments(
		'-D__wchar_t=__please_no_wchar_t_thank_you',
		'-Wno-gnu-offsetof-extensions',
		language: 'c',
	)
else
	add_project_arguments(
		'-Werror=lto-type-mismatch',
		language: 'c',
	)
endif

sixel = get_option('sixel')
libsixel_dep = []
if sixel.disabled()
	src += ['sixel_disabled.c']
else
	libsixel = dependency('libsixel', required: sixel)
	if libsixel.found()
		src += ['sixel.c']
		libsixel_dep = [libsixel]
	else
		src += ['sixel_disabled.c']
	endif
endif

math = cc.find_library('m', required: false)

boot = custom_target(
	'boot',
	capture: true,
	input: [
		'flisp.boot',
	],
	output: [
		'flisp.boot.h',
	],
	command: [
		'boot2h.sh', '@INPUT@',
	],
)

builtins = custom_target(
	'builtins',
	capture: true,
	input: [
		src,
	],
	output: [
		'builtin_fns.h',
	],
	command: [
		'builtins2h.sh', '@INPUT@',
	],
)

mp = static_library(
	'mp',
	[
		'3rd/mp/mpadd.c',
		'3rd/mp/mpaux.c',
		'3rd/mp/mpcmp.c',
		'3rd/mp/mpdigdiv.c',
		'3rd/mp/mpdiv.c',
		'3rd/mp/mpexp.c',
		'3rd/mp/mpextendedgcd.c',
		'3rd/mp/mpfmt.c',
		'3rd/mp/mpinvert.c',
		'3rd/mp/mpleft.c',
		'3rd/mp/mplogic.c',
		'3rd/mp/mpmod.c',
		'3rd/mp/mpmodop.c',
		'3rd/mp/mpmul.c',
		'3rd/mp/mprand.c',
		'3rd/mp/mpright.c',
		'3rd/mp/mpsub.c',
		'3rd/mp/mptobe.c',
		'3rd/mp/mptober.c',
		'3rd/mp/mptod.c',
		'3rd/mp/mptoi.c',
		'3rd/mp/mptoui.c',
		'3rd/mp/mptouv.c',
		'3rd/mp/mptov.c',
		'3rd/mp/mpvecadd.c',
		'3rd/mp/mpveccmp.c',
		'3rd/mp/mpvecdigmuladd.c',
		'3rd/mp/mpvecsub.c',
		'3rd/mp/mpvectscmp.c',
		'3rd/mp/strtomp.c',
		'3rd/mp/u16.c',
	],
	include_directories: include_directories(
		'3rd/mp',
		'posix',
	),
)

flisp = executable(
	'flisp',
	sources: [
		src,
		utf,
		boot,
		builtins,
	],
	dependencies: [
		math,
	] + libsixel_dep,
	include_directories: include_directories(
		'3rd',
		'3rd/mp',
		'3rd/utf',
		'posix',
	),
	link_with: [
		mp,
	],
)

mptest = executable(
	'mptest',
	sources: [
		'3rd/mp/test.c',
	],
	include_directories: include_directories(
		'posix',
	),
	link_with: [
		mp,
	],
)
test('mp', mptest)

mptest2 = executable(
	'mptest2',
	sources: [
		'3rd/mp/test/convtest.c',
		'3rd/mp/test/gen.tab.c',
		'3rd/mp/test/ld.c',
		'3rd/mp/test/main.c',
	],
	include_directories: include_directories(
		'3rd/mp/test',
		'posix',
	),
	link_with: [
		mp,
	],
)
test('mp2', mptest2, timeout: -1)

tests_dir = join_paths(meson.current_source_dir(), 'test')

test('argv.lsp', flisp, args: ['argv.lsp'], workdir: tests_dir)
test('hash.lsp', flisp, args: ['hashtest.lsp'], workdir: tests_dir)
test('mp.lsp', flisp, args: ['mp.lsp'], workdir: tests_dir)
test('perf.lsp', flisp, args: ['perf.lsp'], workdir: tests_dir, timeout: -1)
test('tme.lsp', flisp, args: ['tme.lsp'], workdir: tests_dir)
test('torture.lsp', flisp, args: ['torture.scm'], workdir: tests_dir, timeout: -1)
test('torus.lsp', flisp, args: ['torus.lsp'], workdir: tests_dir)
test('unit.lsp', flisp, args: ['unittest.lsp'], workdir: tests_dir)