latex3 / l3build

A testing and building system for LaTeX
LaTeX Project Public License v1.3c
84 stars 14 forks source link

customize targets and options #374

Closed jlaurens closed 5 days ago

jlaurens commented 2 weeks ago

The actual documentation suggests in section "5.6 Customising the target and option lists" that it is possible to customize the target and options.

Custom targets:

Instead of editing the global table target_list : function available in build.lua.

---Declare a custom command line target
---@param name string name of the target
---@param kv table named arguments including target data
function declaretarget(name, kv)
...
end

This function validates its entries.

Custom options:

In practice, it is not possible to add new options by just changing the option_list variable.

Why? the option_list global variable is initialized just before parsing the command line arguments

At least 2 approaches that do not exclude each other

An extended mode

l3build --extended|-x ... to accept any "-" argument. If an argument is not known, add an entry for it in the option list. The type of the argument is guessed from name and usage by the rules

  1. name starts with "is-" ⇒ boolean
  2. last argument or followed by a "-" argument ⇒ boolean
  3. name ends with "s" ⇒ array of strings
  4. otherwise ⇒ string

Notes

a configuration file

A cfg.lua near build.lua is executed before the arguments are parsed.

-- cfg.lua
-- inheritcfg() -- uncomment to the module inherit from its enclosing bundle
declareoption("my-option", {
  desc = "my cutting edge option",
  short="O",
  type = "boolean",
}

Notes