-
Notifications
You must be signed in to change notification settings - Fork 36
/
providers.bzl
53 lines (49 loc) · 1.9 KB
/
providers.bzl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# Copyright (c) Meta Platforms, Inc. and affiliates.
#
# This source code is licensed under both the MIT license found in the
# LICENSE-MIT file in the root directory of this source tree and the Apache
# License, Version 2.0 found in the LICENSE-APACHE file in the root directory
# of this source tree.
load("@prelude//:artifacts.bzl", "ArtifactExt")
ThirdPartyBuild = record(
# A logical project name for the project, currently used for logging.
project = field(str),
# The directory containing the build output.
root = field(ArtifactExt),
# The prefix to install the build output.
prefix = field(str, "/"),
# A manifest of build env settings to use to build against this build.
manifest = field(Artifact | None, None),
# Environment variables to set to build against this project.
# TODO(agallagher): Can this move into the manifest?
exported_env = field(dict[str, str], {}),
)
# Work-around for buck2 bug causing "transitive values must be of the same
# transitive set type" errors:
# https://fb.prod.workplace.com/groups/buck2users/posts/3637287806527574/
ThirdPartyBuildTSet = transitive_set()
ThirdPartyBuildInfo = provider(fields = {
"build": provider_field(ThirdPartyBuild | None),
"_tset": provider_field(ThirdPartyBuildTSet),
})
def third_party_build_info(
actions,
build: [ThirdPartyBuild, None] = None,
children: list[ThirdPartyBuildInfo] = [],
deps: list[Dependency] = []) -> ThirdPartyBuildInfo:
kwargs = {}
if build != None:
kwargs["value"] = build
if deps or children:
kwargs["children"] = [
child._tset
for child in children
] + [
dep[ThirdPartyBuildInfo]._tset
for dep in deps
if ThirdPartyBuildInfo in dep
]
return ThirdPartyBuildInfo(
build = build,
_tset = actions.tset(ThirdPartyBuildTSet, **kwargs),
)