build: refactor

This commit is contained in:
Aydar Zarifullin 2024-03-09 23:30:30 +04:00 committed by GitHub
parent beef42249e
commit 4de8c65c0d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -5,48 +5,37 @@ project('TR1X', ['c'],
],
)
warning_level = 3
c_compiler = meson.get_compiler('c')
is_mingw = c_compiler.get_id() == 'gcc' and host_machine.system() == 'windows'
if is_mingw
add_project_link_arguments([], language: 'c')
endif
build_opts = [
'-Wno-unused',
'-DMESON_BUILD',
]
c_opts = []
add_project_arguments(build_opts + c_opts, language: 'c')
add_project_arguments(build_opts, language: 'c')
staticdeps = get_option('staticdeps')
null_dep = dependency('', required: false)
if host_machine.system() == 'windows'
dep_opengl32 = c_compiler.find_library('opengl32')
dep_opengl = c_compiler.find_library('opengl32')
else
dep_opengl32 = dependency('GL')
dep_opengl = dependency('GL')
endif
null_dep = dependency('', required: false)
dep_avcodec = dependency('libavcodec', static: staticdeps)
dep_avformat = dependency('libavformat', static: staticdeps)
dep_avutil = dependency('libavutil', static: staticdeps)
dep_backtrace = dependency('libbacktrace', static: staticdeps, required: false)
dep_backtrace = c_compiler.find_library('backtrace', static: staticdeps, required: false)
dep_swscale = dependency('libswscale', static: staticdeps)
dep_swresample = dependency('libswresample', static: staticdeps)
dep_sdl2 = dependency('SDL2', static: staticdeps)
dep_zlib = null_dep
if not staticdeps
dep_zlib = dependency('zlib', static: staticdeps)
endif
dep_mathlibrary = c_compiler.find_library('m', required : false, static: staticdeps)
dep_sdl2 = dependency('SDL2', static: staticdeps)
# autogenerated files
resources = []
python3 = find_program('python3', required: true)
@ -67,6 +56,7 @@ init = custom_target(
command: [python3, meson.source_root() + '/tools/generate_init', '--version-file', '@INPUT@', '-o', '@OUTPUT0@'],
build_by_default: true,
)
version_rc = custom_target(
'fake_version',
depends: [version],
@ -75,21 +65,25 @@ version_rc = custom_target(
command: [python3, meson.source_root() + '/tools/generate_rcfile', '--version-file', '@INPUT@', '-o', '@OUTPUT0@'],
build_by_default: true,
)
icon_rc = custom_target(
'fake_icon',
input: [version[0]],
output: ['icon.rc'],
command: [python3, meson.source_root() + '/tools/generate_rcfile', '--version-file', '@INPUT@', '-o', '@OUTPUT0@'],
)
link_args = []
if host_machine.system() == 'windows'
windows = import('windows')
resources = [
windows.compile_resources(version_rc),
windows.compile_resources(icon_rc),
]
link_args = ['-static']
else
link_args = []
link_args += ['-static']
endif
sources = [
@ -296,21 +290,20 @@ dependencies = [
dep_avcodec,
dep_avformat,
dep_avutil,
dep_opengl32,
dep_opengl,
dep_sdl2,
dep_swresample,
dep_swscale,
dep_zlib,
dep_mathlibrary,
dep_backtrace
]
if dep_backtrace.found() and host_machine.system() == 'linux'
sources += ['src/specific/s_log_linux.c']
dependencies += [dep_backtrace]
elif dep_backtrace.found() and host_machine.system() == 'windows'
sources += ['src/specific/s_log_windows.c']
dep_win_dbghelp = c_compiler.find_library('dbghelp')
dependencies += [dep_win_dbghelp]
dep_dbghelp = c_compiler.find_library('dbghelp')
dependencies += [dep_dbghelp]
else
sources += ['src/specific/s_log_unknown.c']
endif
@ -318,7 +311,6 @@ endif
executable(
'TR1X',
sources,
name_prefix: '',
include_directories: ['src/'],
dependencies: dependencies,
link_args: link_args,