aea0a6fcc6
Running and testing should be working on the three platforms, but there's still a fair bit that needs to be done: - Wheel building + testing in a venv still needs to be implemented. - Python requirements still need to be compiled with piptool and pinned; need to compile on all platforms then merge - Cargo deps in cargo/ and rslib/ need to be cleaned up, and ideally unified into one place - Currently using rustls to work around openssl compilation issues on Linux, but this will break corporate proxies with custom SSL authorities; need to conditionally use openssl or use https://github.com/seanmonstar/reqwest/pull/1058 - Makefiles and docs still need cleaning up - It may make sense to reparent ts/* to the top level, as we don't nest the other modules under a specific language. - rspy and pylib must always be updated in lock-step, so merging rspy into pylib as a private module would simplify things. - Merging desktop-ftl and mobile-ftl into the core ftl would make managing and updating translations easier. - Obsolete scripts need removing. - And probably more.
83 lines
2.1 KiB
Python
83 lines
2.1 KiB
Python
def _rustfmt_impl(ctx):
|
|
toolchain = ctx.toolchains["@io_bazel_rules_rust//rust:toolchain"]
|
|
script_name = ctx.label.name + "_script"
|
|
rustfmt = toolchain.rustfmt.path
|
|
if ctx.attr.is_windows:
|
|
script_name += ".bat"
|
|
rustfmt = "@" + rustfmt.replace("/", "\\")
|
|
script = ctx.actions.declare_file(script_name)
|
|
|
|
args = [f.path for f in ctx.files.srcs]
|
|
|
|
if ctx.attr.fix:
|
|
mode = "--emit files"
|
|
else:
|
|
mode = "--check"
|
|
|
|
ctx.actions.write(
|
|
output = script,
|
|
content = "{rustfmt} {mode} --edition {edition} {files}".format(
|
|
rustfmt = rustfmt,
|
|
edition = toolchain.default_edition,
|
|
files = " ".join(args),
|
|
mode = mode,
|
|
),
|
|
)
|
|
|
|
runfiles = ctx.runfiles(files = ctx.files.srcs + [toolchain.rustfmt])
|
|
return [DefaultInfo(runfiles = runfiles, executable = script)]
|
|
|
|
_ATTRS = {
|
|
"srcs": attr.label_list(allow_files = True),
|
|
"is_windows": attr.bool(mandatory = True),
|
|
"fix": attr.bool(mandatory = True),
|
|
}
|
|
|
|
_rustfmt_test = rule(
|
|
implementation = _rustfmt_impl,
|
|
test = True,
|
|
toolchains = [
|
|
"@io_bazel_rules_rust//rust:toolchain",
|
|
],
|
|
attrs = _ATTRS,
|
|
)
|
|
|
|
_rustfmt_fix = rule(
|
|
implementation = _rustfmt_impl,
|
|
executable = True,
|
|
toolchains = [
|
|
"@io_bazel_rules_rust//rust:toolchain",
|
|
],
|
|
attrs = _ATTRS,
|
|
)
|
|
|
|
def rustfmt_test(name, srcs, **kwargs):
|
|
_rustfmt_test(
|
|
name = name,
|
|
srcs = srcs,
|
|
testonly = True,
|
|
fix = False,
|
|
is_windows = select({
|
|
"@bazel_tools//src/conditions:host_windows": True,
|
|
"//conditions:default": False,
|
|
}),
|
|
**kwargs
|
|
)
|
|
|
|
def rustfmt_fix(name, srcs, **kwargs):
|
|
# don't match //package/...
|
|
tags = kwargs.get("tags", [])
|
|
tags.append("manual")
|
|
|
|
_rustfmt_fix(
|
|
name = name,
|
|
srcs = srcs,
|
|
tags = tags,
|
|
fix = True,
|
|
is_windows = select({
|
|
"@bazel_tools//src/conditions:host_windows": True,
|
|
"//conditions:default": False,
|
|
}),
|
|
**kwargs
|
|
)
|