1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
---@meta
local
--- Declares a new group for organizing task generators, with conditional execution based on a specified condition.
--- - Groups are collections of task generators that allow for logical task organization and control over task execution.
--- - Each generator belongs to a group. By default, generators belong to the unnamed group, which is represented by the context's `fs_name` value and doesn’t require explicit declaration.
--- - Groups can be conditionally enabled or disabled based on a command-line option or a boolean value, which controls whether tasks within the group are scheduled for execution.
---
--- Conditional Execution:
--- - If `enabled_if` is a boolean, the group is enabled or disabled directly based on its value.
--- - If `enabled_if` is a string, it must refer to an existing command-line option, enabling the group based on the option's value at runtime.
--- Passing the option as a string bypasses the setting object, therefore avoiding an execution of the script in case the options change.
--- - When enabled, all tasks generated by the group's generators are scheduled for execution.
--- - When disabled, tasks in the group only run if required by dependencies of enabled tasks.
---
--- Shared Task Caching:
--- - Groups also support shared task caching across different commands.
--- - For example, tasks in a "preprocess" group can be reused across commands that share preprocessing needs, avoiding redundant execution.
--- - For efficient caching, tasks within the group must be declared consistently across commands to avoid cache conflicts and unnecessary recomputation.
---
---@param name string The unique name of the group.
---@param enabled_if boolean|string|nil A condition for enabling the group. If a boolean, it directly determines group status. If a string, it should refer to an existing command-line option, enabling the group based on the option's value. If no value is provided, the group is enabled unless other groups are enabled by command-line options.
--- Changes the enabling condition for an existing group.
--- - This method allows you to change the enabling condition for a group after it has been declared.
--- - The new condition can be a boolean value or a string referring to a command-line option, or even `nil` to set the group as default-enabled.
--- - default-enabled groups are always enabled unless other groups are enabled by command-line options.
---
--- @param name string The name of the group to enable or disable.
--- @param enabled boolean|string|nil A boolean value indicating whether the group should be enabled (`true`) or disabled (`false`).
--- Creates a new task generator, associating it with a specified group for logical organization and caching.
--- - Generators are associated with groups to enable or disable their tasks collectively and to manage task caching.
--- - Groups can be conditionally enabled via `declare_group`, based on either boolean conditions or command-line options.
--- - If no group is specified, the generator will belong to the default group, which is represented by the context’s `fs_name` value.
---
---@param name string The name of the generator.
---@param features string|string[]|nil Initial list of features for this generator.
---@param env Environment|nil The default environment for tasks created by this generator.
---@param group string|nil The group this generator belongs to, declared via `declare_group` for conditional control. Defaults to the context’s `fs_name` value if not specified.
---@return Generator A new generator object.
--- Retrieves a generator by its name, if it exists.
---
---@param name string The name of the generator to search for.
---@return Generator|nil The generator with the specified name, or `nil` if it is not found.
--- Posts a generator to initiate the execution of its associated feature callbacks.
--- - When posted, all methods linked to the generator's features are executed in dependency order.
--- - Callbacks may create additional tasks or post other generators. Posting the same generator multiple times has no effect.
---
---@param generator Generator The generator to post.
--- Represents a task generator, responsible for creating and managing tasks within the build system.
--- - Generators group tasks by name, feature, environment, and build group.
--- - Each generator has a default environment for its tasks, although specific tasks can use their own environments.
---@class Generator
---@field name string The name of the generator.
---@field group string The build group this generator belongs to. Groups can be shared across different build commands and must be declared using `context:declare_group`.
---@field env Environment The default environment. Tasks generated from this generator will inherit this environment unless another is specified.
Generator =
--- Creates a new task to transform specified inputs into outputs, using the given tool.
--- - Tasks represent build actions, with each one typically performing a specific transformation or build step.
--- - Inputs and outputs can be further adjusted after task creation.
---
---@param driver string The name of the driver used for the task (e.g., compiler, linker). The driver must have been declared in the context using one of `lua_driver`, `command_driver` or `dependency_driver`.
---@param inputs Node|Node[]|nil Initial inputs required for the task. Additional inputs can be added with `Task:add_input`.
---@param outputs Node|Node[]|nil Initial outputs produced by the task. Additional outputs can be added with `Task:add_output`.
---@param env Environment|nil The environment to use for this task, overriding the generator’s default environment if specified.
---@return Task A new task object, ready for configuration and execution.
--- Checks if the generator has a specific property.
---
---@param name string The name of the property to check.
---@return boolean Returns `true` if the generator has a property with the specified name, otherwise returns `false`.