Skip to content

Commit

Permalink
Done command package
Browse files Browse the repository at this point in the history
  • Loading branch information
jcs090218 committed Mar 26, 2022
1 parent 661a294 commit a304cc2
Show file tree
Hide file tree
Showing 6 changed files with 92 additions and 27 deletions.
2 changes: 1 addition & 1 deletion cmds/compile.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

const util = require("../src/util");

exports.command = ['compile [names..]'];
exports.command = ['compile [names..]', 'build [names..]'];
exports.desc = 'byte compile all Emacs Lisp files in the package';
exports.builder = {
names: {
Expand Down
13 changes: 10 additions & 3 deletions cmds/build.js → cmds/package.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,16 @@

const util = require("../src/util");

exports.command = ['build'];
exports.desc = '';
exports.command = ['package [dest]'];
exports.desc = 'Build a package artefact, and put it into the given destination';
exports.builder = {
dest: {
description: 'destination path/folder',
requiresArg: false,
type: 'string',
},
};

exports.handler = async (argv) => {
await util.e_call(argv, 'build');
await util.e_call(argv, 'package', argv.dest);
};
23 changes: 0 additions & 23 deletions lisp/build.el

This file was deleted.

22 changes: 22 additions & 0 deletions lisp/extern/package-build.el
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,28 @@
;;; Commentary:
;;; Code:

(defun package-build--create-tar (name version directory)
"Create a tar file containing the contents of VERSION of package NAME."
(let ((tar (expand-file-name (concat name "-" version ".tar")
package-build-archive-dir))
(dir (concat name "-" version)))
;; XXX https://github.com/melpa/package-build/pull/34
;; (when (eq system-type 'windows-nt)
;; (setq tar (replace-regexp-in-string "^\\([a-z]\\):" "/\\1" tar)))
(let ((default-directory directory))
(process-file package-build-tar-executable nil
(get-buffer-create "*package-build-checkout*") nil
"-cvf" tar
"--exclude=.git"
"--exclude=.hg"
dir))
(when (and package-build-verbose noninteractive)
(message "Created %s containing:" (file-name-nondirectory tar))
(dolist (line (sort (process-lines package-build-tar-executable
"--list" "--file" tar)
#'string<))
(message " %s" line)))))

(defun package-build-expand-file-specs (dir specs &optional subdir allow-empty)
"In DIR, expand SPECS, optionally under SUBDIR.
The result is a list of (SOURCE . DEST), where SOURCE is a source
Expand Down
16 changes: 16 additions & 0 deletions lisp/extern/package-recipe.el
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
;;; package-recipe.el --- External module `package-recipe' -*- lexical-binding: t; -*-
;;; Commentary:
;;; Code:

(with-eval-after-load 'package-recipe
;; Specializations of package-build classes and methods to define a
;; directory based recipe.
(defclass package-directory-recipe (package-recipe)
((dir :initarg :dir :initform ".")))

(cl-defmethod package-recipe--working-tree ((rcp package-directory-recipe))
(oref rcp dir))

(cl-defmethod package-build--get-commit ((_rcp package-directory-recipe))))

;;; package-recipe.el ends here
43 changes: 43 additions & 0 deletions lisp/package.el
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
;;; package.el --- Build a package artefact -*- lexical-binding: t; -*-

;;; Commentary:
;;
;; Build a package artefact, and put it into the given destination
;;
;; $ eask package [dest]
;;
;;
;; Positional options:
;;
;; [dest] destination path/folder
;;

;;; Code:

(load-file (expand-file-name
"_prepare.el"
(file-name-directory (nth 1 (member "-scriptload" command-line-args)))))

(defconst eask-dist-path "dist"
"Name of default target directory for building packages.")

(eask-start
(let ((dest (or (eask-argv 0) eask-dist-path)))
(ignore-errors (make-directory (expand-file-name dest) t))

(eask-package-install 'package-build)
(require 'package-recipe)
(eask-load "./extern/package-build") ; override
(eask-load "./extern/package-recipe")

(let* ((name (eask-guess-package-name))
(patterns (or eask-files package-build-default-files-spec))
(path default-directory)
(version (eask-package-get :version))
(rcp (package-directory-recipe name :name name :files patterns :dir path))
(package-build-working-dir path)
(package-build-archive-dir (expand-file-name dest)))
(package-build--package rcp version))
(message "\n Done.")))

;;; package.el ends here

0 comments on commit a304cc2

Please sign in to comment.