Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SCons: How to generate dependencies after some targets have been built?

Tags:

python

scons

I have a SCons project that builds set of Python modules (mostly as shared objects compiled from C++). This part works flawlessly, all dependencies seem to be fine.

However, now I reached point where I started trying to add tests for those modules. Those tests are supposed to be run as part of build. Tests are written in Python and when run they need to be run under environment that already has all modules built (so that import statements can find them).

I got that part working up to the point of dependencies for those tests. Tests are run, however I can't seem to find a way to generate dependencies for them from import statements.

I have found modulefinder which does exactly what I want. What's more I am able to run it in built environment and get expected results after my project is built. I wanted to use modulefinder in emitter to scan for files the test/Python script depends on.

Problem is that dependency scanning/building + running of emitters happens before SCons has built all modules and before it can set up environment properly for tests, hence also modulefinder can't work.

I can't seem to work out how to make SCons look for dependencies for specific targets after some other targets are already built.

edit:

I found ParseDepends in SCons documentation which seems to talk about the same type of issue (well, almost exactly same with exception to langauge).

This limitation of ParseDepends leads to unnecessary recompilations. Therefore, ParseDepends should only be used if scanners are not available for the employed language or not powerful enough for the specific task.

I am still hopeful though that there is some clean solution to my problem.

like image 235
elmo Avatar asked Dec 05 '25 03:12

elmo


1 Answers

You can't change dependencies in SCons during the compilation phase. SCons creates its dependency tree and after it runs it. You can't change it. I suggest you to write a Scanner for your builder. In C++, SCons uses a Scanner to find include dependencies. [http://www.scons.org/doc/1.1.0/HTML/scons-user/c3742.html][1]

like image 65
efficks Avatar answered Dec 07 '25 17:12

efficks