dependency-analysis

command module
v0.0.0-...-4843124 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 3, 2024 License: BSD-3-Clause Imports: 12 Imported by: 0

README

CRAS Dependency Analysis

Usage

devtools/dependency-analysis/run.bash

Currently this prints the dependenecy information as JSON to stdout.

Actual analysis TODO.

How

This tool does the following steps to collect information from the dependency graph.

  1. Do a full build to produce the object files and depfiles.
  2. Use bazel aquery to query the action graph. The output is a ActionGraphContainer protobuf.
  3. Inspect the action graph to figure out the headers declared in the BUILD.bazel graph, and inspect the depfiles to figure out the headers that are actually needed to compile each translation unit.
  4. Inspect the object files using the elf package to figure out the symbols provided & required by each translation unit.

Ideas

  • Plot the dependency graph.
  • Suggest leaf modules / translation units for Rustification.
  • Flag stubbed functions declared in unit tests. We should replace them with real ones or fakes. See also SWE Book on test doubles.
  • Remove unneeded dependencies. If a build target X declares a dependency on Y, but does not actually need headers or symbols provided by Y, automatically remove Y from X's cc_library(deps = ...).

Examples

Print all information:

devtools/dependency-analysis/run.bash
[
  {
    "target_label": "//cras/src/server:libcrasserver",
    "source": "cras/src/server/cras_tm.c",
    "inputs_bazel": [
      "cras/src/server/cras_tm.c",
      "cras/src/server/cras_tm.h",
      "cras/include/cras_util.h",
      "cras/include/cras_types.h",
      "cras/include/cras_audio_format.h",
      "cras/include/cras_iodev_info.h",
      "cras/include/cras_timespec.h",
      "cras/include/packet_status_logger.h",
      "third_party/utlist/utlist.h"
    ],
    "inputs_makefile": [
      "cras/src/server/cras_tm.c",
      "cras/src/server/cras_tm.h",
      "cras/include/cras_util.h",
      "cras/include/cras_types.h",
      "cras/include/cras_audio_format.h",
      "cras/include/cras_iodev_info.h",
      "cras/include/cras_timespec.h",
      "cras/include/packet_status_logger.h",
      "third_party/utlist/utlist.h"
    ],
    "provided_symbols": [
      "cras_tm_create_timer",
      "cras_tm_cancel_timer",
      "cras_tm_init",
      "cras_tm_deinit",
      "cras_tm_get_next_timeout",
      "cras_tm_call_callbacks"
    ],
    "dependant_symbols": [
      "calloc",
      "clock_gettime",
      "__assert_fail",
      "free"
    ]
  },
  ...
]

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL