0

How does scons cache the dependencies that is scans for C code?

The context of the question is I want to use that same technique in other languages.

Right now I have to do something like this:

env.Depends(target = 'lib/PROG1.so', dependency = getDependencies('src/PROG1.xxx'))

where getDependencies() returns a list of dependencies. But that will scan for dependencies on every run. I want to cache those results and only rescan if the source file changes.

Be Kind To New Users
  • 9,672
  • 13
  • 78
  • 125

1 Answers1

0

If you're using Depends() you're probably doing something wrong... (this usually means you're not specifying a target or a source, or the scanner for your builder(s) are missing files)

SCons' builders define scanners which scan the source code looking for included files and save that info.

Additionally you specify to all builders the sources for the targets they build.

Generally files are already only re-scanned if they change.

There are some command line flags to SCons which can impact the scanning of source files (From the manpage: https://scons.org/doc/production/HTML/scons-man.html )

--implicit-cache
Cache implicit dependencies. This causes scons to use the implicit (scanned) dependencies from the last time it was run instead of scanning the files for implicit dependencies. This can significantly speed up SCons, but with the following limitations:

scons will not detect changes to implicit dependency search paths (e.g. CPPPATH, LIBPATH) that would ordinarily cause different versions of same-named files to be used.

scons will miss changes in the implicit dependencies in cases where a new implicit dependency is added earlier in the implicit dependency search path (e.g. CPPPATH, LIBPATH) than a current implicit dependency with the same name.

--implicit-deps-changed
Forces SCons to ignore the cached implicit dependencies. This causes the implicit dependencies to be rescanned and recached. This implies --implicit-cache.

--implicit-deps-unchanged
Force SCons to ignore changes in the implicit dependencies. This causes cached implicit dependencies to always be used. This implies --implicit-cache.

Or did you mean something else?

bdbaddog
  • 3,357
  • 2
  • 22
  • 33
  • "If you're using Depends() you're probably doing something wrong". Yup, probably. I am trying to add support for a language that scons does not know how to scan. Perhaps my question should be: "How do I add a scanner to scons?" – Be Kind To New Users Oct 03 '21 at 12:06
  • 1
    I believe I answered the how to add a scanner (or at least pointed you to the docs).. in your other question here: https://stackoverflow.com/questions/69418646/scons-for-cobol – bdbaddog Oct 03 '21 at 23:43
  • Post that answer here and I will accept it. Let's leave the other question open for cobol specific answers. The other guy had some good cobol specific answer. Then we can delete these comments. – Be Kind To New Users Oct 03 '21 at 23:47