Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions releases.json
Original file line number Diff line number Diff line change
Expand Up @@ -3001,6 +3001,7 @@
"lua"
],
"versions": [
"5.5.0-2",
"5.5.0-1",
"5.4.8-1",
"5.4.6-5",
Expand Down
32 changes: 28 additions & 4 deletions subprojects/packagefiles/lua/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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 = []
Expand Down Expand Up @@ -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',
Expand Down
6 changes: 6 additions & 0 deletions subprojects/packagefiles/lua/meson_options.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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 ',
)
Loading