Remove the single C TU from the codebase

This leaves one non-C++ TU in the entire codebase: Cocoa.mm is Objective C++ and is only compiled on MacOS, where it's used for clipboard integration. This too will go away when we move to SDL3, which has a proper clipboard API.
This commit is contained in:
Tamás Bálint Misius
2024-10-12 18:07:21 +02:00
parent c2bb777212
commit f9ccc24177
13 changed files with 21 additions and 55 deletions

1
.github/build.sh vendored
View File

@@ -370,7 +370,6 @@ java_runtime_jar = '$JAVA_HOME_8_X64/jre/lib/rt.jar'
[binaries] [binaries]
# android_ndk_toolchain_prefix comes from the correct cross-file in ./android/cross # 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++') cpp = andriod_ndk_toolchain_bin / (android_ndk_toolchain_prefix + 'clang++')
strip = andriod_ndk_toolchain_bin / 'llvm-strip' strip = andriod_ndk_toolchain_bin / 'llvm-strip'
javac = '$JAVA_HOME_8_X64/bin/javac' javac = '$JAVA_HOME_8_X64/bin/javac'

View File

@@ -1,5 +1,4 @@
[binaries] [binaries]
c = 'emcc'
cpp = 'em++' cpp = 'em++'
strip = 'emstrip' strip = 'emstrip'
ar = 'emar' ar = 'emar'

View File

@@ -1,5 +1,4 @@
[binaries] [binaries]
c = [ 'clang', '-arch', 'arm64' ]
cpp = [ 'clang++', '-arch', 'arm64' ] cpp = [ 'clang++', '-arch', 'arm64' ]
objcpp = [ 'clang++', '-arch', 'arm64' ] objcpp = [ 'clang++', '-arch', 'arm64' ]
strip = 'strip' strip = 'strip'

View File

@@ -2,7 +2,6 @@
prefix = 'x86_64-w64-mingw32' prefix = 'x86_64-w64-mingw32'
[binaries] [binaries]
c = prefix + '-gcc'
cpp = prefix + '-g++' cpp = prefix + '-g++'
strip = prefix + '-strip' strip = prefix + '-strip'
windres = prefix + '-windres' windres = prefix + '-windres'

View File

@@ -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' java_runtime_jar = '/usr/lib/jvm/java-8-openjdk/jre/lib/rt.jar'
[binaries] [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 = andriod_ndk_toolchain_bin / (android_ndk_toolchain_prefix + 'clang++')
# cpp = [ 'ccache', 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' strip = andriod_ndk_toolchain_bin / 'llvm-strip'

View File

@@ -1,5 +1,4 @@
[binaries] [binaries]
c = [ 'clang', '-arch', 'arm64' ]
cpp = [ 'clang++', '-arch', 'arm64' ] cpp = [ 'clang++', '-arch', 'arm64' ]
objcpp = [ 'clang++', '-arch', 'arm64' ] objcpp = [ 'clang++', '-arch', 'arm64' ]
strip = 'strip' strip = 'strip'

View File

@@ -2,7 +2,6 @@
prefix = 'x86_64-w64-mingw32' prefix = 'x86_64-w64-mingw32'
[binaries] [binaries]
c = prefix + '-gcc'
cpp = prefix + '-g++' cpp = prefix + '-g++'
strip = prefix + '-strip' strip = prefix + '-strip'
windres = prefix + '-windres' windres = prefix + '-windres'

View File

@@ -1,9 +1,8 @@
project( project(
'the-powder-toy', 'the-powder-toy',
[ 'c', 'cpp' ], 'cpp',
version: 'the.cake.is.a.lie', version: 'the.cake.is.a.lie',
default_options: [ default_options: [
'c_std=c99',
'cpp_std=c++17', 'cpp_std=c++17',
'cpp_rtti=false', 'cpp_rtti=false',
], ],
@@ -29,7 +28,7 @@ to_array = generator(
render_icons_with_inkscape = get_option('render_icons_with_inkscape') render_icons_with_inkscape = get_option('render_icons_with_inkscape')
inkscape = find_program('inkscape', required: 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_x86 = host_machine.cpu_family() in [ 'x86', 'x86_64' ]
is_64bit = host_machine.cpu_family() in [ 'aarch64', '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_arch = host_machine.cpu_family()
host_platform = host_machine.system() host_platform = host_machine.system()
# educated guesses follow, PRs welcome # 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' if host_platform != 'windows'
error('this seems fishy') error('this seems fishy')
endif endif
host_libc = 'msvc' 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' host_libc = 'mingw'
elif host_platform in [ 'darwin' ] elif host_platform in [ 'darwin' ]
host_libc = 'macos' host_libc = 'macos'
@@ -115,7 +114,7 @@ else
bzip2_include_dir = include_directories(get_option('workaround_elusive_bzip2_include_dir')) bzip2_include_dir = include_directories(get_option('workaround_elusive_bzip2_include_dir'))
bzip2_static = get_option('workaround_elusive_bzip2_static') bzip2_static = get_option('workaround_elusive_bzip2_static')
meson.override_dependency('bzip2', declare_dependency( meson.override_dependency('bzip2', declare_dependency(
dependencies: c_compiler.find_library( dependencies: cpp_compiler.find_library(
bzip2_lib_name, bzip2_lib_name,
has_headers: bzip2_include_name, has_headers: bzip2_include_name,
dirs: bzip2_lib_dir, dirs: bzip2_lib_dir,
@@ -199,7 +198,6 @@ if enable_http and host_platform != 'emscripten'
endif endif
project_link_args = [] project_link_args = []
project_c_args = []
project_cpp_args = [] project_cpp_args = []
fftw_dep = dependency('fftw3f', static: is_static) fftw_dep = dependency('fftw3f', static: is_static)
@@ -234,7 +232,6 @@ if host_platform == 'emscripten'
emcc_args += [ '-gsource-map' ] emcc_args += [ '-gsource-map' ]
endif endif
project_link_args += emcc_args project_link_args += emcc_args
project_c_args += emcc_args
project_cpp_args += emcc_args project_cpp_args += emcc_args
else else
zlib_dep = dependency('zlib', static: is_static) zlib_dep = dependency('zlib', static: is_static)
@@ -246,7 +243,7 @@ json_dep = dependency('jsoncpp', static: is_static)
if not is_debug if not is_debug
args_ccomp_opt = [] args_ccomp_opt = []
if c_compiler.get_argument_syntax() == 'msvc' if cpp_compiler.get_argument_syntax() == 'msvc'
args_ccomp_opt += [ args_ccomp_opt += [
'/Oy-', '/Oy-',
'/fp:fast', '/fp:fast',
@@ -263,34 +260,31 @@ if not is_debug
'-fomit-frame-pointer', '-fomit-frame-pointer',
] ]
endif endif
project_c_args += args_ccomp_opt
project_cpp_args += args_ccomp_opt project_cpp_args += args_ccomp_opt
endif endif
if not is_debug if not is_debug
args_ccomp_lto = [] 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 # use ThinLTO for Clang/LLVM
args_ccomp_lto += [ '-flto=thin' ] args_ccomp_lto += [ '-flto=thin' ]
elif c_compiler.get_argument_syntax() == 'msvc' elif cpp_compiler.get_argument_syntax() == 'msvc'
args_ccomp_lto += [ '/GL' ] args_ccomp_lto += [ '/GL' ]
project_link_args += [ '/LTCG' ] project_link_args += [ '/LTCG' ]
endif endif
project_c_args += args_ccomp_lto
project_cpp_args += args_ccomp_lto project_cpp_args += args_ccomp_lto
endif endif
if c_compiler.get_argument_syntax() == 'msvc' if cpp_compiler.get_argument_syntax() == 'msvc'
args_msvc = [ args_msvc = [
'/GS', '/GS',
'/D_SCL_SECURE_NO_WARNINGS', '/D_SCL_SECURE_NO_WARNINGS',
] ]
project_c_args += args_msvc
project_cpp_args += args_msvc project_cpp_args += args_msvc
endif endif
# clang-cl supports both syntaxes. use the GCC one. # 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 = [] args_ccomp_sse = []
if x86_sse_level == 30 if x86_sse_level == 30
warning('SSE3 configured to be enabled but unavailable in msvc') 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' elif x86_sse_level >= 10 and host_machine.cpu_family() == 'x86'
args_ccomp_sse += [ '/arch:SSE' ] args_ccomp_sse += [ '/arch:SSE' ]
endif endif
project_c_args += args_ccomp_sse
project_cpp_args += args_ccomp_sse project_cpp_args += args_ccomp_sse
else else
args_ccomp_sse = [] args_ccomp_sse = []
@@ -331,7 +324,6 @@ else
elif x86_sse_level >= 10 elif x86_sse_level >= 10
args_ccomp_sse += [ '-msse' ] args_ccomp_sse += [ '-msse' ]
endif endif
project_c_args += args_ccomp_sse
project_cpp_args += args_ccomp_sse project_cpp_args += args_ccomp_sse
endif endif
@@ -369,13 +361,12 @@ if host_platform == 'windows'
endforeach endforeach
endif endif
foreach def : defs_ccomp_win foreach def : defs_ccomp_win
if c_compiler.get_argument_syntax() == 'msvc' if cpp_compiler.get_argument_syntax() == 'msvc'
args_ccomp_win += [ '/D' + def ] args_ccomp_win += [ '/D' + def ]
else else
args_ccomp_win += [ '-D' + def ] args_ccomp_win += [ '-D' + def ]
endif endif
endforeach endforeach
project_c_args += args_ccomp_win
project_cpp_args += args_ccomp_win project_cpp_args += args_ccomp_win
elif host_platform == 'android' elif host_platform == 'android'
args_ccomp_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 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 # the app alongside libpowder.so, and possibly add it to SDL's list of libraries to load
project_link_args += [ '-static-libstdc++' ] project_link_args += [ '-static-libstdc++' ]
project_c_args += args_ccomp_android
project_cpp_args += args_ccomp_android project_cpp_args += args_ccomp_android
endif endif
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' ]
project_c_args += [
'/wd5262',
'/wd4834',
'/wd4100',
]
project_cpp_args += [ project_cpp_args += [
'/wd4834', '/wd4834',
'/wd4100', '/wd4100',
] ]
else else
project_c_args += [
'-Wno-implicit-fallthrough',
'-Wno-missing-field-initializers',
'-Wno-unused-result',
'-Wno-unused-parameter',
]
project_cpp_args += [ project_cpp_args += [
'-Wno-invalid-offsetof', '-Wno-invalid-offsetof',
'-Wno-unused-result', '-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 is_static and lua_variant != 'none' and not project_export_dynamic
if host_platform == 'windows' if host_platform == 'windows'
error('Lua symbols are currently impossible to export correctly on 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 += [ project_link_args += [
'-Wl,--export-dynamic-symbol=lua_*', '-Wl,--export-dynamic-symbol=lua_*',
'-Wl,--export-dynamic-symbol=luaL_*', '-Wl,--export-dynamic-symbol=luaL_*',
@@ -479,7 +458,6 @@ if get_option('build_powder')
app_exe, app_exe,
sources: powder_files, sources: powder_files,
include_directories: project_inc, include_directories: project_inc,
c_args: project_c_args,
cpp_args: project_cpp_args, cpp_args: project_cpp_args,
link_args: project_link_args, link_args: project_link_args,
dependencies: powder_deps, dependencies: powder_deps,
@@ -491,7 +469,6 @@ if get_option('build_powder')
app_exe, app_exe,
sources: powder_files, sources: powder_files,
include_directories: project_inc, include_directories: project_inc,
c_args: project_c_args,
cpp_args: project_cpp_args, cpp_args: project_cpp_args,
win_subsystem: is_debug ? 'console' : 'windows', win_subsystem: is_debug ? 'console' : 'windows',
link_args: project_link_args, link_args: project_link_args,
@@ -522,7 +499,6 @@ if get_option('build_render')
'render', 'render',
sources: render_files, sources: render_files,
include_directories: project_inc, include_directories: project_inc,
c_args: project_c_args,
cpp_args: project_cpp_args, cpp_args: project_cpp_args,
link_args: render_link_args, link_args: render_link_args,
dependencies: render_deps, dependencies: render_deps,
@@ -547,7 +523,6 @@ if get_option('build_font')
'font', 'font',
sources: font_files, sources: font_files,
include_directories: project_inc, include_directories: project_inc,
c_args: project_c_args,
cpp_args: project_cpp_args, cpp_args: project_cpp_args,
link_args: project_link_args, link_args: project_link_args,
dependencies: font_deps, dependencies: font_deps,

View File

@@ -12,7 +12,7 @@ else
if host_platform == 'windows' if host_platform == 'windows'
use_system_cert_provider = true use_system_cert_provider = true
client_files += files('WindowsCertProvider.cpp') client_files += files('WindowsCertProvider.cpp')
powder_deps += c_compiler.find_library('crypt32') powder_deps += cpp_compiler.find_library('crypt32')
endif endif
if host_platform == 'android' if host_platform == 'android'
use_system_cert_provider = true use_system_cert_provider = true

View File

@@ -1,8 +1,8 @@
if host_platform == 'windows' if host_platform == 'windows'
if use_bluescreen if use_bluescreen
project_deps += [ project_deps += [
c_compiler.find_library('dbghelp'), cpp_compiler.find_library('dbghelp'),
c_compiler.find_library('psapi'), cpp_compiler.find_library('psapi'),
] ]
endif endif
stacktrace_files = files('Windows.cpp') stacktrace_files = files('Windows.cpp')
@@ -18,7 +18,7 @@ elif host_platform == 'linux'
bluescreen_export_symbols = true bluescreen_export_symbols = true
if host_machine.system() in [ 'freebsd' ] if host_machine.system() in [ 'freebsd' ]
project_deps += [ project_deps += [
c_compiler.find_library('execinfo'), cpp_compiler.find_library('execinfo'),
] ]
endif endif
else else

View File

@@ -1,5 +1,7 @@
#include "LuaCompat.h" #include "LuaCompat.h"
extern "C"
{
#if LUA_VERSION_NUM >= 502 #if LUA_VERSION_NUM >= 502
// Implement missing luaL_typerror function // Implement missing luaL_typerror function
int luaL_typerror(lua_State *L, int narg, const char *tname) int luaL_typerror(lua_State *L, int narg, const char *tname)
@@ -27,3 +29,4 @@ void lua_pushglobaltable(lua_State *L)
} }
# endif # endif
#endif #endif
}

View File

@@ -1,9 +1,7 @@
#pragma once #pragma once
#ifdef __cplusplus
extern "C" extern "C"
{ {
#endif
#include <lua.h> #include <lua.h>
#include <lauxlib.h> #include <lauxlib.h>
@@ -23,6 +21,4 @@ LUALIB_API void (lua_pushglobaltable) (lua_State *L);
# endif # endif
#endif #endif
#ifdef __cplusplus
} }
#endif

View File

@@ -2,7 +2,7 @@ luaconsole_files = files(
'LuaButton.cpp', 'LuaButton.cpp',
'LuaBz2.cpp', 'LuaBz2.cpp',
'LuaCheckbox.cpp', 'LuaCheckbox.cpp',
'LuaCompat.c', 'LuaCompat.cpp',
'LuaComponent.cpp', 'LuaComponent.cpp',
'LuaElements.cpp', 'LuaElements.cpp',
'LuaEvent.cpp', 'LuaEvent.cpp',