Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • bazel/ape
1 result
Show changes
Commits on Source (6)
# [1.0.0-beta.10](https://git.gitlab.arm.com/bazel/ape/compare/v1.0.0-beta.9...v1.0.0-beta.10) (2024-06-18)
### Bug Fixes
- alias assimilate targets ([1632a5f](https://git.gitlab.arm.com/bazel/ape/commit/1632a5fd837b2d8a0c1b73a6f5606e9a4ede0f72))
- **assimilate:** propagate runfiles ([afcd247](https://git.gitlab.arm.com/bazel/ape/commit/afcd247373004a05c4ede739a571cb9ef6b82d64))
- **assimilate:** symlink on Apple Silicon ([d3a0590](https://git.gitlab.arm.com/bazel/ape/commit/d3a0590934a3c560d3456942a202caeda4158e08))
### Code Refactoring
- **binary:** change from `target` to `src` ([ce0fb14](https://git.gitlab.arm.com/bazel/ape/commit/ce0fb14f408a2a5bd3afb5c2a3b0b8673bd7aed0))
### BREAKING CHANGES
- **binary:** The `ape_binary#target` attribute has changed to `ape_binary#src`.
This aligns to other `*_binary` rules such as `sh_binary`.
# [1.0.0-beta.9](https://git.gitlab.arm.com/bazel/ape/compare/v1.0.0-beta.8...v1.0.0-beta.9) (2024-06-17)
### Bug Fixes
......
module(
name = "ape",
version = "1.0.0-beta.9",
version = "1.0.0-beta.10",
bazel_compatibility = [
">=7.0.0",
],
......
load("//:binaries.bzl", "BINARIES")
load("//ape/assimilate:defs.bzl", "ape_assimilate")
[
ape_assimilate(
alias(
name = binary,
src = "@cosmos-{}//:{}".format(binary, binary),
actual = "//ape/assimilate:{}".format(binary),
visibility = ["//:__subpackages__"],
)
for binary in BINARIES
......
load("//:binaries.bzl", "BINARIES")
load("//ape/assimilate:defs.bzl", "ape_assimilate")
[
ape_assimilate(
name = binary,
src = "@cosmos-{}//:{}".format(binary, binary),
visibility = ["//:__subpackages__"],
)
for binary in BINARIES
]
......@@ -40,20 +40,22 @@ ATTRS = {
def implementation(ctx):
windows = ctx.attr._windows[platform_common.ConstraintValueInfo]
macos = ctx.attr._macos[platform_common.ConstraintValueInfo]
arm64 = ctx.attr._arm64[platform_common.ConstraintValueInfo]
basename = ctx.attr.basename or ctx.label.name
executable = ctx.actions.declare_file("{}.ape/{}".format(ctx.label.name, basename))
if ctx.target_platform_has_constraint(windows):
_symlink(ctx, executable)
runfiles = _symlink(ctx, executable)
elif ctx.target_platform_has_constraint(macos) and ctx.target_platform_has_constraint(arm64):
runfiles = _symlink(ctx, executable)
else:
_assimilate(ctx, executable)
runfiles = _assimilate(ctx, executable)
files = depset([executable])
runfiles = ctx.runfiles([executable])
return DefaultInfo(
executable = executable,
files = files,
......@@ -74,7 +76,9 @@ def _assimilate(ctx, executable):
# Executable format
if ctx.target_platform_has_constraint(windows):
fail("Cannot assimilate on Windows, APE are already PE format. Symlink instead.")
elif ctx.target_platform_has_constraint(macos) and not ctx.target_platform_has_constraint(arm64):
elif ctx.target_platform_has_constraint(macos) and ctx.target_platform_has_constraint(arm64):
fail("Cannot assimilate on Apple Silicon, assimilate binaries are not runnable without APE loader. Symlink instead.")
elif ctx.target_platform_has_constraint(macos):
args.add("-m") # MachO
else:
args.add("-e") # ELF
......@@ -101,6 +105,8 @@ def _assimilate(ctx, executable):
toolchain = "//ape/toolchain/assimilate:type",
)
return ctx.runfiles([executable])
def _symlink(ctx, executable):
ctx.actions.symlink(
output = executable,
......@@ -108,6 +114,11 @@ def _symlink(ctx, executable):
is_executable = True,
)
runfiles = ctx.runfiles([executable, ctx.file.src])
runfiles.merge(ctx.attr.src.default_runfiles)
return runfiles
ape_assimilate = rule(
doc = DOC,
attrs = ATTRS,
......
load("//:binaries.bzl", "BINARIES")
load(":rule.bzl", "ape_binary")
[
ape_binary(
name = binary,
src = "@cosmos-{}//:{}".format(binary, binary),
visibility = ["//:__subpackages__"],
)
for binary in BINARIES
]
alias(
name = "template",
actual = select({
......
......@@ -9,7 +9,7 @@ if errorlevel 1 (
)
:: Bazel substitutions
call :runfiles TARGET "{{target}}"
call :runfiles TARGET "{{src}}"
if errorlevel 1 exit /b %ERRORLEVEL%
call :runfiles APE "{{ape}}"
if errorlevel 1 exit /b %ERRORLEVEL%
......@@ -52,4 +52,4 @@ if [%RESOLVED%] equ [] (
)
endlocal & set %~1=%RESOLVED%
goto :eof
\ No newline at end of file
goto :eof
......@@ -23,7 +23,7 @@ rlocation() (
)
# Bazel substitutions
TARGET="$(rlocation "{{target}}")"
TARGET="$(rlocation "{{src}}")"
APE="$(rlocation "{{ape}}")"
readonly TARGET APE
......
......@@ -6,7 +6,7 @@ This avoids any issues with `binfmt_misc` picking up binaries under Wine or simi
"""
ATTRS = {
"target": attr.label(
"src": attr.label(
doc = "The ape binary target to launch",
allow_single_file = True,
executable = True,
......@@ -26,7 +26,7 @@ def implementation(ctx):
substitutions = ctx.actions.template_dict()
substitutions.add("{{ape}}", ape.executable.short_path)
substitutions.add("{{target}}", ctx.file.target.short_path)
substitutions.add("{{src}}", ctx.file.src.short_path)
ctx.actions.expand_template(
template = ctx.file._template,
......@@ -37,8 +37,8 @@ def implementation(ctx):
files = depset([executable])
runfiles = ctx.runfiles([executable, ctx.executable.target, ape.executable])
runfiles = runfiles.merge(ctx.attr.target.default_runfiles)
runfiles = ctx.runfiles([executable, ctx.executable.src, ape.executable])
runfiles = runfiles.merge(ctx.attr.src.default_runfiles)
runfiles = runfiles.merge(ape.default.default_runfiles)
return DefaultInfo(
......