Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce meson build system #196

Draft
wants to merge 5 commits into
base: master
Choose a base branch
from
Draft
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
87 changes: 87 additions & 0 deletions core/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
core_src = [
'metamod.cpp',
'metamod_console.cpp',
'metamod_oslink.cpp',
'metamod_plugins.cpp',
'metamod_util.cpp',
'provider/provider_base.cpp',
'sourcehook/sourcehook.cpp',
'sourcehook/sourcehook_impl_chookidman.cpp',
'sourcehook/sourcehook_impl_chookmaninfo.cpp',
'sourcehook/sourcehook_impl_cproto.cpp',
'sourcehook/sourcehook_impl_cvfnptr.cpp',
'sourcehook/sourcehook_hookmangen.cpp',
'gamedll_bridge.cpp',
]

foreach sdk : get_option('sdks')
sdk_dep = dependency(sdk)

if sdk_dep.get_variable('engine') == 'source2'
sdk_src = [
'provider/source2/provider_source2.cpp',
]
sdk_cpp_args = [
'-DMETA_IS_SOURCE2',
]
else
sdk_src = [
'provider/source/provider_source.cpp',
'provider/source/provider_source_console.cpp',
'vsp_bridge.cpp',
]
endif

sdk_link_args = []
if target_machine.system() == 'linux'
if compiler.get_id() == 'gcc'
sdk_link_args += [
'-static-libgcc',
]
elif compiler.get_id() == 'clang'
sdk_link_args += [
'-lgcc_eh',
]
endif
sdk_link_args += [
'-static-libstdc++',
]
elif target_machine.system() == 'mac'
sdk_link_args += ['-liconv']
endif

if target_machine.cpu_family() == 'x86_64' and target_machine.system() != 'linux'
sdk_src += ['sourcehook/sourcehook_hookmangen_x86_64.cpp']
elif target_machine.cpu_family() == 'x86'
sdk_src += ['sourcehook/sourcehook_hookmangen_x86.cpp']
endif

build_target('metamod.' + sdk_dep.get_variable('suffix'),
name_prefix: '',
target_type: 'shared_library',
override_options: 'b_lundef=false',
sources: [
core_src,
sdk_src,
],
include_directories: [
core_inc,
loader_inc,
sourcehook_inc,
amtl_inc,
public_inc,
],
cpp_args: [
sdk_cpp_args
],
link_args: [
sdk_link_args,
],
dependencies: [
sdk_dep,
],
link_with: [
versionlib,
]
)
endforeach
60 changes: 60 additions & 0 deletions loader/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
loader_src = [
'loader.cpp',
'gamedll.cpp',
'serverplugin.cpp',
'utility.cpp',
]

if target_machine.system() == 'linux'
build_target('server',
target_type: 'shared_library',
override_options: 'b_lundef=false',
sources: loader_src,
include_directories: [
sourcehook_inc,
],
name_prefix: '',
cpp_args: [
'-DLIB_PREFIX=""',
'-DLIB_SUFFIX=".so"',
]
)

if target_machine.cpu_family() == 'x86_64'
build_target('libserver',
target_type: 'shared_library',
override_options: 'b_lundef=false',
sources: loader_src,
include_directories: [
sourcehook_inc,
],
name_prefix: '',
cpp_args: [
'-DLIB_PREFIX="lib"',
'-DLIB_SUFFIX=".so"',
]
)
elif target_machine.cpu_family() == 'x86'
build_target('server_i486',
target_type: 'shared_library',
override_options: 'b_lundef=false',
sources: loader_src,
include_directories: [
sourcehook_inc,
],
cpp_args: [
'-DLIB_PREFIX=""',
'-DLIB_SUFFIX="_i486.so"',
]
)
endif
else
build_target('server',
target_type: 'shared_library',
override_options: 'b_lundef=false',
sources: loader_src,
include_directories: [
sourcehook_inc,
],
)
endif
78 changes: 78 additions & 0 deletions meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
project('metamod', 'c', 'cpp', default_options: [
'warning_level=1',
'werror=true',
'cpp_std=c++14',
])

compiler = meson.get_compiler('cpp')
if compiler.get_id() == 'clang' or compiler.get_id() == 'gcc'
# C/C++ Defines
add_project_arguments([
'-Dstricmp=strcasecmp',
'-D_stricmp=strcasecmp',
'-D_snprintf=snprintf',
'-D_vsnprintf=vsnprintf',
'-DHAVE_STDINT_H',
'-DGNUC',
'-DCOMPILER_GCC',
], language: ['c', 'cpp'])

# C/C++ Arguments
add_project_arguments([
'-pipe',
'-fno-strict-aliasing',
'-Wno-uninitialized',
'-Wno-unused',
'-Wno-switch',
'-msse',
'-fPIC',
'-fno-omit-frame-pointer',
], language: ['c', 'cpp'])

# C++ Arguments
add_project_arguments([
'-fno-exceptions',
'-fno-rtti',
'-fno-threadsafe-statics',
'-Wno-non-virtual-dtor',
'-Wno-overloaded-virtual',
], language: 'cpp')

# Optional C++ Arguments
optional_arguments = [
'-Wno-delete-non-virtual-dtor',
'-mfpmath=sse',
'-Wno-implicit-exception-spec-mismatch',
'-Wno-expansion-to-defined',
'-Wno-inconsistent-missing-override',
'-Wno-deprecated-register',
'-Wno-deprecated',
'-Wno-implicit-int-float-conversion',
'-Wno-tautological-overlap-compare',
]
foreach arg : optional_arguments
if compiler.has_argument(arg)
add_project_arguments(arg, language: 'cpp')
endif
endforeach

# Platform Arguments
add_project_arguments('-D_LINUX', language: 'cpp')
add_project_arguments('-DPOSIX', language: 'cpp')
add_project_arguments('-D_FILE_OFFSET_BITS=64', language: 'cpp')
endif

if target_machine.cpu_family() == 'x86_64'
add_project_arguments('-DPLATFORM_64BITS', language: 'cpp')
add_project_arguments('-DX64BITS', language: 'cpp')
endif

public_inc = include_directories('public')
loader_inc = include_directories('loader')
core_inc = include_directories('core')
sourcehook_inc = include_directories('core/sourcehook')
amtl_inc = include_directories('third_party/amtl')

subdir('versionlib')
subdir('loader')
subdir('core')
26 changes: 26 additions & 0 deletions meson_options.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
option('sdks', type: 'array', choices: [
'csgo',
'hl2dm',
'nucleardawn',
'l4d2',
'dods',
'l4d',
'css',
'tf2',
'insurgency',
'sdk2013',
'dota',
'doi',
'orangebox',
'blade',
'episode1',
'bms',
'pvkii',
'mcv',
'darkm',
'swarm',
'bgt',
'eye',
'contagion',
'cs2',
])
2 changes: 2 additions & 0 deletions subprojects/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
hl2sdk-*
!hl2sdk-*.wrap
7 changes: 7 additions & 0 deletions subprojects/hl2sdk-cs2.wrap
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[wrap-git]
url = https://github.com/PeakKS/hl2sdk.git
revision = cs2
depth = 1

[provide]
cs2 = cs2_dep
46 changes: 46 additions & 0 deletions versionlib/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
fs = import('fs')
metamod_version_string = fs.read('../product.version').strip()

version_tag = metamod_version_string.split('-')

version = version_tag[0].split('.')
major = version[0]
minor = version[1]
release = version[2]

tag = version_tag[1]

revision = run_command('git', 'rev-list', '--count', 'HEAD', check: true).stdout().strip()
shorthash = run_command('git', 'log', '--pretty=format:%h', '-n', '1', check: true).stdout().strip()
product = '.'.join(major, minor, release)

if tag != ''
product += '-' + tag
if tag == 'dev'
product += '+' + revision
endif
endif

metamod_version_config = configuration_data({
'tag': tag,
'shorthash': shorthash,
'major': major,
'minor': minor,
'release': release,
'product': product,
'revision': revision,
})

configure_file(
input: 'metamod_version_auto.h.in',
output: 'metamod_version_auto.h',
configuration: metamod_version_config
)

versionlib = static_library(
'version',
'versionlib.cpp',
include_directories: [
public_inc,
]
)
16 changes: 16 additions & 0 deletions versionlib/metamod_version_auto.h.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#ifndef _METAMOD_AUTO_VERSION_INFORMATION_H_
#define _METAMOD_AUTO_VERSION_INFORMATION_H_

#define MMS_BUILD_TAG "@tag@"
#define MMS_BUILD_CSET "@shorthash@"
#define MMS_BUILD_MAJOR "@major@"
#define MMS_BUILD_MINOR "@minor@"
#define MMS_BUILD_RELEASE "@release@"
#define MMS_BUILD_LOCAL_REV "@revision@"

#define MMS_BUILD_UNIQUEID "@revision@:" MMS_BUILD_CSET

#define MMS_VERSION_STRING "@product@"
#define MMS_VERSION_FILE @major@,@minor@,@release@,0

#endif /* _METAMOD_AUTO_VERSION_INFORMATION_H_ */
Loading