package mopsa
Install
Dune Dependency
Authors
Maintainers
Sources
md5=fdee20e988343751de440b4f6b67c0f4
sha512=f5cbf1328785d3f5ce40155dada2d95e5de5cce4f084ea30cfb04d1ab10cc9403a26cfb3fa55d0f9da72244482130fdb89c286a9aed0d640bba46b7c00e09500
doc/mopsa.mopsa_build_db/Mopsa_build_db/index.html
Module Mopsa_build_db
Source
Mopsa_build_db - Build a database to manage the analysis of multi-file projects
To help with the analysis of large projects that may have multiple source files, specific libraries, headers, preprocessing and compilation options, we create a database of these information. The database is typically extracted from an actual build, using wrappers for the build tools - see BuildWrapper.
Note: the database is not very efficient as it is completely loaded and recreated at each file operation. Also, it requires a file lock in case of a concurrent build (e.g.: make -j). It should suffice for small project though and is probably not a bottleneck.
DB representation
type source = {
source_path : string;
(*absolute path of source file
*)source_obj : string;
(*absolute path of the object file
*)source_kind : source_kind;
source_opts : string list;
(*compilation options
*)source_cwd : string;
(*directory from where the compilation was launched
*)
}
Represents a compiled source.
type file_kind =
| Object of source
| Library of library_kind * file StringMap.t
(*contents, indexed by file name
*)| Executable of file list
| Unknown of string
(*absolute path
*)
Represents a full compilation database. Files are indexed by absolute paths.
Printing
Apply file operations to DB
db_remove recurse db file
deletes a file or directory, possibly recursively.
db_copymove move rcur db org_file dest_file
copies or moves a file or directory.
db_add_archive db archive kind files
creates or add files to a static or dynamic library.
db_remove_archive db archive files
removes some files from a static or dynamic library.
db_extract_archive db archive files
extracts a specified set of files from a library.
db_extract_archive_all db archive
extracts a the files in a library.
db_compile db language source object args
compliles the specified source file in the specified language into the specified object file, with the specified compilation command-line arguments.
db_link db executable sources
links the specified list of files into the specified executable file.
DB loading, saving, locking
Open DB file and lock. Optionally create if it does not exist.
Unlock and close DB file.
Read from open DB file.
Write to open DB file.
DB extraction for analysis driver
get_executables db
returns the list of all executable compiled in this database. Full path-names are returned.
get_libraries db
returns the list of all libraries compiled in this database. Full path-names are returned.
get_file_sources expected_kind db executable_path
returns the list of sources that compose the given expected kind (by default, executables) in the database (includes recursively the contents of libraries linked to the executable, when known).
get_executable_sources db executable
behaves as get_file_sources
but uses the short executable name instead of the full path-name.
get_library_sources db executable
behaves as get_file_sources
with the library kind, but it uses the short executable name instead of the full path-name.