Skip to content

[Support]: How to rebuild a package at init if source is newer than compiled #368

@meedstrom

Description

@meedstrom

Confirmation

  • I have checked the documentation (README, Wiki, docstrings, etc)
  • I am checking these without reading them.
  • I have searched previous issues to see if my question is a duplicate.

Elpaca Version

Elpaca a65fcc5 HEAD -> master, origin/master, origin/HEAD
installer: 0.7
emacs-version: GNU Emacs 29.4 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.42, cairo version 1.18.0)
of 2024-06-30, modified by Debian
git --version: git version 2.45.2

Operating System

Debian sid

Description

I decided I'd like to avoid using M-x elpaca-rebuild all the time on the packages I develop. Better if my init process will do it automatically.

I took a stab at this, but I don't quite understand how to design build steps to take this into account. Here's my attempt:

(defun +elpaca/build-if-new (e)
  (let ((compiled-main (file-name-concat
                        (elpaca<-build-dir e)
                        (concat (file-name-base (elpaca<-main e))
                                ".elc"))))
    (if (file-newer-than-file-p (elpaca<-main e) compiled-main)
        (elpaca--build-steps (elpaca<-recipe e))
      elpaca--pre-built-steps)))

(use-package org-node
  :ensure (:build (+elpaca/build-if-new))
  :after org)

I got this backtrace:

Debugger entered--Lisp error: (wrong-type-argument stringp nil)
  file-name-base(nil)
  (concat (file-name-base (progn (progn (nth 8 e)))) ".elc")
  (file-name-concat (progn (progn (nth 6 e))) (concat (file-name-base (progn (progn (nth 8 e)))) ".elc"))
  (let ((compiled (file-name-concat (progn (progn (nth 6 e))) (concat (file-name-base (progn (progn ...))) ".elc")))) (if (file-newer-than-file-p (progn (progn (nth 8 e))) compiled) (elpaca--build-steps (progn (progn (nth 11 e)))) elpaca--pre-built-steps))
  +elpaca/build-if-new((elpaca org-node "org-node" (org-node :build (+elpaca/build-if-new)) (queued) "/home/me/.config/emacs/elpaca/repos/org-node/" "/home/me/.config/emacs/elpaca/builds29.4/org-node" nil nil nil nil (:package "org-node" :fetcher github :repo "meedstrom/org-node" :files ("*.el" "*.el.in" "dir" "*.info" "*.texi" "*.texinfo" "doc/dir" "doc/*.info" "doc/*.texi" "doc/*.texinfo" "lisp/*.el" "docs/dir" "docs/*.info" "docs/*.texi" "docs/*.texinfo" (:exclude ".dir-locals.el" "test.el" "tests.el" "*-test.el" "*-tests.el" "LICENSE" "README*" "*-pkg.el")) :source "MELPA" :protocol https :inherit t :depth treeless :build (+elpaca/build-if-new)) nil nil nil nil 3 (26366 35685 603907 107000) init nil ((queued (26366 35686 81696 661000) "Continued by: elpaca--process" 2) (queued (26366 35685 603914 562000) "Package queued" 1)) t))
  elpaca--continue-build((elpaca org-node "org-node" (org-node :build (+elpaca/build-if-new)) (queued) "/home/me/.config/emacs/elpaca/repos/org-node/" "/home/me/.config/emacs/elpaca/builds29.4/org-node" nil nil nil nil (:package "org-node" :fetcher github :repo "meedstrom/org-node" :files ("*.el" "*.el.in" "dir" "*.info" "*.texi" "*.texinfo" "doc/dir" "doc/*.info" "doc/*.texi" "doc/*.texinfo" "lisp/*.el" "docs/dir" "docs/*.info" "docs/*.texi" "docs/*.texinfo" (:exclude ".dir-locals.el" "test.el" "tests.el" "*-test.el" "*-tests.el" "LICENSE" "README*" "*-pkg.el")) :source "MELPA" :protocol https :inherit t :depth treeless :build (+elpaca/build-if-new)) nil nil nil nil 3 (26366 35685 603907 107000) init nil ((queued (26366 35686 81696 661000) "Continued by: elpaca--process" 2) (queued (26366 35685 603914 562000) "Package queued" 1)) t))

Now I'm considering an alternative trick of using a :pre-build command to simply delete the built directory if it's older. Maybe that would be easier.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions