1380: format with buildifier r=ArthurJordao a=BrianHicks

# 🚧 Don't merge before #1378

This formats all our Buck files with buildifier, a formatter for Starlark designed for use with Bazel.

Co-authored-by: Brian Hicks <brian@brianthicks.com>
This commit is contained in:
noredinkbot-duet[bot] 2023-05-02 21:09:01 +00:00 committed by GitHub
commit 8b9e51b2c6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 65 additions and 52 deletions

2
BUCK
View File

@ -11,7 +11,7 @@ elm_docs(
filegroup(
name = "src",
srcs = glob(["src/**/*.elm"]),
visibility = ["//component-catalog:app"]
visibility = ["//component-catalog:app"],
)
node_modules(

View File

@ -8,7 +8,7 @@ elm_app(
source_directories = {
"../src": "//:src",
"src": "src",
}
},
)
filegroup(
@ -20,5 +20,5 @@ filegroup(
"elm.js": ":app",
"application.json": "elm.json",
"package.json": "//:elm.json",
}
},
)

View File

@ -11,12 +11,16 @@ def _elm_docs_impl(ctx: "context") -> [DefaultInfo.type]:
ctx.attrs._python_toolchain[PythonToolchainInfo].interpreter,
elm_toolchain.isolated_compile[DefaultInfo].default_outputs,
ctx.attrs.elm_json,
"--build-dir", build.as_output(),
"--elm-compiler", elm_toolchain.elm,
"--build-dir",
build.as_output(),
"--elm-compiler",
elm_toolchain.elm,
"--verbose",
"docs",
"--out", docs.as_output(),
"--src", ctx.attrs.src,
"--out",
docs.as_output(),
"--src",
ctx.attrs.src,
)
ctx.actions.run(
@ -30,18 +34,18 @@ def _elm_docs_impl(ctx: "context") -> [DefaultInfo.type]:
elm_docs = rule(
impl = _elm_docs_impl,
attrs = {
"out": attrs.string(default="docs.json"),
"out": attrs.string(default = "docs.json"),
"elm_json": attrs.source(),
"src": attrs.source(allow_directory = True),
"_elm_toolchain": attrs.toolchain_dep(
default="toolchains//:elm",
providers=[ElmToolchainInfo]
default = "toolchains//:elm",
providers = [ElmToolchainInfo],
),
"_python_toolchain": attrs.toolchain_dep(
default="toolchains//:python",
providers=[PythonToolchainInfo]
default = "toolchains//:python",
providers = [PythonToolchainInfo],
),
}
},
)
def _elm_app_impl(ctx: "context") -> [DefaultInfo.type]:
@ -54,16 +58,19 @@ def _elm_app_impl(ctx: "context") -> [DefaultInfo.type]:
ctx.attrs._python_toolchain[PythonToolchainInfo].interpreter,
elm_toolchain.isolated_compile[DefaultInfo].default_outputs,
ctx.attrs.elm_json,
"--build-dir", build.as_output(),
"--elm-compiler", elm_toolchain.elm,
"--build-dir",
build.as_output(),
"--elm-compiler",
elm_toolchain.elm,
"--verbose",
"make",
ctx.attrs.main,
"--output", out.as_output(),
"--output",
out.as_output(),
)
for (name, value) in ctx.attrs.source_directories.items():
cmd.add(cmd_args(value, format="--source-directory=" + name + "={}"))
cmd.add(cmd_args(value, format = "--source-directory=" + name + "={}"))
if ctx.attrs.debug and ctx.attrs.optimize:
fail("Only one of `optimize` and `debug` may be true!")
@ -90,17 +97,17 @@ elm_app = rule(
"main": attrs.source(),
"source_directories": attrs.dict(
attrs.string(),
attrs.source(allow_directory=True),
attrs.source(allow_directory = True),
),
"debug": attrs.bool(default = False),
"optimize": attrs.bool(default = False),
"_elm_toolchain": attrs.toolchain_dep(
default="toolchains//:elm",
providers=[ElmToolchainInfo]
default = "toolchains//:elm",
providers = [ElmToolchainInfo],
),
"_python_toolchain": attrs.toolchain_dep(
default="toolchains//:python",
providers=[PythonToolchainInfo]
default = "toolchains//:python",
providers = [PythonToolchainInfo],
),
}
},
)

View File

@ -1,4 +1,4 @@
ElmToolchainInfo = provider(fields=[
ElmToolchainInfo = provider(fields = [
"elm",
"isolated_compile",
])
@ -16,11 +16,10 @@ def _system_elm_toolchain_impl(ctx) -> [[DefaultInfo.type, ElmToolchainInfo.type
),
]
system_elm_toolchain = rule(
impl = _system_elm_toolchain_impl,
attrs = {
"_isolated_compile": attrs.dep(default="prelude-nri//elm:isolated_compile.py"),
"_isolated_compile": attrs.dep(default = "prelude-nri//elm:isolated_compile.py"),
},
is_toolchain_rule = True,
)
@ -45,7 +44,7 @@ elm_toolchain = rule(
providers = [RunInfo],
default = "prelude-nri//elm:elm_compiler_binary",
),
"_isolated_compile": attrs.dep(default="prelude-nri//elm:isolated_compile.py"),
"_isolated_compile": attrs.dep(default = "prelude-nri//elm:isolated_compile.py"),
},
is_toolchain_rule = True,
)

View File

@ -11,9 +11,12 @@ def _node_modules_impl(ctx: "context") -> [DefaultInfo.type]:
ctx.attrs._python_toolchain[PythonToolchainInfo].interpreter,
node_toolchain.build_node_modules[DefaultInfo].default_outputs,
out.as_output(),
"--package", ctx.attrs.package,
"--package-lock", ctx.attrs.package_lock,
"--bin-dir", node_toolchain.bin_dir[DefaultInfo].default_outputs,
"--package",
ctx.attrs.package,
"--package-lock",
ctx.attrs.package_lock,
"--bin-dir",
node_toolchain.bin_dir[DefaultInfo].default_outputs,
],
category = "npm",
)
@ -26,14 +29,14 @@ node_modules = rule(
"package": attrs.source(),
"package_lock": attrs.source(),
"_node_toolchain": attrs.toolchain_dep(
default="toolchains//:node",
providers=[NodeToolchainInfo]
default = "toolchains//:node",
providers = [NodeToolchainInfo],
),
"_python_toolchain": attrs.toolchain_dep(
default="toolchains//:python",
providers=[PythonToolchainInfo]
default = "toolchains//:python",
providers = [PythonToolchainInfo],
),
}
},
)
def _npm_bin_impl(ctx: "context") -> [[DefaultInfo.type, RunInfo.type]]:
@ -50,7 +53,8 @@ def _npm_bin_impl(ctx: "context") -> [[DefaultInfo.type, RunInfo.type]]:
ctx.attrs.node_modules,
bin_name,
out.as_output(),
"--bin-dir", node_toolchain.bin_dir[DefaultInfo].default_outputs,
"--bin-dir",
node_toolchain.bin_dir[DefaultInfo].default_outputs,
],
category = "build_npm_bin",
)
@ -63,15 +67,15 @@ def _npm_bin_impl(ctx: "context") -> [[DefaultInfo.type, RunInfo.type]]:
npm_bin = rule(
impl = _npm_bin_impl,
attrs = {
"bin_name": attrs.option(attrs.string(), default=None),
"bin_name": attrs.option(attrs.string(), default = None),
"node_modules": attrs.source(),
"_node_toolchain": attrs.toolchain_dep(
default="toolchains//:node",
providers=[NodeToolchainInfo]
default = "toolchains//:node",
providers = [NodeToolchainInfo],
),
"_python_toolchain": attrs.toolchain_dep(
default="toolchains//:python",
providers=[PythonToolchainInfo]
default = "toolchains//:python",
providers = [PythonToolchainInfo],
),
}
},
)

View File

@ -1,4 +1,4 @@
NodeToolchainInfo = provider(fields=[
NodeToolchainInfo = provider(fields = [
"bin_dir",
"node",
"build_node_modules",
@ -24,17 +24,17 @@ node_toolchain = rule(
impl = _node_toolchain_impl,
attrs = {
"bin_dir": attrs.dep(
default="prelude-nri//node:bin"
default = "prelude-nri//node:bin",
),
"node": attrs.dep(
providers = [RunInfo],
default="prelude-nri//node:node"
default = "prelude-nri//node:node",
),
"_build_node_modules": attrs.dep(
default="prelude-nri//node:build_node_modules.py",
default = "prelude-nri//node:build_node_modules.py",
),
"_build_npm_bin": attrs.dep(
default="prelude-nri//node:build_npm_bin.py",
default = "prelude-nri//node:build_npm_bin.py",
),
},
is_toolchain_rule = True,

View File

@ -959,6 +959,6 @@ def omnibus_environment_attr():
})
# In open source, we don't want to use omnibus
default = None # @oss-enable
default = None # @oss-enable
return attrs.option(attrs.dep(), default = default)

4
prelude/genrule.bzl generated
View File

@ -55,8 +55,8 @@ def _requires_no_srcs_environment(ctx: "context") -> bool.type:
return _NO_SRCS_ENVIRONMENT_LABEL in ctx.attrs.labels
# We don't want to use cache mode in open source because the config keys that drive it aren't wired up
# @oss-disable: _USE_CACHE_MODE = True
_USE_CACHE_MODE = False # @oss-enable
# @oss-disable: _USE_CACHE_MODE = True
_USE_CACHE_MODE = False # @oss-enable
# Extra attributes required by every genrule based on genrule_impl
def genrule_attributes() -> {str.type: "attribute"}:

2
prelude/rules.bzl generated
View File

@ -37,7 +37,7 @@ def _mk_rule(rule_spec: "") -> "rule":
# Fat platforms is an idea specific to our toolchains, so doesn't apply to
# open source. Ideally this restriction would be done at the toolchain level.
fat_platform_compatible = True # @oss-enable
fat_platform_compatible = True # @oss-enable
if not fat_platform_compatible:
# copy so we don't try change the passed in object

View File

@ -18,7 +18,7 @@ _CONSTRAINTS = [
"ovr_config//third-party/python/constraints:cinder.3.8",
]
_CONSTRAINTS = [] # @oss-enable
_CONSTRAINTS = [] # @oss-enable
# Apparently, `==` doesn't do value comparison for `ConstraintValueInfo`, so
# impl a hacky eq impl to workaround.

View File

@ -41,5 +41,8 @@ stdenv.mkDerivation {
# stuff we need for running builds in a `nix-shell --pure` environment.
which
netcat-gnu
# Buck dependencies
buildifier
] ++ lib.optionals stdenv.isLinux [ pkgs.fsatrace pkgs.strace pkgs.cacert ];
}