Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(cmds): Add recompile command #254

Merged
merged 5 commits into from
Jun 7, 2024
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how
* fix: Don't pollute outer programs (#239)
* feat(generate/test): Add commands to setup test files (#243)
* feat: Add `docs` command (#245)
* feat(cmds): Add `recompile` command (#254)

## 0.9.x
> Released Nov 17, 2023
Expand Down
2 changes: 1 addition & 1 deletion cmds/core/compile.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"use strict";

exports.command = ['compile [names..]'];
exports.desc = 'Byte compile all Emacs Lisp files in the package';
exports.desc = "Byte-compile `.el' files";
exports.builder = yargs => yargs
.positional(
'[names..]', {
Expand Down
40 changes: 40 additions & 0 deletions cmds/core/recompile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/**
* Copyright (C) 2024 the Eask authors.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

"use strict";

exports.command = ['recompile [names..]'];
exports.desc = "Byte-recompile `.el' files";
exports.builder = yargs => yargs
.positional(
'[names..]', {
description: 'specify files to byte-compile',
type: 'array',
})
.options({
'clean': {
description: 'clean byte-recompile files individually',
type: 'boolean',
group: TITLE_CMD_OPTION,
},
});

exports.handler = async (argv) => {
await UTIL.e_call(argv, 'core/recompile'
, argv.names
, UTIL.def_flag(argv.clean, '--clean'));
};
5 changes: 3 additions & 2 deletions docs/content/Getting-Started/Basic-Usage/_index.en.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ Commands:
analyze [files..] Run Eask checker
archives List out all package archives [aliases: sources]
clean <type> Delete various files produced during building
compile [names..] Byte compile all Emacs Lisp files in the package
compile [names..] Byte-compile `.el' files
create <type> Create a new elisp project
docker <version> [args..] Launch specified Emacs version in a Docker container
docs Build documentation [aliases: doc]
docs [names..] Build documentation [aliases: doc]
emacs [args..] Execute emacs with the appropriate environment
eval [form] Evaluate lisp form with a proper PATH
path [patterns..] Print the PATH (exec-path) from workspace [aliases: exec-path]
Expand All @@ -60,6 +60,7 @@ Commands:
package-directory Print path to package directory
package [destination] Build a package artifact, and put it into the given destination [aliases: pack]
recipe Suggest a recipe format
recompile [names..] Byte-recompile `.el' files
refresh Download package archives
reinstall [names..] Reinstall packages
run <type> Run custom tasks
Expand Down
5 changes: 3 additions & 2 deletions docs/content/Getting-Started/Basic-Usage/_index.zh-tw.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ Commands:
analyze [files..] Run Eask checker
archives List out all package archives [aliases: sources]
clean <type> Delete various files produced during building
compile [names..] Byte compile all Emacs Lisp files in the package
compile [names..] Byte-compile `.el' files
create <type> Create a new elisp project
docker <version> [args..] Launch specified Emacs version in a Docker container
docs Build documentation [aliases: doc]
docs [names..] Build documentation [aliases: doc]
emacs [args..] Execute emacs with the appropriate environment
eval [form] Evaluate lisp form with a proper PATH
path [patterns..] Print the PATH (exec-path) from workspace [aliases: exec-path]
Expand All @@ -57,6 +57,7 @@ Commands:
package-directory Print path to package directory
package [destination] Build a package artifact, and put it into the given destination [aliases: pack]
recipe Suggest a recipe format
recompile [names..] Byte-recompile `.el' files
refresh Download package archives
reinstall [names..] Reinstall packages
run <type> Run custom tasks
Expand Down
15 changes: 14 additions & 1 deletion docs/content/Getting-Started/Commands-and-options/_index.en.md
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ by default.

## 🔍 eask compile

Byte-compile files.
Byte-compile `.el` files.

```sh
$ eask compile [FILES..]
Expand All @@ -201,6 +201,19 @@ Or compile files that are already specified in your `Eask`-file.
$ eask compile
```

## 🔍 eask recompile

Byte-recompile `.el` files.

```sh
$ eask recompile [FILES..]
```

{{< hint info >}}
💡 Similar to `eask compile`, but it will also remove old `.elc` files before
compiling.
{{< /hint >}}

## 🔍 eask package-directory

Print path to package directory, where all dependencies are installed.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ $ eask package [DESTINATION]

## 🔍 eask compile

字節編譯文件
字節編譯 `.el` 文件

```sh
$ eask compile [FILES..]
Expand All @@ -198,6 +198,18 @@ $ eask compile file-1.el file-2.el
$ eask compile
```

## 🔍 eask recompile

重新字節編譯 `.el` 文件。

```sh
$ eask recompile [FILES..]
```

{{< hint info >}}
💡 與 `eask compile` 類似,但它在編譯前會刪除舊的 `.elc` 檔案。
{{< /hint >}}

## 🔍 eask package-directory

打印包目錄的路徑,其中安裝了所有依賴項。
Expand Down
3 changes: 2 additions & 1 deletion lisp/_prepare.el
Original file line number Diff line number Diff line change
Expand Up @@ -1681,7 +1681,8 @@ For arguments MSG and ARGS, please see function `eask-print' for the detials."

For arguments MSG and ARGS, please see function `eask--format-paint-kwds' for
the detials."
(message (apply #'eask--format-paint-kwds msg args)))
(apply #'eask-write msg args)
(eask-princ "\n" t))

(defun eask-write (msg &rest args)
"Like the function `eask-msg' but without newline at the end.
Expand Down
4 changes: 2 additions & 2 deletions lisp/core/compile.el
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
;;; core/compile.el --- Byte compile all Emacs Lisp files in the package -*- lexical-binding: t; -*-
;;; core/compile.el --- Byte-compile `.el' files -*- lexical-binding: t; -*-

;;; Commentary:
;;
;; Byte compile all Emacs Lisp files in the package
;; Byte-compile `.el' files,
;;
;; $ eask compile [names..]
;;
Expand Down
30 changes: 30 additions & 0 deletions lisp/core/recompile.el
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
;;; core/recompile.el --- Byte-recompile `.el' files -*- lexical-binding: t; -*-

;;; Commentary:
;;
;; Byte-recompile `.el' files,
;;
;; $ eask recompile [names..]
;;
;;
;; Positionals:
;;
;; [names..] specify files to byte-recompile
;;

;;; Code:

(let ((dir (file-name-directory (nth 1 (member "-scriptload" command-line-args)))))
(load (expand-file-name "_prepare.el"
(locate-dominating-file dir "_prepare.el"))
nil t))

;;
;;; Core

(eask-start
(eask-call "clean/elc")
(eask-write "")
(eask-call "core/compile"))

;;; core/recompile.el ends here
2 changes: 2 additions & 0 deletions test/commands/local/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ eask package
# Development
eask compile
eask compile --clean
eask recompile
eask recompile --clean
eask recipe
eask keywords
eask run script
Expand Down
Loading