Drop meson support

I don't want to learn or maintain two build systems.  cmake is the javascript
of cross-platform build systems:  Yes, it's weird and old and crusty and you
can point out all sorts of problems with it.  But it's also what the
community is consolidating on.
This commit is contained in:
Fletcher Dunn
2020-08-31 17:16:29 -07:00
parent 3d35c23835
commit 174d27e707
8 changed files with 12 additions and 429 deletions
-48
View File
@@ -1,48 +0,0 @@
#!/bin/bash
#
# Meson build test
#
set -e
cleanup() {
echo "Cleaning up Meson build directories" >&2
rm -rf build-meson{,-ref,-sodium{,25519}}
}
trap cleanup EXIT
cleanup
MESON_ARGS=(
-Dlight_tests=true
-DWerror=true
)
BUILD_LIBSODIUM=1
# libsodium's AES implementation only works on x86_64
[[ $(uname -m) != x86_64 ]] && BUILD_LIBSODIUM=0
set -x
# Build lightweight test builds
meson . build-meson ${MESON_ARGS[@]} --buildtype debugoptimized
meson . build-meson-ref ${MESON_ARGS[@]} --buildtype debugoptimized -Duse_crypto25519=Reference
[[ $BUILD_LIBSODIUM -ne 0 ]] && meson . build-meson-sodium ${MESON_ARGS[@]} --buildtype debugoptimized -Duse_crypto=libsodium -Duse_crypto25519=libsodium
meson . build-meson-sodium25519 ${MESON_ARGS[@]} --buildtype debugoptimized -Duse_crypto25519=libsodium
# Build all targets
ninja -v -C build-meson
[[ $BUILD_LIBSODIUM -ne 0 ]] && ninja -v -C build-meson-sodium
ninja -v -C build-meson-sodium25519
ninja -v -C build-meson-ref
# Run basic tests
build-meson/tests/test_crypto
[[ $BUILD_LIBSODIUM -ne 0 ]] && build-meson-sodium/tests/test_crypto
build-meson-sodium25519/tests/test_crypto
build-meson-ref/tests/test_crypto
set +x
exit 0
+6 -6
View File
@@ -52,8 +52,8 @@ fi
msg "Image is $IMAGE:$IMAGE_TAG, sanitizers enabled: $BUILD_SANITIZERS"
# We need at least one build system available
has cmake || has meson || die "No build system available"
# Make sure cmake is installed
has cmake || die "cmake required"
# We also need at least one compiler
has_clang || has_gcc || die "No compiler available"
@@ -63,16 +63,16 @@ ccache -M4G
if has_clang; then
msg "Beginning build tests with Clang"
export CC="ccache clang" CXX="ccache clang++"
has meson && bash .travis/build-meson.sh
#export CC="ccache clang" CXX="ccache clang++"
#has meson && bash .travis/build-meson.sh
export CC=clang CXX=clang++
has cmake && bash .travis/build-cmake.sh
fi
if has_gcc; then
msg "Beginning build tests with GCC"
export CC="ccache gcc" CXX="ccache g++"
has meson && bash .travis/build-meson.sh
#export CC="ccache gcc" CXX="ccache g++"
#has meson && bash .travis/build-meson.sh
export CC=gcc CXX=g++
has cmake && bash .travis/build-cmake.sh
fi
+6 -17
View File
@@ -3,7 +3,8 @@ Building
## Dependencies
* CMake or Meson, and build tool like Ninja, GNU Make or Visual Studio
* CMake 3.10 or later
* A build tool like Ninja, GNU Make or Visual Studio
* A C++11-compliant compiler, such as:
* GCC 7.3 or later
* Clang 3.3 or later
@@ -51,13 +52,6 @@ $ cmake -G Ninja ..
$ ninja
```
Or Meson (supported...kind-of):
```
$ meson . build
$ ninja -C build
```
## Windows / Visual Studio
On Windows, you can use the [vcpkg](https://github.com/microsoft/vcpkg/) package manager.
@@ -229,7 +223,6 @@ a 32-bit build, install the i686 versions of these packages):
$ pacman -S \
git \
mingw-w64-x86_64-gcc \
mingw-w64-x86_64-meson \
mingw-w64-x86_64-openssl \
mingw-w64-x86_64-pkg-config \
mingw-w64-x86_64-protobuf
@@ -240,8 +233,10 @@ And finally, clone the repository and build it:
```
$ git clone https://github.com/ValveSoftware/GameNetworkingSockets.git
$ cd GameNetworkingSockets
$ meson . build
$ ninja -C build
$ mkdir build
$ cd build
$ cmake -G Ninja ..
$ ninja
```
**NOTE:** When building with MSYS2, be sure you launch the correct version of
@@ -267,9 +262,3 @@ This extension allows for configuring the CMake project and building it from
within the Visual Studio Code IDE.
VS Marketplace Link: https://marketplace.visualstudio.com/items?itemName=vector-of-bool.cmake-tools
### Meson by Ali Sabil
This extension comes in handy if you're editing the Meson build files.
VS Marketplace Link: https://marketplace.visualstudio.com/items?itemName=asabil.meson
-12
View File
@@ -1,12 +0,0 @@
cxx_compiler = meson.get_compiler('cpp')
dependencies = [
dep_threads,
dep_GameNetworkingSockets_so # Declared in the other project
]
executable('example_chat',
'example_chat.cpp',
dependencies: dependencies,
)
-121
View File
@@ -1,121 +0,0 @@
project('GameNetworkingSockets', 'cpp', 'c',
default_options: [
'buildtype=debugoptimized',
],
license: 'BSD'
)
flags_common = [
'-fno-strict-aliasing',
'-fvisibility=hidden',
]
target_os = target_machine.system()
if target_os == 'windows'
flags_common += [
'-fno-stack-protector',
]
else
flags_common += [
'-fstack-protector-strong',
'-fstack-clash-protection',
]
endif
flags_cxx = [
'-fno-rtti',
'-fno-exceptions',
'-fvisibility-inlines-hidden',
]
warn_flags_common = [
'-Wall',
'-Wextra',
# Explicitly disable noisy warnings
'-Wno-documentation',
'-Wno-implicit-fallthrough',
'-Wno-padded',
'-Wno-sign-compare',
'-Wno-sign-conversion',
'-Wno-signed-enum-bitfield',
'-Wno-unknown-pragmas',
'-Wno-unused-const-variable',
'-Wno-unused-local-typedef',
'-Wno-unused-parameter',
'-Wno-nested-anon-types',
'-Wno-format-truncation'
]
werror = get_option('Werror')
if werror
warn_flags_common += [ '-Werror' ]
endif
use_crypto_25519 = get_option('use_crypto25519')
if use_crypto_25519 == 'Reference'
warn_flags_common += [ '-Wno-unused-function' ]
endif
warn_flags_c = [
'-Wimplicit',
'-Wstrict-prototypes',
'-Wno-missing-prototypes',
]
warn_flags_cxx = [
'-Wno-c++98-compat',
'-Wno-c++98-compat-pedantic',
'-Wno-exit-time-destructors',
'-Wno-global-constructors',
'-Wno-non-virtual-dtor',
'-Wno-old-style-cast',
'-Wno-reorder',
# These ones are prolific but don't really matter. Most are in generated
# protobuf code.
'-Wno-zero-as-null-pointer-constant',
'-Wno-missing-variable-declarations',
]
c_compiler = meson.get_compiler('c')
cxx_compiler = meson.get_compiler('cpp')
c_flags = []
c_flags += c_compiler.first_supported_argument(['-std=c11', '-std=gnu99'])
foreach arg : flags_common + warn_flags_common + warn_flags_c
if c_compiler.has_argument(arg)
c_flags += [ arg ]
endif
endforeach
add_project_arguments(c_flags, language: 'c')
cxx_flags = []
cxx_flags += cxx_compiler.first_supported_argument(['-std=c++11', '-std=c++0x'])
foreach arg : flags_common + warn_flags_common + flags_cxx + warn_flags_cxx
if cxx_compiler.has_argument(arg)
cxx_flags += [ arg ]
endif
endforeach
add_project_arguments(cxx_flags, language: 'cpp')
# Preprocessor defines for platform and compiler
cpp_flags = []
if target_os == 'linux'
cpp_flags += ['-DPOSIX', '-DLINUX']
elif target_os == 'darwin'
cpp_flags += ['-DPOSIX', '-DOSX']
elif target_os == 'windows'
cpp_flags += ['-D_WIN32', '-DWIN32', '-D__STDC_FORMAT_MACROS=1', '-D__USE_MINGW_ANSI_STDIO=0']
else
error('Could not identify your target operating system')
endif
add_project_arguments(cpp_flags, language: 'c')
add_project_arguments(cpp_flags, language: 'cpp')
dep_threads = dependency('threads')
subdir('src')
subdir('tests')
subdir('examples')
-21
View File
@@ -1,21 +0,0 @@
option('light_tests',
type: 'boolean',
value: true,
description: 'Use smaller/shorter tests for simple integration testing (e.g. Travis)')
option('Werror',
type: 'boolean',
value: false,
description: 'Enable -Werror flag when compiling')
option('use_crypto',
type: 'combo',
value: 'OpenSSL',
description: 'Crypto library to use for AES/SHA256',
choices: ['OpenSSL', 'libsodium', 'BCrypt'])
option('use_crypto25519',
type: 'combo',
value: 'OpenSSL',
description: 'Crypto library to use for ed25519/curve25519',
choices: ['OpenSSL', 'libsodium', 'Reference'])
-165
View File
@@ -1,165 +0,0 @@
dependencies = []
c_compiler = meson.get_compiler('c')
protoc_bin = find_program('protoc')
protoc = generator(protoc_bin,
output : ['@BASENAME@.pb.cc', '@BASENAME@.pb.h'],
arguments : ['-I@CURRENT_SOURCE_DIR@/common', '--proto_path=@CURRENT_SOURCE_DIR@', '--cpp_out=@BUILD_DIR@', '@INPUT@'])
use_crypto = get_option('use_crypto')
use_crypto25519 = get_option('use_crypto25519')
if use_crypto == 'OpenSSL' or use_crypto25519 == 'OpenSSL'
min_libcrypto = dependency('libcrypto', version: '>=1.1.0')
good_libcrypto = dependency('libcrypto', version: '>=1.1.1', required: false)
if good_libcrypto.found()
dependencies += [ good_libcrypto ]
else
dependencies += [ min_libcrypto ]
endif
if use_crypto25519 == 'OpenSSL' and not good_libcrypto.found()
error('This version of OpenSSL does not support ed25519/curve25519. Please use -Duse_crypto25519=Reference or upgrade OpenSSL to 1.1.1 or later.')
endif
code = '''#include <openssl/evp.h>
int main(int argc, char **argv) {
EVP_MD_CTX_free(NULL);
return 0;
}
'''
result = c_compiler.links(code, dependencies: dependencies, name: 'EVP API')
if not result
error('Your OpenSSL version appears to be too old. Check that you\'re using OpenSSL 1.1.0 or later.')
endif
endif
if use_crypto == 'libsodium' or use_crypto25519 == 'libsodium'
dependencies += [ dependency('libsodium') ]
endif
dependencies += [
dep_threads,
dependency('protobuf', version: '>=3.0.0'),
]
incdirs = include_directories('.', '../include', 'common', 'public')
cpp_flags = [
'-DSTEAMNETWORKINGSOCKETS_FOREXPORT',
'-DVALVE_CRYPTO_ENABLE_25519',
'-DCRYPTO_DISABLE_ENCRYPT_WITH_PASSWORD',
'-DGOOGLE_PROTOBUF_NO_RTTI',
]
target_os = target_machine.system()
if target_os == 'windows'
dependencies += [
c_compiler.find_library('ws2_32'),
]
endif
protobuf_sources = [
'common/steamnetworkingsockets_messages_certs.proto',
'common/steamnetworkingsockets_messages.proto',
'common/steamnetworkingsockets_messages_udp.proto',
]
sources = [
'common/crypto_textencode.cpp',
'common/keypair.cpp',
'common/steamid.cpp',
'steamnetworkingsockets/clientlib/csteamnetworkingsockets.cpp',
'steamnetworkingsockets/clientlib/steamnetworkingsockets_flat.cpp',
'steamnetworkingsockets/clientlib/steamnetworkingsockets_connections.cpp',
'steamnetworkingsockets/clientlib/steamnetworkingsockets_lowlevel.cpp',
'steamnetworkingsockets/clientlib/steamnetworkingsockets_p2p.cpp',
'steamnetworkingsockets/clientlib/steamnetworkingsockets_snp.cpp',
'steamnetworkingsockets/clientlib/steamnetworkingsockets_udp.cpp',
'steamnetworkingsockets/steamnetworkingsockets_certs.cpp',
'steamnetworkingsockets/steamnetworkingsockets_certstore.cpp',
'steamnetworkingsockets/steamnetworkingsockets_shared.cpp',
'steamnetworkingsockets/steamnetworkingsockets_stats.cpp',
'steamnetworkingsockets/steamnetworkingsockets_thinker.cpp',
'tier0/dbg.cpp',
'tier0/platformtime.cpp',
'tier1/bitstring.cpp',
'tier1/ipv6text.c',
'tier1/netadr.cpp',
'tier1/utlbuffer.cpp',
'tier1/utlmemory.cpp',
'vstdlib/strtools.cpp',
]
if use_crypto == 'OpenSSL'
cpp_flags += [ '-DSTEAMNETWORKINGSOCKETS_CRYPTO_VALVEOPENSSL' ]
sources += [
'common/opensslwrapper.cpp',
'common/crypto_openssl.cpp',
]
endif
if use_crypto == 'BCrypt'
dependencies += [ c_compiler.find_library('bcrypt') ]
cpp_flags += [ '-DED25519_HASH_BCRYPT', '-DSTEAMNETWORKINGSOCKETS_CRYPTO_BCRYPT' ]
sources += [ 'common/crypto_bcrypt.cpp' ]
endif
if use_crypto == 'libsodium'
if target_machine.cpu_family() != 'x86' and target_machine.cpu_family() != 'x86_64'
error('-Duse_crypto=libsodium invalid, libsodium AES implementation only works on x86/x86_64 CPUs')
endif
cpp_flags += [ '-DSTEAMNETWORKINGSOCKETS_CRYPTO_LIBSODIUM' ]
sources += [ 'common/crypto_libsodium.cpp' ]
endif
if use_crypto25519 == 'OpenSSL'
cpp_flags += [ '-DSTEAMNETWORKINGSOCKETS_CRYPTO_25519_OPENSSL' ]
sources += [ 'common/crypto_25519_openssl.cpp' ]
endif
if use_crypto25519 == 'libsodium'
cpp_flags += [ '-DSTEAMNETWORKINGSOCKETS_CRYPTO_25519_LIBSODIUM' ]
sources += [ 'common/crypto_25519_libsodium.cpp' ]
endif
if use_crypto25519 == 'Reference'
cpp_flags += [ '-DVALVE_CRYPTO_25519_DONNA' ]
sources += [
'common/crypto_25519_donna.cpp',
'external/curve25519-donna/curve25519.c',
'external/curve25519-donna/curve25519_VALVE_sse2.c',
'external/ed25519-donna/ed25519_VALVE.c',
'external/ed25519-donna/ed25519_VALVE_sse2.c',
]
endif
protobufs = protoc.process(protobuf_sources)
GameNetworkingSockets_static = static_library('GameNetworkingSockets',
sources, protobufs,
c_args: cpp_flags,
cpp_args: cpp_flags,
include_directories: incdirs,
dependencies: dependencies)
dep_GameNetworkingSockets_static = declare_dependency(
include_directories: include_directories( '../include', '.' ),
compile_args: ['-DSTEAMNETWORKINGSOCKETS_STATIC_LINK'],
link_with: GameNetworkingSockets_static )
GameNetworkingSockets_so = library('GameNetworkingSockets',
sources, protobufs,
c_args: cpp_flags,
cpp_args: cpp_flags,
include_directories: incdirs,
dependencies: dependencies)
dep_GameNetworkingSockets_so = declare_dependency(
include_directories: include_directories( '../include', '.' ),
link_with: GameNetworkingSockets_so )
# vim: set ts=2 sts=2 sw=2 et:
-39
View File
@@ -1,39 +0,0 @@
common_deps = [ dep_threads ]
cppflags = [
'-DVALVE_CRYPTO_ENABLE_25519'
]
light_tests= get_option('light_tests')
if light_tests
cppflags += ['-DLIGHT_TESTS']
endif
executable('test_connection',
'test_connection.cpp',
dependencies: common_deps + [ dep_GameNetworkingSockets_so ],
cpp_args: cppflags,
)
executable('test_crypto',
'test_crypto.cpp',
dependencies: common_deps + [ dep_GameNetworkingSockets_static ],
cpp_args: cppflags + ['-DTEST_VECTOR_DIR="' + join_paths(meson.source_root(), 'tests/aesgcmtestvectors') + '/"'],
include_directories: include_directories('../src', '../src/public', '../src/common')
)
# !FIXME! Ug cannot link with the static lib, because we need to #define the hardcoded key.
# So we'll need the crypto and protobuf dependencies, and those are pretty complicated.
# We need to refactor these files to get that organized.
#executable('test_pki',
# 'test_pki.cpp',
# dependencies: common_deps,
# cpp_args: cppflags + ['-DSTEAMNETWORKINGSOCKETS_HARDCODED_ROOT_CA_KEY="ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOMPsJA3FUaQSsHkyYhWvcYt9v3XbwRBcWuVuayWGdK1"'],
# include_directories: include_directories('../src', '../include', '../src/public', '../src/common')
#)
#incdirs = include_directories('../include')
#executable('test_flat',
# 'test_flat.c',
# dependence: dependencies,
# include_directories: incdirs
#)