Commit Graph

194 Commits

Author SHA1 Message Date
David Anderson
6b6436db17 Update SourcePawn.
Fix fix an hl2sdk-mock build error.
2023-08-30 22:08:45 +02:00
Peace-Maker
3c0f700a6b Import DHooks + Dynamic Detouring
This is the latest DHooks version from 1314f2d1b4
2023-08-30 22:08:45 +02:00
David Anderson
f182feed9d Add support for ASAN. 2023-08-30 22:08:45 +02:00
Asher Baker
2e763c287c Fix build against released MM:S branches (#1607)
`SOURCE_ENGINE_MOCK` is part of the MM:S API and only available in 1.12
which is the dev branch of MM:S. We can build the mock SM build without
it anyway, but this is still a little gross as it is just missing loader
support which could be confusing.

This also changes AMBuildScript to first look for a checkout of MM:S
1.11 which has been the stable branch for a while, 1.10 is still allowed
as a fallback as that seems to still build without issue.
2023-08-30 22:08:45 +02:00
Nick Hastings
167e6d8571 On Linux, link against server libs instead of client (fixes META_CONPRINT). 2023-08-30 22:08:45 +02:00
Nick Hastings
800f613f92 Enable 64-bit builds for Blade Symphony. 2023-08-30 22:08:44 +02:00
David Anderson
c49d51206c Don't require hl2sdk-mock if sdks=all 2023-08-30 22:08:44 +02:00
David Anderson
74ad70ba30 Add support for hl2sdk-mock. 2023-08-30 22:08:44 +02:00
David Anderson
7c3cb49dfa Fix minimal rebuild. 2021-07-20 16:39:48 -07:00
peace-maker
845c20ad93
Start using Github Actions (#1488)
* Start using Github Actions

Build on windows and linux. Cannot build for macos,
since the builders only support xcode 10+ which dropped
x86 support.

* Build sourcepawn tooling as separate package

Upload build artifacts containing only spcomp and the includes.
This adds a new `--scripting-only` flag to configure.py which skips
everything and goes straight to building spcomp and packaging the
include folder with it.

* Only run the workflows for the master branch

* Split common operations into PackageHelpers file

Don't duplicate the code for packaging releases for the tooling-only packages. Instead use a common `PackageHelpers` class which provides the functionality common to both packages.

This replaces the explicit list of files to package with a directory scan, so we don't have to list them all.

The pgsql sql-init-scripts were missing from the release package before, so they were added here as well. Three scripts from the testsuite were missing from the explicit list (mapdisplayname, floats, findmap), so they're now included.

* Fix Python 2 compatibility

os.scandir is Python 3 only.
2021-05-09 01:46:08 +02:00
peace-maker
e5342afe2a
Add PostgreSQL database driver (#32)
* Add PostgreSQL DBI extension

Bug #3849
This adds a postgresql database driver called "pgsql".
The ambuild script changes could be very wrong ;)

* Add pgsql support to clientprefs

This was originally made by Lyfe in bug 3849! Thanks for that.
PostgreSQL supports the 'IF NOT EXISTS' clause when creating tables
since version 9.1, so i've switched to use that.

* Added pgsql support to sql-admin-manager

* Add --pgsql-path to ambuild configure

* More ambuild fixes

* Compile libpq with ambuild

* Try to generate postgres configs

* Add dummy config file

* More ambuild fixes

* Get errorcode and readable error in preparequery

No need to stop getting the errorCode, if the error string should be
retrieved. Just return both!

* Fix indentation in AMBuilderPGSQL

* Try to patch and configure postgres through ambuild

* Revert "Try to patch and configure postgres through ambuild"

This reverts commit 68dfc82b8eb0ce11f621af67ec247b5f47e4a189.

* Update to use PostgreSQL 9.4

* Move postgres preparation into seperate script

Fetching, preparing and configuring of the postgresql sourcecode
is done in a seperate prepare_postgresql.sh script now.

People can use this script for their manual builds,
if they don't want to use checkout-deps.sh.

* Add patch to configure.in again

Remove the version check for autoconf in postgres 9.4 too.

* Nit: Support older objdirs for hasPgSql ambuild option

* Update to use PostgreSQL 9.4.6

* Use newer AMTL and PGSQL 9.6

* Fix threaded queries

When running the thread part of a query, it already gets the atomic
lock. Don't try to get it twice in that case.

Use a seperate lock to protect access to the lastInsertID and
lastAffectedRows variables.

* Fix SetCharacterSet racing with threaded queries

Same fix like in the mysql driver.

* Use ke::AutoLock for lastInsertID mutex

* Fix fetching one more row than available

Don't try to access a row that doesn't exist when iterating rows.

* Improve sanity checks on column access

Don't call libpq functions with out of bounds column indices.

* Let QuoteString return false if quoting failed

* Fix build for x64 support changes and update to PGSQL 9.6.9

* Fix linux build

* Fix building of connection options string

snprintf doesn't support overlapping buffers.

* Update to PostgreSQL 9.6.15

* Fix crash after freeing first IQuery object

* Fix code crunch

* Fix memory leak, cleanup

* Nuke MSVC project and Makefile

* Remove unsupported numeric error codes

* Use STL threads

* Add prebuilt libpq for Linux and Windows

* Restore and fix version.rc file

* Add PostgreSQL build instructions

* Add prebuilt libpq for Mac

* Add win64 libpq build

This is version 9.6.15 since that's what I still had laying around.

* Fix buildscript

* Fix x64 build on linux and mac

Co-authored-by: Erik Minekus <tsunami@tsunami-productions.nl>
2021-03-11 11:21:51 +01:00
Headline
1cd0efad41
NPOTB: Fix no SDK target exception (#1359) 2020-11-07 13:14:58 -08:00
Peace-Maker
3eb2cd2971 Remove verbose hl2sdk-X not found warning
None of the available usage options have any use for such a warning.
2020-10-28 20:55:00 +01:00
David Anderson
d48cf93a94 Fix builder.target usage. 2020-10-22 23:41:01 -07:00
David Anderson
6e2c5a66b3 Remove use of the Dep API.
This is going away.
2020-08-24 20:48:57 -07:00
David Anderson
9acf2b5cda Use Python 3.8 on the Windows buildbot. 2020-08-19 00:39:54 -07:00
David Anderson
785c6aa1cf Update to AMBuild 2.2.
This is a pretty big diff because SourceMod had lots of multi-arch
workarounds that can now go away. I've also changed 'x64' to 'x86_64' in
many places since this is how AMBuild normalizes it, and it's far too
late to pick the shorter string, so we might as well suck it up.

The --target-archs parameter has been replaced with --targets. It works
the same way.

The default behavior for SDK inclusion is now "present" instead of
"all" since this lowers the burden of storing many SDKs. Official builds
will still be made with --sdks=all.
2020-08-18 23:09:43 -07:00
peace-maker
510bd261f8
core: Add Insurgency support for amd64 Windows (#1295)
* Add basic Insurgency support on Windows x64

This allows SourceMod to load on x64 Insurgency. There are still a lot of variable truncation warnings that have to be dealt with.

* Fix 32bit builds

* Compile MySQL extension as well

The hack for __iob_func being removed from the core runtime, but required by the old mysql we're building against can be simplified a lot due to the `_ReturnAddress` intrinsic available since MSVC 2015.

* Don't include the offset we want to extract in the signature
2020-08-06 19:53:06 -07:00
David Anderson
e5ddbd9886 Introduce a pbproxy library to solve macOS linker issues.
On SDKs which use protobufs, the engine has objects compiled against a specific
version of protobuf. Normally this is fine, we take care on Linux to use the
same C++ ABI. On macOS however, we use libc++ to enable C++11 functionality,
whereas the protobuf library has been compiled with libstc++. These ABIs are
not compatible.

To address the problem, we introduce PbHandle. PbHandle is a wrapper around
protobuf::Message with two added pieces of state: whether or not the handle
"owns" the message (and can free it in its destructor), and whether or not
the handle was created by the engine (private) or created by SourceMod
(local).

Whenever we transfer a protobuf::Message pointer to SourceMod, we must take
care to convert it to a Local version first. Whenever we transfer a protobuf
pointer to the engine, we must convert it to a Private handle.

For platforms with no ABI differences (almost all of them), the handle is a
no-op. The private and local localities are compatible and no translation
takes place.

On macOS, CS:GO does require translation. SourceMod loads a tiny shim
library that contains a copy of the protobuf sources compiled against the
game's ABI. It then provides serialization and deserialization methods.
SourceMod must not interact with the game's protobuf objects without first
going through this proxy library.

Note that PbHandle is not quite like unique_ptr. It can be converted into a
PbHandle that does not destroy the underlying object. This is mainly because
UserMessages.cpp has rather complex state, so it is useful to track locality
without destroying an object. An unowned PbHandle must not outlive the
owning PbHandle.
2020-05-30 22:13:07 -07:00
David Anderson
d525b466ec Use C++11 for macOS and CS:GO. 2020-05-30 22:13:07 -07:00
David Anderson
49669f6585 Revert "Fix linking on Linux."
This reverts commit acf8782786.
2020-05-26 20:04:55 -07:00
David Anderson
acf8782786 Fix linking on Linux. 2020-05-25 21:35:50 -07:00
David Anderson
c9f574c27b Fix mac build. 2020-05-20 22:50:41 -07:00
David Anderson
7a3e4054c7 Enable exception handling in C++ code.
It turns out this was already enabled on MSVC (due to /EHsc), but let's
enable it on other platforms as well.

Exception handling comes with a huge caveat: SourceMod and SourcePawn
are not exception safe. Not only do they predate usable STL (C++11),
they often predate C++03, and sometimes even C++ itself. There are many
places we do not use RAII, or where we accumulate state in a way that
cannot be interrupted.

By enabling exceptions, we are NOT inviting general try/catch. We are
still assuming that a `throw` anywhere within SourceMod will ultimately
result in a crash.

However, as we enable more and more STL, we are losing the ability to
gracefully handle constructor failures and malloc failures. So try-catch
is now enabled. It should only be used in the narrowest of
circumstances:

 - When an exception can be thrown by a library call, and
 - There is no way "a priori" to tell if an exception will be thrown
(for example, std::bad_alloc or std::system_error), and
 - Handling the exception is meaningful.

Generally malloc failures should not be considered meaningful. Once
memory is exhausted, the program will crash or be OOM-killed, so there's
no point in handling the failure. However, cases where the allocation
amount is variable may be meaningful to handle. A simple example would
be CDataPack, where if a plugin leaks entries, it's better to handle
this gracefully given that vector growth is geometric. Another example
might be reads of a massive file or network request into a buffer.

These cases should be rare, given that memory pressure is usually
fatal to srcds anyway. But if you've decided to handle an exception,
the try-catch block should be as narrow as possible. For example,
the following is erroneous:

    ke::Maybe<SomeGiganticThing> object;
    try {
        object.init();
    } catch (const std::bad_alloc&) {
    }

`ke::Maybe` is not threadsafe, and this can leak. Basically, do as
little as possible in try blocks, and use them sparingly, because
they're very difficult to audit.

We are also not inviting use of `throw`, as auditing it is even more
complex than try/catch. It is better to abort(), or use boolean
returns and two-stage object initialization.
2020-05-19 12:21:57 -07:00
David Anderson
ff018a9a5d Improve Travis coverage.
Our official builds use clang-3.4 (for macOS) and clang-3.8 for Linux.
Linux uses libstdc++-4.9. Make sure these two compilers are being tested
and that libstdc++-4.9 is being used for STL.

Add a macOS builder to get coverage there. This will use a newer
clang than we actually use, but as opposed to the linux builder will
test the platform-specific bits.

Finally, use the latest GCC and clang versions from a bionic image, so
we have some coverage of a popular distribution.
2020-05-13 19:09:20 -07:00
David Anderson
f76cb94511 Pare down ThreadSupport and remove ancient thread code.
This patch removes almost all of the existing platform-specific
ThreadSupport code, as well as code derived from it. It is now
implemented on top of C++11 threads and is much simpler.

This is the first inclusion of STL in SourceMod. Mac and Windows are
allowed to dynamically link to their respective implementations. On
Linux, libstdc++ is statically linked, except in the cases where it was
already dynamically linked (csgo, blade).

IEventSignal has been retained because sourcemod-curl-extension relies
on it. As written, it is impossible to use as a condition variable,
because the caller does not have access to the underlying mutex. There
is no way to make this API safe or non-racy, so extensions relying on
it should switch to C++11 threads.

ThreadWorker is now pared down and does not interact or inherit from
BaseWorker in any way. Basic functionality has been tested. Since it is
not used anywhere in SourceMod, or seemingly in any repository on
GitHub, it's unclear whether it should even exist. But it has been
tested in this patch.

This change bumps the minimum macOS version to OS X 10.7, and the
minimum C++ standard level to C++14.
2020-05-13 00:35:29 -07:00
David Anderson
87cc42d348 Fix build failures with clang 10. 2020-05-12 23:04:55 -07:00
Asher Baker
6465bd83a4 Update for latest Blade Symphony SDK 2020-03-11 22:36:25 +00:00
Asher Baker
bff8585411
Add an option to build against no SDKs (#1201) 2020-03-04 21:52:07 +00:00
Asher Baker
6a307bfcee
Restore the frame pointer on Linux (#1200)
Looks like the default here changed when we upgraded the Linux build server.

This is causing issues when debugging crash dumps.
2020-03-04 21:43:13 +00:00
Nicholas Hastings
1000d419fc Throw configuration error on unsupported compilers (#1029) 2019-11-15 16:40:39 -08:00
David Anderson
7ab3a3cfd9 Update SourcePawn to master.
This turns on the new expression parser by default.
2019-10-28 21:19:22 -07:00
Asher Baker
8ce99e0540 Link pthread library for Linux binaries 2019-07-24 14:47:13 +01:00
Headline
2164f5191e
Fix GCC 9 Builds (#1024) 2019-05-28 17:57:40 -07:00
Asher Baker
1ca4517f46 Revert "Remove arch loops from build scripts. (#889)"
This reverts commit 7ed329c11f.
2018-10-04 17:59:40 +00:00
David Anderson
7ed329c11f
Remove arch loops from build scripts. (#889)
This simplifies non-sdk build scripts by removing their loops over SM.archs. Instead the top-level
build script will re-evaluate them for each architecture.
2018-09-30 09:59:28 -07:00
peace-maker
9cc518e408 Fix MySQL extension build using vs2015 (#824)
MySQL defines its own timespec_t. Official mysql builds are built using VS2013, so you still need to compile the client library yourself to be able to link it, but this change makes the dbi extension compatible with future versions already.
2018-06-05 09:29:11 -04:00
Nicholas Hastings
4637cf9221
Use MySQL 5.5 for MySQL extension. (#786) 2018-03-20 17:12:30 -04:00
Scott Ehlert
ce1a4dcac0
64-bit support for CSGO on Linux and macOS (#705) 2017-12-20 01:56:23 -06:00
Nicholas Hastings
4007ec8cf8 Temp fix for load issues on Linux. 2017-12-05 20:44:53 -05:00
Nicholas Hastings
95afe72307
Separate out DOI build. (#718) 2017-11-03 15:45:16 -04:00
Scott Ehlert
27b69559a3 Really fix macOS build. 2017-10-26 20:38:25 -05:00
Kyle Sanderson
65bf85fcbe (Re-)Add support for gcc and clang3.9, 4.0, and 5.0. 2017-10-09 16:53:19 -07:00
Scott Ehlert
bbdecceb4b Switch to AMBuild 2.1 API. (#694) 2017-10-02 07:18:57 -05:00
peace-maker
8840ce905d Update to latest SourcePawn (#639) 2017-07-18 12:48:39 +01:00
Nicholas Hastings
ad3588d0aa Use newer MM:S api for Ep1/Original engine. (#548)
* Use newer MM:S api for Ep1/Original engine.

* Remove doubled FILENAME_1_6_EP1 define.
2017-01-11 21:25:00 -05:00
Nicholas Hastings
7fda6e412a Don't build for CS:GO on Mac anymore. (Game is 64-bit-only there now). 2016-10-13 20:54:54 -04:00
Nicholas Hastings
f668b3fe6c 🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍 2016-06-11 12:43:04 -04:00
Nicholas Hastings
f12924458f Merge branch 'vs2015' 2016-06-11 12:14:12 -04:00
Nicholas Hastings
40f2512317 Remove support for Source 1 Dota 2. (#496) 2016-04-26 23:18:47 -04:00