format all bzl files consistently with buildifier

This commit is contained in:
Brian Hicks 2023-05-02 08:48:58 -05:00
parent 4db7f76d3a
commit 6c15c63487
No known key found for this signature in database
GPG Key ID: C4F324B9CAAB0D50
10 changed files with 62 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,