ref: a70379d7e4b822f532fb0a8ccdd1624a90b64a68
dir: /meson.build/
project( 'sl', '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', '-Wpedantic', '-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_sl = [ '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/sl.c', 'src/slmain.c', 'src/hashing.c', 'src/htable.c', 'src/io.c', 'src/ios.c', 'src/math.c', 'src/opcodes.c', 'src/operators.c', 'src/print.c', 'src/ptrhash.c', 'src/random.c', 'src/read.c', 'src/str.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 sl_exe_name = 'sl.code.bin' add_languages( 'cpp', native: false, required: true, ) cpp = meson.get_compiler('cpp') if cpu == 'm68k' # 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 src_common += [ 'src/mem.c', ] endif extras += [ cpp.find_library('RetroConsole', required: true), cpp.find_library('retrocrt', required: true), ] elif sys == 'dos' platform = sys sl_exe_name = 'sl.exe' else platform = 'posix' sl_exe_name = 'sl' endif inc += [include_directories('src'/platform)] src_sl += ['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) brieflz = static_library( 'brieflz', sources: [ '3rd/brieflz/brieflz.c', '3rd/brieflz/depacks.c', ], include_directories: inc, pic: false, prelink: false, ) lzpack = executable( 'lzpack', sources: [ '3rd/brieflz/brieflz.c', '3rd/brieflz/depacks.c', 'tools/lzpack.c', ], include_directories: inc, native: true, ) boot = custom_target( 'boot', capture: true, input: [ 'boot/sl.boot', ], output: [ 'sl.boot.h', ], command: [ 'tools/boot2h.sh', lzpack, '@INPUT@', ], ) builtins = custom_target( 'builtins', capture: true, input: [ src_sl, ], output: [ 'builtin_fns.h', ], command: [ 'tools/builtins2h.sh', '@INPUT@', ], ) ops = custom_target( 'ops', capture: true, input: [ 'src/vm.h', ], output: [ 'vm_goto.h', ], command: [ 'tools/ops2h.sh', '@INPUT@', ], ) 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, ) sl = executable( sl_exe_name, sources: [ src_sl, 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 = 'm68k.r' rez_data = '--copy' rezflags = [] sl_code = sl else assert(cpu == 'ppc', 'unexpected cpu setting') template = 'ppc.r' rez_data = '--data' rezflags = ['-DTARGET_API_MAC_CARBON=0'] sl_code = custom_target( 'sl.pef', input: [ sl ], output: [ 'sl.pef', ], command: [ makepef, '@INPUT@', '-o', '@OUTPUT@', ], ) endif template = meson.global_source_root()/'src/macos'/template sl_bin = custom_target( 'sl.bin', input: [ sl_code, template, ], output: [ 'sl.bin', 'sl.dsk', ], command: [ rez, '-I' + rincludes, ] + rezflags + [ template, '-DCFRAG_NAME="sl"', '-o', 'sl.bin', '-t', 'APPL', '-c', '????', rez_data, sl_code, '--cc', 'sl.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.sl', sl, args: ['100x100.sl'], workdir: tests_dir) test('argv.sl', sl, args: ['argv.sl'], workdir: tests_dir) test('exit0.sl', sl, args: ['exit0.sl'], workdir: tests_dir) test('exit1.sl', sl, args: ['exit1.sl'], workdir: tests_dir, should_fail: true) test('bench.sl', sl, args: ['bench.sl'], workdir: tests_dir, timeout: -1) test('hashtest.sl', sl, args: ['hashtest.sl'], workdir: tests_dir) test('mp.sl', sl, args: ['mp.sl'], workdir: tests_dir) test('perf.sl', sl, args: ['perf.sl'], workdir: tests_dir, timeout: -1) test('tme.sl', sl, args: ['tme.sl'], workdir: tests_dir, timeout: -1) test('torture.sl', sl, args: ['-S', '8m', 'torture.sl'], workdir: tests_dir, timeout: -1) test('torus.sl', sl, args: ['torus.sl'], workdir: tests_dir) test('unit.sl', sl, args: ['-S', '1m', 'unittest.sl'], 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)