Add waf buildscript, a reference waf build, that can be copied to any FWGS project, make env names for subproject more complex to avoid collision, add subproject test
This commit is contained in:
parent
c331a35bc8
commit
9ba31f9ed2
4
.gitignore
vendored
Normal file
4
.gitignore
vendored
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
build/*
|
||||||
|
.waf*
|
||||||
|
.lock*
|
||||||
|
*.pyc
|
10
build-waf.sh
Normal file
10
build-waf.sh
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
TOOLS="msvc,clang_compilation_database"
|
||||||
|
PRELUDE=$'\tsys.path.insert(0, \'scripts/waifulib\')'
|
||||||
|
|
||||||
|
pushd wafsrc
|
||||||
|
./waf-light "--tools=$TOOLS" "--prelude=$PRELUDE"
|
||||||
|
mv waf ../
|
||||||
|
popd
|
||||||
|
|
@ -7,10 +7,13 @@ Subproject tool
|
|||||||
|
|
||||||
Helps you have standalone environment for each subproject(subdirectory)
|
Helps you have standalone environment for each subproject(subdirectory)
|
||||||
|
|
||||||
Usage::
|
Usage:
|
||||||
|
def options(opt):
|
||||||
|
opt.load('subproject')
|
||||||
|
|
||||||
def configure(conf):
|
def configure(conf):
|
||||||
conf.add_subproject('folder1 folder2')
|
conf.add_subproject('folder1 folder2')
|
||||||
|
|
||||||
def build(bld):
|
def build(bld):
|
||||||
bld.add_subproject('folder1 folder2')
|
bld.add_subproject('folder1 folder2')
|
||||||
'''
|
'''
|
||||||
@ -22,19 +25,20 @@ DEPTH = ''
|
|||||||
|
|
||||||
def depth_push(path):
|
def depth_push(path):
|
||||||
global DEPTH
|
global DEPTH
|
||||||
|
|
||||||
DEPTH = os.path.join(DEPTH, path)
|
DEPTH = os.path.join(DEPTH, path)
|
||||||
# print DEPTH
|
# print DEPTH
|
||||||
|
|
||||||
def depth_pop():
|
def depth_pop():
|
||||||
global DEPTH
|
global DEPTH
|
||||||
|
|
||||||
DEPTH = os.path.dirname(DEPTH)
|
DEPTH = os.path.dirname(DEPTH)
|
||||||
# print DEPTH
|
# print DEPTH
|
||||||
|
|
||||||
def depth():
|
def get_name_by_depth():
|
||||||
global DEPTH
|
global DEPTH
|
||||||
return DEPTH
|
|
||||||
|
return DEPTH.replace(os.sep, '_')
|
||||||
|
|
||||||
def opt(f):
|
def opt(f):
|
||||||
"""
|
"""
|
||||||
@ -49,12 +53,12 @@ def opt(f):
|
|||||||
@opt
|
@opt
|
||||||
def add_subproject(ctx, names):
|
def add_subproject(ctx, names):
|
||||||
names_lst = Utils.to_list(names)
|
names_lst = Utils.to_list(names)
|
||||||
|
|
||||||
for name in names_lst:
|
for name in names_lst:
|
||||||
depth_push(name)
|
depth_push(name)
|
||||||
|
|
||||||
wscript_path = os.path.join(depth(), 'wscript')
|
wscript_path = os.path.join(DEPTH, 'wscript')
|
||||||
|
|
||||||
if not os.path.isfile(wscript_path):
|
if not os.path.isfile(wscript_path):
|
||||||
# HACKHACK: this way we get warning message right in the help
|
# HACKHACK: this way we get warning message right in the help
|
||||||
# so this just becomes more noticeable
|
# so this just becomes more noticeable
|
||||||
@ -66,8 +70,8 @@ def add_subproject(ctx, names):
|
|||||||
|
|
||||||
def options(opt):
|
def options(opt):
|
||||||
grp = opt.add_option_group('Subproject options')
|
grp = opt.add_option_group('Subproject options')
|
||||||
|
|
||||||
grp.add_option('-S', '--skip-subprojects', action='store', dest = 'SKIP_SUBDIRS', default=None,
|
grp.add_option('-S', '--skip-subprojects', action='store', dest = 'SKIP_SUBDIRS', default=None,
|
||||||
help = 'don\'t recurse into specified subprojects. Use only directory name.')
|
help = 'don\'t recurse into specified subprojects. Use only directory name.')
|
||||||
|
|
||||||
def get_subproject_env(ctx, path, log=False):
|
def get_subproject_env(ctx, path, log=False):
|
||||||
@ -90,28 +94,26 @@ def get_subproject_env(ctx, path, log=False):
|
|||||||
if log: Logs.pprint('YELLOW', 'env: changed to default env')
|
if log: Logs.pprint('YELLOW', 'env: changed to default env')
|
||||||
raise IndexError('top env')
|
raise IndexError('top env')
|
||||||
|
|
||||||
|
|
||||||
def configure(conf):
|
|
||||||
if conf.options.SKIP_SUBDIRS:
|
|
||||||
conf.env.IGNORED_SUBDIRS = conf.options.SKIP_SUBDIRS.split(',')
|
|
||||||
|
|
||||||
@Configure.conf
|
@Configure.conf
|
||||||
def add_subproject(ctx, names):
|
def add_subproject(ctx, names):
|
||||||
names_lst = Utils.to_list(names)
|
names_lst = Utils.to_list(names)
|
||||||
|
|
||||||
if isinstance(ctx, Configure.ConfigurationContext):
|
if isinstance(ctx, Configure.ConfigurationContext):
|
||||||
|
if not ctx.env.IGNORED_SUBDIRS and ctx.options.SKIP_SUBDIRS:
|
||||||
|
ctx.env.IGNORED_SUBDIRS = ctx.options.SKIP_SUBDIRS.split(',')
|
||||||
|
|
||||||
for name in names_lst:
|
for name in names_lst:
|
||||||
depth_push(name)
|
depth_push(name)
|
||||||
if name in ctx.env.IGNORED_SUBDIRS:
|
if name in ctx.env.IGNORED_SUBDIRS:
|
||||||
ctx.msg(msg='--X %s' % depth(), result='ignored', color='YELLOW')
|
ctx.msg(msg='--X %s' % DEPTH, result='ignored', color='YELLOW')
|
||||||
depth_pop()
|
depth_pop()
|
||||||
continue
|
continue
|
||||||
saveenv = ctx.env
|
saveenv = ctx.env
|
||||||
ctx.setenv(name, ctx.env) # derive new env from previous
|
ctx.setenv(get_name_by_depth(), ctx.env) # derive new env from previous
|
||||||
ctx.env.ENVNAME = name
|
ctx.env.ENVNAME = name
|
||||||
ctx.msg(msg='--> %s' % depth(), result='in progress', color='BLUE')
|
ctx.msg(msg='--> %s' % DEPTH, result='in progress', color='BLUE')
|
||||||
ctx.recurse(name)
|
ctx.recurse(name)
|
||||||
ctx.msg(msg='<-- %s' % depth(), result='done', color='BLUE')
|
ctx.msg(msg='<-- %s' % DEPTH, result='done', color='BLUE')
|
||||||
ctx.setenv('') # save env changes
|
ctx.setenv('') # save env changes
|
||||||
ctx.env = saveenv # but use previous
|
ctx.env = saveenv # but use previous
|
||||||
depth_pop()
|
depth_pop()
|
||||||
@ -119,9 +121,12 @@ def add_subproject(ctx, names):
|
|||||||
if not ctx.all_envs:
|
if not ctx.all_envs:
|
||||||
ctx.load_envs()
|
ctx.load_envs()
|
||||||
for name in names_lst:
|
for name in names_lst:
|
||||||
|
depth_push(name)
|
||||||
if name in ctx.env.IGNORED_SUBDIRS:
|
if name in ctx.env.IGNORED_SUBDIRS:
|
||||||
|
depth_pop()
|
||||||
continue
|
continue
|
||||||
saveenv = ctx.env
|
saveenv = ctx.env
|
||||||
ctx.env = ctx.all_envs[name]
|
ctx.env = ctx.all_envs[get_name_by_depth()]
|
||||||
ctx.recurse(name)
|
ctx.recurse(name)
|
||||||
ctx.env = saveenv
|
ctx.env = saveenv
|
||||||
|
depth_pop()
|
||||||
|
22
tests/subdirs/foo/wscript
Normal file
22
tests/subdirs/foo/wscript
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
#! /usr/bin/env python
|
||||||
|
# encoding: utf-8
|
||||||
|
# a1batross, 2019
|
||||||
|
|
||||||
|
def options(opt):
|
||||||
|
opt.add_option('--foo_test', action='store_true', default=True, dest='foo_test')
|
||||||
|
|
||||||
|
def configure(conf):
|
||||||
|
conf.env.SUBDIRS_FOO = 'foo'
|
||||||
|
|
||||||
|
# check options() was called
|
||||||
|
if not conf.options.foo_test:
|
||||||
|
raise Exception('TEST FAILED')
|
||||||
|
|
||||||
|
# check if we really derived environment
|
||||||
|
if conf.env.SUBDIRS_ROOT != 'meow':
|
||||||
|
raise Exception('TEST FAILED')
|
||||||
|
|
||||||
|
def build(bld):
|
||||||
|
# check if environment was derived correctly
|
||||||
|
if bld.env.SUBDIRS_ROOT != 'meow':
|
||||||
|
raise Exception('TEST FAILED')
|
21
tests/subdirs/wscript
Normal file
21
tests/subdirs/wscript
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
#! /usr/bin/env python
|
||||||
|
# encoding: utf-8
|
||||||
|
# a1batross, 2019
|
||||||
|
|
||||||
|
def options(opt):
|
||||||
|
opt.add_subproject('foo')
|
||||||
|
|
||||||
|
def configure(conf):
|
||||||
|
conf.env.SUBDIRS_ROOT = 'meow'
|
||||||
|
conf.add_subproject('foo')
|
||||||
|
|
||||||
|
# check that we're still using our enviroment
|
||||||
|
if 'SUBDIRS_FOO' in conf.env:
|
||||||
|
raise Exception('TEST FAILED')
|
||||||
|
|
||||||
|
def build(bld):
|
||||||
|
bld.add_subproject('foo')
|
||||||
|
|
||||||
|
# check that 'foo' env isn't derived
|
||||||
|
if 'SUBDIRS_FOO' in bld.env:
|
||||||
|
raise Exception('TEST FAILED')
|
15
tests/wscript
Normal file
15
tests/wscript
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
#! /usr/bin/env python
|
||||||
|
# encoding: utf-8
|
||||||
|
# a1batross, 2019
|
||||||
|
|
||||||
|
def options(opt):
|
||||||
|
opt.add_subproject('subdirs')
|
||||||
|
pass
|
||||||
|
|
||||||
|
def configure(conf):
|
||||||
|
conf.add_subproject('subdirs')
|
||||||
|
pass
|
||||||
|
|
||||||
|
def build(bld):
|
||||||
|
bld.add_subproject('subdirs')
|
||||||
|
pass
|
25
wscript
Normal file
25
wscript
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
#! /usr/bin/env python
|
||||||
|
# encoding: utf-8
|
||||||
|
# a1batross, mittorn, 2018
|
||||||
|
|
||||||
|
from __future__ import print_function
|
||||||
|
|
||||||
|
VERSION = '1.0'
|
||||||
|
APPNAME = 'waifu-tests'
|
||||||
|
top = '.'
|
||||||
|
|
||||||
|
def subdirs():
|
||||||
|
return map(lambda x: x.name, SUBDIRS)
|
||||||
|
|
||||||
|
def options(opt):
|
||||||
|
opt.load('subproject')
|
||||||
|
opt.add_subproject('tests')
|
||||||
|
pass
|
||||||
|
|
||||||
|
def configure(conf):
|
||||||
|
conf.add_subproject('tests')
|
||||||
|
pass
|
||||||
|
|
||||||
|
def build(bld):
|
||||||
|
bld.add_subproject('tests')
|
||||||
|
pass
|
Loading…
Reference in New Issue
Block a user