readDependencies: Read source code file dependencies on other files

Description Usage Arguments Value Author(s) References See Also Examples

Description

This function is used to post-process the output of a call to the GCC compiler (gcc or g++) to generate the list of files on which a particular source file depends, i.e. includes either directly or indirectly. This information is then used to filter the symbols, routines, data structures, etc. in which we are interested by limiting them to files typically other than these or by matching these to ones in a known directory of interest.

This function does not perform the call to the compiler to generate the dependencies. Instead

Usage

1
readDependencies(filename)

Arguments

filename

the name of the file to which the dependency information was written in the call to the GCC compiler, or the output itself, i.e. the raw lines emitted by the compiler.

Value

A character vector giving the fully-qualified names of the included files and the names of the elements in this vector are the corresponding base names of these files. Since the TU output discards the directory information, we return this base name form for easy comparison but maintain the directory information for completeness. So often we use the names() of the result for use with TUs. Additionally, the name of the file from which the dependencies were computed, i.e. the source file passed to the compiler, is available via the attribute "source".

Author(s)

Duncan Temple Lang

References

The GCC compiler suite

See Also

getClassNodes getAllDeclarations getRoutines getGlobalVariables getEnumerations

Examples

1
2
3
4
5
6
7
8
  fname = paste(tempfile(), ".c", sep = "")
  cat("#include <stdio.h>\n", file = fname)
  ll = system(paste("gcc -M", fname), intern = TRUE)
  readDependencies(ll)

  oname = tempfile()
  ll = system(paste("gcc -M", fname, ">", oname), intern = TRUE)
  readDependencies(oname)

omegahat/RGCCTranslationUnit documentation built on May 24, 2019, 1:53 p.m.