diff --git a/meson.build b/meson.build index 685a9efad2..2d3d8f6621 100644 --- a/meson.build +++ b/meson.build @@ -316,7 +316,9 @@ if get_option('enable_update_checker') deps += [libcurl_dep] endif -luajit = dependency('luajit', version: '>=2.0.0', required: get_option('system_luajit')) +luajit = dependency('luajit', version: '>=2.0.0', required: get_option('system_luajit'), + allow_fallback: false, + default_options: ['amalgam=true', 'luajit=false', 'lua52compat=true']) if luajit.found() and luajit.type_name() != 'internal' luajit_test = cc.run('''#include int main(void) @@ -332,18 +334,26 @@ int main(void) if get_option('system_luajit') error('System luajit found but not compiled in 5.2 mode') else - message('System luajit found but not compiled in 5.2 mode; using built-in luajit') + message('System luajit found but not compiled in 5.2 mode') + luajit = dependency('', required: false) endif else deps += luajit endif -else - message('System luajit not found; using built-in luajit') endif -if not deps.contains(luajit) - deps += subproject('luajit').get_variable('luajit_dep') +if not luajit.found() + message('Using built-in luajit') + subproject('luajit') # Initialize subproject to ignore system luajit + luajit = dependency('luajit', version: '>=2.0.0', + default_options: ['amalgam=true', 'luajit=false', 'lua52compat=true']) + assert(luajit.type_name() == 'internal', 'System luajit used instead of built-in luajit') +endif + +if luajit.type_name() == 'internal' + deps += luajit endif + deps += subproject('luabins').get_variable('luabins_dep') dep_gl = dependency('gl', required: false) diff --git a/subprojects/luabins/meson.build b/subprojects/luabins/meson.build index 1d87ab2b1e..254a41ff30 100644 --- a/subprojects/luabins/meson.build +++ b/subprojects/luabins/meson.build @@ -11,7 +11,9 @@ luabins_src = files( deps = [] -luajit = dependency('luajit', version: '>=2.0.0') +luajit = dependency('luajit', version: '>=2.0.0', required: get_option('system_luajit'), + allow_fallback: false, + default_options: ['amalgam=true', 'luajit=false', 'lua52compat=true']) if luajit.found() and luajit.type_name() != 'internal' luajit_test = meson.get_compiler('c').run('''#include int main(void) @@ -24,16 +26,27 @@ int main(void) }''', dependencies: luajit) if luajit_test.returncode() == 1 - message('System luajit found but not compiled in 5.2 mode; using built-in luajit') + if get_option('system_luajit') + error('System luajit found but not compiled in 5.2 mode') + else + message('System luajit found but not compiled in 5.2 mode') + luajit = dependency('', required: false) + endif else deps += luajit endif -else - message('System luajit not found; using built-in luajit') endif -if not deps.contains(luajit) - deps += subproject('luajit').get_variable('luajit_dep') +if not luajit.found() + message('Using built-in luajit') + subproject('luajit') # Initialize subproject to ignore system luajit + luajit = dependency('luajit', version: '>=2.0.0', + default_options: ['amalgam=true', 'luajit=false', 'lua52compat=true']) + assert(luajit.type_name() == 'internal', 'System luajit used instead of built-in luajit') +endif + +if luajit.type_name() == 'internal' + deps += luajit endif luabins = static_library('luabins', luabins_src, dependencies: deps) diff --git a/subprojects/luajit.wrap b/subprojects/luajit.wrap index e1daad5ab6..99d70cf3ce 100644 --- a/subprojects/luajit.wrap +++ b/subprojects/luajit.wrap @@ -1,8 +1,14 @@ -[wrap-git] -directory = luajit -url = https://github.com/LuaJIT/LuaJIT.git -revision = v2.1 -patch_directory = luajit +[wrap-file] +directory = LuaJIT-04dca7911ea255f37be799c18d74c305b921c1a6 +source_url = https://github.com/LuaJIT/LuaJIT/archive/04dca7911ea255f37be799c18d74c305b921c1a6.tar.gz +source_filename = luajit-2.1.1720049189.tar.gz +source_hash = 346b028d9ba85e04b7e23a43cc51ec076574d2efc0d271d4355141b0145cd6e0 +patch_filename = luajit_2.1.1720049189-1_patch.zip +patch_url = https://wrapdb.mesonbuild.com/v2/luajit_2.1.1720049189-1/get_patch +patch_hash = 3d62fd49cc65bc89c187bf94f633d9d48056f6034541c372e5180fc7bd64d7ae +source_fallback_url = https://github.com/mesonbuild/wrapdb/releases/download/luajit_2.1.1720049189-1/luajit-2.1.1720049189.tar.gz +wrapdb_version = 2.1.1720049189-1 [provide] -luajit = luajit_dep +dependency_names = luajit +program_names = luajit diff --git a/subprojects/packagefiles/luajit/meson.build b/subprojects/packagefiles/luajit/meson.build deleted file mode 100644 index e27a933feb..0000000000 --- a/subprojects/packagefiles/luajit/meson.build +++ /dev/null @@ -1,40 +0,0 @@ -project('luajit', 'c', version: '2.1.0', license: 'MIT') - -cc = meson.get_compiler('c') - -system_deps = [ - cc.find_library('dl', required: false), - cc.find_library('m', required: false) -] - -# get architecture id for the host machine so it can be set when compiling buildvm natively -lj_target_id = cc.get_define('LUAJIT_TARGET', prefix: '#include "@0@/src/lj_arch.h"'.format(meson.current_source_dir())) -add_project_arguments('-DLUAJIT_TARGET=@0@'.format(lj_target_id), language: 'c', native: true) - -# compat flag is needed for both the buildvm code generator (compiled natively) and luajit itself -add_project_arguments('-DLUAJIT_ENABLE_LUA52COMPAT', '-DENDIAN_LE', language: 'c', native: true) -add_project_arguments('-DLUAJIT_ENABLE_LUA52COMPAT', '-DENDIAN_LE', language: 'c', native: false) -if host_machine.system() == 'linux' - add_project_arguments('-DLUAJIT_OS=LUAJIT_OS_LINUX', language: 'c', native: true) - add_project_arguments('-DLUAJIT_UNWIND_EXTERNAL', language: 'c', native: false) - ljvm_mode = 'elfasm' - ljvm_bout = 'lj_vm.s' -elif host_machine.system() == 'darwin' - add_project_arguments('-DLUAJIT_OS=LUAJIT_OS_OSX', language: 'c', native: true) - add_project_arguments('-DLUAJIT_UNWIND_EXTERNAL', language: 'c', native: false) - ljvm_mode = 'machasm' - ljvm_bout = 'lj_vm.s' -elif host_machine.system() == 'windows' - add_project_arguments('-DLUAJIT_OS=LUAJIT_OS_WINDOWS', language: 'c', native: true) - if cc.get_id() != 'msvc' - add_project_arguments('-malign-double', language: 'c', native: true) - endif - ljvm_mode = 'peobj' - ljvm_bout = 'lj_vm.o' -else - error('Unsupported platform') -endif - -subdir('src') - -luajit_dep = declare_dependency(link_with: luajit_lib, include_directories: src_inc) diff --git a/subprojects/packagefiles/luajit/src/host/meson.build b/subprojects/packagefiles/luajit/src/host/meson.build deleted file mode 100644 index bf1e2450ef..0000000000 --- a/subprojects/packagefiles/luajit/src/host/meson.build +++ /dev/null @@ -1,56 +0,0 @@ -cpu_family = host_machine.cpu_family() -if cpu_family == 'x86_64' - dynasm_arch = 'x64' -elif cpu_family == 'aarch64' - dynasm_arch = 'arm64' -else - dynasm_arch = cpu_family -endif - -dynasm_dasc = files('../vm_@0@.dasc'.format(dynasm_arch)) -dasm = [minilua, files('../../dynasm/dynasm.lua')] - -# BUG: meson does not resolve paths correctly for subprojects -hpre = '#include "@0@/../lj_arch.h"'.format(meson.current_source_dir()) - -checkdefs = [ - ['LJ_LE', '1', ['-D', 'ENDIAN_LE']], - ['LJ_ARCH_BITS', '64', ['-D', 'P64']], - ['LJ_HASJIT', '1', ['-D', 'JIT']], - ['LJ_HASFFI', '1', ['-D', 'FFI']], - ['LJ_DUALNUM', '1', ['-D', 'DUALNUM']], - ['LJ_ARCH_HASFPU', '1', ['-D', 'FPU']], - ['LJ_ABI_SOFTFP', '0', ['-D', 'HFABI']], - ['LJ_NO_UNWIND', '1', ['-D', 'NO_UNWIND']], - ['LJ_ABI_PAUTH', '1', ['-D', 'PAUTH']], -] - -foreach def: checkdefs - if cc.get_define(def[0], prefix: hpre) == def[1] - dasm += def[2] - endif -endforeach - -if host_machine.system() == 'windows' - dasm += ['-D', 'WIN'] -endif - -dasm += ['-D', 'VER=' + cc.get_define('LJ_ARCH_VERSION', prefix: hpre)] - -buildvm_src = files( - 'buildvm.c', - 'buildvm_asm.c', - 'buildvm_peobj.c', - 'buildvm_lib.c', - 'buildvm_fold.c', -) - -buildvm_arch = custom_target('buildvm_arch.h', - command: dasm + ['-o', '@OUTPUT@', '@INPUT@'], - input: dynasm_dasc, - output: 'buildvm_arch.h') - -buildvm = executable('buildvm', buildvm_src, buildvm_arch, luajit_h, - dependencies: system_deps, - include_directories: src_inc, - native: true) diff --git a/subprojects/packagefiles/luajit/src/luajit_relver.txt.in b/subprojects/packagefiles/luajit/src/luajit_relver.txt.in deleted file mode 100644 index a380c6df95..0000000000 --- a/subprojects/packagefiles/luajit/src/luajit_relver.txt.in +++ /dev/null @@ -1 +0,0 @@ -@VCS_CT@ diff --git a/subprojects/packagefiles/luajit/src/meson.build b/subprojects/packagefiles/luajit/src/meson.build deleted file mode 100644 index f4deb0079e..0000000000 --- a/subprojects/packagefiles/luajit/src/meson.build +++ /dev/null @@ -1,121 +0,0 @@ -ljlib_src = files( - 'lib_base.c', - 'lib_bit.c', - 'lib_buffer.c', - 'lib_debug.c', - 'lib_ffi.c', - 'lib_io.c', - 'lib_jit.c', - 'lib_math.c', - 'lib_os.c', - 'lib_package.c', - 'lib_string.c', - 'lib_table.c', -) - -ljcore_src = files( - 'lib_aux.c', - 'lib_init.c', - 'lj_alloc.c', - 'lj_api.c', - 'lj_asm.c', - 'lj_assert.c', - 'lj_bc.c', - 'lj_bcread.c', - 'lj_bcwrite.c', - 'lj_buf.c', - 'lj_carith.c', - 'lj_ccall.c', - 'lj_ccallback.c', - 'lj_cconv.c', - 'lj_cdata.c', - 'lj_char.c', - 'lj_clib.c', - 'lj_cparse.c', - 'lj_crecord.c', - 'lj_ctype.c', - 'lj_debug.c', - 'lj_dispatch.c', - 'lj_err.c', - 'lj_ffrecord.c', - 'lj_func.c', - 'lj_gc.c', - 'lj_gdbjit.c', - 'lj_ir.c', - 'lj_lex.c', - 'lj_lib.c', - 'lj_load.c', - 'lj_mcode.c', - 'lj_meta.c', - 'lj_obj.c', - 'lj_opt_dce.c', - 'lj_opt_fold.c', - 'lj_opt_loop.c', - 'lj_opt_mem.c', - 'lj_opt_narrow.c', - 'lj_opt_sink.c', - 'lj_opt_split.c', - 'lj_parse.c', - 'lj_prng.c', - 'lj_profile.c', - 'lj_record.c', - 'lj_serialize.c', - 'lj_snap.c', - 'lj_state.c', - 'lj_str.c', - 'lj_strfmt.c', - 'lj_strfmt_num.c', - 'lj_strscan.c', - 'lj_tab.c', - 'lj_trace.c', - 'lj_udata.c', - 'lj_vmevent.c', - 'lj_vmmath.c', -) - -src_inc = include_directories('.') - -minilua = executable('minilua', 'host/minilua.c', - dependencies: system_deps, - native: true) - -relver = vcs_tag(command: ['git', 'show', '-s', '--format=%ct'], - fallback: 'ROLLING', - input: 'luajit_relver.txt.in', - output: 'luajit_relver.txt', - replace_string: '@VCS_CT@') - -luajit_rolling_h = files('luajit_rolling.h') - -luajit_h = custom_target('luajit_h', - command: [minilua, '@INPUT@', '@OUTPUT@'], - input: ['host/genversion.lua', 'luajit_rolling.h', relver], - output: 'luajit.h') - -subdir('host') - -hdrgen = [ - 'bcdef', - 'ffdef', - 'libdef', - 'recdef', -] - -genheaders = [luajit_h] - -foreach h: hdrgen - genheaders += custom_target(h, - command: [buildvm, '-m', h, '-o', '@OUTPUT@', ljlib_src], - output: 'lj_@0@.h'.format(h)) -endforeach - -genheaders += custom_target('folddef', - command: [buildvm, '-m', 'folddef', '-o', '@OUTPUT@', files('lj_opt_fold.c')], - output: 'lj_folddef.h') - -ljvm = custom_target(ljvm_bout, - command: [buildvm, '-m', ljvm_mode, '-o', '@OUTPUT@'], - output: ljvm_bout) - -luajit_lib = static_library('luajit', ljlib_src, ljcore_src, genheaders, ljvm, - dependencies: system_deps)