Merge pull request #545 from tvandijck/generated-files-vcxproj

Add generated files to vxcproj file.
This commit is contained in:
Tom van Dijck 2016-09-07 08:14:57 -07:00 committed by GitHub
commit 785671fad5
4 changed files with 101 additions and 4 deletions

View File

@ -176,6 +176,12 @@
}
}
api.register {
name = "compilebuildoutputs",
scope = "config",
kind = "boolean"
}
api.register {
name = "configmap",
scope = "project",

View File

@ -57,7 +57,6 @@
end
--
-- Output the XML declaration and opening <Project> tag.
--
@ -578,6 +577,15 @@
end
function m.generatedFile(cfg, file)
if file.generated then
local path = path.translate(file.dependsOn.relpath)
m.element("AutoGen", nil, 'true')
m.element("DependentUpon", nil, path)
end
end
---
-- Write out the list of source code files, and any associated configuration.
---
@ -601,7 +609,7 @@
priority = 1,
emitFiles = function(prj, group)
m.emitFiles(prj, group, "ClInclude")
m.emitFiles(prj, group, "ClInclude", {m.generatedFile})
end,
emitFilter = function(prj, group)
@ -641,7 +649,7 @@
end
end
m.emitFiles(prj, group, "ClCompile", nil, fileCfgFunc)
m.emitFiles(prj, group, "ClCompile", {m.generatedFile}, fileCfgFunc)
end,
emitFilter = function(prj, group)
@ -658,7 +666,7 @@
priority = 3,
emitFiles = function(prj, group)
m.emitFiles(prj, group, "None")
m.emitFiles(prj, group, "None", {m.generatedFile})
end,
emitFilter = function(prj, group)

View File

@ -115,6 +115,10 @@
oven.bakeObjDirs(self)
-- now we can post process the projects for 'buildoutputs' files
-- that have the 'compilebuildoutputs' flag
oven.addGeneratedFiles(self)
-- Build a master list of configuration/platform pairs from all of the
-- projects contained by the workspace; I will need this when generating
-- workspace files in order to provide a map from workspace configurations
@ -124,6 +128,66 @@
end
function oven.addGeneratedFiles(wks)
local function addGeneratedFile(cfg, source, filename)
-- mark that we have generated files.
cfg.project.hasGeneratedFiles = true
-- add generated file to the project.
local files = cfg.project._.files
local node = files[filename]
if not node then
node = p.fileconfig.new(filename, cfg.project)
files[filename] = node
table.insert(files, node)
end
-- always overwrite the dependency information.
node.dependsOn = source
node.generated = true
-- add to config if not already added.
if not p.fileconfig.getconfig(node, cfg) then
p.fileconfig.addconfig(node, cfg)
end
end
local function addFile(cfg, node)
local filecfg = p.fileconfig.getconfig(node, cfg)
if not filecfg or filecfg.flags.ExcludeFromBuild or not filecfg.compilebuildoutputs then
return
end
if p.fileconfig.hasCustomBuildRule(filecfg) then
local buildoutputs = filecfg.buildoutputs
if buildoutputs and #buildoutputs > 0 then
for _, output in ipairs(buildoutputs) do
if not path.islinkable(output) then
addGeneratedFile(cfg, node, output)
end
end
end
end
end
for prj in p.workspace.eachproject(wks) do
local files = table.shallowcopy(prj._.files)
for cfg in p.project.eachconfig(prj) do
table.foreachi(files, function(node)
addFile(cfg, node)
end)
end
-- generated files might screw up the object sequences.
if prj.hasGeneratedFiles and p.project.iscpp(prj) then
oven.assignObjectSequences(prj)
end
end
end
function p.project.bake(self)
verbosef(' Baking %s...', self.name)

View File

@ -274,6 +274,11 @@
local tr = tree.new(prj.name)
table.foreachi(prj._.files, function(fcfg)
-- if the file is a generated file, we add those in a second pass.
if fcfg.generated then
return;
end
-- The tree represents the logical source code tree to be displayed
-- in the IDE, not the physical organization of the file system. So
-- virtual paths are used when adding nodes.
@ -300,6 +305,20 @@
setmetatable(node, { __index = fcfg })
end)
table.foreachi(prj._.files, function(fcfg)
-- if the file is not a generated file, we already added them
if not fcfg.generated then
return;
end
local parent = tree.add(tr, path.getdirectory(fcfg.dependsOn.vpath))
local node = tree.insert(parent, tree.new(path.getname(fcfg.vpath)))
-- Pass through value fetches to the file configuration
setmetatable(node, { __index = fcfg })
end)
tree.trimroot(tr)
tree.sort(tr, sorter)