Skip to content

Commit

Permalink
Fix remaining examples/no-prelude (#15)
Browse files Browse the repository at this point in the history
Summary:
Same as #13 but for the Go and Rust examples.

Pull Request resolved: #15

Reviewed By: lmvasquezg

Differential Revision: D39781318

Pulled By: lmvasquezg

fbshipit-source-id: 88a35404ec327ce051fa5c831a55092f05a2080b
  • Loading branch information
aherrmann authored and facebook-github-bot committed Sep 26, 2022
1 parent 9c7a765 commit 3d43c79
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 15 deletions.
6 changes: 6 additions & 0 deletions examples/no_prelude/go/.buckconfig
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,9 @@ name=BUILD

[repositories]
root = .
prelude = prelude
buck = no
fbcode = no
fbsource = no
ovr_config = no
toolchains = no
1 change: 1 addition & 0 deletions examples/no_prelude/go/prelude
12 changes: 6 additions & 6 deletions examples/no_prelude/go/rules.bzl
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
load("//toolchain.bzl", "GoCompilerInfo")

def _go_binary_impl(ctx: "context") -> ["provider"]:
sources = ctx.attr.srcs
sources = ctx.attrs.srcs
out = ctx.actions.declare_output("main")

cmd = cmd_args([ctx.attr.toolchain[GoCompilerInfo].compiler_path, "build", "-o", out.as_output()] + sources)
cmd = cmd_args([ctx.attrs.toolchain[GoCompilerInfo].compiler_path, "build", "-o", out.as_output()] + sources)

ctx.actions.run(cmd, category = "compile")

Expand All @@ -14,10 +14,10 @@ def _go_binary_impl(ctx: "context") -> ["provider"]:
]

go_binary = rule(
implementation = _go_binary_impl,
impl = _go_binary_impl,
attrs = {
"deps": attr.list(attr.dep()),
"srcs": attr.list(attr.source()),
"toolchain": attr.dep(),
"deps": attrs.list(attrs.dep()),
"srcs": attrs.list(attrs.source()),
"toolchain": attrs.dep(),
},
)
12 changes: 6 additions & 6 deletions examples/no_prelude/go/toolchain.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ GoCompilerInfo = provider(
)

def _go_toolchain_impl(ctx):
url = "https://go.dev/dl/go" + ctx.attr.version + "." + ctx.attr.platform + ".tar.gz"
url = "https://go.dev/dl/go" + ctx.attrs.version + "." + ctx.attrs.platform + ".tar.gz"

download = http_archive_impl(ctx, url, ctx.attr.sha1)
download = http_archive_impl(ctx, url, ctx.attrs.sha1)

compiler_dst = ctx.actions.declare_output("compiler")
compiler_src = cmd_args(download[0].default_outputs[0], format = "{}/go/bin/go")
Expand All @@ -15,11 +15,11 @@ def _go_toolchain_impl(ctx):
return download + [GoCompilerInfo(compiler_path = compiler_dst, GOROOT = "")]

go_toolchain = rule(
implementation = _go_toolchain_impl,
impl = _go_toolchain_impl,
attrs = {
"platform": attr.string(),
"sha1": attr.string(),
"version": attr.string(),
"platform": attrs.string(),
"sha1": attrs.string(),
"version": attrs.string(),
},
)

Expand Down
6 changes: 6 additions & 0 deletions examples/no_prelude/rust/.buckconfig
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,9 @@ name=BUILD

[repositories]
root = .
prelude = prelude
buck = no
fbcode = no
fbsource = no
ovr_config = no
toolchains = no
1 change: 1 addition & 0 deletions examples/no_prelude/rust/prelude
6 changes: 3 additions & 3 deletions examples/no_prelude/rust/rules.bzl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
def _rust_binary_impl(ctx):
file = ctx.attr.file
file = ctx.attrs.file
out = ctx.actions.declare_output("main")

cmd = cmd_args(["rustc", "--crate-type=bin", file, "-o", out.as_output()])
Expand All @@ -9,8 +9,8 @@ def _rust_binary_impl(ctx):
return [DefaultInfo(default_outputs = [out]), RunInfo(args = cmd_args([out]))]

rust_binary = rule(
implementation = _rust_binary_impl,
impl = _rust_binary_impl,
attrs = {
"file": attr.source(),
"file": attrs.source(),
},
)

0 comments on commit 3d43c79

Please sign in to comment.