Buck: subdir_glob()
Support Ukraine. Help Provide Humanitarian Aid to Ukraine.

subdir_glob()

This is liable to change in the future.

The subdir_glob() function is useful for defining header maps for C/C++ libraries which should be relative the given sub-directory. Given a list of tuples, the form of (relative-sub-directory, glob-pattern), return a dict of sub-directory relative paths to full paths.

Please refer to glob() for explanations and examples of the pattern.

Arguments

  • glob_specs The array of tuples in form of (relative-sub-directory, glob-pattern inside relative-sub-directory).
  • excludes (defaults to []) A list of patterns to identify files that should be removed from the set specified by the first argument.
  • prefix (defaults to None) If is not None, prepends it to each key in the dictionary.

Examples

Given this exported_headers description:
exported_headers = subdir_glob([
    ("lib/source", "video/**/*.h"),
    ("lib/source", "audio/**/*.h"),
  ],
  excludes = [
    "lib/source/video/codecs/*.h",
  ],
  prefix = "MediaLib/")
It will map the following on disk directory structure below to the following includes:
lib/
  source/
    video/
      converter/
        converter.h   ->   #include "MediaLib/video/converter/converter.h"
      player/
        player.h      ->   #include "MediaLib/video/player/player.h"
      codecs/
        codec1.h      ->   not includable - defined in `excludes`
        codec2.h      ->   not includable - defined in `excludes`
    audio/
      codecs/
        codec1.h      ->   #include "MediaLib/audio/codecs/codec1.h"
        codec2.h      ->   #include "MediaLib/audio/codecs/codec2.h"
      player/
        player.h      ->   #include "MediaLib/audio/player/player.h"
    internal/
      otherheader.h   ->   not includable