diff --git a/.github/build.sh b/.github/build.sh index 2fc7cd5b4..66623d7d7 100755 --- a/.github/build.sh +++ b/.github/build.sh @@ -370,7 +370,6 @@ java_runtime_jar = '$JAVA_HOME_8_X64/jre/lib/rt.jar' [binaries] # android_ndk_toolchain_prefix comes from the correct cross-file in ./android/cross -c = andriod_ndk_toolchain_bin / (android_ndk_toolchain_prefix + 'clang') cpp = andriod_ndk_toolchain_bin / (android_ndk_toolchain_prefix + 'clang++') strip = andriod_ndk_toolchain_bin / 'llvm-strip' javac = '$JAVA_HOME_8_X64/bin/javac' diff --git a/.github/emscripten-ghactions.ini b/.github/emscripten-ghactions.ini index d6fffacaf..4bcd3d7de 100644 --- a/.github/emscripten-ghactions.ini +++ b/.github/emscripten-ghactions.ini @@ -1,5 +1,4 @@ [binaries] -c = 'emcc' cpp = 'em++' strip = 'emstrip' ar = 'emar' diff --git a/.github/macaa64-ghactions.ini b/.github/macaa64-ghactions.ini index 774d77dfe..fa22490f8 100644 --- a/.github/macaa64-ghactions.ini +++ b/.github/macaa64-ghactions.ini @@ -1,5 +1,4 @@ [binaries] -c = [ 'clang', '-arch', 'arm64' ] cpp = [ 'clang++', '-arch', 'arm64' ] objcpp = [ 'clang++', '-arch', 'arm64' ] strip = 'strip' diff --git a/.github/mingw-ghactions.ini b/.github/mingw-ghactions.ini index 2c30577af..185ad3e2b 100644 --- a/.github/mingw-ghactions.ini +++ b/.github/mingw-ghactions.ini @@ -2,7 +2,6 @@ prefix = 'x86_64-w64-mingw32' [binaries] -c = prefix + '-gcc' cpp = prefix + '-g++' strip = prefix + '-strip' windres = prefix + '-windres' diff --git a/cross-examples/android.ini b/cross-examples/android.ini index a93d31231..7bb33a6d0 100644 --- a/cross-examples/android.ini +++ b/cross-examples/android.ini @@ -10,8 +10,6 @@ android_platform_jar = '/opt/android-sdk/platforms/' + android_platform + '/andr java_runtime_jar = '/usr/lib/jvm/java-8-openjdk/jre/lib/rt.jar' [binaries] -c = andriod_ndk_toolchain_bin / (android_ndk_toolchain_prefix + 'clang') -# c = [ 'ccache', andriod_ndk_toolchain_bin / (android_ndk_toolchain_prefix + 'clang') ] cpp = andriod_ndk_toolchain_bin / (android_ndk_toolchain_prefix + 'clang++') # cpp = [ 'ccache', andriod_ndk_toolchain_bin / (android_ndk_toolchain_prefix + 'clang++') ] strip = andriod_ndk_toolchain_bin / 'llvm-strip' diff --git a/cross-examples/macaa64.ini b/cross-examples/macaa64.ini index 774d77dfe..fa22490f8 100644 --- a/cross-examples/macaa64.ini +++ b/cross-examples/macaa64.ini @@ -1,5 +1,4 @@ [binaries] -c = [ 'clang', '-arch', 'arm64' ] cpp = [ 'clang++', '-arch', 'arm64' ] objcpp = [ 'clang++', '-arch', 'arm64' ] strip = 'strip' diff --git a/cross-examples/mingw.ini b/cross-examples/mingw.ini index 2c30577af..185ad3e2b 100644 --- a/cross-examples/mingw.ini +++ b/cross-examples/mingw.ini @@ -2,7 +2,6 @@ prefix = 'x86_64-w64-mingw32' [binaries] -c = prefix + '-gcc' cpp = prefix + '-g++' strip = prefix + '-strip' windres = prefix + '-windres' diff --git a/meson.build b/meson.build index 7ce083a6b..e917630c2 100644 --- a/meson.build +++ b/meson.build @@ -1,9 +1,8 @@ project( 'the-powder-toy', - [ 'c', 'cpp' ], + 'cpp', version: 'the.cake.is.a.lie', default_options: [ - 'c_std=c99', 'cpp_std=c++17', 'cpp_rtti=false', ], @@ -29,7 +28,7 @@ to_array = generator( render_icons_with_inkscape = get_option('render_icons_with_inkscape') inkscape = find_program('inkscape', required: render_icons_with_inkscape) -c_compiler = meson.get_compiler('c') +cpp_compiler = meson.get_compiler('cpp') is_x86 = host_machine.cpu_family() in [ 'x86', 'x86_64' ] is_64bit = host_machine.cpu_family() in [ 'aarch64', 'x86_64' ] @@ -37,12 +36,12 @@ is_64bit = host_machine.cpu_family() in [ 'aarch64', 'x86_64' ] host_arch = host_machine.cpu_family() host_platform = host_machine.system() # educated guesses follow, PRs welcome -if c_compiler.get_id() in [ 'msvc', 'clang-cl' ] +if cpp_compiler.get_id() in [ 'msvc', 'clang-cl' ] if host_platform != 'windows' error('this seems fishy') endif host_libc = 'msvc' -elif c_compiler.get_id() in [ 'gcc' ] and host_platform == 'windows' +elif cpp_compiler.get_id() in [ 'gcc' ] and host_platform == 'windows' host_libc = 'mingw' elif host_platform in [ 'darwin' ] host_libc = 'macos' @@ -115,7 +114,7 @@ else bzip2_include_dir = include_directories(get_option('workaround_elusive_bzip2_include_dir')) bzip2_static = get_option('workaround_elusive_bzip2_static') meson.override_dependency('bzip2', declare_dependency( - dependencies: c_compiler.find_library( + dependencies: cpp_compiler.find_library( bzip2_lib_name, has_headers: bzip2_include_name, dirs: bzip2_lib_dir, @@ -199,7 +198,6 @@ if enable_http and host_platform != 'emscripten' endif project_link_args = [] -project_c_args = [] project_cpp_args = [] fftw_dep = dependency('fftw3f', static: is_static) @@ -234,7 +232,6 @@ if host_platform == 'emscripten' emcc_args += [ '-gsource-map' ] endif project_link_args += emcc_args - project_c_args += emcc_args project_cpp_args += emcc_args else zlib_dep = dependency('zlib', static: is_static) @@ -246,7 +243,7 @@ json_dep = dependency('jsoncpp', static: is_static) if not is_debug args_ccomp_opt = [] - if c_compiler.get_argument_syntax() == 'msvc' + if cpp_compiler.get_argument_syntax() == 'msvc' args_ccomp_opt += [ '/Oy-', '/fp:fast', @@ -263,34 +260,31 @@ if not is_debug '-fomit-frame-pointer', ] endif - project_c_args += args_ccomp_opt project_cpp_args += args_ccomp_opt endif if not is_debug args_ccomp_lto = [] - if c_compiler.get_id() in [ 'clang', 'clang-cl' ] + if cpp_compiler.get_id() in [ 'clang', 'clang-cl' ] # use ThinLTO for Clang/LLVM args_ccomp_lto += [ '-flto=thin' ] - elif c_compiler.get_argument_syntax() == 'msvc' + elif cpp_compiler.get_argument_syntax() == 'msvc' args_ccomp_lto += [ '/GL' ] project_link_args += [ '/LTCG' ] endif - project_c_args += args_ccomp_lto project_cpp_args += args_ccomp_lto endif -if c_compiler.get_argument_syntax() == 'msvc' +if cpp_compiler.get_argument_syntax() == 'msvc' args_msvc = [ '/GS', '/D_SCL_SECURE_NO_WARNINGS', ] - project_c_args += args_msvc project_cpp_args += args_msvc endif # clang-cl supports both syntaxes. use the GCC one. -if c_compiler.get_argument_syntax() == 'msvc' and c_compiler.get_id() not in [ 'clang-cl' ] +if cpp_compiler.get_argument_syntax() == 'msvc' and cpp_compiler.get_id() not in [ 'clang-cl' ] args_ccomp_sse = [] if x86_sse_level == 30 warning('SSE3 configured to be enabled but unavailable in msvc') @@ -306,7 +300,6 @@ if c_compiler.get_argument_syntax() == 'msvc' and c_compiler.get_id() not in [ ' elif x86_sse_level >= 10 and host_machine.cpu_family() == 'x86' args_ccomp_sse += [ '/arch:SSE' ] endif - project_c_args += args_ccomp_sse project_cpp_args += args_ccomp_sse else args_ccomp_sse = [] @@ -331,7 +324,6 @@ else elif x86_sse_level >= 10 args_ccomp_sse += [ '-msse' ] endif - project_c_args += args_ccomp_sse project_cpp_args += args_ccomp_sse endif @@ -369,13 +361,12 @@ if host_platform == 'windows' endforeach endif foreach def : defs_ccomp_win - if c_compiler.get_argument_syntax() == 'msvc' + if cpp_compiler.get_argument_syntax() == 'msvc' args_ccomp_win += [ '/D' + def ] else args_ccomp_win += [ '-D' + def ] endif endforeach - project_c_args += args_ccomp_win project_cpp_args += args_ccomp_win elif host_platform == 'android' args_ccomp_android = [] @@ -386,27 +377,15 @@ elif host_platform == 'android' # the alternative would be to grab libc++_shared.so from the NDK and ship it with # the app alongside libpowder.so, and possibly add it to SDL's list of libraries to load project_link_args += [ '-static-libstdc++' ] - project_c_args += args_ccomp_android project_cpp_args += args_ccomp_android endif -if c_compiler.get_argument_syntax() == 'msvc' and c_compiler.get_id() not in [ 'clang-cl' ] - project_c_args += [ - '/wd5262', - '/wd4834', - '/wd4100', - ] +if cpp_compiler.get_argument_syntax() == 'msvc' and cpp_compiler.get_id() not in [ 'clang-cl' ] project_cpp_args += [ '/wd4834', '/wd4100', ] else - project_c_args += [ - '-Wno-implicit-fallthrough', - '-Wno-missing-field-initializers', - '-Wno-unused-result', - '-Wno-unused-parameter', - ] project_cpp_args += [ '-Wno-invalid-offsetof', '-Wno-unused-result', @@ -449,7 +428,7 @@ if get_option('export_lua_symbols') if is_static and lua_variant != 'none' and not project_export_dynamic if host_platform == 'windows' error('Lua symbols are currently impossible to export correctly on Windows') - elif c_compiler.has_link_argument('-Wl,--export-dynamic-symbol') + elif cpp_compiler.has_link_argument('-Wl,--export-dynamic-symbol') project_link_args += [ '-Wl,--export-dynamic-symbol=lua_*', '-Wl,--export-dynamic-symbol=luaL_*', @@ -479,7 +458,6 @@ if get_option('build_powder') app_exe, sources: powder_files, include_directories: project_inc, - c_args: project_c_args, cpp_args: project_cpp_args, link_args: project_link_args, dependencies: powder_deps, @@ -491,7 +469,6 @@ if get_option('build_powder') app_exe, sources: powder_files, include_directories: project_inc, - c_args: project_c_args, cpp_args: project_cpp_args, win_subsystem: is_debug ? 'console' : 'windows', link_args: project_link_args, @@ -522,7 +499,6 @@ if get_option('build_render') 'render', sources: render_files, include_directories: project_inc, - c_args: project_c_args, cpp_args: project_cpp_args, link_args: render_link_args, dependencies: render_deps, @@ -547,7 +523,6 @@ if get_option('build_font') 'font', sources: font_files, include_directories: project_inc, - c_args: project_c_args, cpp_args: project_cpp_args, link_args: project_link_args, dependencies: font_deps, diff --git a/src/client/http/requestmanager/meson.build b/src/client/http/requestmanager/meson.build index 2044c6993..d862abcce 100644 --- a/src/client/http/requestmanager/meson.build +++ b/src/client/http/requestmanager/meson.build @@ -12,7 +12,7 @@ else if host_platform == 'windows' use_system_cert_provider = true client_files += files('WindowsCertProvider.cpp') - powder_deps += c_compiler.find_library('crypt32') + powder_deps += cpp_compiler.find_library('crypt32') endif if host_platform == 'android' use_system_cert_provider = true diff --git a/src/common/platform/stacktrace/meson.build b/src/common/platform/stacktrace/meson.build index c2a2c04f5..e18a6576f 100644 --- a/src/common/platform/stacktrace/meson.build +++ b/src/common/platform/stacktrace/meson.build @@ -1,8 +1,8 @@ if host_platform == 'windows' if use_bluescreen project_deps += [ - c_compiler.find_library('dbghelp'), - c_compiler.find_library('psapi'), + cpp_compiler.find_library('dbghelp'), + cpp_compiler.find_library('psapi'), ] endif stacktrace_files = files('Windows.cpp') @@ -18,7 +18,7 @@ elif host_platform == 'linux' bluescreen_export_symbols = true if host_machine.system() in [ 'freebsd' ] project_deps += [ - c_compiler.find_library('execinfo'), + cpp_compiler.find_library('execinfo'), ] endif else diff --git a/src/lua/LuaCompat.c b/src/lua/LuaCompat.cpp similarity index 97% rename from src/lua/LuaCompat.c rename to src/lua/LuaCompat.cpp index 53b39aea8..65d44b353 100644 --- a/src/lua/LuaCompat.c +++ b/src/lua/LuaCompat.cpp @@ -1,5 +1,7 @@ #include "LuaCompat.h" +extern "C" +{ #if LUA_VERSION_NUM >= 502 // Implement missing luaL_typerror function int luaL_typerror(lua_State *L, int narg, const char *tname) @@ -27,3 +29,4 @@ void lua_pushglobaltable(lua_State *L) } # endif #endif +} diff --git a/src/lua/LuaCompat.h b/src/lua/LuaCompat.h index e4d2df3b4..de9e575ef 100644 --- a/src/lua/LuaCompat.h +++ b/src/lua/LuaCompat.h @@ -1,9 +1,7 @@ #pragma once -#ifdef __cplusplus extern "C" { -#endif #include #include @@ -23,6 +21,4 @@ LUALIB_API void (lua_pushglobaltable) (lua_State *L); # endif #endif -#ifdef __cplusplus } -#endif diff --git a/src/lua/meson.build b/src/lua/meson.build index 7446e68bd..baa4f21fb 100644 --- a/src/lua/meson.build +++ b/src/lua/meson.build @@ -2,7 +2,7 @@ luaconsole_files = files( 'LuaButton.cpp', 'LuaBz2.cpp', 'LuaCheckbox.cpp', - 'LuaCompat.c', + 'LuaCompat.cpp', 'LuaComponent.cpp', 'LuaElements.cpp', 'LuaEvent.cpp',