Vendor dependencies
Let's see how I like this workflow.
This commit is contained in:
parent
34d1830413
commit
9c435dc440
7500 changed files with 1665121 additions and 99 deletions
44
vendor/cxx/tools/buck/prelude/go/go_binary.bzl
vendored
Normal file
44
vendor/cxx/tools/buck/prelude/go/go_binary.bzl
vendored
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
# 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//utils:utils.bzl",
|
||||
"expect",
|
||||
)
|
||||
load(":compile.bzl", "compile", "get_filtered_srcs")
|
||||
load(":link.bzl", "link")
|
||||
|
||||
def go_binary_impl(ctx: "context") -> ["provider"]:
|
||||
lib = compile(ctx, "main", get_filtered_srcs(ctx, ctx.attrs.srcs), deps = ctx.attrs.deps)
|
||||
(bin, runtime_files) = link(ctx, lib, deps = ctx.attrs.deps, link_mode = ctx.attrs.link_mode)
|
||||
|
||||
hidden = []
|
||||
for resource in ctx.attrs.resources:
|
||||
if type(resource) == "artifact":
|
||||
hidden.append(resource)
|
||||
else:
|
||||
# Otherwise, this is a dependency, so extract the resource and other
|
||||
# resources from the `DefaultInfo` provider.
|
||||
info = resource[DefaultInfo]
|
||||
expect(
|
||||
len(info.default_outputs) == 1,
|
||||
"expected exactly one default output from {} ({})"
|
||||
.format(resource, info.default_outputs),
|
||||
)
|
||||
[resource] = info.default_outputs
|
||||
other = info.other_outputs
|
||||
|
||||
hidden.append(resource)
|
||||
hidden.extend(other)
|
||||
|
||||
return [
|
||||
DefaultInfo(
|
||||
default_outputs = [bin],
|
||||
other_outputs = hidden + runtime_files,
|
||||
),
|
||||
RunInfo(args = cmd_args(bin).hidden(hidden + runtime_files)),
|
||||
]
|
||||
Loading…
Add table
Add a link
Reference in a new issue