Hi all.
I've been fighting an issue in the Python port for a while and I haven't been able to figure it out. It deals with generated headers and implicit dependencies. It works well on the Jam side, but is failing on the Python side under certain conditions.
For our module tests we sometimes use mocking to mock out external functions in a function under test. To facilitate the mocking, mock header (which includes specifics for our mock framework) and implementation (includes the mocked function) files are generated at build time. These mock files are then placed as dependencies to the test executable.
I've attached a simple project that reproduces the error. The tests directory contains a single test that tests source1.c in the src directory. source1.c requires a function from the "hello" library in the lib directory and for the purposes of the test, the function will be mocked out.
In order to mock out functions, the mock generator takes in a header file and mocks out all function prototypes that it sees and then produces a "mock_hello.h" and "mock_hello.c". The header file to be mocked is called out in the test's build.jam (the "hello" target). Then the test is built and run. The test driver then #includes the "mock_hello.h" to get access to all of the special mock helper functions. Note: the test driver now has an implicit dependency on the generated mock_hello.h header.
Commands to reproduce:
Note: The bin directory (or at least, the generated header) must be removed after each run since the mock header file will no longer be generated on subsequent runs and the error only exists in a clean environment.
# with Jam
b2 tests\test1 # success
# with Python
b2 --python tests\test1 # success
# with Jam
# some random lib is also built BEFORE the test
b2 random_lib tests\test1 # success
# with Python
# some random lib is also built BEFORE the test
b2 --python random_lib tests\test1 # FAIL - Cannot open include file: 'mock_hello.h'
Taking a look at the dependency graph (-d+12) for test_source1.c, the scanner sees that mock_hello.h is a dependency, but it's marked as stable. And so, the test driver is built before the mocked header is generated.
I would greatly appreciate any help or guidance in resolving this issue. Let me know if you need any more information.
Thanks,
Aaron