diff --git a/releases.json b/releases.json index 099dd342ed..a77db78313 100644 --- a/releases.json +++ b/releases.json @@ -3001,6 +3001,7 @@ "lua" ], "versions": [ + "5.5.0-2", "5.5.0-1", "5.4.8-1", "5.4.6-5", diff --git a/subprojects/packagefiles/lua/meson.build b/subprojects/packagefiles/lua/meson.build index 2b27d5fa03..74daa4b86c 100644 --- a/subprojects/packagefiles/lua/meson.build +++ b/subprojects/packagefiles/lua/meson.build @@ -10,9 +10,15 @@ project( lua_versions = meson.project_version().split('.') cc = meson.get_compiler('c') -override_options = [ - 'c_std=c99', -] +override_options = [] + +build_as_cpp = get_option('lua_cpp') + +if not build_as_cpp + override_options += [ + 'c_std=c99', + ] +endif # Skip bogus warning. add_project_arguments( @@ -73,6 +79,19 @@ if dl_dep.found() ) endif + +if build_as_cpp + if cc.get_id() == 'msvc' + add_project_arguments('/TP', '/EHa', language: 'c') + elif cc.get_id() == 'gcc' or cc.get_id() == 'clang' + add_project_arguments( + '-xc++', + language: 'c' + ) + else + warning('Unknown compiler family. We do not know how to enforce C++ on C files') +endif + # Interpreter dependencies. lua_exe_deps = [] lua_exe_args = [] @@ -146,7 +165,12 @@ meson.override_dependency( lua_dep, ) -if get_option('interpreter') +# Note: you can compile C code as C++, but you can't link it. Clang compiler +# has option to treat C source code as C++, but clang linker does not. And +# as there are several possible C++ standard libraries, we can't just pick +# one and pass it to linker explicitly. +# If building Lua as C++ is enabed, then disable interpreter +if get_option('interpreter') and not build_as_cpp lua_exe = executable( 'lua', 'src/lua.c', diff --git a/subprojects/packagefiles/lua/meson_options.txt b/subprojects/packagefiles/lua/meson_options.txt index 23f04bbe14..6efea06cc0 100644 --- a/subprojects/packagefiles/lua/meson_options.txt +++ b/subprojects/packagefiles/lua/meson_options.txt @@ -14,3 +14,9 @@ option( value: true, description: 'Build the Lua interpreter.', ) +option( + 'lua_cpp', + type: 'boolean', + value: false, + description: 'Build Lua as C++. This will disable building interpreter and executable ', +)