| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268 |
- #!/usr/bin/python
- # Copyright 2012 Steven Watanabe
- # Distributed under the Boost Software License, Version 1.0.
- # (See accompanying file LICENSE.txt or https://www.bfgroup.xyz/b2/LICENSE.txt)
- import BoostBuild
- t = BoostBuild.Tester(use_test_config=False)
- # Test a header loop that depends on (but does not contain) a generated header.
- t.write("test.cpp", '#include "header1.h"\n')
- t.write("header1.h", """\
- #ifndef HEADER1_H
- #define HEADER1_H
- #include "header2.h"
- #endif
- """)
- t.write("header2.h", """\
- #ifndef HEADER2_H
- #define HEADER2_H
- #include "header1.h"
- #include "header3.h"
- #endif
- """)
- t.write("header3.in", "/* empty file */\n")
- t.write("jamroot.jam", """\
- import common ;
- make header3.h : header3.in : @common.copy ;
- obj test : test.cpp : <implicit-dependency>header3.h ;
- """)
- t.run_build_system(["-j2"])
- t.expect_addition("bin/header3.h")
- t.expect_addition("bin/$toolset/debug*/test.obj")
- t.expect_nothing_more()
- t.rm(".")
- # Test a linear sequence of generated headers.
- t.write("test.cpp", '#include "header1.h"\n')
- t.write("header1.in", """\
- #ifndef HEADER1_H
- #define HEADER1_H
- #include "header2.h"
- #endif
- """)
- t.write("header2.in", """\
- #ifndef HEADER2_H
- #define HEADER2_H
- #include "header3.h"
- #endif
- """)
- t.write("header3.in", "/* empty file */\n")
- t.write("jamroot.jam", """\
- import common ;
- make header1.h : header1.in : @common.copy ;
- make header2.h : header2.in : @common.copy ;
- make header3.h : header3.in : @common.copy ;
- obj test : test.cpp :
- <implicit-dependency>header1.h
- <implicit-dependency>header2.h
- <implicit-dependency>header3.h ;
- """)
- t.run_build_system(["-j2", "test"])
- t.expect_addition("bin/header1.h")
- t.expect_addition("bin/header2.h")
- t.expect_addition("bin/header3.h")
- t.expect_addition("bin/$toolset/debug*/test.obj")
- t.expect_nothing_more()
- t.rm(".")
- # Test a loop in generated headers.
- t.write("test.cpp", '#include "header1.h"\n')
- t.write("header1.in", """\
- #ifndef HEADER1_H
- #define HEADER1_H
- #include "header2.h"
- #endif
- """)
- t.write("header2.in", """\
- #ifndef HEADER2_H
- #define HEADER2_H
- #include "header3.h"
- #endif
- """)
- t.write("header3.in", """\
- #ifndef HEADER2_H
- #define HEADER2_H
- #include "header1.h"
- #endif
- """)
- t.write("jamroot.jam", """\
- import common ;
- actions copy {
- sleep 1
- cp $(>) $(<)
- }
- make header1.h : header1.in : @common.copy ;
- make header2.h : header2.in : @common.copy ;
- make header3.h : header3.in : @common.copy ;
- obj test : test.cpp :
- <implicit-dependency>header1.h
- <implicit-dependency>header2.h
- <implicit-dependency>header3.h ;
- """)
- t.run_build_system(["-j2", "test"])
- t.expect_addition("bin/header1.h")
- t.expect_addition("bin/header2.h")
- t.expect_addition("bin/header3.h")
- t.expect_addition("bin/$toolset/debug*/test.obj")
- t.expect_nothing_more()
- t.rm(".")
- # Test that all the dependencies of a loop are updated before any of the
- # dependents.
- t.write("test1.cpp", '#include "header1.h"\n')
- t.write("test2.cpp", """\
- #include "header2.h"
- int main() {}
- """)
- t.write("header1.h", """\
- #ifndef HEADER1_H
- #define HEADER1_H
- #include "header2.h"
- #endif
- """)
- t.write("header2.h", """\
- #ifndef HEADER2_H
- #define HEADER2_H
- #include "header1.h"
- #include "header3.h"
- #endif
- """)
- t.write("header3.in", "\n")
- t.write("sleep.bat", """\
- ::@timeout /T %1 /NOBREAK >nul
- @ping 127.0.0.1 -n 2 -w 1000 >nul
- @ping 127.0.0.1 -n %1 -w 1000 >nul
- @exit /B 0
- """)
- t.write("jamroot.jam", """\
- import common ;
- import os ;
- if [ os.name ] = NT
- {
- SLEEP = call sleep.bat ;
- }
- else
- {
- SLEEP = sleep ;
- }
- rule copy { common.copy $(<) : $(>) ; }
- actions copy { $(SLEEP) 1 }
- make header3.h : header3.in : @copy ;
- exe test : test2.cpp test1.cpp : <implicit-dependency>header3.h ;
- """)
- t.run_build_system(["-j2", "test"])
- t.expect_addition("bin/header3.h")
- t.expect_addition("bin/$toolset/debug*/test1.obj")
- t.expect_addition("bin/$toolset/debug*/test2.obj")
- t.expect_addition("bin/$toolset/debug*/test.exe")
- t.ignore_addition("bin/*/test.rsp")
- t.expect_nothing_more()
- t.touch("header3.in")
- t.run_build_system(["-j2", "test"])
- t.expect_touch("bin/header3.h")
- t.expect_touch("bin/$toolset/debug*/test1.obj")
- t.expect_touch("bin/$toolset/debug*/test2.obj")
- t.expect_touch("bin/$toolset/debug*/test.exe")
- t.ignore_touch("bin/*/test.rsp")
- t.expect_nothing_more()
- t.rm(".")
- # Test a loop that includes a generated header
- t.write("test1.cpp", '#include "header1.h"\n')
- t.write("test2.cpp", """\
- #include "header2.h"
- int main() {}
- """)
- t.write("header1.h", """\
- #ifndef HEADER1_H
- #define HEADER1_H
- #include "header2.h"
- #endif
- """)
- t.write("header2.in", """\
- #ifndef HEADER2_H
- #define HEADER2_H
- #include "header3.h"
- #endif
- """)
- t.write("header3.h", """\
- #ifndef HEADER3_H
- #define HEADER3_H
- #include "header1.h"
- #endif
- """)
- t.write("sleep.bat", """\
- ::@timeout /T %1 /NOBREAK >nul
- @ping 127.0.0.1 -n 2 -w 1000 >nul
- @ping 127.0.0.1 -n %1 -w 1000 >nul
- @exit /B 0
- """)
- t.write("jamroot.jam", """\
- import common ;
- import os ;
- if [ os.name ] = NT
- {
- SLEEP = call sleep.bat ;
- }
- else
- {
- SLEEP = sleep ;
- }
- rule copy { common.copy $(<) : $(>) ; }
- actions copy { $(SLEEP) 1 }
- make header2.h : header2.in : @copy ;
- exe test : test2.cpp test1.cpp : <implicit-dependency>header2.h <include>. ;
- """)
- t.run_build_system(["-j2", "test"])
- t.expect_addition("bin/header2.h")
- t.expect_addition("bin/$toolset/debug*/test1.obj")
- t.expect_addition("bin/$toolset/debug*/test2.obj")
- t.expect_addition("bin/$toolset/debug*/test.exe")
- t.ignore_addition("bin/*/test.rsp")
- t.expect_nothing_more()
- t.cleanup()
|