diff --git a/prelude-nri/elm/BUCK b/prelude-nri/elm/BUCK index 44364d40..c54017f9 100644 --- a/prelude-nri/elm/BUCK +++ b/prelude-nri/elm/BUCK @@ -2,3 +2,27 @@ export_file( name = "isolated_compile.py", visibility = ["PUBLIC"], ) + +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, + visibility = ["PUBLIC"], +) diff --git a/prelude-nri/elm/isolated_compile.py b/prelude-nri/elm/isolated_compile.py index bf8a9fed..87d3c046 100644 --- a/prelude-nri/elm/isolated_compile.py +++ b/prelude-nri/elm/isolated_compile.py @@ -22,7 +22,7 @@ def symlink_if_necessary(source, target): - If the target already exists and points somewhere else, remove it and relink. """ - if os.path.exists(target): + if os.path.lexists(target): if os.path.isfile(target): logging.debug(f"`{target}` is a regular file") diff --git a/prelude-nri/elm/toolchain.bzl b/prelude-nri/elm/toolchain.bzl index 44887309..ec2f469d 100644 --- a/prelude-nri/elm/toolchain.bzl +++ b/prelude-nri/elm/toolchain.bzl @@ -41,7 +41,10 @@ def _elm_toolchain_impl(ctx: "context") -> [[DefaultInfo.type, ElmToolchainInfo. elm_toolchain = rule( impl = _elm_toolchain_impl, attrs = { - "elm": attrs.dep(providers = [RunInfo]), + "elm": attrs.dep( + providers = [RunInfo], + default = "prelude-nri//elm:elm_compiler_binary", + ), "_isolated_compile": attrs.dep(default="prelude-nri//elm:isolated_compile.py"), }, is_toolchain_rule = True, diff --git a/toolchains/BUCK b/toolchains/BUCK index 14037781..f23234b8 100644 --- a/toolchains/BUCK +++ b/toolchains/BUCK @@ -21,30 +21,6 @@ system_python_bootstrap_toolchain( 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, ) node_toolchain(