mirror of
https://github.com/NoRedInk/noredink-ui.git
synced 2025-01-06 22:49:38 +03:00
add an Elm toolchain which will download Elm
This commit is contained in:
parent
44d452bf53
commit
7ec695b9ec
@ -1,6 +1,7 @@
|
||||
[repositories]
|
||||
root = .
|
||||
prelude = prelude
|
||||
prelude-nri = prelude-nri
|
||||
toolchains = toolchains
|
||||
none = none
|
||||
|
||||
|
42
prelude-nri/elm/toolchain.bzl
Normal file
42
prelude-nri/elm/toolchain.bzl
Normal file
@ -0,0 +1,42 @@
|
||||
ElmToolchainInfo = provider(fields=[
|
||||
"elm",
|
||||
])
|
||||
|
||||
def _system_elm_toolchain_impl(_ctx) -> [[DefaultInfo.type, ElmToolchainInfo.type]]:
|
||||
"""
|
||||
An Elm toolchain that assumes the current environment has all the binaries
|
||||
it needs in PATH.
|
||||
"""
|
||||
return [
|
||||
DefaultInfo(),
|
||||
ElmToolchainInfo(
|
||||
elm = RunInfo(args = ["elm"]),
|
||||
),
|
||||
]
|
||||
|
||||
|
||||
system_elm_toolchain = rule(
|
||||
impl = _system_elm_toolchain_impl,
|
||||
attrs = {},
|
||||
is_toolchain_rule = True,
|
||||
)
|
||||
|
||||
def _elm_toolchain_impl(ctx: "context") -> [[DefaultInfo.type, ElmToolchainInfo.type]]:
|
||||
"""
|
||||
An Elm toolchain which you can source binaries from wherever it makes sense
|
||||
to you.
|
||||
"""
|
||||
return [
|
||||
DefaultInfo(),
|
||||
ElmToolchainInfo(
|
||||
elm = ctx.attrs.elm[RunInfo],
|
||||
),
|
||||
]
|
||||
|
||||
elm_toolchain = rule(
|
||||
impl = _elm_toolchain_impl,
|
||||
attrs = {
|
||||
"elm": attrs.dep(providers = [RunInfo]),
|
||||
},
|
||||
is_toolchain_rule = True,
|
||||
)
|
@ -1,6 +1,36 @@
|
||||
load("@prelude//toolchains:genrule.bzl", "system_genrule_toolchain")
|
||||
load("@prelude-nri//elm:toolchain.bzl", "elm_toolchain")
|
||||
|
||||
system_genrule_toolchain(
|
||||
name = "genrule",
|
||||
visibility = ["PUBLIC"],
|
||||
)
|
||||
|
||||
elm_toolchain(
|
||||
name = "elm",
|
||||
visibility = ["PUBLIC"],
|
||||
elm = ":elm_compiler_binary",
|
||||
)
|
||||
|
||||
ELM_COMPILER_URL = select({
|
||||
"config//os:linux": "https://github.com/elm/compiler/releases/download/0.19.1/binary-for-linux-64-bit.gz",
|
||||
"config//os:macos": "https://github.com/elm/compiler/releases/download/0.19.1/binary-for-mac-64-bit.gz",
|
||||
})
|
||||
|
||||
ELM_COMPILER_SHA256 = select({
|
||||
"config//os:linux": "e44af52bb27f725a973478e589d990a6428e115fe1bb14f03833134d6c0f155c",
|
||||
"config//os:macos": "05289f0e3d4f30033487c05e689964c3bb17c0c48012510dbef1df43868545d1",
|
||||
})
|
||||
|
||||
http_file(
|
||||
name = "elm_compiler_archive",
|
||||
urls = [ELM_COMPILER_URL],
|
||||
sha256 = ELM_COMPILER_SHA256,
|
||||
)
|
||||
|
||||
genrule(
|
||||
name = "elm_compiler_binary",
|
||||
cmd = "gzip --decompress --stdout --keep $(location :elm_compiler_archive) > $OUT && chmod +x $OUT",
|
||||
out = "elm",
|
||||
executable = True,
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user