Browse Source

wscript: rework subproject filtering, use lambdas everywhere. Deprecate --ignore-projects flag, use Waf capability to select targets instead

pull/2/head
Alibek Omarov 2 years ago
parent
commit
1fda8753bd
  1. 81
      wscript

81
wscript

@ -14,60 +14,44 @@ top = '.'
Context.Context.line_just = 55 # should fit for everything on 80x26 Context.Context.line_just = 55 # should fit for everything on 80x26
class Subproject: class Subproject:
name = '' def __init__(self, name, fnFilter = None):
dedicated = True # if true will be ignored when building dedicated server
singlebin = False # if true will be ignored when singlebinary is set
ignore = False # if true will be ignored, set by user request
mandatory = False
def __init__(self, name, dedicated=True, singlebin=False, mandatory = False, utility = False, fuzzer = False):
self.name = name self.name = name
self.dedicated = dedicated self.fnFilter = fnFilter
self.singlebin = singlebin
self.mandatory = mandatory
self.utility = utility
self.fuzzer = fuzzer
def is_enabled(self, ctx): def is_exists(self, ctx):
if not self.mandatory: return ctx.path.find_node(self.name + '/wscript')
if self.name in ctx.env.IGNORE_PROJECTS:
self.ignore = True
if self.ignore: def is_enabled(self, ctx):
return False if not self.is_exists(ctx):
if ctx.env.SINGLE_BINARY and self.singlebin:
return False
if ctx.env.DEST_OS == 'android' and self.singlebin:
return False
if ctx.env.DEDICATED and self.dedicated:
return False
if self.utility and not ctx.env.ENABLE_UTILS:
return False return False
if self.fuzzer and not ctx.env.ENABLE_FUZZER: if self.fnFilter:
return False return self.fnFilter(ctx)
return True return True
SUBDIRS = [ SUBDIRS = [
Subproject('3rdparty/opus', dedicated=False, mandatory=True), # always configured and built
Subproject('public', dedicated=False, mandatory = True), Subproject('public'),
Subproject('filesystem', dedicated=False, mandatory = True), Subproject('filesystem'),
Subproject('game_launch', singlebin=True), Subproject('engine'),
Subproject('ref_gl',), Subproject('stub/server'),
Subproject('ref_soft'),
Subproject('mainui'),
Subproject('vgui_support'),
Subproject('stub/server', dedicated=False),
Subproject('stub/client'),
Subproject('dllemu'), Subproject('dllemu'),
Subproject('engine', dedicated=False),
Subproject('utils/mdldec', utility=True), # disable only by engine feature, makes no sense to even parse subprojects in dedicated mode
Subproject('utils/run-fuzzer', fuzzer=True) Subproject('ref_gl', lambda x: not x.env.DEDICATED),
Subproject('ref_soft', lambda x: not x.env.DEDICATED),
Subproject('mainui', lambda x: not x.env.DEDICATED),
Subproject('vgui_support', lambda x: not x.env.DEDICATED),
Subproject('stub/client', lambda x: not x.env.DEDICATED),
Subproject('game_launch', lambda x: not x.env.SINGLE_BINARY and not x.env.DEST_OS != 'android'),
# disable only by external dependency presense
Subproject('3rdparty/opus', lambda x: not x.env.HAVE_SYSTEM_OPUS),
# enabled optionally
Subproject('utils/mdldec', lambda x: x.env.ENABLE_UTILS),
Subproject('utils/run-fuzzer', lambda x: x.env.ENABLE_FUZZER),
] ]
def subdirs(): def subdirs():
@ -94,9 +78,6 @@ def options(opt):
grp.add_option('--low-memory-mode', action = 'store', dest = 'LOW_MEMORY', default = 0, type = 'int', grp.add_option('--low-memory-mode', action = 'store', dest = 'LOW_MEMORY', default = 0, type = 'int',
help = 'enable low memory mode (only for devices have <128 ram)') help = 'enable low memory mode (only for devices have <128 ram)')
grp.add_option('--ignore-projects', action = 'store', dest = 'IGNORE_PROJECTS', default = None,
help = 'disable selected projects from build [default: %default]')
grp.add_option('--disable-werror', action = 'store_true', dest = 'DISABLE_WERROR', default = False, grp.add_option('--disable-werror', action = 'store_true', dest = 'DISABLE_WERROR', default = False,
help = 'disable compilation abort on warning') help = 'disable compilation abort on warning')
@ -111,8 +92,7 @@ def options(opt):
opt.load('compiler_optimizations subproject') opt.load('compiler_optimizations subproject')
for i in SUBDIRS: for i in SUBDIRS:
if not i.mandatory and not opt.path.find_node(i.name+'/wscript'): if not i.is_exists(opt):
i.ignore = True
continue continue
opt.add_subproject(i.name) opt.add_subproject(i.name)
@ -124,9 +104,6 @@ def options(opt):
def configure(conf): def configure(conf):
conf.load('fwgslib reconfigure compiler_optimizations') conf.load('fwgslib reconfigure compiler_optimizations')
if conf.options.IGNORE_PROJECTS:
conf.env.IGNORE_PROJECTS = conf.options.IGNORE_PROJECTS.split(',')
conf.env.MSVC_TARGETS = ['x86' if not conf.options.ALLOW64 else 'x64'] conf.env.MSVC_TARGETS = ['x86' if not conf.options.ALLOW64 else 'x64']
# Load compilers early # Load compilers early

Loading…
Cancel
Save