(defun erb--builder-func () "Build commits from `erb--unbuilt-commits'." (catch 'stop (while t (condition-case err (let ((commit (thread-queue-get erb--unbuilt-commits)) build-result) (when (eq commit 'stop) (message "ERB builder thread stopping") (throw 'stop nil)) (erb--status-remove commit 'waiting-to-build) (erb--status-add commit 'building) (unwind-protect (let ((job (thread-message-value erb--job))) (unless (eq job 'cancel) (with-current-buffer (erb--job-buffer job) (setq build-result (erb--build commit))))) (erb--status-remove commit 'building) (if build-result (erb--status-add commit 'built) (erb--status-add commit 'failed-builds)) (thread-queue-put (list commit build-result) erb--built-commits))) ((error quit) (message "Error in ERB benchmark build thread: %s" err)))))) (defun erb--build (commit) "Build Emacs from COMMIT. Run the build in an asynchonous process in a temporary directory. Save the directory name if the build is successful. If the build fails, save the output of the build script in the file COMMIT.log in the results/MACHINE/failed-builds directory of `erb-suite-directory'." (let* ((temp-dir (file-name-as-directory (make-temp-file "erb" t))) (default-directory temp-dir) (name (format "ERB-build-%s" commit)) (outbuf (generate-new-buffer name)) (build-script (erb--get-build-script-filename)) process success) (unwind-protect (map-let (project-repo) erb--config (setq process (condition-case _err (start-file-process name outbuf build-script project-repo commit) ((error quit) nil))) (if (null process) (progn (message "Failed to start build process for commit `%s'" commit) (erb-run--record-failure commit "Failed to start build process")) (catch 'quit (while (process-live-p process) (accept-process-output nil 0.5) (when (erb--cancel-now-p) (delete-process process) (throw 'quit nil))) (if (= (process-exit-status process) 0) (progn (setq success temp-dir) (erb-run--remove-old-failure commit)) (message "Building commit `%s' failed" commit) (erb-run--record-failure commit outbuf))))) (unless success (delete-directory temp-dir t)) (kill-buffer outbuf)) success))