Begin implementation of property definitions for generated rules
- add new API propertyDefinition() with name, kind, and default value keys - write default values to Visual Studio .props files
This commit is contained in:
parent
8108d278df
commit
6471232ced
@ -565,6 +565,12 @@
|
||||
tokens = true,
|
||||
}
|
||||
|
||||
api.register {
|
||||
name = "propertyDefinition",
|
||||
scope = "rule",
|
||||
kind = "list:table",
|
||||
}
|
||||
|
||||
api.register {
|
||||
name = "rebuildcommands",
|
||||
scope = "config",
|
||||
|
@ -48,9 +48,9 @@
|
||||
p.indent(" ")
|
||||
p.escaper(vs2010.esc)
|
||||
|
||||
p.generate(rule, ".props", vstudio.rules.props.generate)
|
||||
p.generate(rule, ".targets", vstudio.rules.targets.generate)
|
||||
p.generate(rule, ".xml", vstudio.rules.xml.generate)
|
||||
p.generate(rule, ".props", vs2010.rules.props.generate)
|
||||
p.generate(rule, ".targets", vs2010.rules.targets.generate)
|
||||
p.generate(rule, ".xml", vs2010.rules.xml.generate)
|
||||
end
|
||||
|
||||
|
||||
|
@ -4,16 +4,17 @@
|
||||
-- Copyright (c) 2014 Jason Perkins and the Premake project
|
||||
--
|
||||
|
||||
premake.vstudio.rules = {}
|
||||
premake.vstudio.rules.props = {}
|
||||
local m = premake.vstudio.rules.props
|
||||
|
||||
premake.vstudio.vs2010.rules = {}
|
||||
premake.vstudio.vs2010.rules.props = {}
|
||||
|
||||
local m = premake.vstudio.vs2010.rules.props
|
||||
m.elements = {}
|
||||
|
||||
local p = premake
|
||||
|
||||
|
||||
|
||||
|
||||
---
|
||||
-- Entry point; generate the root <Project> element.
|
||||
---
|
||||
@ -81,19 +82,40 @@
|
||||
|
||||
m.elements.ruleGroup = function(r)
|
||||
return {
|
||||
m.propertyDefaults,
|
||||
}
|
||||
end
|
||||
|
||||
function m.ruleGroup(r)
|
||||
p.push('<ItemDefinitionGroup>')
|
||||
p.push('<%s>', r.name)
|
||||
p.callArray(m.elements.ruleGroup)
|
||||
p.callArray(m.elements.ruleGroup, r)
|
||||
p.pop('</%s>', r.name)
|
||||
p.pop('</ItemDefinitionGroup>')
|
||||
end
|
||||
|
||||
|
||||
|
||||
---
|
||||
-- Output the default values for all of the property definitions.
|
||||
---
|
||||
|
||||
function m.propertyDefaults(r)
|
||||
local defs = r.propertyDefinition
|
||||
for i = 1, #defs do
|
||||
local def = defs[i]
|
||||
local value = def.defaultValue
|
||||
if value then
|
||||
if def.kind == "path" then
|
||||
value = path.translate(value)
|
||||
end
|
||||
p.w('<%s>%s</%s>', def.name, value, def.name)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
---
|
||||
-- Implementations of individual elements.
|
||||
---
|
||||
|
@ -4,9 +4,9 @@
|
||||
-- Copyright (c) 2014 Jason Perkins and the Premake project
|
||||
--
|
||||
|
||||
premake.vstudio.rules.targets = {}
|
||||
premake.vstudio.vs2010.rules.targets = {}
|
||||
|
||||
local m = premake.vstudio.rules.targets
|
||||
local m = premake.vstudio.vs2010.rules.targets
|
||||
m.elements = {}
|
||||
|
||||
local p = premake
|
||||
|
@ -4,8 +4,9 @@
|
||||
-- Copyright (c) 2014 Jason Perkins and the Premake project
|
||||
--
|
||||
|
||||
premake.vstudio.rules.xml = {}
|
||||
local m = premake.vstudio.rules.xml
|
||||
premake.vstudio.vs2010.rules.xml = {}
|
||||
|
||||
local m = premake.vstudio.vs2010.rules.xml
|
||||
m.elements = {}
|
||||
|
||||
local p = premake
|
||||
|
@ -406,8 +406,8 @@
|
||||
---
|
||||
|
||||
function api.target(fld)
|
||||
if api.scope.rules and p.field.hasScope(fld, "rule") then
|
||||
return api.scope.rules
|
||||
if api.scope.rule and p.field.hasScope(fld, "rule") then
|
||||
return api.scope.rule
|
||||
elseif fld.scope ~= "rule" then
|
||||
return api.scope.project or api.scope.solution or api.scope.root
|
||||
else
|
||||
|
@ -18,8 +18,40 @@
|
||||
|
||||
|
||||
|
||||
---
|
||||
-- The metatable allows container functions to be called with the ":" syntax,
|
||||
-- and also allows API field values to be get and set as if they were direct
|
||||
-- properties.
|
||||
--
|
||||
-- TODO: I think I'd like to get away from treating the fields as direct
|
||||
-- properties on the containers (fine on the baked contexts later) and require
|
||||
-- explicit fetch() and store() calls instead.
|
||||
---
|
||||
|
||||
p.containerClass.__index = p.containerClass
|
||||
p.container.__index = p.container
|
||||
|
||||
p.container.__index = function(c, key)
|
||||
local f = p.field.get(key)
|
||||
if f then
|
||||
return p.configset.fetch(c, f)
|
||||
else
|
||||
return p.container[key]
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
p.container.__newindex = function(c, key, value)
|
||||
local f = p.field.get(key)
|
||||
if f then
|
||||
local status, err = p.configset.store(c, f, value)
|
||||
if err then
|
||||
error(err, 2)
|
||||
end
|
||||
else
|
||||
rawset(c, key, value)
|
||||
return value
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
@ -89,8 +121,9 @@
|
||||
-- A new instance of the container class.
|
||||
---
|
||||
|
||||
function p.containerClass:new(name)
|
||||
local c = p.configset.new(self.parent)
|
||||
function p.containerClass:new(name, parent)
|
||||
local c = p.configset.new(parent)
|
||||
setmetatable(c, p.container)
|
||||
|
||||
c.class = self
|
||||
c.name = name
|
||||
@ -98,7 +131,6 @@
|
||||
c.basedir = os.getcwd()
|
||||
c.filename = name
|
||||
|
||||
setmetatable(c, p.container)
|
||||
return c
|
||||
end
|
||||
|
||||
@ -144,7 +176,7 @@
|
||||
local c = children[key]
|
||||
|
||||
if not c and type(key) == "string" then
|
||||
c = cc:new(key)
|
||||
c = cc:new(key, parent)
|
||||
table.insert(children, c)
|
||||
children[key] = c
|
||||
end
|
||||
|
@ -69,5 +69,9 @@
|
||||
---
|
||||
|
||||
function string:plural()
|
||||
return self .. "s"
|
||||
if self:endswith("y") then
|
||||
return self:sub(1, #self - 1) .. "ies"
|
||||
else
|
||||
return self .. "s"
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user