ref: 75fa6d220de69bdb91954ea8cf942611b25214cb
dir: /meson.build/
project( 'femtolisp', 'c', version: '0.999', meson_version: '>=1.1.0', default_options: [ 'warning_level=3', 'buildtype=debugoptimized', 'b_ndebug=if-release' ], ) add_project_arguments( #'-Wcast-align=strict', #'-Wconversion', #'-Wfloat-equal', #'-Wsign-conversion', '-Waggregate-return', '-Werror=odr', '-Werror=strict-aliasing', '-Wformat=2', '-Wint-to-pointer-cast', '-Wmissing-noreturn', '-Wmissing-prototypes', '-Wpointer-arith', '-Wpointer-to-int-cast', '-Wredundant-decls', '-Wsequence-point', '-Wshadow', '-Wstrict-prototypes', '-Wundef', '-Wunused-but-set-parameter', '-Wunused-parameter', '-Wwrite-strings', '-D_DEFAULT_SOURCE', '-DCOMPUTED_GOTO', '-DBLZ_NO_LUT=1', language: 'c', ) src_flisp = [ '3rd/fn.c', '3rd/iswprint.c', '3rd/mt19937-64.c', '3rd/spooky.c', '3rd/tbl.c', '3rd/wcwidth.c', 'src/bitvector.c', 'src/builtins.c', 'src/compress.c', 'src/cvalues.c', 'src/equal.c', 'src/equalhash.c', 'src/flisp.c', 'src/flmain.c', 'src/hashing.c', 'src/htable.c', 'src/ios.c', 'src/iostream.c', 'src/math.c', 'src/opcodes.c', 'src/operators.c', 'src/print.c', 'src/ptrhash.c', 'src/random.c', 'src/read.c', 'src/string.c', 'src/table.c', 'src/types.c', 'src/utf8.c', ] cc = meson.get_compiler('c') if cc.get_id() == 'clang' add_project_arguments( '-D__wchar_t=__please_no_wchar_t_thank_you', '-Wunused-const-variable', language: 'c', ) else add_project_arguments( '-Werror=lto-type-mismatch', '-Wformat-truncation=2', '-Wlogical-op', '-Wsuggest-attribute=const', '-Wsuggest-attribute=noreturn', '-Wsuggest-attribute=pure', '-Wunused-const-variable=2', language: 'c', ) endif src_common = [ 'src/nan.c', ] inc = [include_directories('src', '3rd', '3rd/mp', '3rd/utf', '3rd/brieflz')] extras = [] sys = host_machine.system() cpu = host_machine.cpu() if sys == 'macos' platform = sys flisp_exe_name = 'flisp.code.bin' add_languages( 'cpp', native: false, required: true, ) cpp = meson.get_compiler('cpp') if cpu == 'm68k' add_project_arguments( # don't expect NewPtr-returned pointers to be aligned by 8 bytes # hence just use dlmalloc, which is also a much faster way to go about it '-DUSE_DLMALLOC', language: 'c', ) src_common += [ 'src/mem.c', ] endif extras += [ cpp.find_library('RetroConsole', required: true), cpp.find_library('retrocrt', required: true), ] elif sys == 'dos' platform = sys flisp_exe_name = 'flisp.exe' else platform = 'posix' flisp_exe_name = 'flisp' endif inc += [include_directories('src'/platform)] src_flisp += ['src'/platform/'sys.c'] common = static_library( 'common', sources: src_common, include_directories: inc, pic: false, prelink: false, ) math = cc.find_library('m', required: false) boot = custom_target( 'boot', capture: true, input: [ 'boot/flisp.boot.builtin', ], output: [ 'flisp.boot.h', ], command: [ 'tools/boot2h.sh', '@INPUT@', ], ) builtins = custom_target( 'builtins', capture: true, input: [ src_flisp, ], output: [ 'builtin_fns.h', ], command: [ 'tools/builtins2h.sh', '@INPUT@', ], ) ops = custom_target( 'ops', capture: true, input: [ 'src/vm.inc', ], output: [ 'vm_goto.inc', ], command: [ 'tools/ops2h.sh', '@INPUT@', ], ) brieflz = static_library( 'brieflz', sources: [ '3rd/brieflz/brieflz.c', '3rd/brieflz/depacks.c', ], include_directories: inc, pic: false, prelink: false, ) mp = static_library( 'mp', sources: [ '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: inc, pic: false, prelink: false, ) utf = static_library( 'utf', sources: [ '3rd/utf/rune.c', '3rd/utf/runeistype.c', '3rd/utf/runetotype.c', '3rd/utf/utfnlen.c', ], include_directories: inc, pic: false, prelink: false, ) flisp = executable( flisp_exe_name, sources: [ src_flisp, boot, builtins, ops, ], dependencies: [ math, ] + extras, include_directories: inc, link_with: [ brieflz, common, mp, utf, ], pie: false, ) if platform == 'macos' fs = import('fs') makepef = find_program( 'MakePEF', native: false, required: true, ) rez = find_program( 'Rez', native: false, required: true, ) rincludes = fs.parent(fs.parent(rez.full_path()))/'RIncludes' if cpu == 'm68k' template = 'femtolispm68k.r' rez_data = '--copy' rezflags = [] flisp_code = flisp else assert(cpu == 'ppc', 'unexpected cpu setting') template = 'femtolispppc.r' rez_data = '--data' rezflags = ['-DTARGET_API_MAC_CARBON=0'] flisp_code = custom_target( 'flisp.pef', input: [ flisp ], output: [ 'flisp.pef', ], command: [ makepef, '@INPUT@', '-o', '@OUTPUT@', ], ) endif template = meson.global_source_root()/'src/macos'/template flisp_bin = custom_target( 'flisp.bin', input: [ flisp_code, template, ], output: [ 'flisp.bin', 'flisp.dsk', ], command: [ rez, '-I' + rincludes, ] + rezflags + [ template, '-DCFRAG_NAME="flisp"', '-o', 'flisp.bin', '-t', 'APPL', '-c', '????', rez_data, flisp_code, '--cc', 'flisp.dsk', ], build_by_default: true, ) endif test3rd = get_option('test3rd') if test3rd.enabled() mptest = executable( 'mptest', sources: [ '3rd/mp/test.c', ], include_directories: inc, link_with: [ common, 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: inc, link_with: [ common, mp, ], ) test('mp2', mptest2, timeout: -1) endif src_dir = meson.current_source_dir() tests_dir = join_paths(src_dir, 'test') test('100x100.lsp', flisp, args: ['100x100.lsp'], workdir: tests_dir) test('argv.lsp', flisp, args: ['argv.lsp'], workdir: tests_dir) test('exit0.lsp', flisp, args: ['exit0.lsp'], workdir: tests_dir) test('exit1.lsp', flisp, args: ['exit1.lsp'], workdir: tests_dir, should_fail: true) test('bench.lsp', flisp, args: ['bench.lsp'], workdir: tests_dir) test('hashtest.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: ['-S', '8m', 'torture.lsp'], workdir: tests_dir, timeout: -1) test('torus.lsp', flisp, args: ['torus.lsp'], workdir: tests_dir) test('unit.lsp', flisp, args: ['-S', '1m', 'unittest.lsp'], workdir: tests_dir) bootstrap = find_program( 'bootstrap.sh', dirs: [ join_paths(src_dir, 'tools'), ], native: true, ) test('bootstrap', bootstrap, [], workdir: src_dir, is_parallel : false, priority: 9999)