diff --git a/ape/entrypoint/repository.bzl b/ape/entrypoint/repository.bzl index 020f83ce0d8b26d1a3a4bf206ac2a8fda19adace..4696b855574d3727c3bdb547ece265f9a7ff74fd 100644 --- a/ape/entrypoint/repository.bzl +++ b/ape/entrypoint/repository.bzl @@ -13,6 +13,13 @@ ATTRS = { cfg = "exec", default = "@launcher//:ape", ), + "assimilate": attr.label( + doc = "The assimilation APE binary.", + allow_single_file = True, + executable = True, + cfg = "exec", + default = "@cosmos-assimilate//:assimilate", + ), "binary": attr.label( doc = "The αcτµαlly pδrταblε εxεcµταblε binary.", allow_single_file = True, @@ -31,13 +38,19 @@ ATTRS = { } def implementation(rctx): - if "windows" in rctx.os.name: + if rctx.os.name != "linux": rctx.symlink(rctx.attr.binary, "entrypoint") else: - rctx.template("entrypoint", rctx.attr.posix, { - "{{launcher}}": str(rctx.path(rctx.attr.launcher)), - "{{binary}}": str(rctx.path(rctx.attr.binary)), - }, executable = True) + cmd = ( + rctx.attr.launcher, + rctx.path(rctx.attr.assimilate), + "-o", + "entrypoint", + rctx.path(rctx.attr.binary), + ) + result = rctx.execute(cmd) + if result.return_code != 0: + fail("Failed to assimilate: {}".format(cmd)) rctx.template("BUILD.bazel", rctx.attr.build, { "{{exports}}": repr(["entrypoint"]), @@ -48,4 +61,5 @@ entrypoint = repository_rule( attrs = ATTRS, implementation = implementation, configure = True, + local = True, )