From 057b47555db40293817a756ae1a1c6348b30f9e0 Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Mon, 7 Oct 2024 18:11:29 +0300 Subject: [PATCH] 3rdparty: bzip2: add wscript for bzip2, check for system-wide bzip2, add readme note --- 3rdparty/bzip2/wscript | 35 +++++++++++++++++++++++++++++++++++ README.md | 4 ++-- engine/wscript | 2 +- wscript | 8 ++++++++ 4 files changed, 46 insertions(+), 3 deletions(-) create mode 100644 3rdparty/bzip2/wscript diff --git a/3rdparty/bzip2/wscript b/3rdparty/bzip2/wscript new file mode 100644 index 00000000..3e8c0cc1 --- /dev/null +++ b/3rdparty/bzip2/wscript @@ -0,0 +1,35 @@ +#! /usr/bin/env python +# encoding: utf-8 + +BZIP_CHECK='''#include +int main(void) { return BZ2_bzlibVersion() != NULL; } +''' + +def options(opt): + pass + +def configure(conf): + conf.define('_GNU_SOURCE', 1) + + if conf.env.DEST_OS == 'win32': + conf.define('BZ_LCCWIN32', 1) + else: + conf.define('BZ_UNIX', 1) + +def build(bld): + bld( + features = 'subst', + source = 'bzip2/bz_version.h.in', + target = 'bz_version.h', + BZ_VERSION='1.1.0-fwgs' + ) + + bld.stlib( + source = bld.path.ant_glob(['bzip2/*.c']), + target = 'bzip2', + use = 'bz_version.h', + features = 'c', + includes = ['bzip2/', '.'], + subsystem = bld.env.MSVC_SUBSYSTEM, + export_includes = ['bzip2/'] + ) diff --git a/README.md b/README.md index 934153cc..8c04853f 100644 --- a/README.md +++ b/README.md @@ -67,9 +67,9 @@ This repository contains our fork of HLSDK and restored source code for Half-Lif `$ sudo dpkg --add-architecture i386` * Install development tools * For 32-bit engine on amd64: \ - `$ sudo apt install build-essential gcc-multilib g++-multilib python libsdl2-dev:i386 libfontconfig-dev:i386 libfreetype6-dev:i386 libopus-dev:i386` + `$ sudo apt install build-essential gcc-multilib g++-multilib python libsdl2-dev:i386 libfontconfig-dev:i386 libfreetype6-dev:i386 libopus-dev:i386 libbz2-dev:i386` * For everything else: \ - `$ sudo apt install build-essential python libsdl2-dev libfontconfig-dev libfreetype6-dev libopus-dev` + `$ sudo apt install build-essential python libsdl2-dev libfontconfig-dev libfreetype6-dev libopus-dev libbz2-dev` * Clone this repostory: `$ git clone --recursive https://github.com/FWGS/xash3d-fwgs` diff --git a/engine/wscript b/engine/wscript index 14a07035..16075adb 100644 --- a/engine/wscript +++ b/engine/wscript @@ -222,7 +222,7 @@ def build(bld): 'client/*.c', 'client/vgui/*.c', 'client/avi/*.c']) - libs += ['opus'] + libs += ['opus', 'bzip2'] includes = ['server', 'client', 'client/vgui' ] diff --git a/wscript b/wscript index c14d2453..4f79c96f 100644 --- a/wscript +++ b/wscript @@ -79,6 +79,7 @@ SUBDIRS = [ Subproject('ref/gl', lambda x: not x.env.DEDICATED and (x.env.GL or x.env.NANOGL or x.env.GLWES or x.env.GL4ES)), Subproject('ref/soft', lambda x: not x.env.DEDICATED and not x.env.SUPPORT_BSP2_FORMAT and x.env.SOFT), Subproject('ref/null', lambda x: not x.env.DEDICATED and x.env.NULL), + Subproject('3rdparty/bzip2', lambda x: not x.env.DEDICATED and not x.env.HAVE_SYSTEM_BZ2), Subproject('3rdparty/mainui', lambda x: not x.env.DEDICATED), Subproject('3rdparty/vgui_support', lambda x: not x.env.DEDICATED), # Subproject('3rdparty/freevgui', lambda x: not x.env.DEDICATED), @@ -459,6 +460,13 @@ int main(void) { return !opus_custom_encoder_init((OpusCustomEncoder *)1, (const if conf.check_cc(msg='Checking if opus supports custom modes', defines='CUSTOM_MODES=1', use='opus werror', fragment=frag, mandatory=False): conf.env.HAVE_SYSTEM_OPUS = True + # search for bzip2 + BZIP2_CHECK='''#include +int main(void) { return (int)BZ2_bzlibVersion(); }''' + + if conf.check_cc(lib='bz2', fragment=BZIP2_CHECK, uselib_store='bzip2', mandatory=False): + conf.env.HAVE_SYSTEM_BZ2 = True + conf.define('XASH_LOW_MEMORY', conf.options.LOW_MEMORY) for i in SUBDIRS: