Repository navigation
feat(OtpInfo): add an optional relocatable tree - #18
Open
TrapsterDK wants to merge 1 commit into
Open
TrapsterDK wants to merge 1 commit into
TrapsterDK wants to merge 1 commit into
Conversation
A toolchain can only provide erlang as an absolute erlang_home on the
host, or as a release tar that each action unpacks to a fixed absolute
path under /tmp. Neither lets an erlang that lives inside the build
(for example a relocatable release checked in or fetched as a repo) be
used as plain inputs and runfiles.
Add an optional tree field to OtpInfo: a depset of every file of a
relocatable erlang whose root directory holds version_file. When it is
set:
- erlang_dirs puts the tree in the runfiles and returns the home
${RULES_ERLANG_HOME} (exported as TREE_ERLANG_HOME).
- maybe_install_erlang assigns RULES_ERLANG_HOME from the directory of
version_file (path in actions, short_path in tests) instead of
unpacking a tar. The variable is a plain shell variable, not exported.
- The ERLANG_HOME make variable of erlang_toolchain and erlang_vars is
the directory of version_file.
The field is read with getattr, so providers that do not set it, and
all existing toolchains, keep the current behaviour. Only the POSIX
shell scripts support a tree. erlang_headers now double-quotes the
home so the variable expands.
Add analysis tests with a fake tree toolchain (stub bin/erl, erlc,
escript): the erl_eval action derives the home and has every tree file
as input, the eunit script derives it from the short path and has the
tree in its runfiles, a release-tar toolchain still unpacks its tar,
and the make variable points at the tree. A sh_test builds erl_eval
with the tree toolchain and checks that the stub erl ran from the tree.
Assisted by Claude.
This was referenced Nov 4, 2026
rules_elixir: upstream the relocatable tree patch after rules_erlang#18 lands
devhusdk/rules_dx#6940
Open
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #17.
Problem
A toolchain can give erlang in two ways only: an absolute
erlang_homeon the host, or a release tar that each action unpacks to a fixed absolute path. Neither lets an erlang that lives inside the build be used as plain inputs and runfiles. Examples are a relocatable release in a repository rule or in the source tree.Change
OtpInfogets an optional, documentedtreefield. It is a depset of every file of a relocatable erlang whose root directory holdsversion_file.treeis set:erlang_dirsputs the tree in the runfiles. It returns the home${RULES_ERLANG_HOME}, which is exported asTREE_ERLANG_HOME.maybe_install_erlangassignsRULES_ERLANG_HOMEfrom the directory ofversion_file, using the path in actions and the short path in tests. It does not unpack a tar. The variable is a plain shell variable and is not exported.ERLANG_HOMEmake variable fromerlang_toolchainanderlang_varsis the directory ofversion_file. A genrule that uses it must list the tree files as inputs.treeis read withgetattr. Providers that do not set it, and every existing toolchain, behave as before.erlang_headersnow double-quotes the home, so the variable expands.erlang_dirsalso emitsmaybe_install_erlang. A new rule that skips it fails at once with an unset variable. (erlang_xrl_yrlhas this bug on main for release tars as well; PR 1 fixes it.)Test
private/otp_tree_testhas a fake tree toolchain:OTP_VERSIONplus stubbin/erl,bin/erlcandbin/escript.erl_evalderives the home, runs"${RULES_ERLANG_HOME}"/bin/erl, has every tree file as an input, and does not unpack a tar.eunitscript derives the home from the short path and has the tree in its runfiles.sh_testbuildserl_evalwith the tree toolchain (through a transition onextra_toolchains) and checks that the stub erl ran from the tree in the sandbox.OtpInfohas notreefield.Notes:
erlang_xrl_yrlwith an unboundRULES_ERLANG_HOME.treeyet; it is for toolchains defined by other repositories.Test output (OTP 29.1.2, Bazel 9.2.0,
--nohome_rc)The PR was also checked alone on
main(rootbazel test //...passes). The output below is from all four of my PRs stacked (bazel test //...in the root, then intest/).Assisted by Claude.