2
0
mirror of https://gitlab.com/ita1024/waf.git synced 2024-11-22 01:46:15 +01:00
This commit is contained in:
Thomas Nagy 2012-01-08 14:56:58 +01:00
parent 8683e29136
commit 6371ebbc5b

View File

@ -0,0 +1,46 @@
#! /usr/bin/env python
"""
Illustrate the effect of weak order constraints for the build (generates diagrams)
waf configure clean build -j2 --dwidth=800 --dtitle='Default constraints on "waf -j2"' --dmaxtime=15
waf configure clean build -j2 --dwidth=800 --dtitle='Additional constraints on "waf -j2"' --dmaxtime=15
"""
def options(ctx):
ctx.load('parallel_debug')
def configure(ctx):
ctx.load('parallel_debug')
def build(ctx):
ctx(rule='sleep 1', color='BLUE', name='blue')
for x in range(80):
ctx(rule='sleep 0.1', color='GREEN', name='green', always=True)
ctx(rule='sleep 6', color='RED', name='red', after='blue')
from waflib import Task, Runner
old = Task.set_file_constraints
def meth(lst):
lst.sort(cmp=lambda x, y: cmp(x.__class__.__name__, y.__class__.__name__))
old(lst)
Task.set_file_constraints = meth
def get_out(self):
tsk = self.prev_get_out()
if tsk.__class__.__name__ == 'blue':
reds = []
def remove_red(lst):
for tsk in reversed(lst):
if tsk.__class__.__name__ == 'red':
lst.remove(tsk)
reds.append(tsk)
remove_red(self.outstanding)
remove_red(self.frozen)
for x in reds:
self.outstanding.insert(0, x)
return tsk
Runner.Parallel.prev_get_out = Runner.Parallel.get_out
Runner.Parallel.get_out = get_out