texlive[66474] branches/branch2022.final: light-latex-make (8mar23)

commits+karl at tug.org commits+karl at tug.org
Wed Mar 8 22:32:39 CET 2023


Revision: 66474
          http://tug.org/svn/texlive?view=revision&revision=66474
Author:   karl
Date:     2023-03-08 22:32:39 +0100 (Wed, 08 Mar 2023)
Log Message:
-----------
light-latex-make (8mar23) (branch)

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

Modified: branches/branch2022.final/Build/source/texk/texlive/linked_scripts/light-latex-make/llmk.lua
===================================================================
--- branches/branch2022.final/Build/source/texk/texlive/linked_scripts/light-latex-make/llmk.lua	2023-03-08 21:32:23 UTC (rev 66473)
+++ branches/branch2022.final/Build/source/texk/texlive/linked_scripts/light-latex-make/llmk.lua	2023-03-08 21:32:39 UTC (rev 66474)
@@ -3,7 +3,7 @@
 --
 -- This is file `llmk.lua'.
 --
--- Copyright 2018-2021 Takuto ASAKURA (wtsnjp)
+-- Copyright 2018-2023 Takuto Asakura (wtsnjp)
 --   GitHub:   https://github.com/wtsnjp
 --   Twitter:  @wtsnjp
 --
@@ -39,9 +39,9 @@
 
 -- program information
 M.prog_name = 'llmk'
-M.version = '1.1.0'
-M.copyright = 'Copyright 2018-2021'
-M.author = 'Takuto ASAKURA (wtsnjp)'
+M.version = '1.2.0'
+M.copyright = 'Copyright 2018-2023'
+M.author = 'Takuto Asakura (wtsnjp)'
 M.llmk_toml = 'llmk.toml'
 
 -- exit codes
@@ -67,9 +67,11 @@
   latex = {'string', 'lualatex'},
   llmk_version = {'string', nil},
   makeindex = {'string', 'makeindex'},
+  makeglossaries = {'string', 'makeglossaries'},
   max_repeat = {'integer', 5},
+  output_directory = {'string', nil},
   ps2pdf = {'string', 'ps2pdf'},
-  sequence = {'[string]', {'latex', 'bibtex', 'makeindex', 'dvipdf'}},
+  sequence = {'[string]', {'latex', 'bibtex', 'makeindex', 'makeglossaries', 'dvipdf'}},
   source = {'*[string]', nil},
 }
 
@@ -104,6 +106,7 @@
       '-interaction=nonstopmode',
       '-file-line-error',
       '-synctex=1',
+      '-output-directory="%o"',
     },
     aux_file = '%B.aux',
     aux_empty_size = 9, -- "\\relax \n" is empty
@@ -113,6 +116,13 @@
     generated_target = true,
     postprocess = 'latex',
   },
+  makeglossaries = {
+    target = '%B.glo',
+    generated_target = true,
+    postprocess = 'latex',
+    opts = {'-d "%o"'},
+    args = {'%b.glo'}, -- "%B.glo" will result in an error
+  },
   ps2pdf = {
     target = '%B.ps',
     generated_target = true,
@@ -180,19 +190,29 @@
 end
 
 -- Replace config param to filename
-function M.replace_specifiers(str, source, target)
+function M.replace_specifiers(str, source, target, output_directory)
   local tmp = '/' .. source
-  local basename = tmp:match('^.*/(.*)%..*$')
+  local basename_match = tmp:match('^.*/(.*)%..*$')
 
   str = str:gsub('%%S', source)
   str = str:gsub('%%T', target)
 
-  if basename then
-    str = str:gsub('%%B', basename)
-  else
-    str = str:gsub('%%B', source)
+  local sub_basename = source
+  if basename_match then
+    sub_basename = basename_match
   end
 
+  local sub_output_directory = '.'
+  local sub_output_directory_basename = sub_basename
+  if output_directory then
+    sub_output_directory = output_directory
+    sub_output_directory_basename = output_directory .. '/' .. sub_basename
+  end
+
+  str = str:gsub('%%b', sub_basename)
+  str = str:gsub('%%o', sub_output_directory)
+  str = str:gsub('%%B', sub_output_directory_basename)
+
   return str
 end
 
@@ -380,7 +400,7 @@
   local config = merge_table(config, tab)
 
   -- set essential program names from top-level
-  local prg_names = {'latex', 'bibtex', 'makeindex', 'dvipdf', 'dvips', 'ps2pdf'}
+  local prg_names = {'latex', 'bibtex', 'makeindex', 'makeglossaries', 'dvipdf', 'dvips', 'ps2pdf'}
   for _, name in pairs(prg_names) do
     config = fetch_from_top_level(config, name)
   end
@@ -998,7 +1018,7 @@
       cur_target = fn
     else
       -- here, %T should be replaced by `fn`
-      cur_target = llmk.util.replace_specifiers(prog.target, fn, fn)
+      cur_target = llmk.util.replace_specifiers(prog.target, fn, fn, config.output_directory)
     end
 
     prog.target = cur_target
@@ -1018,11 +1038,11 @@
           if type(prog[k]) == 'table' then
             for ik, iv in ipairs(prog[k]) do
               if type(prog[k][ik]) == 'string' then
-                prog[k][ik] = llmk.util.replace_specifiers(iv, fn, cur_target)
+                prog[k][ik] = llmk.util.replace_specifiers(iv, fn, cur_target, config.output_directory)
               end
             end
           elseif type(prog[k]) == 'string' then
-            prog[k] = llmk.util.replace_specifiers(prog[k], fn, cur_target)
+            prog[k] = llmk.util.replace_specifiers(prog[k], fn, cur_target, config.output_directory)
           end
         end
       end
@@ -1087,7 +1107,7 @@
   return fdb
 end
 
-local function construct_cmd(prog, fn, target)
+local function construct_cmd(prog)
   -- construct the option
   local cmd_opt = ''
 
@@ -1213,7 +1233,7 @@
   -- does target exist?
   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',
+      'Skipping "%s" because target (%s) does not exist',
       prog.command, prog.target)
     return false
   end
@@ -1225,7 +1245,7 @@
         prog.target)
     elseif file_mtime(prog.target) < start_time then
       llmk.util.dbg_print('run',
-        'Skiping "%s" because target (%s) is not updated',
+        'Skipping "%s" because target (%s) is not updated',
         prog.command, prog.target)
       return false
     end
@@ -1235,7 +1255,7 @@
     end
   end
 
-  local cmd = construct_cmd(prog, fn, prog.target)
+  local cmd = construct_cmd(prog)
   if llmk.core.dry_run then
     print('Dry running: ' .. cmd)
     if #cond > 0 then
@@ -1306,6 +1326,11 @@
   llmk.util.dbg_print('fdb', 'The initial file database is as follows:')
   llmk.util.dbg_print_table('fdb', fdb)
 
+  -- check if output directory exists
+  if config.output_directory and not lfs.isdir(config.output_directory) then
+    llmk.util.err_print('error', 'Output directory does not exist "%s"', config.output_directory)
+  end
+
   for _, name in ipairs(config.sequence) do
     llmk.util.dbg_print('run', 'Preparing for program "%s"', name)
     process_program(programs, name, fn, fdb, config)
@@ -1336,9 +1361,9 @@
   end
 end
 
-local function replace_spec_and_remove_files(fns, source)
+local function replace_spec_and_remove_files(fns, source, output_directory)
   for _, fn in ipairs(fns) do
-    local replaced_fn = llmk.util.replace_specifiers(fn, source, source)
+    local replaced_fn = llmk.util.replace_specifiers(fn, source, source, output_directory)
     if lfs.isfile(replaced_fn) then
       remove(replaced_fn)
     end
@@ -1348,16 +1373,16 @@
 -- the actual process for the --clean action
 function M.clean(fn, config)
   llmk.util.err_print('info', 'Begining cleaning for "%s"', fn)
-  replace_spec_and_remove_files(config.clean_files, fn)
-  replace_spec_and_remove_files(config.extra_clean_files, fn)
+  replace_spec_and_remove_files(config.clean_files, fn, config.output_directory)
+  replace_spec_and_remove_files(config.extra_clean_files, fn, config.output_directory)
 end
 
 -- the actual process for the --clobber action
 function M.clobber(fn, config)
   llmk.util.err_print('info', 'Begining clobbering for "%s"', fn)
-  replace_spec_and_remove_files(config.clean_files, fn)
-  replace_spec_and_remove_files(config.extra_clean_files, fn)
-  replace_spec_and_remove_files(config.clobber_files, fn)
+  replace_spec_and_remove_files(config.clean_files, fn, config.output_directory)
+  replace_spec_and_remove_files(config.extra_clean_files, fn, config.output_directory)
+  replace_spec_and_remove_files(config.clobber_files, fn, config.output_directory)
 end
 
 llmk.cleaner = M
@@ -1460,7 +1485,7 @@
     elseif (curr_arg == '-V') or (curr_arg == '--version') then
       return 'version' -- immediately show version
     elseif (curr_arg == '-c') or (curr_arg == '--clean') then
-      action = 'clean'      
+      action = 'clean'
     elseif (curr_arg == '-C') or (curr_arg == '--clobber') then
       action = 'clobber'
     -- debug

Modified: branches/branch2022.final/Master/texmf-dist/doc/man/man1/llmk.1
===================================================================
--- branches/branch2022.final/Master/texmf-dist/doc/man/man1/llmk.1	2023-03-08 21:32:23 UTC (rev 66473)
+++ branches/branch2022.final/Master/texmf-dist/doc/man/man1/llmk.1	2023-03-08 21:32:39 UTC (rev 66474)
@@ -1,7 +1,7 @@
 .\" generated with Ronn/v0.7.3
 .\" http://github.com/rtomayko/ronn/tree/0.7.3
 .
-.TH "LLMK" "1" "August 2021" "llmk 1.1.0" "llmk manual"
+.TH "LLMK" "1" "March 2023" "llmk 1.2.0" "llmk manual"
 .
 .SH "NAME"
 \fBllmk\fR \- Light LaTeX Make
@@ -69,7 +69,7 @@
 .
 .TP
 2
-Failure executing the workflow\. The exit status of the external program is reported in an error message\.
+Error in invoked program\. The exit status of the external program is reported in an error message\.
 .
 .TP
 3
@@ -86,7 +86,7 @@
 Source: \fIhttps://github\.com/wtsnjp/llmk\fR
 .
 .SH "COPYRIGHT"
-Copyright 2018\-2021 Takuto ASAKURA (wtsnjp)\.
+Copyright 2018\-2023 Takuto Asakura (wtsnjp)\.
 .
 .br
 License: The MIT License \fIhttps://opensource\.org/licenses/mit\-license\fR\.

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

Modified: branches/branch2022.final/Master/texmf-dist/doc/support/light-latex-make/LICENSE
===================================================================
--- branches/branch2022.final/Master/texmf-dist/doc/support/light-latex-make/LICENSE	2023-03-08 21:32:23 UTC (rev 66473)
+++ branches/branch2022.final/Master/texmf-dist/doc/support/light-latex-make/LICENSE	2023-03-08 21:32:39 UTC (rev 66474)
@@ -1,6 +1,6 @@
 The MIT License (MIT)
 
-Copyright 2018-2021 Takuto ASAKURA (wtsnjp)
+Copyright 2018-2023 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

Modified: branches/branch2022.final/Master/texmf-dist/doc/support/light-latex-make/README.md
===================================================================
--- branches/branch2022.final/Master/texmf-dist/doc/support/light-latex-make/README.md	2023-03-08 21:32:23 UTC (rev 66473)
+++ branches/branch2022.final/Master/texmf-dist/doc/support/light-latex-make/README.md	2023-03-08 21:32:39 UTC (rev 66474)
@@ -42,7 +42,7 @@
 Suppose we save this file as `hello.tex`, then run
 
 ```shell
-$ llmk hello.tex
+llmk hello.tex
 ```
 
 will produce a PDF document (`hello.pdf`) with XeLaTeX, since it is specified in the TOML line of the source.
@@ -63,7 +63,7 @@
 If you run llmk without any argument, llmk will load `llmk.toml` in the working directory, and compile files specified by the `source` key with the settings written in the file.
 
 ```shell
-$ llmk
+llmk
 ```
 
 ### Supports for other magic comment formats
@@ -116,7 +116,7 @@
 Specifically,
 
 ```shell
-$ llmk --clean FILE...
+llmk --clean FILE...
 ```
 
 removes files generated by the specified `FILE`s. In case you omit the argument `FILE`, files generated by the `source` files are removed. In both cases, the files to remove by these actions can be customized (see the reference manual for the details).
@@ -153,7 +153,9 @@
 
 * `%S`: the file name given to llmk as an argument (source)
 * `%T`: the target for each program
-* `%B`: the base name of `%S`
+* `%o`: the output directory, or `.` if none was specified
+* `%b`: the base name of `%S`
+* `%B`: the output directory concatenated with the base name of `%S`
 
 This way is a bit complicated but strong enough allowing you to use any kind of outer programs.
 
@@ -170,7 +172,9 @@
 * `latex` (type: *string*, default: `"lualatex"`)
 * `llmk_version` (type: *string*)
 * `makeindex` (type: *string*, default: `"makeindex"`)
+* `makeglossaries` (type: *string*, default: `"makeglossaries"`)
 * `max_repeat` (type: *integer*, default: `5`)
+* `output_directory` (type: *string*)
 * `programs` (type: *table*)
 	* \<program name\>
 		* `args` (type: *string* or *array of strings*, default: `["%T"]`)
@@ -182,7 +186,7 @@
 		* `postprocess` (type: *string*)
 		* `target` (type: *string*, default: `"%S"`)
 * `ps2pdf` (type: *string*, default: `"ps2pdf"`)
-* `sequence` (type: *array of strings*, default: `["latex", "bibtex", "makeindex", "dvipdf"]`)
+* `sequence` (type: *array of strings*, default: `["latex", "bibtex", "makeindex", "makeglossaries", "dvipdf"]`)
 * `source` (type: *string* or *array of strings*, only for `llmk.toml`)
 
 ### Default `programs` table
@@ -208,7 +212,7 @@
 
 [programs.latex]
 command = "lualatex"
-opts = ["-interaction=nonstopmode", "-file-line-error", "-synctex=1"]
+opts = ["-interaction=nonstopmode", "-file-line-error", "-synctex=1", '-output-directory="%o"']
 aux_file = "%B.aux"
 aux_empty_size = 9
 
@@ -218,6 +222,14 @@
 generated_target = true
 postprocess = "latex"
 
+[programs.makeglossaries]
+command = "makeglossaries"
+target = "%B.glo"
+generated_target = true
+postprocess = "latex"
+opts = ['-d "%o"']
+args = ["%b.glo"]
+
 [programs.ps2pdf]
 command = "ps2pdf"
 target = "%B.ps"
@@ -224,6 +236,50 @@
 generated_target = true
 ```
 
+## Building and testing
+
+Some maintenance tasks are defined as [Rake](https://github.com/ruby/rake) tasks. To run these tasks, please install the dependencies first:
+
+```shell
+bundle install
+```
+
+### Generating all documentation
+
+The following will generate both the PDF and the manpage in `doc/` directory.
+
+```shell
+rake doc
+```
+
+### Running tests
+
+The following will run all tests in `spec/` directory.
+
+```shell
+rake test
+```
+
+Alternatively, you can give spec names with the `--list` (`-l`) option for this task. E.g., following will run only `spec/help_spec.rb` and `spec/version_spec.rb`:
+
+```shell
+rake test -- -l help,version
+```
+
+### Showing all available tasks
+
+Following will show all available tasks with a short description.
+
+```shell
+rake -T
+```
+
+In addition to that, for options available tasks, e.g., `rake test`, you can get options information with `-h` option for each task:
+
+```shell
+rake test -- -h
+```
+
 ## Links to other materials
 
 * [Reference manual](http://mirrors.ctan.org/support/light-latex-make/llmk.pdf): it describes the full specification.
@@ -236,7 +292,7 @@
 
 ## License
 
-Copyright 2018-2021 Takuto ASAKURA ([wtsnjp](https://twitter.com/wtsnjp))
+Copyright 2018-2023 Takuto Asakura ([wtsnjp](https://twitter.com/wtsnjp))
 
 This software is licensed under [the MIT license](./LICENSE).
 
@@ -246,4 +302,4 @@
 
 ---
 
-Takuto ASAKURA ([wtsnjp](https://twitter.com/wtsnjp))
+Takuto Asakura ([wtsnjp](https://twitter.com/wtsnjp))

Modified: branches/branch2022.final/Master/texmf-dist/doc/support/light-latex-make/llmk-doc.cls
===================================================================
--- branches/branch2022.final/Master/texmf-dist/doc/support/light-latex-make/llmk-doc.cls	2023-03-08 21:32:23 UTC (rev 66473)
+++ branches/branch2022.final/Master/texmf-dist/doc/support/light-latex-make/llmk-doc.cls	2023-03-08 21:32:39 UTC (rev 66474)
@@ -39,19 +39,23 @@
 \RequirePackage{listings}
 \RequirePackage{xparse}
 
+% font settings
+\RequirePackage{fontspec}
+\defaultfontfeatures{Ligatures=TeX}
+
+\RequirePackage{unicode-math}
+\RequirePackage{utfsym}
+
+\setmainfont{STIX Two Text}
+\setsansfont{Helvetica Neue}
+\setmathfont{STIX Two Math}[StylisticSet=02, StylisticSet=08]
+\setmonofont[StylisticSet={1,3}]{Inconsolatazi4}
+
 % logo
-\input{llmk-logo-code}
-\RequirePackage[no-math]{fontspec}
-\defaultfontfeatures{Ligatures=TeX}
 \newcommand{\logomainfont}{\fontspec{Helvetica Neue}}
 \newcommand{\logosubfont}{\fontspec{Helvetica Neue Thin}}
+\input{llmk-logo-code}
 
-% font settings
-\let\Zbar\relax
-\RequirePackage[defaultsups]{newtxtext}
-\RequirePackage[varqu,varl]{inconsolata}
-\RequirePackage[bigdelims,vvarbb]{newtxmath}
-
 % for headings
 %\setkomafont{title}{}
 %\setkomafont{subtitle}{\Huge\itshape}

Modified: branches/branch2022.final/Master/texmf-dist/doc/support/light-latex-make/llmk-logo-code.tex
===================================================================
--- branches/branch2022.final/Master/texmf-dist/doc/support/light-latex-make/llmk-logo-code.tex	2023-03-08 21:32:23 UTC (rev 66473)
+++ branches/branch2022.final/Master/texmf-dist/doc/support/light-latex-make/llmk-logo-code.tex	2023-03-08 21:32:39 UTC (rev 66474)
@@ -1,7 +1,7 @@
 %
 % This is LaTeX source for the llmk logo.
 %
-% Copyright 2018-2020 Takuto ASAKURA (wtsnjp)
+% Copyright 2018-2023 Takuto Asakura (wtsnjp)
 %   GitHub:   https://github.com/wtsnjp
 %   Twitter:  @wtsnjp
 %

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

Modified: branches/branch2022.final/Master/texmf-dist/doc/support/light-latex-make/llmk.tex
===================================================================
--- branches/branch2022.final/Master/texmf-dist/doc/support/light-latex-make/llmk.tex	2023-03-08 21:32:23 UTC (rev 66473)
+++ branches/branch2022.final/Master/texmf-dist/doc/support/light-latex-make/llmk.tex	2023-03-08 21:32:39 UTC (rev 66474)
@@ -1,8 +1,8 @@
 % llmk: the reference manual
-% Copyright 2020 Takuto ASAKURA (wtsnjp)
+% Copyright 2020-2023 Takuto Asakura (wtsnjp)
 
 % +++
-% latex = "xelatex"
+% latex = "texfot xelatex"
 % +++
 \documentclass{llmk-doc}
 
@@ -10,7 +10,7 @@
 \title{llmk: Light {\LaTeX} Make}
 \author{Takuto Asakura (wtsnjp)}
 \subtitle{Reference Manual}
-\date{v1.1.0\quad\today}
+\date{v1.2.0\quad\today}
 \keywords{llmk, build-tool, toml, lua, luatex}
 
 \begin{document}
@@ -220,9 +220,9 @@
 \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 & \\
+\code{0} & Success & \code{3} & Parser error \\
+\code{1} & General error & \code{4} & Type error \\
+\code{2} & Error in invoked program & \\
 \bottomrule
 \end{tabular}
 \end{center}
@@ -249,7 +249,7 @@
 supported.
 
 \begin{center}
-\newcommand{\ok}{{\color{special}\checkmark}}
+\newcommand{\ok}{{\color{special}\usym{1F5F8}}}
 \begin{tabular}{llc}
 \toprule
 Type & Example & Supported \\ \midrule
@@ -368,8 +368,12 @@
   argument or as an element of the \ckey{source} array.
 \item |%T|
   is replaced by the target for each program.
+\item |%o|
+  is replaced by the output directory, or \code{.} if none was specified.
+\item |%b|
+  is replaced by the basename of |%S|.
 \item |%B|
-  is replaced by the basename of |%S|.
+  is replaced by the output directory concatenated with the basename of |%S|.
 \end{itemize}
 
 Some keys have default values; the default configuration of \prog{llmk} should
@@ -462,6 +466,13 @@
 ineffective.
 \end{confkey}
 
+\begin{confkey}{makeglossaries}{type: \type{string}}[default: \code{"makeglossaries"}]
+The command to use for the \progname{makeglossaries} program. Internally, this key
+is an alias for the \ckey{command} key in the \progname{makeglossaries} entry. If
+the \ckey{command} key is specified in the \ckey{programs} table, this alias is
+ineffective.
+\end{confkey}
+
 \begin{confkey}{max\_repeat}{type: \type{integer}}[default: \code{5}]
 You can specify the maximum number of execution repetitions for each command in
 your \ckey{sequence}. When processing your \ckey{sequence}, \prog{llmk} repeats
@@ -470,6 +481,10 @@
 prevent the potential infinite loop of repetition.
 \end{confkey}
 
+\begin{confkey}{output\_directory}{type: \type{string}}
+Use this option to specify a directory where \progname{latex} output files should be written to and read from. This directory must already exist, or else \prog{llmk} will fail with an error. If the option is not specified, then output files will be written to the directory where \prog{llmk} is run from.
+\end{confkey}
+
 \begin{confkey}{programs}{type: \type{table}}
   [default: see Section~\ref{sec:default-programs}]
 The table that contains the detailed configuration for each program. See
@@ -644,7 +659,12 @@
 \begin{lstlisting}[style=toml]
 [programs.latex]
 command = "lualatex"
-opts = ["-interaction=nonstopmode", "-file-line-error", "-synctex=1"]
+opts = [
+  "-interaction=nonstopmode",
+  "-file-line-error",
+  "-synctex=1",
+  '-output-directory="%o"'
+]
 aux_file = "%B.aux"
 aux_empty_size = 9
 \end{lstlisting}
@@ -661,6 +681,20 @@
 postprocess = "latex"
 \end{lstlisting}
 
+\Program{makeglossaries} The entry for the Makeglossaries program and friends. The
+\progname{latex} program is set as \ckey{postprocess} so that to make sure
+rerunning {\LaTeX} command after this execution.
+%
+\begin{lstlisting}[style=toml]
+[programs.makeglossaries]
+command = "makeglossaries"
+target = "%B.glo"
+generated_target = true
+postprocess = "latex"
+opts = ['-d "%o"']
+args = ["%b.glo"]
+\end{lstlisting}
+
 \Program{ps2pdf} The entry for the \prog{ps2pdf} program and friends.
 %
 \begin{lstlisting}[style=toml]
@@ -676,7 +710,7 @@
 The following is the default value for the \ckey{sequence} array:
 %
 \begin{htcode}
-["latex", "bibtex", "makeindex", "dvipdf"]
+["latex", "bibtex", "makeindex", "makeglossaries", "dvipdf"]
 \end{htcode}
 
 With these default settings in the \ckey{programs} table the \ckey{sequence}
@@ -691,9 +725,10 @@
   \code{\%B.bib}, exists, the {\BibTeX} program is executed. When the execution
   occurs, the \progname{latex} program is executed again right after because
   the program is set as \ckey{postprocess}.
-\item Identically, if the corresponding input file for Makeindex exists, the
-  program is executed. When the execution occurs, the \progname{latex} program
-  is executed again right after because the program is set as \ckey{postprocess}.
+\item Identically, if the corresponding input files for Makeindex and
+  Makeglossaries exist, the program is executed. When the execution occurs,
+  the \progname{latex} program is executed again right after because the
+  program is set as \ckey{postprocess}.
 \item In case the corresponding DVI file is generated in the previous steps,
   though this will not happen with the default value of \ckey{latex}, \ie
   \code{"lualatex"}, the \progname{dvipdf} program, by default \code{dvipdfmx},
@@ -705,9 +740,11 @@
 $\text{\progname{dvips}}+\text{\progname{ps2pdf}}$ combination instead of
 \progname{dvipdf}, you can just modify the value of \ckey{sequence} a bit:
 %
-\begin{lstlisting}[style=toml]
-sequence = ["latex", "bibtex", "makeindex", "dvips", "ps2pdf"]
-\end{lstlisting}
+\begin{htcode}
+sequence = [
+  "latex", "bibtex", "makeindex", "makeglossaries", "dvips", "ps2pdf"
+]
+\end{htcode}
 
 \section{Other supported formats}
 \label{sec:magic-comment}

Modified: branches/branch2022.final/Master/texmf-dist/scripts/light-latex-make/llmk.lua
===================================================================
--- branches/branch2022.final/Master/texmf-dist/scripts/light-latex-make/llmk.lua	2023-03-08 21:32:23 UTC (rev 66473)
+++ branches/branch2022.final/Master/texmf-dist/scripts/light-latex-make/llmk.lua	2023-03-08 21:32:39 UTC (rev 66474)
@@ -3,7 +3,7 @@
 --
 -- This is file `llmk.lua'.
 --
--- Copyright 2018-2021 Takuto ASAKURA (wtsnjp)
+-- Copyright 2018-2023 Takuto Asakura (wtsnjp)
 --   GitHub:   https://github.com/wtsnjp
 --   Twitter:  @wtsnjp
 --
@@ -39,9 +39,9 @@
 
 -- program information
 M.prog_name = 'llmk'
-M.version = '1.1.0'
-M.copyright = 'Copyright 2018-2021'
-M.author = 'Takuto ASAKURA (wtsnjp)'
+M.version = '1.2.0'
+M.copyright = 'Copyright 2018-2023'
+M.author = 'Takuto Asakura (wtsnjp)'
 M.llmk_toml = 'llmk.toml'
 
 -- exit codes
@@ -67,9 +67,11 @@
   latex = {'string', 'lualatex'},
   llmk_version = {'string', nil},
   makeindex = {'string', 'makeindex'},
+  makeglossaries = {'string', 'makeglossaries'},
   max_repeat = {'integer', 5},
+  output_directory = {'string', nil},
   ps2pdf = {'string', 'ps2pdf'},
-  sequence = {'[string]', {'latex', 'bibtex', 'makeindex', 'dvipdf'}},
+  sequence = {'[string]', {'latex', 'bibtex', 'makeindex', 'makeglossaries', 'dvipdf'}},
   source = {'*[string]', nil},
 }
 
@@ -104,6 +106,7 @@
       '-interaction=nonstopmode',
       '-file-line-error',
       '-synctex=1',
+      '-output-directory="%o"',
     },
     aux_file = '%B.aux',
     aux_empty_size = 9, -- "\\relax \n" is empty
@@ -113,6 +116,13 @@
     generated_target = true,
     postprocess = 'latex',
   },
+  makeglossaries = {
+    target = '%B.glo',
+    generated_target = true,
+    postprocess = 'latex',
+    opts = {'-d "%o"'},
+    args = {'%b.glo'}, -- "%B.glo" will result in an error
+  },
   ps2pdf = {
     target = '%B.ps',
     generated_target = true,
@@ -180,19 +190,29 @@
 end
 
 -- Replace config param to filename
-function M.replace_specifiers(str, source, target)
+function M.replace_specifiers(str, source, target, output_directory)
   local tmp = '/' .. source
-  local basename = tmp:match('^.*/(.*)%..*$')
+  local basename_match = tmp:match('^.*/(.*)%..*$')
 
   str = str:gsub('%%S', source)
   str = str:gsub('%%T', target)
 
-  if basename then
-    str = str:gsub('%%B', basename)
-  else
-    str = str:gsub('%%B', source)
+  local sub_basename = source
+  if basename_match then
+    sub_basename = basename_match
   end
 
+  local sub_output_directory = '.'
+  local sub_output_directory_basename = sub_basename
+  if output_directory then
+    sub_output_directory = output_directory
+    sub_output_directory_basename = output_directory .. '/' .. sub_basename
+  end
+
+  str = str:gsub('%%b', sub_basename)
+  str = str:gsub('%%o', sub_output_directory)
+  str = str:gsub('%%B', sub_output_directory_basename)
+
   return str
 end
 
@@ -380,7 +400,7 @@
   local config = merge_table(config, tab)
 
   -- set essential program names from top-level
-  local prg_names = {'latex', 'bibtex', 'makeindex', 'dvipdf', 'dvips', 'ps2pdf'}
+  local prg_names = {'latex', 'bibtex', 'makeindex', 'makeglossaries', 'dvipdf', 'dvips', 'ps2pdf'}
   for _, name in pairs(prg_names) do
     config = fetch_from_top_level(config, name)
   end
@@ -998,7 +1018,7 @@
       cur_target = fn
     else
       -- here, %T should be replaced by `fn`
-      cur_target = llmk.util.replace_specifiers(prog.target, fn, fn)
+      cur_target = llmk.util.replace_specifiers(prog.target, fn, fn, config.output_directory)
     end
 
     prog.target = cur_target
@@ -1018,11 +1038,11 @@
           if type(prog[k]) == 'table' then
             for ik, iv in ipairs(prog[k]) do
               if type(prog[k][ik]) == 'string' then
-                prog[k][ik] = llmk.util.replace_specifiers(iv, fn, cur_target)
+                prog[k][ik] = llmk.util.replace_specifiers(iv, fn, cur_target, config.output_directory)
               end
             end
           elseif type(prog[k]) == 'string' then
-            prog[k] = llmk.util.replace_specifiers(prog[k], fn, cur_target)
+            prog[k] = llmk.util.replace_specifiers(prog[k], fn, cur_target, config.output_directory)
           end
         end
       end
@@ -1087,7 +1107,7 @@
   return fdb
 end
 
-local function construct_cmd(prog, fn, target)
+local function construct_cmd(prog)
   -- construct the option
   local cmd_opt = ''
 
@@ -1213,7 +1233,7 @@
   -- does target exist?
   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',
+      'Skipping "%s" because target (%s) does not exist',
       prog.command, prog.target)
     return false
   end
@@ -1225,7 +1245,7 @@
         prog.target)
     elseif file_mtime(prog.target) < start_time then
       llmk.util.dbg_print('run',
-        'Skiping "%s" because target (%s) is not updated',
+        'Skipping "%s" because target (%s) is not updated',
         prog.command, prog.target)
       return false
     end
@@ -1235,7 +1255,7 @@
     end
   end
 
-  local cmd = construct_cmd(prog, fn, prog.target)
+  local cmd = construct_cmd(prog)
   if llmk.core.dry_run then
     print('Dry running: ' .. cmd)
     if #cond > 0 then
@@ -1306,6 +1326,11 @@
   llmk.util.dbg_print('fdb', 'The initial file database is as follows:')
   llmk.util.dbg_print_table('fdb', fdb)
 
+  -- check if output directory exists
+  if config.output_directory and not lfs.isdir(config.output_directory) then
+    llmk.util.err_print('error', 'Output directory does not exist "%s"', config.output_directory)
+  end
+
   for _, name in ipairs(config.sequence) do
     llmk.util.dbg_print('run', 'Preparing for program "%s"', name)
     process_program(programs, name, fn, fdb, config)
@@ -1336,9 +1361,9 @@
   end
 end
 
-local function replace_spec_and_remove_files(fns, source)
+local function replace_spec_and_remove_files(fns, source, output_directory)
   for _, fn in ipairs(fns) do
-    local replaced_fn = llmk.util.replace_specifiers(fn, source, source)
+    local replaced_fn = llmk.util.replace_specifiers(fn, source, source, output_directory)
     if lfs.isfile(replaced_fn) then
       remove(replaced_fn)
     end
@@ -1348,16 +1373,16 @@
 -- the actual process for the --clean action
 function M.clean(fn, config)
   llmk.util.err_print('info', 'Begining cleaning for "%s"', fn)
-  replace_spec_and_remove_files(config.clean_files, fn)
-  replace_spec_and_remove_files(config.extra_clean_files, fn)
+  replace_spec_and_remove_files(config.clean_files, fn, config.output_directory)
+  replace_spec_and_remove_files(config.extra_clean_files, fn, config.output_directory)
 end
 
 -- the actual process for the --clobber action
 function M.clobber(fn, config)
   llmk.util.err_print('info', 'Begining clobbering for "%s"', fn)
-  replace_spec_and_remove_files(config.clean_files, fn)
-  replace_spec_and_remove_files(config.extra_clean_files, fn)
-  replace_spec_and_remove_files(config.clobber_files, fn)
+  replace_spec_and_remove_files(config.clean_files, fn, config.output_directory)
+  replace_spec_and_remove_files(config.extra_clean_files, fn, config.output_directory)
+  replace_spec_and_remove_files(config.clobber_files, fn, config.output_directory)
 end
 
 llmk.cleaner = M
@@ -1460,7 +1485,7 @@
     elseif (curr_arg == '-V') or (curr_arg == '--version') then
       return 'version' -- immediately show version
     elseif (curr_arg == '-c') or (curr_arg == '--clean') then
-      action = 'clean'      
+      action = 'clean'
     elseif (curr_arg == '-C') or (curr_arg == '--clobber') then
       action = 'clobber'
     -- debug



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