Update ambuild tooling to work on both Windows / Linux with boost distrib (#3)

* Add Windows / msvc boost support on AMBuild

* Disable RTTI and use config on b2's side

* Update AMBuild to require boost's setup on Windows / Linux

* Remove HL2SDK and MM:S settings in configure/buildscript

* Indenting is hard
This commit is contained in:
nosoop
2020-03-22 17:35:54 -04:00
committed by GitHub
parent 624d2423c3
commit c168b3b4b4
3 changed files with 49 additions and 29 deletions
+15 -11
View File
@@ -26,7 +26,7 @@ class ExtensionConfig(object):
def __init__(self): def __init__(self):
self.extensions = [] self.extensions = []
self.sm_root = None self.sm_root = None
self.mms_root = None self.boost_root = None
@property @property
def tag(self): def tag(self):
@@ -49,15 +49,11 @@ class ExtensionConfig(object):
self.sm_root = Normalize(self.sm_root) self.sm_root = Normalize(self.sm_root)
def detectMetaMod(self): def detectBoost(self):
if builder.options.mms_path: if builder.options.boost_path:
self.mms_root = builder.options.mms_path self.boost_root = builder.options.boost_path
else: else:
self.mms_root = ResolveEnvPath('MMSOURCE110', 'mmsource-1.10') raise Exception('Could not find a copy of Boost')
if not self.mms_root:
self.mms_root = ResolveEnvPath('MMSOURCE', 'metamod-source')
if not self.mms_root:
self.mms_root = ResolveEnvPath('MMSOURCE_DEV', 'mmsource-central')
def configure(self): def configure(self):
cxx = builder.DetectCompilers() cxx = builder.DetectCompilers()
@@ -156,6 +152,7 @@ class ExtensionConfig(object):
'_CRT_SECURE_NO_WARNINGS', '_CRT_SECURE_NO_WARNINGS',
'_CRT_NONSTDC_NO_DEPRECATE', '_CRT_NONSTDC_NO_DEPRECATE',
'_ITERATOR_DEBUG_LEVEL=0', '_ITERATOR_DEBUG_LEVEL=0',
'_WIN32_WINNT=0x0601',
] ]
cxx.cflags += [ cxx.cflags += [
'/W3', '/W3',
@@ -181,6 +178,9 @@ class ExtensionConfig(object):
'odbccp32.lib', 'odbccp32.lib',
] ]
# setup boost libraries
cxx.linkflags += ['/LIBPATH:"' + os.path.join(self.boost_root, 'stage', 'x86', 'lib') + '"']
if builder.options.opt == '1': if builder.options.opt == '1':
cxx.cflags += ['/Ox', '/Zo'] cxx.cflags += ['/Ox', '/Zo']
cxx.linkflags += ['/OPT:ICF', '/OPT:REF'] cxx.linkflags += ['/OPT:ICF', '/OPT:REF']
@@ -196,7 +196,10 @@ class ExtensionConfig(object):
cxx.defines += ['_LINUX', 'POSIX'] cxx.defines += ['_LINUX', 'POSIX']
# link flags based off of socket Makefile # link flags based off of socket Makefile
cxx.linkflags += ['-lpthread', '-Wl,-Bstatic', '-lm', '-lboost_thread', '-lboost_system', '-lstdc++', '-Wl,-Bdynamic'] cxx.linkflags += ['-lpthread', '-Wl,-Bstatic', '-lm', '-lstdc++']
cxx.linkflags += ['-L', os.path.join(self.boost_root, 'stage', 'x86', 'lib')]
cxx.linkflags += ['-lboost_thread']
cxx.linkflags += ['-Wl,-Bdynamic']
if cxx.vendor == 'gcc': if cxx.vendor == 'gcc':
cxx.linkflags += ['-static-libgcc'] cxx.linkflags += ['-static-libgcc']
elif cxx.vendor == 'clang': elif cxx.vendor == 'clang':
@@ -224,6 +227,7 @@ class ExtensionConfig(object):
os.path.join(self.sm_root, 'sourcepawn', 'include'), os.path.join(self.sm_root, 'sourcepawn', 'include'),
os.path.join(self.sm_root, 'public', 'amtl', 'amtl'), os.path.join(self.sm_root, 'public', 'amtl', 'amtl'),
os.path.join(self.sm_root, 'public', 'amtl'), os.path.join(self.sm_root, 'public', 'amtl'),
os.path.join(self.boost_root)
] ]
return compiler return compiler
@@ -233,8 +237,8 @@ class ExtensionConfig(object):
return binary return binary
Extension = ExtensionConfig() Extension = ExtensionConfig()
Extension.detectMetaMod()
Extension.detectSourceMod() Extension.detectSourceMod()
Extension.detectBoost()
Extension.configure() Extension.configure()
# Add additional buildscripts here # Add additional buildscripts here
+32 -14
View File
@@ -1,16 +1,34 @@
SourceMod Socket Extension # SourceMod Socket Extension
========================== This has been forked from [sfPlayer's origin Git repository][socket-git].
This has been forked from [sfPlayer´s origin Git repository](http://player.to/gitweb/index.cgi?p=sm-ext-socket.git). Get to the [AlliedModders forum thread](https://forums.alliedmods.net/showthread.php?t=67640) for more information. Get to the [AlliedModders forum thread][socket-am] for more information.
Dependencies for building [socket-git]: http://player.to/gitweb/index.cgi?p=sm-ext-socket.git
------------------------- [socket-am]: https://forums.alliedmods.net/showthread.php?t=67640
* [SourceMod](https://github.com/alliedmodders/sourcemod)
* [Boost](http://www.boost.org/)
* ~~[msinttypes](https://code.google.com/p/msinttypes/)~~
Building on Windows ## Building with AMBuild
-------------------
Set the following environment variables on your system: ### Dependencies
* `SOURCEMOD` - path to SourceMod (>= 1.5.x) - [SourceMod][] toolchain (follow the instructions on [Building SourceMod][] to set up your
* `BOOST155` - path to boost libraries (>= 1.5.5) environment, if you haven't already)
* ~~`MSINTTYPES` - path to latest version of msinttypes~~ (Replaced "stdlib.h" with \<cstdlib\>) - [Boost][]
[SourceMod]: https://github.com/alliedmodders/sourcemod/
[Building SourceMod]: https://wiki.alliedmods.net/Building_SourceMod
[Boost]: http://www.boost.org/
### Configuration
1. Configure Boost.
- Download the release archive from the site and extract the archive to a location
`${BOOST_PATH}`. Set that location as your working directory.
- Run the `bootstrap` script for your platform to build `b2`. Pass `--with-toolset` with
either `msvc`, `gcc`, or `clang` depending on what compiler you plan on building with.
- Invoke `b2 define=BOOST_TYPE_INDEX_FORCE_NO_RTTI_COMPATIBILITY address-model=32 runtime-link=static link=static --build-dir=build/x86 --stagedir=stage/x86 --with-thread --with-date_time --with-regex`
to build the required libraries in mixed RTTI mode (boost will use RTTI, the extension will
not). The configuration should build fully static x86 libraries on both Withdows and Linux,
with versioned filenames on the former and system names on the latter (which allows us to
use `-lboost_*` without additional extensions when setting up the link flags on `ambuild`).
- If an existing build is present with a different configuration, use `-a` to force
rebuilding the libraries.
2. `cd build/` and run `../configure.py --sm-path ${SM_PATH} --boost-path ${BOOST_PATH}`
3. `ambuild` as normal.
+2 -4
View File
@@ -6,12 +6,10 @@ from ambuild2 import run
builder = run.PrepareBuild(sourcePath = sys.path[0]) builder = run.PrepareBuild(sourcePath = sys.path[0])
builder.options.add_option('--hl2sdk-root', type=str, dest='hl2sdk_root', default=None,
help='Root search folder for HL2SDKs')
builder.options.add_option('--mms-path', type=str, dest='mms_path', default=None,
help='Path to Metamod:Source')
builder.options.add_option('--sm-path', type=str, dest='sm_path', default=None, builder.options.add_option('--sm-path', type=str, dest='sm_path', default=None,
help='Path to SourceMod') help='Path to SourceMod')
builder.options.add_option('--boost-path', type=str, dest='boost_path', default=None,
help='Path to Boost')
builder.options.add_option('--enable-debug', action='store_const', const='1', dest='debug', builder.options.add_option('--enable-debug', action='store_const', const='1', dest='debug',
help='Enable debugging symbols') help='Enable debugging symbols')
builder.options.add_option('--enable-optimize', action='store_const', const='1', dest='opt', builder.options.add_option('--enable-optimize', action='store_const', const='1', dest='opt',