From 41fe2a5826aa667ab53d70791c0b0ac2ad396101 Mon Sep 17 00:00:00 2001 From: PeakKS Date: Mon, 7 Oct 2024 10:15:40 -0400 Subject: [PATCH] meson: add hl2sdk-cs2 as subproject, build core --- core/meson.build | 107 ++++++++++++++++++++++++++++++++++++ meson.build | 11 +++- subprojects/.gitignore | 2 + subprojects/hl2sdk-cs2.wrap | 4 ++ 4 files changed, 123 insertions(+), 1 deletion(-) create mode 100644 core/meson.build create mode 100644 subprojects/.gitignore create mode 100644 subprojects/hl2sdk-cs2.wrap diff --git a/core/meson.build b/core/meson.build new file mode 100644 index 0000000..80cb904 --- /dev/null +++ b/core/meson.build @@ -0,0 +1,107 @@ +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_proj = subproject('hl2sdk-' + sdk) + + sdk_platforms = sdk_proj.get_variable('sdk_platforms') + if target_machine.system() not in sdk_platforms + error(sdk, 'not supported for', target_machine.system()) + elif target_machine.cpu_family() not in sdk_platforms[target_machine.system()] + error(sdk, 'not supported for', target_machine.system(), target_machine.cpu_family()) + endif + + sdk_suffix = sdk_proj.get_variable('sdk_suffix') + sdk_source2 = sdk_proj.get_variable('sdk_source2', false) + sdk_src = [] + sdk_inc = sdk_proj.get_variable('sdk_inc') + sdk_libs = sdk_proj.get_variable('sdk_libs') + sdk_deps = sdk_proj.get_variable('sdk_deps') + sdk_cpp_args = sdk_proj.get_variable('sdk_cpp_args') + sdk_link_args = [] + sdk_proto = sdk_proj.get_variable('sdk_proto') + sdk_proto_lib = sdk_proj.get_variable('sdk_proto_lib') + + if sdk_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 + + 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_suffix, + name_prefix: '', + target_type: 'shared_library', + override_options: 'b_lundef=false', + sources: [ + core_src, + sdk_src, + sdk_proto, + ], + include_directories: [ + core_inc, + sdk_inc, + loader_inc, + sourcehook_inc, + amtl_inc, + public_inc, + ], + cpp_args: [ + sdk_cpp_args, + ], + link_args: [ + sdk_link_args, + ], + dependencies: [ + sdk_deps, + ], + link_with: [ + versionlib, + sdk_libs, + ] + ) +endforeach \ No newline at end of file diff --git a/meson.build b/meson.build index 025e6c3..9f84af5 100644 --- a/meson.build +++ b/meson.build @@ -14,6 +14,7 @@ if compiler.get_id() == 'clang' or compiler.get_id() == 'gcc' '-D_vsnprintf=vsnprintf', '-DHAVE_STDINT_H', '-DGNUC', + '-DCOMPILER_GCC', ], language: ['c', 'cpp']) # C/C++ Arguments @@ -61,9 +62,17 @@ if compiler.get_id() == 'clang' or compiler.get_id() == 'gcc' 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') \ No newline at end of file +subdir('loader') +subdir('core') \ No newline at end of file diff --git a/subprojects/.gitignore b/subprojects/.gitignore new file mode 100644 index 0000000..32f8ff1 --- /dev/null +++ b/subprojects/.gitignore @@ -0,0 +1,2 @@ +hl2sdk-* +!hl2sdk-*.wrap diff --git a/subprojects/hl2sdk-cs2.wrap b/subprojects/hl2sdk-cs2.wrap new file mode 100644 index 0000000..a608b6d --- /dev/null +++ b/subprojects/hl2sdk-cs2.wrap @@ -0,0 +1,4 @@ +[wrap-git] +url = https://github.com/PeakKS/hl2sdk.git +revision = cs2 +depth = 1 \ No newline at end of file