Share object files between powder/render/font

I'm not sure why we weren't using static_libraries to begin with; most likely because the object files (as opposed to the sources) were not possible to share due to different sets of macros being defined in cpp_args, see 3a591b8539 to 4f0c365e05.
This commit is contained in:
Tamás Bálint Misius
2025-05-07 18:32:41 +02:00
parent 3511d047ac
commit 6784d8a10f
9 changed files with 87 additions and 62 deletions

View File

@@ -459,9 +459,7 @@ foreach embedded_file : embedded_files
endforeach
powder_files += powder_external_files
powder_files += data_files
render_files += data_files
font_files += data_files
common_files += data_files
if host_platform == 'emscripten'
project_link_args += [
@@ -487,17 +485,49 @@ endif
clang_tidy_sources = []
sta_libs = {}
foreach sta_info : [
[ 'common', common_files, [
host_platform == 'android' ? sdl2_dep : [],
png_dep,
zlib_dep,
bzip2_dep,
] ],
[ 'gui', gui_files, [
sdl2_dep,
] ],
[ 'simulation', simulation_files, [
json_dep,
] ],
]
sta_name = sta_info[0]
sta_srcs = sta_info[1]
sta_deps = sta_info[2]
sta_libs += { sta_name: declare_dependency(
include_directories: project_inc,
link_with: static_library(
sta_name,
sources: sta_srcs,
include_directories: project_inc,
cpp_args: project_cpp_args,
override_options: target_options,
pic: host_platform == 'android',
dependencies: sta_deps,
),
dependencies: sta_deps,
) }
clang_tidy_sources += sta_srcs
endforeach
if get_option('build_powder')
powder_deps += project_deps + [
threads_dep,
zlib_dep,
png_dep,
sdl2_dep,
lua_dep,
curl_dep,
fftw_dep,
bzip2_dep,
json_dep,
sta_libs['common'],
sta_libs['gui'],
sta_libs['simulation'],
]
if host_platform == 'android'
powder_sha = shared_library(
@@ -530,15 +560,13 @@ if get_option('build_powder')
endif
if get_option('build_render')
if host_platform == 'emscripten'
error('render does not target emscripten')
if host_platform in [ 'android', 'emscripten' ]
error('render does not target @0@'.format(host_platform))
endif
render_deps = project_deps + [
threads_dep,
zlib_dep,
bzip2_dep,
json_dep,
png_dep,
sta_libs['common'],
sta_libs['simulation'],
]
render_link_args = project_link_args
if host_platform == 'linux' and is_static
@@ -559,16 +587,13 @@ if get_option('build_render')
endif
if get_option('build_font')
if host_platform == 'emscripten'
error('font does not target emscripten')
if host_platform in [ 'android', 'emscripten' ]
error('font does not target @0@'.format(host_platform))
endif
font_deps = project_deps + [
threads_dep,
zlib_dep,
png_dep,
sdl2_dep,
bzip2_dep,
json_dep,
sta_libs['common'],
sta_libs['gui'],
]
executable(
'font',

View File

@@ -0,0 +1,36 @@
#include "Clipboard.h"
#include "client/GameSave.h"
namespace Clipboard
{
void SetClipboardData(std::unique_ptr<GameSave> data)
{
}
const GameSave *GetClipboardData()
{
return nullptr;
}
void Init()
{
}
bool GetEnabled()
{
return false;
}
void SetEnabled(bool)
{
}
void RecreateWindow()
{
}
std::optional<String> Explanation()
{
return std::nullopt;
}
}

View File

@@ -1,36 +1,12 @@
#include "Clipboard.h"
#include "client/GameSave.h"
namespace Clipboard
{
void SetClipboardData(std::unique_ptr<GameSave> data)
{
}
const GameSave *GetClipboardData()
{
return nullptr;
}
void Init()
{
}
bool GetEnabled()
{
return false;
}
void SetEnabled(bool)
{
}
void RecreateWindow()
{
}
std::optional<String> Explanation()
{
return std::nullopt;
}
}

View File

@@ -33,7 +33,7 @@ if platform_clipboard
endif
powder_files += files('Dynamic.cpp')
else
powder_files += files('Null.cpp')
powder_files += files('Local.cpp')
endif
render_files += files('Null.cpp')
font_files += files('Null.cpp')

View File

@@ -8,6 +8,6 @@ powder_graphics_files = files(
'Renderer.cpp',
)
powder_files += graphics_files + powder_graphics_files
render_files += graphics_files + powder_graphics_files
font_files += graphics_files
common_files += graphics_files
powder_files += powder_graphics_files
render_files += powder_graphics_files

View File

@@ -21,6 +21,3 @@ subdir('save')
subdir('search')
subdir('tags')
subdir('update')
powder_files += gui_files
font_files += gui_files

View File

@@ -203,10 +203,6 @@ subdir('resampler')
subdir('simulation')
subdir('tasks')
powder_files += common_files
render_files += common_files
font_files += common_files
simulation_elem_defs = []
foreach elem_name_id : simulation_elem_ids
simulation_elem_defs += 'ELEMENT_DEFINE(' + elem_name_id[0] + ', ' + elem_name_id[1].to_string() + ');'

View File

@@ -2,6 +2,4 @@ resampler_files = files(
'resampler.cpp',
)
powder_files += resampler_files
render_files += resampler_files
font_files += resampler_files
common_files += resampler_files

View File

@@ -16,9 +16,6 @@ subdir('elements')
subdir('simtools')
subdir('gravity')
powder_files += simulation_files
render_files += simulation_files
powder_files += files(
'AccessPropertyParse.cpp',
'Editing.cpp',