This repository was archived by the owner on Dec 22, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 76
This repository was archived by the owner on Dec 22, 2025. It is now read-only.
Precompiled headers get generated multiple times when using DefRule #317
Copy link
Copy link
Open
Description
When adding a DefRule to my Sources list, precompiled headers seem to be created N times for each Variant declared, resulting in the same file being the output target and failing to build.
The following tundra.lua demonstrates this using the latest v2.08 build:
Build {
Units = function()
DefRule {
Name = "ExampleGenerator",
Pass = "ExamplePass",
Command = "echo Building $(<) $(@) > $(@)",
ConfigInvariant = false,
Blueprint = {
Source = {Required = true, Type = "string", Help = "Input filename"},
OutName = {Required = true, Type = "string", Help = "Output filename"}
},
Setup = function(env, data)
return {
InputFiles = {data.Source},
OutputFiles = {"$(OBJECTDIR)/_generated/" .. data.OutName}
}
end
}
local App = Program
{
Name = "App",
PrecompiledHeader = {
Source = "stdafx.cpp",
Header = "stdafx.h",
Pass = "PchGen"
},
Sources = {
ExampleGenerator {
Source = "example.txt",
OutName = "example.h"
}
}
}
Default(App)
end,
Passes = {
ExamplePass = {Name = "Example Pass", BuildOrder = 1},
PchGen = {Name = "Precompiled Header Generation", BuildOrder = 2}
},
Configs = {
Config {
Name = "win32-msvc",
SupportedHosts = {"windows"},
DefaultOnHost = "windows",
Tools = {
{"msvc-vs2017", TargetArch = "x86"}
}
}
},
Variants = {"debug", "release", "production"}
}Logging the source_files var from x_source_list shows this clearly:
Generating DAG for win32-msvc-release-default
Source list
{
[1] = {
DagCache= <nested table>
__index= <nested table>
Decl= <nested table>
},
[2] = "stdafx.cpp",
}
Generating DAG for win32-msvc-debug-default
Source list
{
[1] = {
DagCache= <nested table>
__index= <nested table>
Decl= <nested table>
},
[2] = "stdafx.cpp",
[3] = "stdafx.cpp",
}
Generating DAG for win32-msvc-production-default
Source list
{
[1] = {
DagCache= <nested table>
__index= <nested table>
Decl= <nested table>
},
[2] = "stdafx.cpp",
[3] = "stdafx.cpp",
[4] = "stdafx.cpp",
}
save_dag_data: 3 bindings, 26 accessed files
Metadata
Metadata
Assignees
Labels
No labels