Vendor dependencies

Let's see how I like this workflow.
This commit is contained in:
John Doty 2022-12-19 08:27:18 -08:00
parent 34d1830413
commit 9c435dc440
7500 changed files with 1665121 additions and 99 deletions

View file

@ -0,0 +1,61 @@
# 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//linking:link_info.bzl",
"MergedLinkInfo",
"merge_link_infos",
)
load(
"@prelude//linking:shared_libraries.bzl",
"SharedLibraryInfo",
"merge_shared_libraries",
)
load(
"@prelude//utils:utils.bzl",
"map_idx",
)
load(":compile.bzl", "GoPkgCompileInfo", "GoTestInfo", "compile", "get_filtered_srcs", "get_inherited_compile_pkgs")
load(":link.bzl", "GoPkgLinkInfo", "get_inherited_link_pkgs")
load(":packages.bzl", "go_attr_pkg_name", "merge_pkgs")
def go_library_impl(ctx: "context") -> ["provider"]:
pkgs = {}
default_outputs = []
pkg_name = None
if ctx.attrs.srcs:
pkg_name = go_attr_pkg_name(ctx)
lib = compile(
ctx,
pkg_name,
get_filtered_srcs(ctx, ctx.attrs.srcs),
deps = ctx.attrs.deps + ctx.attrs.exported_deps,
)
default_outputs.append(lib)
pkgs[pkg_name] = lib
return [
DefaultInfo(default_outputs = default_outputs),
GoPkgCompileInfo(pkgs = merge_pkgs([
pkgs,
get_inherited_compile_pkgs(ctx.attrs.exported_deps),
])),
GoPkgLinkInfo(pkgs = merge_pkgs([
pkgs,
get_inherited_link_pkgs(ctx.attrs.deps + ctx.attrs.exported_deps),
])),
GoTestInfo(
deps = ctx.attrs.deps,
srcs = ctx.attrs.srcs,
pkg_name = pkg_name,
),
merge_link_infos(ctx, filter(None, [d.get(MergedLinkInfo) for d in ctx.attrs.deps])),
merge_shared_libraries(
ctx.actions,
deps = filter(None, map_idx(SharedLibraryInfo, ctx.attrs.deps)),
),
]