Skip to main content

extract_archive

Extracts an archive into a directory. The archive is a file in the repository or the output of another target; http_archive is the rule for one that is downloaded.

Details​

extract_archive(
name = "assets",
src = "assets.tar.gz",
strip_prefix = "assets-1.0",
)

Function Signature​

def extract_archive(
*,
name: str,
default_target_platform: None | str = None,
target_compatible_with: list[str] = [],
compatible_with: list[str] = [],
exec_compatible_with: list[str] = [],
visibility: list[str | target_name_glob] = [],
within_view: list[str | target_name_glob] = ["PUBLIC"],
metadata: OpaqueMetadata = {},
tests: list[str] = [],
modifiers: OpaqueMetadata = [],
directory_name: None | str = None,
excludes: list[str] = [],
exec_deps: str = "prelude//http_archive/tools:exec_deps",
out: None | str = None,
src: str,
strip_prefix: None | str = None,
sub_targets: list[str] | dict[str, list[str]] = [],
type: None | str = None,
) -> None

Parameters​

  • name: (required)

    name of the target

  • default_target_platform: (defaults to: None)

    specifies the default target platform, used when no platforms are specified on the command line

  • target_compatible_with: (defaults to: [])

    a list of constraints that are required to be satisfied for this target to be compatible with a configuration

  • compatible_with: (defaults to: [])

    a list of constraints that are required to be satisfied for this target to be compatible with a configuration

  • exec_compatible_with: (defaults to: [])

    a list of constraints that are required to be satisfied for this target to be compatible with an execution platform

  • visibility: (defaults to: [])

    a list of visibility patterns restricting what targets can depend on this one

  • within_view: (defaults to: ["PUBLIC"])

    a list of visibility patterns restricting what this target can depend on

  • metadata: (defaults to: {})

    a key-value map of metadata associated with this target

  • tests: (defaults to: [])

    a list of targets that provide tests for this one

  • modifiers: (defaults to: [])

    an array of modifiers associated with this target

  • directory_name: (defaults to: None)

    Name of the result directory, if omitted, name attribute will be used instead. Deprecated in favour of out.

  • excludes: (defaults to: [])

    An optional list of regex patterns. All file paths in the extracted archive which match any of the given patterns will be omitted.

  • exec_deps: (defaults to: "prelude//http_archive/tools:exec_deps")

    When using http_archive as an anon target, the rule invoking the anon target needs to mirror this attribute into its own attributes, and forward the provider into the anon target invocation.

    When using http_archive normally not as an anon target, the default value is always fine.

  • out: (defaults to: None)

    An optional name to call the directory that the downloaded artifact is extracted into. Buck will generate a default name if one is not provided that uses the name of the rule.

  • src: (required)

    .tar.gz or zip archive with the contents of the result directory

  • strip_prefix: (defaults to: None)

    If set, files under this path will be extracted to the root of the output directory. Siblings or cousins to this prefix will not be extracted at all.

    For example, if a tarball has the layout:

    • foo/bar/bar-0.1.2/data.dat
    • foo/baz/baz-0.2.3
    • foo_prime/bar-0.1.2

    Only data.dat will be extracted, and it will be extracted into the output directory specified in out.

  • sub_targets: (defaults to: [])

    A list of filepaths within the archive to be made accessible as sub-targets. For example if we have an http_archive with name = "archive" and sub_targets = ["src/lib.rs"], then other targets would be able to refer to that file as ":archive[src/lib.rs]".

    Or, a dict of sub_target name to list of files to be in that subtarget. For example, with

    http_archive(
    name = "archive",
    ...
    sub_targets = {
    "group_1": ["a.txt", "b.txt"],
    "a.txt": ["a.txt"]
    },
    )

    ... you get two sub targets: :archive[group_1] consisting of two files, and :archive[a.txt] consisting of one file.

  • type: (defaults to: None)

    Normally, archive type is determined by the file's extension. If type is set, then autodetection is overridden, and the specified type is used instead.

    Supported values are: zip, tar, tar.gz, tar.bz2, tar.xz, and tar.zst.