MCPcopy Create free account
hub / github.com/boostorg/build / __write_appender

Function __write_appender

v2/test/project_id.py:322–407  ·  view source on GitHub ↗
(t, name)

Source from the content-addressed store, hash-verified

320
321
322def __write_appender(t, name):
323 t.write(name,
324r"""# Copyright 2012 Jurko Gospodnetic
325# Distributed under the Boost Software License, Version 1.0.
326# (See accompanying file LICENSE_1_0.txt or copy at
327# http://www.boost.org/LICENSE_1_0.txt)
328
329# Support for registering test generators that construct their targets by
330# simply appending their given input data, e.g. list of sources & targets.
331
332import "class" : new ;
333import generators ;
334import modules ;
335import sequence ;
336
337rule register ( id composing ? : source-types + : target-types + )
338{
339 local caller-module = [ CALLER_MODULE ] ;
340 id = $(caller-module).$(id) ;
341 local g = [ new generator $(id) $(composing) : $(source-types) :
342 $(target-types) ] ;
343 $(g).set-rule-name $(__name__).appender ;
344 generators.register $(g) ;
345 return $(id) ;
346}
347
348if [ modules.peek : NT ]
349{
350 X = ")" ;
351 ECHO_CMD = (echo. ;
352}
353else
354{
355 X = \" ;
356 ECHO_CMD = "echo $(X)" ;
357}
358
359local appender-runs ;
360
361# We set up separate actions for building each target in order to avoid having
362# to iterate over them in action (i.e. shell) code. We have to be extra careful
363# though to achieve the exact same effect as if doing all the work in just one
364# action. Otherwise Boost Jam might, under some circumstances, run only some of
365# our actions. To achieve this we register a series of actions for all the
366# targets (since they all have the same target list - either all or none of them
367# get run independent of which target actually needs to get built), each
368# building only a single target. Since all our actions use the same targets, we
369# can not use 'on-target' parameters to pass data to a specific action so we
370# pass them using the second 'sources' parameter which our actions then know how
371# to interpret correctly. This works well since Boost Jam does not automatically
372# add dependency relations between specified action targets & sources and so the
373# second argument, even though most often used to pass in a list of sources, can
374# actually be used for passing in any type of information.
375rule appender ( targets + : sources + : properties * )
376{
377 appender-runs = [ CALC $(appender-runs:E=0) + 1 ] ;
378 local target-index = 0 ;
379 local target-count = [ sequence.length $(targets) ] ;

Calls 1

writeMethod · 0.45