1#!/usr/local/bin/python3.8
2
3# Copyright 2008 Jurko Gospodnetic, Vladimir Prus
4# Copyright 2011 Steven Watanabe
5# Distributed under the Boost Software License, Version 1.0.
6# (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
7
8#   Added to guard against a bug causing targets to be used before they
9# themselves have finished building. This used to happen for targets built by a
10# multi-file action that got triggered by another target, except when the
11# target triggering the action was the first one in the list of targets
12# produced by that action.
13#
14# Example:
15#   When target A and target B were declared as created by a single action with
16# A being the first one listed, and target B triggered running that action
17# then, while the action was still running, target A was already reporting as
18# being built causing other targets depending on target A to be built
19# prematurely.
20
21import BoostBuild
22
23t = BoostBuild.Tester(pass_toolset=0)
24
25t.write("sleep.bat", """\
26::@timeout /T %1 /NOBREAK >nul
27@ping 127.0.0.1 -n 2 -w 1000 >nul
28@ping 127.0.0.1 -n %1 -w 1000 >nul
29@exit /B 0
30""")
31
32t.write("file.jam", """\
33if $(NT)
34{
35    SLEEP = @call sleep.bat ;
36}
37else
38{
39    SLEEP = sleep ;
40}
41
42actions link
43{
44    $(SLEEP) 1
45    echo 001 - linked
46}
47
48link dll lib ;
49
50actions install
51{
52    echo 002 - installed
53}
54
55install installed_dll : dll ;
56DEPENDS installed_dll : dll ;
57
58DEPENDS all : lib installed_dll ;
59""")
60
61t.run_build_system(["-ffile.jam", "-j2"], stdout="""\
62...found 4 targets...
63...updating 3 targets...
64link dll
65001 - linked
66install installed_dll
67002 - installed
68...updated 3 targets...
69""")
70
71t.cleanup()
72