Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions cmake-integration-configure.el
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,16 @@
(defvar ci-after-set-configure-preset-hook nil "A hook run after changing the configure preset.")


(defun ci--cmake-expand-env-vars (s)
"Expand $env{VAR} in string S."
(let ((expanded
(replace-regexp-in-string
"\\$env{\\([^}]+\\)}"
(lambda (match)
(or (getenv (match-string 1 match)) ""))
s)))
expanded))

(defun ci--perform-binaryDir-replacements (binaryDir project-root-folder preset-name)
"Replace `${sourceDir}' and `${presetName}' in a BINARYDIR string.

Expand All @@ -19,8 +29,7 @@ NOTE: `project-root-folder' must end with a slash."
(let* ((source-dir-replacement (cons "${sourceDir}/" project-root-folder))
(preset-name-replacement (cons "${presetName}" preset-name))
(replacements (list source-dir-replacement preset-name-replacement)))
(s-replace-all replacements binaryDir)))

(ci--cmake-expand-env-vars (s-replace-all replacements binaryDir))))

(defun ci--get-binaryDir (preset)
"Get the `binaryDir' field of a preset PRESET.
Expand Down