Function: bazel--external-repository
bazel--external-repository is a natively compiled function defined in
bazel.el.
Signature
(bazel--external-repository REPOSITORY-NAME THIS-REPOSITORY-ROOT)
Documentation
Return the repository root of an external repository.
REPOSITORY-NAME should be either a string naming an external repository, or nil to refer to the current repository. THIS-REPOSITORY-ROOT should be the name of the current repository root directory, as returned by ‘bazel--repository-root’. The return value is a directory name or nil if the repository root can’t be determined for any reason.
Source Code
;; Defined in /nix/store/ws8pkszjvcad1rgzqw6wja7qxacylfhn-emacs-packages-deps/share/emacs/site-lisp/elpa/bazel-20261002.1510/bazel.el
(defun bazel--external-repository (repository-name this-repository-root)
"Return the repository root of an external repository.
REPOSITORY-NAME should be either a string naming an external
repository, or nil to refer to the current repository.
THIS-REPOSITORY-ROOT should be the name of the current repository
root directory, as returned by ‘bazel--repository-root’. The
return value is a directory name or nil if the repository root can’t be
determined for any reason."
(declare (ftype (function ((or null string) string) string)))
(cl-check-type repository-name (or null string))
(cl-check-type this-repository-root string)
(cl-assert (not (string-empty-p repository-name)))
(if repository-name
;; See https://bazel.build/remote/output-directories for some overview of
;; the Bazel directory layout. Empirically, the directory
;; $(readlink ROOT/bazel-out)/../../../external/REPOSITORY is a symlink to
;; the repository root of the external repository REPOSITORY; see
;; https://bazel.build/remote/output-directories#layout-diagram. Again,
;; this is a heuristic, and should work for the common case. In
;; particular, we don’t want to shell out to “bazel info workspace” here,
;; because that might block indefinitely if another Bazel instance holds
;; the lock. We don’t check whether the directory exists, because it’s
;; generated and cached when needed.
(when-let* ((dir (bazel--external-repository-dir this-repository-root)))
(file-name-as-directory (expand-file-name repository-name dir)))
(file-name-as-directory this-repository-root)))