Skip to content

Commit

Permalink
Add extra variables to erlang_vars rules
Browse files Browse the repository at this point in the history
Also define a map used to conveniently pass those vars to sh_test
rules
  • Loading branch information
HoloRin committed Jun 14, 2024
1 parent 628356f commit f75854b
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion tools/erlang_vars.bzl
Original file line number Diff line number Diff line change
@@ -1,14 +1,32 @@
ERLANG_VARS_ENV_MAP = {
"OTP_VERSION": "$(OTP_VERSION)",
"OTP_VERSION_FILE_PATH": "$(OTP_VERSION_FILE_PATH)",
"OTP_VERSION_FILE_SHORT_PATH": "$(OTP_VERSION_FILE_SHORT_PATH)",
"ERLANG_HOME": "$(ERLANG_HOME)",
}

ERLANG_VARS_ENV_MAP_INTERNAL = ERLANG_VARS_ENV_MAP | {
"OTP_INSTALL_PATH": "$(OTP_INSTALL_PATH)",
"ERLANG_RELEASE_TAR_PATH": "$(ERLANG_RELEASE_TAR_PATH)",
"ERLANG_RELEASE_TAR_SHORT_PATH": "$(ERLANG_RELEASE_TAR_SHORT_PATH)",
}

def _impl(ctx):
otpinfo = ctx.toolchains["//tools:toolchain_type"].otpinfo
vars = {
"OTP_VERSION": otpinfo.version,
"OTP_VERSION_FILE_PATH": otpinfo.version_file.path,
"OTP_VERSION_FILE_SHORT_PATH": otpinfo.version_file.short_path,
"ERLANG_HOME": otpinfo.erlang_home,
}
if otpinfo.release_dir_tar != None:
vars["OTP_INSTALL_PATH"] = otpinfo.install_path
vars["ERLANG_RELEASE_TAR_PATH"] = otpinfo.release_dir_tar.path
vars["ERLANG_RELEASE_TAR_SHORT_PATH"] = otpinfo.release_dir_tar.short_path

return [platform_common.TemplateVariableInfo(vars)]
return [
platform_common.TemplateVariableInfo(vars),
]

erlang_vars = rule(
implementation = _impl,
Expand Down

0 comments on commit f75854b

Please sign in to comment.