From bfcaba54dc15ede842fd7571e19a72a9b4faaa07 Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Tue, 30 Jan 2024 15:04:57 +0300 Subject: [PATCH] wscript: move werror flags into uselib --- engine/wscript | 2 +- filesystem/wscript | 2 +- game_launch/wscript | 2 +- public/wscript | 2 +- ref/gl/gl2_shim/wscript | 2 +- ref/gl/vgl_shim/wscript | 2 +- ref/gl/wscript | 2 +- ref/soft/wscript | 2 +- utils/mdldec/wscript | 2 +- utils/run-fuzzer/wscript | 3 +-- utils/xar/wscript | 2 +- wscript | 17 +++++++---------- 12 files changed, 18 insertions(+), 22 deletions(-) diff --git a/engine/wscript b/engine/wscript index 74eab406..e2a5157e 100644 --- a/engine/wscript +++ b/engine/wscript @@ -125,7 +125,7 @@ def build(bld): bld(name = 'engine_includes', export_includes = '. common common/imagelib', use = 'filesystem_includes') is_cxx_link = False - libs = [ 'engine_includes', 'public', 'dllemu' ] + libs = [ 'engine_includes', 'public', 'dllemu', 'werror' ] # basic build: dedicated only source = bld.path.ant_glob([ diff --git a/filesystem/wscript b/filesystem/wscript index daedf03f..294dceb8 100644 --- a/filesystem/wscript +++ b/filesystem/wscript @@ -18,7 +18,7 @@ def configure(conf): def build(bld): bld(name = 'filesystem_includes', export_includes = '.') - libs = [ 'filesystem_includes', 'sdk_includes' ] + libs = [ 'filesystem_includes', 'sdk_includes', 'werror' ] # on PSVita do not link any libraries that are already in the main executable, but add the includes target if bld.env.DEST_OS != 'psvita': diff --git a/game_launch/wscript b/game_launch/wscript index 29310701..3f3be0f5 100644 --- a/game_launch/wscript +++ b/game_launch/wscript @@ -33,7 +33,7 @@ def build(bld): bld(source = source, target = 'xash3d', # hl.exe features = 'c cxx cxxprogram', - use = 'sdk_includes DL USER32 SHELL32', + use = 'sdk_includes DL USER32 SHELL32 werror', rpath = bld.env.DEFAULT_RPATH, install_path = bld.env.BINDIR, subsystem = bld.env.MSVC_SUBSYSTEM diff --git a/public/wscript b/public/wscript index 4f7b24f4..e12c34f0 100644 --- a/public/wscript +++ b/public/wscript @@ -19,7 +19,7 @@ def build(bld): bld.stlib(source = bld.path.ant_glob('*.c'), target = 'public', features = 'c', - use = 'sdk_includes', + use = 'sdk_includes werror', subsystem = bld.env.MSVC_SUBSYSTEM) if bld.env.TESTS: diff --git a/ref/gl/gl2_shim/wscript b/ref/gl/gl2_shim/wscript index b34d7da2..6ce58332 100644 --- a/ref/gl/gl2_shim/wscript +++ b/ref/gl/gl2_shim/wscript @@ -12,7 +12,7 @@ def configure(conf): def build(bld): source = bld.path.ant_glob( [ '*.c' ] ) includes = [ '.' ] - libs = [ 'engine_includes', 'sdk_includes' ] + libs = [ 'engine_includes', 'sdk_includes', 'werror' ] bld.env.LDFLAGS += ['-fPIC'] bld.env.CFLAGS += ['-fPIC'] bld.stlib( diff --git a/ref/gl/vgl_shim/wscript b/ref/gl/vgl_shim/wscript index 13926864..9456b7ba 100644 --- a/ref/gl/vgl_shim/wscript +++ b/ref/gl/vgl_shim/wscript @@ -12,7 +12,7 @@ def configure(conf): def build(bld): source = bld.path.ant_glob( [ '*.c' ] ) includes = [ '.' ] - libs = [ 'engine_includes', 'sdk_includes' ] + libs = [ 'engine_includes', 'sdk_includes', 'werror' ] bld.env.LDFLAGS += ['-fPIC'] bld.env.CFLAGS += ['-fPIC'] bld.stlib( diff --git a/ref/gl/wscript b/ref/gl/wscript index 28e1ddd4..e6decf9b 100644 --- a/ref/gl/wscript +++ b/ref/gl/wscript @@ -32,7 +32,7 @@ def configure(conf): conf.check_cc(lib='log') def build(bld): - libs = [ 'engine_includes' ] + libs = [ 'engine_includes', 'werror' ] # on PSVita do not link any libraries that are already in the main executable, but add the includes target if bld.env.DEST_OS == 'psvita': libs += [ 'sdk_includes', 'vgl_shim' ] diff --git a/ref/soft/wscript b/ref/soft/wscript index 78de52d3..894ed88a 100644 --- a/ref/soft/wscript +++ b/ref/soft/wscript @@ -22,7 +22,7 @@ def configure(conf): conf.env.append_unique('DEFINES', 'REF_DLL') def build(bld): - libs = [ 'engine_includes' ] + libs = [ 'engine_includes', 'werror' ] # on PSVita do not link any libraries that are already in the main executable, but add the includes target if bld.env.DEST_OS == 'psvita': libs += [ 'sdk_includes' ] diff --git a/utils/mdldec/wscript b/utils/mdldec/wscript index 72b310d0..49ae07bc 100644 --- a/utils/mdldec/wscript +++ b/utils/mdldec/wscript @@ -20,7 +20,7 @@ def build(bld): target = 'mdldec', features = 'c cprogram', includes = '.', - use = 'engine_includes public M', + use = 'engine_includes public M werror', install_path = bld.env.BINDIR, subsystem = bld.env.CONSOLE_SUBSYSTEM ) diff --git a/utils/run-fuzzer/wscript b/utils/run-fuzzer/wscript index ba471aab..3229c29b 100644 --- a/utils/run-fuzzer/wscript +++ b/utils/run-fuzzer/wscript @@ -18,14 +18,13 @@ def configure(conf): def add_runner_target(bld, lib, func): source = bld.path.ant_glob('*.c') includes = '.' - libs = [ 'DL' ] bld( source = source, target = 'run-fuzzer-' + func, features = 'c cprogram', includes = includes, - use = libs, + use = 'DL werror', defines = ['FUNC="Fuzz_' + func + '"', 'LIB="' + lib + '"'], install_path = bld.env.BINDIR, subsystem = bld.env.CONSOLE_SUBSYSTEM diff --git a/utils/xar/wscript b/utils/xar/wscript index eba2402f..e5378760 100644 --- a/utils/xar/wscript +++ b/utils/xar/wscript @@ -13,7 +13,7 @@ def build(bld): target = 'xar', features = 'c cprogram', includes = '.', - use = 'public filesystem_includes', + use = 'public filesystem_includes werror', rpath = bld.env.DEFAULT_RPATH, install_path = bld.env.BINDIR, subsystem = bld.env.CONSOLE_SUBSYSTEM diff --git a/wscript b/wscript index d22f146f..219bc45b 100644 --- a/wscript +++ b/wscript @@ -340,11 +340,8 @@ def configure(conf): opt_cxxflags = [] # TODO: - cflags = conf.filter_cflags(opt_flags + opt_cflags, cflags) - cxxflags = conf.filter_cxxflags(opt_flags + opt_cxxflags, cxxflags) - - conf.env.append_unique('CFLAGS', cflags) - conf.env.append_unique('CXXFLAGS', cxxflags) + conf.env.CFLAGS_werror = conf.filter_cflags(opt_flags + opt_cflags, cflags) + conf.env.CXXFLAGS_werror = conf.filter_cxxflags(opt_flags + opt_cxxflags, cxxflags) conf.env.TESTS = conf.options.TESTS conf.env.ENABLE_UTILS = conf.options.ENABLE_UTILS @@ -425,7 +422,7 @@ def configure(conf): tgmath_usable = conf.check_cc(fragment='''#include const float val = 2, val2 = 3; int main(void){ return (int)(-asin(val) + cos(val2)); }''', - msg='Checking if tgmath.h is usable', mandatory=False, use='M') + msg='Checking if tgmath.h is usable', mandatory=False, use='M werror') conf.define_cond('HAVE_TGMATH_H', tgmath_usable) else: conf.undefine('HAVE_TGMATH_H') @@ -443,7 +440,7 @@ def configure(conf): int t2[(((64 * GB -1) % 671088649) == 268434537) && (((TB - (64 * GB -1) + 255) % 1792151290) == 305159546)? 1: -1]; int main(void) { return 0; }''', - msg='Checking if _FILE_OFFSET_BITS can be defined to 64', mandatory=False) + msg='Checking if _FILE_OFFSET_BITS can be defined to 64', mandatory=False, use='werror') if file_offset_bits_usable: conf.define('_FILE_OFFSET_BITS', 64) else: conf.undefine('_FILE_OFFSET_BITS') @@ -455,9 +452,9 @@ int main(int argc, char **argv) { strcasestr(argv[1], argv[2]); return 0; }''' int main(int argc, char **argv) { strchrnul(argv[1], 'x'); return 0; }''' def check_gnu_function(frag, msg, define): - if conf.check_cc(msg=msg, mandatory=False, fragment=frag): + if conf.check_cc(msg=msg, mandatory=False, fragment=frag, use='werror'): conf.define(define, 1) - elif conf.check_cc(msg='... with _GNU_SOURCE?', mandatory=False, fragment=frag, defines='_GNU_SOURCE=1'): + elif conf.check_cc(msg='... with _GNU_SOURCE?', mandatory=False, fragment=frag, defines='_GNU_SOURCE=1', use='werror'): conf.define(define, 1) conf.define('_GNU_SOURCE', 1) check_gnu_function(strcasestr_frag, 'Checking for strcasestr', 'HAVE_STRCASESTR') @@ -484,7 +481,7 @@ int main(int argc, char **argv) { strchrnul(argv[1], 'x'); return 0; }''' frag='''#include int main(void) { return !opus_custom_encoder_init((OpusCustomEncoder *)1, (const OpusCustomMode *)1, 1); }''' - if conf.check_cc(msg='Checking if opus supports custom modes', defines='CUSTOM_MODES=1', use='opus', fragment=frag, mandatory=False): + 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 conf.define('XASH_LOW_MEMORY', conf.options.LOW_MEMORY)