texlive[56513] trunk: light-latex-make (2oct20)

commits+karl at tug.org commits+karl at tug.org
Fri Oct 2 23:45:14 CEST 2020


Revision: 56513
          http://tug.org/svn/texlive?view=revision&revision=56513
Author:   karl
Date:     2020-10-02 23:45:14 +0200 (Fri, 02 Oct 2020)
Log Message:
-----------
light-latex-make (2oct20)

Modified Paths:
--------------
    trunk/Build/source/texk/texlive/linked_scripts/light-latex-make/llmk.lua
    trunk/Master/texmf-dist/doc/man/man1/llmk.1
    trunk/Master/texmf-dist/doc/man/man1/llmk.man1.pdf
    trunk/Master/texmf-dist/doc/support/light-latex-make/README.md
    trunk/Master/texmf-dist/doc/support/light-latex-make/llmk-doc.cls
    trunk/Master/texmf-dist/doc/support/light-latex-make/llmk-logo.png
    trunk/Master/texmf-dist/doc/support/light-latex-make/llmk.pdf
    trunk/Master/texmf-dist/doc/support/light-latex-make/llmk.tex
    trunk/Master/texmf-dist/scripts/light-latex-make/llmk.lua

Modified: trunk/Build/source/texk/texlive/linked_scripts/light-latex-make/llmk.lua
===================================================================
--- trunk/Build/source/texk/texlive/linked_scripts/light-latex-make/llmk.lua	2020-10-02 21:41:45 UTC (rev 56512)
+++ trunk/Build/source/texk/texlive/linked_scripts/light-latex-make/llmk.lua	2020-10-02 21:45:14 UTC (rev 56513)
@@ -27,6 +27,7 @@
 }
 M.verbosity_level = 1
 M.silent = false
+M.dry_run = false
 
 llmk.core = M
 end
@@ -38,7 +39,7 @@
 
 -- program information
 M.prog_name = 'llmk'
-M.version = '0.1.0'
+M.version = '0.2.0'
 M.copyright = 'Copyright 2018-2020'
 M.author = 'Takuto ASAKURA (wtsnjp)'
 M.llmk_toml = 'llmk.toml'
@@ -76,7 +77,7 @@
   aux_file = {'string', {true, nil}},
   aux_empty_size = {'integer', {false, nil}},
   command = {'string', {false, ''}}, -- '' default because it must be string
-  generated_target = {'bool', {false, false}},
+  generated_target = {'boolean', {false, false}},
   opts = {'*[string]', {true, nil}},
   postprocess = {'string', {false, nil}},
   target = {'string', {true, '%S'}},
@@ -208,7 +209,7 @@
 
   if expected == 'integer' then
     error_if_wrong_type(v, 'number')
-  elseif expected == 'bool' then
+  elseif expected == 'boolean' then
     error_if_wrong_type(v, 'boolean')
   elseif expected == 'string' then
     error_if_wrong_type(v, 'string')
@@ -215,7 +216,7 @@
   elseif expected == '[string]' then
     error_if_wrong_type(v, 'table')
 
-    if v[1] then -- it is not an empty array
+    if v[1] ~= nil then -- it is not an empty array
       error_if_wrong_type(v[1], 'string')
     end
   elseif expected == '*[string]' then
@@ -224,7 +225,7 @@
     else
       error_if_wrong_type(v, 'table')
 
-      if v[1] then -- it is not an empty array
+      if v[1] ~= nil then -- it is not an empty array
         error_if_wrong_type(v[1], 'string')
       end
     end
@@ -278,22 +279,31 @@
 end
 
 local function version_check(given_version)
-  if given_version then
-    local given_major, given_minor = given_version:match('^(%d+)%.(%d+)')
-    if not given_major or not given_minor then
-      llmk.util.err_print('warning', 'In valid llmk_version: ' .. given_version)
-      return
-    else
-      given_major, given_minor = tonumber(given_major), tonumber(given_minor)
-    end
+  if not given_version then -- nothing to do
+    return
+  end
 
-    local major, minor = llmk.const.version:match('^(%d+)%.(%d+)')
-    major, minor = tonumber(major), tonumber(minor)
-    if major < given_major or (major == given_major and minor < given_minor) then
-      llmk.util.err_print('warning',
-        'This program is older than specified "llmk_version"')
-    end
+  -- parse the given version to the llmk_version key
+  local given_major, given_minor = given_version:match('^(%d+)%.(%d+)')
+  if not given_major or not given_minor then
+    llmk.util.err_print('warning', 'In valid llmk_version: ' .. given_version)
+    return
+  else
+    given_major, given_minor = tonumber(given_major), tonumber(given_minor)
   end
+
+  -- the version of this program
+  local major, minor = llmk.const.version:match('^(%d+)%.(%d+)')
+  major, minor = tonumber(major), tonumber(minor)
+
+  -- warn if this program is older than the given version
+  if major < given_major or (major == given_major and minor < given_minor) then
+    llmk.util.err_print('warning',
+      'This program (v%d.%d) is older than the specified llmk_version (v%d.%d)',
+      major, minor, given_major, given_minor)
+  end
+
+  -- Note: no breaking change has been made (yet)
 end
 
 function M.check(tab)
@@ -464,6 +474,11 @@
 
   local function step(n)
     n = n or 1
+    for i = 0, n-1 do
+      if char(i):match(nl) then
+        line = line + 1
+      end
+    end
     cursor = cursor + n
   end
 
@@ -580,7 +595,6 @@
           num = num .. char()
         end
       elseif char():match(nl) then
-        line = line + 1
         break
       elseif char():match(ws) or char() == '#' then
         break
@@ -604,10 +618,8 @@
 
     while(bounds()) do
       if char() == ']' then
-        line = line + 1
         break
       elseif char():match(nl) then
-        line = line + 1
         step()
         skip_ws()
       elseif char() == '#' then
@@ -684,10 +696,6 @@
       end
     end
 
-    if char():match(nl) then
-      line = line + 1
-    end
-
     if char() == '=' then
       step()
       skip_ws()
@@ -1148,11 +1156,33 @@
   else
     redirect_code = ' >/dev/null 2>&1'
   end
-  silencer = function() return cmd .. redirect_code end
-  return cmd .. redirect_code
+  silencer = function(cmd) return cmd .. redirect_code end
+  return silencer(cmd)
 end
 
-local function run_program(name, prog, fn, fdb)
+local function run_program(name, prog, fn, fdb, postprocess)
+  -- preparation for dry run
+  local function concat_cond(tab)
+    local res
+    for i, v in ipairs(tab) do
+      if i == 1 then
+        res = v
+      else
+        res = res .. '; ' .. v
+      end
+    end
+    return res
+  end
+  local cond = {}
+
+  if postprocess then
+    cond[#cond + 1] = 'as postprocess'
+  end
+
+  if prog.aux_file then
+    cond[#cond + 1] = 'possibly with rerunning'
+  end
+
   -- does command specified?
   if #prog.command < 1 then
     llmk.util.err_print('warning',
@@ -1161,7 +1191,7 @@
   end
 
   -- does target exist?
-  if not lfs.isfile(prog.target) then
+  if not llmk.core.dry_run and not lfs.isfile(prog.target) then
     llmk.util.dbg_print('run',
       'Skiping "%s" because target (%s) does not exist',
       prog.command, prog.target)
@@ -1169,15 +1199,32 @@
   end
 
   -- is the target modified?
-  if prog.generated_target and file_mtime(prog.target) < start_time then
-    llmk.util.dbg_print('run',
-      'Skiping "%s" because target (%s) is not updated',
-      prog.command, prog.target)
-    return false
+  if prog.generated_target then
+    if llmk.core.dry_run then
+      cond[#cond + 1] = string.format('if the target file "%s" has been generated',
+        prog.target)
+    elseif file_mtime(prog.target) < start_time then
+      llmk.util.dbg_print('run',
+        'Skiping "%s" because target (%s) is not updated',
+        prog.command, prog.target)
+      return false
+    end
+  else
+    if llmk.core.dry_run then
+      cond[#cond + 1] = string.format('if the target file "%s" exists', prog.target)
+    end
   end
 
   local cmd = construct_cmd(prog, fn, prog.target)
-  llmk.util.err_print('info', 'Running command: ' .. cmd)
+  if llmk.core.dry_run then
+    print('Dry running: ' .. cmd)
+    if #cond > 0 then
+      llmk.util.err_print('info', '<-- ' .. concat_cond(cond))
+    end
+    return false
+  else
+    llmk.util.err_print('info', 'Running command: ' .. cmd)
+  end
 
   -- redirect stdout and stderr to NULL in silent mode
   if llmk.core.silent then
@@ -1195,7 +1242,8 @@
   return true
 end
 
-local function process_program(programs, name, fn, fdb, config)
+local function process_program(programs, name, fn, fdb, config, postprocess)
+  local postprocess = postprocess or false
   local prog = programs[name]
   local should_rerun
 
@@ -1204,7 +1252,7 @@
   local exe_count = 0
   while true do
     exe_count = exe_count + 1
-    run = run_program(name, prog, fn, fdb)
+    run = run_program(name, prog, fn, fdb, postprocess)
 
     -- if the run is skipped, break immediately
     if not run then break end
@@ -1217,9 +1265,9 @@
   end
 
   -- go to the postprocess process
-  if prog.postprocess and run then
+  if prog.postprocess and (run or llmk.core.dry_run) then
     llmk.util.dbg_print('run', 'Going to postprocess "%s"', prog.postprocess)
-    process_program(programs, prog.postprocess, fn, fdb, config)
+    process_program(programs, prog.postprocess, fn, fdb, config, true)
   end
 end
 
@@ -1253,12 +1301,16 @@
 
 -- fn is filepath of target to remove.
 local function remove(fn)
-  local ok = os.remove(fn)
-  
-  if ok ~= true then
-    llmk.util.err_print('error', 'Failed to remove "%s"', fn)
+  if llmk.core.dry_run then
+    print(string.format('Dry running: removing file "%s"', fn))
   else
-    llmk.util.err_print('info', 'Removed "%s"', fn)
+    local ok = os.remove(fn)
+
+    if ok ~= true then
+      llmk.util.err_print('error', 'Failed to remove "%s"', fn)
+    else
+      llmk.util.err_print('info', 'Removed "%s"', fn)
+    end
   end
 end
 
@@ -1302,12 +1354,13 @@
   -d CAT, --debug=CAT   Activate debug output restricted to CAT.
   -D, --debug           Activate all debug output (equal to "--debug=all").
   -h, --help            Print this help message.
+  -n, --dry-run         Show what would have been executed.
   -q, --quiet           Suppress most messages.
   -s, --silent          Silence messages from called programs.
   -v, --verbose         Print additional information.
   -V, --version         Print the version number.
 
-Please report bugs to <tkt.asakura at gmail.com>.
+Please report bugs to <https://github.com/wtsnjp/llmk/issues>.
 ]]
 
 local version_text = [[
@@ -1405,6 +1458,9 @@
       llmk.core.verbosity_level = 2
     elseif (curr_arg == '-s') or (curr_arg == '--silent') then
       llmk.core.silent = true
+    -- dry run
+    elseif (curr_arg == '-n') or (curr_arg == '--dry-run') then
+      llmk.core.dry_run = true
     -- problem
     else
       llmk.util.err_print('error', 'unknown option: ' .. curr_arg)

Modified: trunk/Master/texmf-dist/doc/man/man1/llmk.1
===================================================================
--- trunk/Master/texmf-dist/doc/man/man1/llmk.1	2020-10-02 21:41:45 UTC (rev 56512)
+++ trunk/Master/texmf-dist/doc/man/man1/llmk.1	2020-10-02 21:45:14 UTC (rev 56513)
@@ -1,10 +1,10 @@
 .\" generated with Ronn/v0.7.3
 .\" http://github.com/rtomayko/ronn/tree/0.7.3
 .
-.TH "LLMK" "1" "September 2020" "llmk 0.1.0" "llmk manual"
+.TH "LLMK" "1" "October 2020" "llmk 0.2.0" "llmk manual"
 .
 .SH "NAME"
-\fBllmk\fR \- The Light LaTeX Make
+\fBllmk\fR \- Light LaTeX Make
 .
 .SH "SYNOPSIS"
 \fBllmk\fR [OPTION]\.\.\. [FILE]\.\.\.
@@ -38,6 +38,10 @@
 Print this help message\.
 .
 .TP
+\fB\-n\fR, \fB\-\-dry\-run\fR
+Show what would have been executed\.
+.
+.TP
 \fB\-q\fR, \fB\-\-quiet\fR
 Suppress warnings and most error messages\.
 .
@@ -47,7 +51,7 @@
 .
 .TP
 \fB\-v\fR, \fB\-\-verbose\fR
-Print additional information (e\.g\., viewer command)\.
+Print additional information (e\.g\., running commands)\.
 .
 .TP
 \fB\-V\fR, \fB\-\-version\fR
@@ -76,10 +80,10 @@
 Type error\.
 .
 .SH "REPORTING BUGS"
-Report bugs to tkt\.asakura at gmail\.com\.
+Report bugs to \fIhttps://github\.com/wtsnjp/llmk/issues\fR\.
 .
 .br
-Source: https://github\.com/wtsnjp/llmk
+Source: \fIhttps://github\.com/wtsnjp/llmk\fR
 .
 .SH "COPYRIGHT"
 Copyright 2018\-2020 Takuto ASAKURA (wtsnjp)\.

Modified: trunk/Master/texmf-dist/doc/man/man1/llmk.man1.pdf
===================================================================
(Binary files differ)

Modified: trunk/Master/texmf-dist/doc/support/light-latex-make/README.md
===================================================================
--- trunk/Master/texmf-dist/doc/support/light-latex-make/README.md	2020-10-02 21:41:45 UTC (rev 56512)
+++ trunk/Master/texmf-dist/doc/support/light-latex-make/README.md	2020-10-02 21:45:14 UTC (rev 56513)
@@ -10,11 +10,17 @@
 * no complicated nesting of configuration, and
 * modern default settings (make LuaTeX de facto standard!)
 
-See the bundled reference manual (llmk.pdf) for the full specification of the program. The following sections are for a quick guidance.
+See the bundled reference manual ([llmk.pdf](http://mirrors.ctan.org/support/light-latex-make/llmk.pdf)) for the full specification of the program. The following sections are for a quick guidance.
 
+## Installation
+
+This software is included in [TeX Live](https://www.tug.org/texlive/) as Package `light-latex-make`. If you are using the latest TeX Live, you normally don't need to install it by yourself (please use the `tlmgr` command to install it, if the package is missing).
+
+In case the package is not installed in your TeX system or you want to use the latest (development) version of the program, you have to install it manually. You can acquire any material related to this software from [our GitHub repository](https://github.com/wtsnjp/llmk). The installation procedure is very simple anyway because the `llmk.lua` is the standalone executable. Running `texlua <path>/llmk.lua` should work in any case. In UNIX-like systems, the easiest way to install the program is copy or symlink the file `llmk.lua` as `llmk` in any place in the `PATH`.
+
 ## Basic Usage
 
-The easiest way to use **llmk** is to write the build settings into the LaTeX document itself. The settings can be written as [TOML](https://toml.io) format in comments of a source file, and those have to be placed between the comment lines only with the consecutive `+` characters (at least three).
+The most simple way to use **llmk** is to write the build settings into the LaTeX document itself. The settings can be written as [TOML](https://toml.io) format in comments of a source file, and those have to be placed between the comment lines only with the consecutive `+` characters (at least three).
 
 Here's a very simple example:
 
@@ -217,6 +223,12 @@
 generated_target = true
 ```
 
+## Links to other materials
+
+* [Reference manual](http://mirrors.ctan.org/support/light-latex-make/llmk.pdf): it describes the full specification.
+* [Talk in TUG 2020](https://www.youtube.com/watch?v=kzqlNHKmzBo): the author talked about the design concept with a demonstration.
+* [TUGboat article](https://tug.org/members/TUGboat/tb41-2/tb128asakura-llmk.pdf): the post-proceedings of the above talk. (currently TUG member access only)
+
 ## Acknowledgements
 
 This project has been supported by the [TeX Development Fund](https://www.tug.org/tc/devfund/) created by the TeX Users Group (No. 29). I would like to thank all contributors and the people who gave me advice and suggestions for new features for the llmk project.

Modified: trunk/Master/texmf-dist/doc/support/light-latex-make/llmk-doc.cls
===================================================================
--- trunk/Master/texmf-dist/doc/support/light-latex-make/llmk-doc.cls	2020-10-02 21:41:45 UTC (rev 56512)
+++ trunk/Master/texmf-dist/doc/support/light-latex-make/llmk-doc.cls	2020-10-02 21:45:14 UTC (rev 56513)
@@ -16,7 +16,7 @@
   \def\@tempb{\@gobble}%
   \@for\next:=\@classoptionslist\do
     {\ifx\next\@tempa
-       \message{Cleared  option \next\space from global list}%
+       \message{Cleared option \next\space from global list}%
      \else
        \edef\@tempb{\@tempb,\next}%
      \fi}%
@@ -131,7 +131,7 @@
     \vskip 1em
     {\fontsize{1.2cm}{0pt}\selectfont\logomainfont llmk}
     \vskip .3em
-    {\fontsize{0.5cm}{0pt}\selectfont\logosubfont The Light {\LaTeX} Make}
+    {\fontsize{0.5cm}{0pt}\selectfont\logosubfont Light {\LaTeX} Make}
     \vskip .5em
     %{\ifx\@subtitle\@empty\else\usekomafont{subtitle}\@subtitle\par\fi}%
     \vskip 1em
@@ -166,8 +166,8 @@
 \newcommand*{\hyph}{-}
 \newcommand*{\meta}[1]{\bgroup
   \normalfont\color{special}$\langle$\textit{#1}$\rangle$\egroup}
-\newcommand*{\code}[1]{\bgroup
-  \chardef\_=`\_\code at font #1\egroup}
+\DeclareRobustCommand{\code}[1]{%
+  \texorpdfstring{\bgroup\chardef\_=`\_\code at font #1\egroup}{#1}}
 \newcommand*{\cs}[1]{\texttt{\char`\\#1}}
 \newcommand*{\sopt}[1]{\hyperlink{clo:#1}{\code{\hyph#1}}}
 \newcommand*{\lopt}[1]{\hyperlink{clo:#1}{\code{\hyph{}\hyph#1}}}
@@ -182,6 +182,13 @@
   \expandafter\egroup\x
   \hyperlink{\@tmp at hyname}{\code{#1}}}
 \newcommand*{\type}[1]{\textcolor{special}{#1}}
+\newcommand*{\README}{%
+  \href{https://github.com/wtsnjp/llmk/blob/master/README.md}
+  {\code{README.md}}}
+\newcommand{\printLICENSE}{%
+  \IfFileExists{./LICENSE}{\input{./LICENSE}}{% else
+    \IfFileExists{../LICENSE}{\input{../LICENSE}}{% else
+      \message{File LICENSE not found}}}}
 
 % verbatim
 \def\code at font{% code

Modified: trunk/Master/texmf-dist/doc/support/light-latex-make/llmk-logo.png
===================================================================
(Binary files differ)

Modified: trunk/Master/texmf-dist/doc/support/light-latex-make/llmk.pdf
===================================================================
(Binary files differ)

Modified: trunk/Master/texmf-dist/doc/support/light-latex-make/llmk.tex
===================================================================
--- trunk/Master/texmf-dist/doc/support/light-latex-make/llmk.tex	2020-10-02 21:41:45 UTC (rev 56512)
+++ trunk/Master/texmf-dist/doc/support/light-latex-make/llmk.tex	2020-10-02 21:45:14 UTC (rev 56513)
@@ -10,7 +10,7 @@
 \title{llmk: Light {\LaTeX} Make}
 \author{Takuto Asakura (wtsnjp)}
 \subtitle{Reference Manual}
-\date{v0.1.0\quad\today}
+\date{v0.2.0\quad\today}
 \keywords{llmk, build-tool, toml, lua, luatex}
 
 \begin{document}
@@ -19,8 +19,8 @@
 
 \section{Overview}
 
-The \prog{llmk} program is yet another build tool specific for {\LaTeX}
-documents. Its aim is to provide a simple way to specify a workflow of
+Light {\LaTeX} Make (\prog{llmk}) is yet another build tool specific for
+{\LaTeX} documents. Its aim is to provide a simple way to specify a workflow of
 processing {\LaTeX} documents and encourage people to always explicitly show
 the right workflow for each document.
 
@@ -36,15 +36,20 @@
 \prog{llmk} setup, the process of typesetting the document must be reproduced
 in any {\TeX} environment with the program.
 
-% TODO: explain that llmk is included in TeX Live and MiKTeX when ready
+\subsection{Installation}
 
+This software is included in {\TeX} Live as Package \code{light-latex-make}. If
+you have the latest {\TeX} Live, you normally don't need to install it by
+yourself. If you want to install the development version, please refer to our
+{\README}.
+% TODO: mention MiKTeX when ready
+
 \subsection{Learning \prog{llmk}}
 
-The bundled \href{https://github.com/wtsnjp/llmk/blob/master/README.md}
-{\code{README.md}} has a general introduction for the program. If you are new
-to \prog{llmk} and looking for a quick guidance, you are recommended to read it
-first. Conversely, this document can be regarded as a reference manual: it
-contains detailed descriptions for every feature of \prog{llmk} as much as
+The bundled {\README} has a general introduction for the program. If you are
+new to \prog{llmk} and looking for a quick guidance, you are recommended to
+read it first. Conversely, this document can be regarded as a reference manual:
+it contains detailed descriptions for every feature of \prog{llmk} as much as
 possible, but unsuitable for getting general ideas of its basic usage.
 
 \begin{samepage}
@@ -85,11 +90,6 @@
 take them into account. Before making a request, it is strongly recommended to
 read the article about the design concept~\cite{asakura2020}.
 
-One more thing: as you can see, the author of the program is not a native
-English speaker. Thus, there should be plenty of grammatical errors and
-unnatural sentences in the documentation, including this manual itself.
-Correction for such writing issues is particularly welcome.
-
 \section{Command-line interface}
 
 \subsection{Command usage}
@@ -143,6 +143,7 @@
 will be ignored.
 
 \subsubsection*{Command-line options \meta{options}}
+\enlargethispage{5mm}% FIXME
 
 We have tried to implement a GNU-compatible option parser. Short options, each of
 which consists of a single letter, must start with a single hyphen |-|.
@@ -149,15 +150,12 @@
 Multiple short options can be specified with a single hyphen, \eg |-vs| is
 equivalent to |-v -s|. Long options have to be following double hyphens |--|.
 All options must be specified before the first argument. A string beginning
-with a hyphen after the first argument will be treated as an argument starting
-with a hyphen.
+with a hyphen after the first argument will be treated as an argument.
 
 When two or more options are specified, \prog{llmk} applies them in the given
 order. If contradicting options are specified, \eg \sopt{q} v.s.\ \sopt{v}, the
 option in the latter position wins over the former one.
 
-The following is the full list of available command-line options:
-
 \begin{clopt}{\sopt{c}, \lopt{clean}}
 Removes temporary files such as \code{aux} and \code{log} files. The files
 removed with this action can be customized with the key \ckey{clean\_files}.
@@ -185,6 +183,13 @@
 ignored.
 \end{clopt}
 
+\begin{clopt}{\sopt{n}, \lopt{dry-run}}
+Show what would have been executed without actually invoking the commands. This
+flag is useful if you want to make sure whether your configuration will work as
+expected before the actual building. With option \lopt{verbose}, you can get
+further detailed information.
+\end{clopt}
+
 \begin{clopt}{\sopt{q}, \lopt{quiet}}
 This suppress most of the messages from the program.
 \end{clopt}
@@ -206,23 +211,23 @@
 
 \subsection{Exit codes}
 
+\begin{samepage}
 You can grasp whether \prog{llmk} successfully executed or not by seeing its
 status code. Note that the exit codes of invoked programs are not directly
 transferred as the exit code of \prog{llmk}; instead, the statuses of external
 programs that failed, if any, are reported in the error messages.
 %
-\begin{description}[left=2em]
-\item[\code{0}]
-  Success.
-\item[\code{1}]
-  General error.
-\item[\code{2}]
-  Invoked program failed.
-\item[\code{3}]
-  Parser error.
-\item[\code{4}]
-  Type error.
-\end{description}
+\begin{center}
+\begin{tabular}{rp{12em}rp{12em}}
+\toprule
+Code & Error type & Code & Error Type \\ \midrule
+\code{0} & Success & \code{3} & Parser Error \\
+\code{1} & General Error & \code{4} & Type Error \\
+\code{2} & Invoked program failed & \\
+\bottomrule
+\end{tabular}
+\end{center}
+\end{samepage}
 
 \section{Writing workflows in TOML format}
 \label{sec:toml}
@@ -376,10 +381,11 @@
 configuration.
 
 \begin{confkey}{bibtex}{type: \type{string}}[default: \code{"bibtex"}]
-The command to use for the \progname{bibtex} program. Internally, this key is
-an alias for the \ckey{command} key in the \progname{bibtex} entry. If the
-\ckey{command} key is specified in the \ckey{programs} table, this alias is
-ineffective.
+The command to use for the \progname{bibtex} program. Reference processing
+tools that are compatible with {\BibTeX} can be specified for this key, \eg
+\code{"biber"}. Internally, this key is an alias for the \ckey{command} key in
+the \progname{bibtex} entry. If the \ckey{command} key is specified in the
+\ckey{programs} table, this alias is ineffective.
 \end{confkey}
 
 \begin{confkey}{clean\_files}{type: \type{array of strings}}
@@ -593,8 +599,8 @@
 \ref{sec:default-sequence}), but other entries can be easily used just by
 overriding the \ckey{sequence} array.
 
-\Program{bibtex} The entry for the {\BibTeX} program and friends. The
-\progname{latex} program is set as \ckey{postprocess} so that to make sure
+\Program{bibtex} The entry for the {\BibTeX} program and friends, \eg Biber.
+The \progname{latex} program is set as \ckey{postprocess} so that to make sure
 rerunning {\LaTeX} command after this execution.
 %
 \begin{lstlisting}[style=toml]
@@ -832,27 +838,7 @@
 \parskip=\baselineskip
 \small\ttfamily
 \noindent
-The MIT License (MIT)
-
-Copyright 2018-2020 Takuto ASAKURA (wtsnjp)
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in all
-copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-SOFTWARE.
+\printLICENSE
 \end{quotation}
 
 \subsection*{Third-party software}

Modified: trunk/Master/texmf-dist/scripts/light-latex-make/llmk.lua
===================================================================
--- trunk/Master/texmf-dist/scripts/light-latex-make/llmk.lua	2020-10-02 21:41:45 UTC (rev 56512)
+++ trunk/Master/texmf-dist/scripts/light-latex-make/llmk.lua	2020-10-02 21:45:14 UTC (rev 56513)
@@ -27,6 +27,7 @@
 }
 M.verbosity_level = 1
 M.silent = false
+M.dry_run = false
 
 llmk.core = M
 end
@@ -38,7 +39,7 @@
 
 -- program information
 M.prog_name = 'llmk'
-M.version = '0.1.0'
+M.version = '0.2.0'
 M.copyright = 'Copyright 2018-2020'
 M.author = 'Takuto ASAKURA (wtsnjp)'
 M.llmk_toml = 'llmk.toml'
@@ -76,7 +77,7 @@
   aux_file = {'string', {true, nil}},
   aux_empty_size = {'integer', {false, nil}},
   command = {'string', {false, ''}}, -- '' default because it must be string
-  generated_target = {'bool', {false, false}},
+  generated_target = {'boolean', {false, false}},
   opts = {'*[string]', {true, nil}},
   postprocess = {'string', {false, nil}},
   target = {'string', {true, '%S'}},
@@ -208,7 +209,7 @@
 
   if expected == 'integer' then
     error_if_wrong_type(v, 'number')
-  elseif expected == 'bool' then
+  elseif expected == 'boolean' then
     error_if_wrong_type(v, 'boolean')
   elseif expected == 'string' then
     error_if_wrong_type(v, 'string')
@@ -215,7 +216,7 @@
   elseif expected == '[string]' then
     error_if_wrong_type(v, 'table')
 
-    if v[1] then -- it is not an empty array
+    if v[1] ~= nil then -- it is not an empty array
       error_if_wrong_type(v[1], 'string')
     end
   elseif expected == '*[string]' then
@@ -224,7 +225,7 @@
     else
       error_if_wrong_type(v, 'table')
 
-      if v[1] then -- it is not an empty array
+      if v[1] ~= nil then -- it is not an empty array
         error_if_wrong_type(v[1], 'string')
       end
     end
@@ -278,22 +279,31 @@
 end
 
 local function version_check(given_version)
-  if given_version then
-    local given_major, given_minor = given_version:match('^(%d+)%.(%d+)')
-    if not given_major or not given_minor then
-      llmk.util.err_print('warning', 'In valid llmk_version: ' .. given_version)
-      return
-    else
-      given_major, given_minor = tonumber(given_major), tonumber(given_minor)
-    end
+  if not given_version then -- nothing to do
+    return
+  end
 
-    local major, minor = llmk.const.version:match('^(%d+)%.(%d+)')
-    major, minor = tonumber(major), tonumber(minor)
-    if major < given_major or (major == given_major and minor < given_minor) then
-      llmk.util.err_print('warning',
-        'This program is older than specified "llmk_version"')
-    end
+  -- parse the given version to the llmk_version key
+  local given_major, given_minor = given_version:match('^(%d+)%.(%d+)')
+  if not given_major or not given_minor then
+    llmk.util.err_print('warning', 'In valid llmk_version: ' .. given_version)
+    return
+  else
+    given_major, given_minor = tonumber(given_major), tonumber(given_minor)
   end
+
+  -- the version of this program
+  local major, minor = llmk.const.version:match('^(%d+)%.(%d+)')
+  major, minor = tonumber(major), tonumber(minor)
+
+  -- warn if this program is older than the given version
+  if major < given_major or (major == given_major and minor < given_minor) then
+    llmk.util.err_print('warning',
+      'This program (v%d.%d) is older than the specified llmk_version (v%d.%d)',
+      major, minor, given_major, given_minor)
+  end
+
+  -- Note: no breaking change has been made (yet)
 end
 
 function M.check(tab)
@@ -464,6 +474,11 @@
 
   local function step(n)
     n = n or 1
+    for i = 0, n-1 do
+      if char(i):match(nl) then
+        line = line + 1
+      end
+    end
     cursor = cursor + n
   end
 
@@ -580,7 +595,6 @@
           num = num .. char()
         end
       elseif char():match(nl) then
-        line = line + 1
         break
       elseif char():match(ws) or char() == '#' then
         break
@@ -604,10 +618,8 @@
 
     while(bounds()) do
       if char() == ']' then
-        line = line + 1
         break
       elseif char():match(nl) then
-        line = line + 1
         step()
         skip_ws()
       elseif char() == '#' then
@@ -684,10 +696,6 @@
       end
     end
 
-    if char():match(nl) then
-      line = line + 1
-    end
-
     if char() == '=' then
       step()
       skip_ws()
@@ -1148,11 +1156,33 @@
   else
     redirect_code = ' >/dev/null 2>&1'
   end
-  silencer = function() return cmd .. redirect_code end
-  return cmd .. redirect_code
+  silencer = function(cmd) return cmd .. redirect_code end
+  return silencer(cmd)
 end
 
-local function run_program(name, prog, fn, fdb)
+local function run_program(name, prog, fn, fdb, postprocess)
+  -- preparation for dry run
+  local function concat_cond(tab)
+    local res
+    for i, v in ipairs(tab) do
+      if i == 1 then
+        res = v
+      else
+        res = res .. '; ' .. v
+      end
+    end
+    return res
+  end
+  local cond = {}
+
+  if postprocess then
+    cond[#cond + 1] = 'as postprocess'
+  end
+
+  if prog.aux_file then
+    cond[#cond + 1] = 'possibly with rerunning'
+  end
+
   -- does command specified?
   if #prog.command < 1 then
     llmk.util.err_print('warning',
@@ -1161,7 +1191,7 @@
   end
 
   -- does target exist?
-  if not lfs.isfile(prog.target) then
+  if not llmk.core.dry_run and not lfs.isfile(prog.target) then
     llmk.util.dbg_print('run',
       'Skiping "%s" because target (%s) does not exist',
       prog.command, prog.target)
@@ -1169,15 +1199,32 @@
   end
 
   -- is the target modified?
-  if prog.generated_target and file_mtime(prog.target) < start_time then
-    llmk.util.dbg_print('run',
-      'Skiping "%s" because target (%s) is not updated',
-      prog.command, prog.target)
-    return false
+  if prog.generated_target then
+    if llmk.core.dry_run then
+      cond[#cond + 1] = string.format('if the target file "%s" has been generated',
+        prog.target)
+    elseif file_mtime(prog.target) < start_time then
+      llmk.util.dbg_print('run',
+        'Skiping "%s" because target (%s) is not updated',
+        prog.command, prog.target)
+      return false
+    end
+  else
+    if llmk.core.dry_run then
+      cond[#cond + 1] = string.format('if the target file "%s" exists', prog.target)
+    end
   end
 
   local cmd = construct_cmd(prog, fn, prog.target)
-  llmk.util.err_print('info', 'Running command: ' .. cmd)
+  if llmk.core.dry_run then
+    print('Dry running: ' .. cmd)
+    if #cond > 0 then
+      llmk.util.err_print('info', '<-- ' .. concat_cond(cond))
+    end
+    return false
+  else
+    llmk.util.err_print('info', 'Running command: ' .. cmd)
+  end
 
   -- redirect stdout and stderr to NULL in silent mode
   if llmk.core.silent then
@@ -1195,7 +1242,8 @@
   return true
 end
 
-local function process_program(programs, name, fn, fdb, config)
+local function process_program(programs, name, fn, fdb, config, postprocess)
+  local postprocess = postprocess or false
   local prog = programs[name]
   local should_rerun
 
@@ -1204,7 +1252,7 @@
   local exe_count = 0
   while true do
     exe_count = exe_count + 1
-    run = run_program(name, prog, fn, fdb)
+    run = run_program(name, prog, fn, fdb, postprocess)
 
     -- if the run is skipped, break immediately
     if not run then break end
@@ -1217,9 +1265,9 @@
   end
 
   -- go to the postprocess process
-  if prog.postprocess and run then
+  if prog.postprocess and (run or llmk.core.dry_run) then
     llmk.util.dbg_print('run', 'Going to postprocess "%s"', prog.postprocess)
-    process_program(programs, prog.postprocess, fn, fdb, config)
+    process_program(programs, prog.postprocess, fn, fdb, config, true)
   end
 end
 
@@ -1253,12 +1301,16 @@
 
 -- fn is filepath of target to remove.
 local function remove(fn)
-  local ok = os.remove(fn)
-  
-  if ok ~= true then
-    llmk.util.err_print('error', 'Failed to remove "%s"', fn)
+  if llmk.core.dry_run then
+    print(string.format('Dry running: removing file "%s"', fn))
   else
-    llmk.util.err_print('info', 'Removed "%s"', fn)
+    local ok = os.remove(fn)
+
+    if ok ~= true then
+      llmk.util.err_print('error', 'Failed to remove "%s"', fn)
+    else
+      llmk.util.err_print('info', 'Removed "%s"', fn)
+    end
   end
 end
 
@@ -1302,12 +1354,13 @@
   -d CAT, --debug=CAT   Activate debug output restricted to CAT.
   -D, --debug           Activate all debug output (equal to "--debug=all").
   -h, --help            Print this help message.
+  -n, --dry-run         Show what would have been executed.
   -q, --quiet           Suppress most messages.
   -s, --silent          Silence messages from called programs.
   -v, --verbose         Print additional information.
   -V, --version         Print the version number.
 
-Please report bugs to <tkt.asakura at gmail.com>.
+Please report bugs to <https://github.com/wtsnjp/llmk/issues>.
 ]]
 
 local version_text = [[
@@ -1405,6 +1458,9 @@
       llmk.core.verbosity_level = 2
     elseif (curr_arg == '-s') or (curr_arg == '--silent') then
       llmk.core.silent = true
+    -- dry run
+    elseif (curr_arg == '-n') or (curr_arg == '--dry-run') then
+      llmk.core.dry_run = true
     -- problem
     else
       llmk.util.err_print('error', 'unknown option: ' .. curr_arg)



More information about the tex-live-commits mailing list.