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,7 +7,10 @@ Subproject tool
|
||||
|
||||
Helps you have standalone environment for each subproject(subdirectory)
|
||||
|
||||
Usage::
|
||||
Usage:
|
||||
def options(opt):
|
||||
opt.load('subproject')
|
||||
|
||||
def configure(conf):
|
||||
conf.add_subproject('folder1 folder2')
|
||||
|
||||
@ -32,9 +35,10 @@ def depth_pop():
|
||||
DEPTH = os.path.dirname(DEPTH)
|
||||
# print DEPTH
|
||||
|
||||
def depth():
|
||||
def get_name_by_depth():
|
||||
global DEPTH
|
||||
return DEPTH
|
||||
|
||||
return DEPTH.replace(os.sep, '_')
|
||||
|
||||
def opt(f):
|
||||
"""
|
||||
@ -53,7 +57,7 @@ def add_subproject(ctx, names):
|
||||
for name in names_lst:
|
||||
depth_push(name)
|
||||
|
||||
wscript_path = os.path.join(depth(), 'wscript')
|
||||
wscript_path = os.path.join(DEPTH, 'wscript')
|
||||
|
||||
if not os.path.isfile(wscript_path):
|
||||
# HACKHACK: this way we get warning message right in the help
|
||||
@ -90,28 +94,26 @@ def get_subproject_env(ctx, path, log=False):
|
||||
if log: Logs.pprint('YELLOW', 'env: changed to default env')
|
||||
raise IndexError('top env')
|
||||
|
||||
|
||||
def configure(conf):
|
||||
if conf.options.SKIP_SUBDIRS:
|
||||
conf.env.IGNORED_SUBDIRS = conf.options.SKIP_SUBDIRS.split(',')
|
||||
|
||||
@Configure.conf
|
||||
def add_subproject(ctx, names):
|
||||
names_lst = Utils.to_list(names)
|
||||
|
||||
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:
|
||||
depth_push(name)
|
||||
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()
|
||||
continue
|
||||
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.msg(msg='--> %s' % depth(), result='in progress', color='BLUE')
|
||||
ctx.msg(msg='--> %s' % DEPTH, result='in progress', color='BLUE')
|
||||
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.env = saveenv # but use previous
|
||||
depth_pop()
|
||||
@ -119,9 +121,12 @@ def add_subproject(ctx, names):
|
||||
if not ctx.all_envs:
|
||||
ctx.load_envs()
|
||||
for name in names_lst:
|
||||
depth_push(name)
|
||||
if name in ctx.env.IGNORED_SUBDIRS:
|
||||
depth_pop()
|
||||
continue
|
||||
saveenv = ctx.env
|
||||
ctx.env = ctx.all_envs[name]
|
||||
ctx.env = ctx.all_envs[get_name_by_depth()]
|
||||
ctx.recurse(name)
|
||||
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