Merge pull request #207 from starkos/more-workspace-renaming

More workspace renaming
This commit is contained in:
starkos 2015-08-13 18:43:31 -04:00
commit 97fc2a0a38
31 changed files with 228 additions and 227 deletions

View File

@ -270,8 +270,8 @@
function m.postBake()
local function shouldLoad(func)
for sln in p.global.eachSolution() do
for prj in p.solution.eachproject(sln) do
for wks in p.global.eachWorkspace() do
for prj in p.workspace.eachproject(wks) do
for cfg in p.project.eachconfig(prj) do
if func(cfg) then
return true

View File

@ -5,9 +5,10 @@
--
premake.make = {}
local make = premake.make
local solution = premake.solution
local project = premake.project
local p = premake
local make = p.make
local project = p.project
---
@ -54,14 +55,15 @@
--
-- Write out the default configuration rule for a solution or project.
-- Write out the default configuration rule for a workspace or project.
--
-- @param target
-- The solution or project object for which a makefile is being generated.
-- The workspace or project object for which a makefile is being generated.
--
function make.defaultconfig(target)
-- find the right configuration iterator function for this object
local eachconfig = iif(target.project, project.eachconfig, solution.eachconfig)
local eachconfig = iif(target.project, project.eachconfig, p.workspace.eachconfig)
local iter = eachconfig(target)
-- grab the first configuration and write the block
@ -92,20 +94,20 @@
--
-- Get the makefile file name for a solution or a project. If this object is the
-- Get the makefile file name for a workspace or a project. If this object is the
-- only one writing to a location then I can use "Makefile". If more than one object
-- writes to the same location I use name + ".make" to keep it unique.
--
function make.getmakefilename(this, searchprjs)
local count = 0
for sln in premake.global.eachSolution() do
if sln.location == this.location then
for wks in p.global.eachWorkspace() do
if wks.location == this.location then
count = count + 1
end
if searchprjs then
for _, prj in ipairs(sln.projects) do
for _, prj in ipairs(wks.projects) do
if prj.location == this.location then
count = count + 1
end
@ -125,17 +127,16 @@
-- Output a makefile header.
--
-- @param target
-- The solution or project object for which the makefile is being generated.
-- The workspace or project object for which the makefile is being generated.
--
function make.header(target)
-- find the right configuration iterator function for this object
local kind = iif(target.project, "project", "solution")
local kind = iif(target.project, "project", "workspace")
_p('# %s %s makefile autogenerated by Premake', premake.action.current().shortname, kind)
_p('')
if kind == "solution" then
if kind == "workspace" then
_p('.NOTPARALLEL:')
_p('')
end
@ -151,7 +152,7 @@
--
-- Rules for file ops based on the shell type. Can't use defines and $@ because
-- it screws up the escaping of spaces and parethesis (anyone know a solution?)
-- it screws up the escaping of spaces and parethesis (anyone know a fix?)
--
function make.mkdirRules(dirname)

View File

@ -1,45 +1,45 @@
--
-- make_solution.lua
-- Generate a solution-level makefile.
-- Copyright (c) 2002-2012 Jason Perkins and the Premake project
-- make_workspace.lua
-- Generate a workspace-level makefile.
-- Copyright (c) 2002-2015 Jason Perkins and the Premake project
--
local make = premake.make
local solution = premake.solution
local tree = premake.tree
local project = premake.project
local p = premake
local make = p.make
local tree = p.tree
local project = p.project
--
-- Generate a GNU make "solution" makefile, with support for the new platforms API.
-- Generate a GNU make "workspace" makefile, with support for the new platforms API.
--
function make.generate_solution(sln)
function make.generate_solution(wks)
premake.eol("\n")
make.header(sln)
make.header(wks)
make.configmap(sln)
make.projects(sln)
make.configmap(wks)
make.projects(wks)
make.solutionPhonyRule(sln)
make.groupRules(sln)
make.solutionPhonyRule(wks)
make.groupRules(wks)
make.projectrules(sln)
make.cleanrules(sln)
make.helprule(sln)
make.projectrules(wks)
make.cleanrules(wks)
make.helprule(wks)
end
--
-- Write out the solution's configuration map, which maps solution
-- Write out the workspace's configuration map, which maps workspace
-- level configurations to the project level equivalents.
--
function make.configmap(sln)
for cfg in solution.eachconfig(sln) do
function make.configmap(wks)
for cfg in p.workspace.eachconfig(wks) do
_p('ifeq ($(config),%s)', cfg.shortname)
for prj in solution.eachproject(sln) do
for prj in p.workspace.eachproject(wks) do
local prjcfg = project.getconfig(prj, cfg.buildcfg, cfg.platform)
if prjcfg then
_p(' %s_config = %s', make.tovar(prj.name), prjcfg.shortname)
@ -55,11 +55,11 @@
-- Write out the rules for the `make clean` action.
--
function make.cleanrules(sln)
function make.cleanrules(wks)
_p('clean:')
for prj in solution.eachproject(sln) do
for prj in p.workspace.eachproject(wks) do
local prjpath = premake.filename(prj, make.getmakefilename(prj, true))
local prjdir = path.getdirectory(path.getrelative(sln.location, prjpath))
local prjdir = path.getdirectory(path.getrelative(wks.location, prjpath))
local prjname = path.getname(prjpath)
_x(1,'@${MAKE} --no-print-directory -C %s -f %s clean', prjdir, prjname)
end
@ -71,13 +71,13 @@
-- Write out the make file help rule and configurations list.
--
function make.helprule(sln)
function make.helprule(wks)
_p('help:')
_p(1,'@echo "Usage: make [config=name] [target]"')
_p(1,'@echo ""')
_p(1,'@echo "CONFIGURATIONS:"')
for cfg in solution.eachconfig(sln) do
for cfg in p.workspace.eachconfig(wks) do
_x(1, '@echo " %s"', cfg.shortname)
end
@ -87,7 +87,7 @@
_p(1,'@echo " all (default)"')
_p(1,'@echo " clean"')
for prj in solution.eachproject(sln) do
for prj in p.workspace.eachproject(wks) do
_p(1,'@echo " %s"', prj.name)
end
@ -97,21 +97,21 @@
--
-- Write out the list of projects that comprise the solution.
-- Write out the list of projects that comprise the workspace.
--
function make.projects(sln)
_p('PROJECTS := %s', table.concat(premake.esc(table.extract(sln.projects, "name")), " "))
function make.projects(wks)
_p('PROJECTS := %s', table.concat(premake.esc(table.extract(wks.projects, "name")), " "))
_p('')
end
--
-- Write out the solution PHONY rule
-- Write out the workspace PHONY rule
--
function make.solutionPhonyRule(sln)
function make.solutionPhonyRule(wks)
local groups = {}
local tr = solution.grouptree(sln)
local tr = p.workspace.grouptree(wks)
tree.traverse(tr, {
onbranch = function(n)
table.insert(groups, n.path)
@ -127,9 +127,9 @@
--
-- Write out the phony rules representing project groups
--
function make.groupRules(sln)
-- Transform solution groups into target aggregate
local tr = solution.grouptree(sln)
function make.groupRules(wks)
-- Transform workspace groups into target aggregate
local tr = p.workspace.grouptree(wks)
tree.traverse(tr, {
onbranch = function(n)
local rule = n.path .. ":"
@ -160,11 +160,11 @@
end
--
-- Write out the rules to build each of the solution's projects.
-- Write out the rules to build each of the workspace's projects.
--
function make.projectrules(sln)
for prj in solution.eachproject(sln) do
function make.projectrules(wks)
for prj in p.workspace.eachproject(wks) do
local deps = project.getdependencies(prj)
deps = table.extract(deps, "name")
_p('%s:%s', premake.esc(prj.name), make.list(deps))
@ -175,7 +175,7 @@
_p(1,'@echo "==== Building %s ($(%s_config)) ===="', prj.name, cfgvar)
local prjpath = premake.filename(prj, make.getmakefilename(prj, true))
local prjdir = path.getdirectory(path.getrelative(sln.location, prjpath))
local prjdir = path.getdirectory(path.getrelative(wks.location, prjpath))
local prjname = path.getname(prjpath)
_x(1,'@${MAKE} --no-print-directory -C %s -f %s config=$(%s_config)', prjdir, prjname, cfgvar)

View File

@ -8,7 +8,6 @@
local vstudio = premake.vstudio
local p = premake
local solution = p.solution
local project = p.project
local config = p.config
@ -515,7 +514,7 @@
local hasnative = false
local hasnet = false
local slnarch
for prj in solution.eachproject(cfg.solution) do
for prj in p.workspace.eachproject(cfg.workspace) do
if project.isnative(prj) then
hasnative = true
elseif project.isdotnet(prj) then
@ -569,7 +568,7 @@
-- if the platform identifier matches a known system or architecture,
--
for prj in solution.eachproject(cfg.solution) do
for prj in p.workspace.eachproject(cfg.workspace) do
if project.isnative(prj) then
hasnative = true
elseif project.isdotnet(prj) then

View File

@ -15,12 +15,12 @@
-- Register a command-line action for Visual Studio 2006.
---
function vs2005.generateSolution(sln)
function vs2005.generateSolution(wks)
p.indent("\t")
p.eol("\r\n")
p.escaper(vs2005.esc)
premake.generate(sln, ".sln", vstudio.sln2005.generate)
premake.generate(wks, ".sln", vstudio.sln2005.generate)
end
@ -94,7 +94,7 @@
dotnet = { "msnet" },
},
-- Solution and project generation logic
-- Workspace and project generation logic
onWorkspace = vstudio.vs2005.generateSolution,
onProject = vstudio.vs2005.generateProject,

View File

@ -1,22 +1,23 @@
--
-- vs2005_solution.lua
-- Generate a Visual Studio 2005-2012 solution.
-- Copyright (c) 2009-2013 Jason Perkins and the Premake project
-- Copyright (c) 2009-2015 Jason Perkins and the Premake project
--
premake.vstudio.sln2005 = {}
local vstudio = premake.vstudio
local sln2005 = premake.vstudio.sln2005
local solution = premake.solution
local project = premake.project
local tree = premake.tree
local p = premake
local vstudio = p.vstudio
local sln2005 = p.vstudio.sln2005
local project = p.project
local tree = p.tree
--
-- Return the list of sections contained in the solution.
--
function sln2005.solutionSections(sln)
function sln2005.solutionSections(wks)
return {
"ConfigurationPlatforms",
"SolutionProperties",
@ -29,17 +30,17 @@
-- Generate a Visual Studio 200x solution, with support for the new platforms API.
--
function sln2005.generate(sln)
function sln2005.generate(wks)
-- Mark the file as Unicode
_p('\239\187\191')
sln2005.reorderProjects(sln)
sln2005.reorderProjects(wks)
sln2005.header()
sln2005.projects(sln)
sln2005.projects(wks)
_p('Global')
sln2005.sections(sln)
sln2005.sections(wks)
_p('EndGlobal')
end
@ -67,13 +68,13 @@
-- in the IDE will cause the orderings to get rewritten.
--
function sln2005.reorderProjects(sln)
if sln.startproject then
function sln2005.reorderProjects(wks)
if wks.startproject then
local np
local tr = solution.grouptree(sln)
local tr = p.workspace.grouptree(wks)
tree.traverse(tr, {
onleaf = function(n)
if n.project.name == sln.startproject then
if n.project.name == wks.startproject then
np = n
end
end
@ -94,15 +95,15 @@
-- Write out the list of projects and groups contained by the solution.
--
function sln2005.projects(sln)
local tr = solution.grouptree(sln)
function sln2005.projects(wks)
local tr = p.workspace.grouptree(wks)
tree.traverse(tr, {
onleaf = function(n)
local prj = n.project
-- Build a relative path from the solution file to the project file
local prjpath = vstudio.projectfile(prj)
prjpath = vstudio.path(prj.solution, prjpath)
prjpath = vstudio.path(prj.workspace, prjpath)
-- Unlike projects, solutions must use old-school %...% DOS style
-- for environment variables.
@ -141,12 +142,12 @@
-- Write out the tables that map solution configurations to project configurations.
--
function sln2005.configurationPlatforms(sln)
function sln2005.configurationPlatforms(wks)
local descriptors = {}
local sorted = {}
for cfg in solution.eachconfig(sln) do
for cfg in p.workspace.eachconfig(wks) do
-- Create a Visual Studio solution descriptor (i.e. Debug|Win32) for
-- this solution configuration. I need to use it in a few different places
@ -171,10 +172,10 @@
-- Now I can output the sorted list of solution configuration descriptors
-- Visual Studio assumes the first configurations as the defaults.
if sln.defaultplatform then
if wks.defaultplatform then
_p(1,'GlobalSection(SolutionConfigurationPlatforms) = preSolution')
table.foreachi(sorted, function (cfg)
if cfg.platform == sln.defaultplatform then
if cfg.platform == wks.defaultplatform then
_p(2,'%s = %s', descriptors[cfg], descriptors[cfg])
end
end)
@ -183,7 +184,7 @@
_p(1,'GlobalSection(SolutionConfigurationPlatforms) = preSolution')
table.foreachi(sorted, function (cfg)
if not sln.defaultplatform or cfg.platform ~= sln.defaultplatform then
if not wks.defaultplatform or cfg.platform ~= wks.defaultplatform then
_p(2,'%s = %s', descriptors[cfg], descriptors[cfg])
end
end)
@ -193,7 +194,7 @@
_p(1,"GlobalSection(ProjectConfigurationPlatforms) = postSolution")
local tr = solution.grouptree(sln)
local tr = p.workspace.grouptree(wks)
tree.traverse(tr, {
onleaf = function(n)
local prj = n.project
@ -240,7 +241,7 @@
-- Write out contents of the SolutionProperties section; currently unused.
--
function sln2005.properties(sln)
function sln2005.properties(wks)
_p('\tGlobalSection(SolutionProperties) = preSolution')
_p('\t\tHideSolutionNode = FALSE')
_p('\tEndGlobalSection')
@ -252,8 +253,8 @@
-- any solution groups.
--
function sln2005.NestedProjects(sln)
local tr = solution.grouptree(sln)
function sln2005.NestedProjects(wks)
local tr = p.workspace.grouptree(wks)
if tree.hasbranches(tr) then
_p(1,'GlobalSection(NestedProjects) = preSolution')
tree.traverse(tr, {
@ -281,13 +282,13 @@
--
-- Write out all of the solution sections.
-- Write out all of the workspace sections.
--
function sln2005.sections(sln)
for _, section in ipairs(sln2005.solutionSections(sln)) do
function sln2005.sections(wks)
for _, section in ipairs(sln2005.solutionSections(wks)) do
if sln2005.sectionmap[section] then
sln2005.sectionmap[section](sln)
sln2005.sectionmap[section](wks)
end
end
end

View File

@ -33,7 +33,7 @@
dotnet = { "msnet" },
},
-- Solution and project generation logic
-- Workspace and project generation logic
onWorkspace = vstudio.vs2005.generateSolution,
onProject = vstudio.vs2005.generateProject,

View File

@ -1443,12 +1443,12 @@
local deps = project.getdependencies(prj)
if #deps > 0 then
-- This is a little odd: Visual Studio wants the "relative path to project"
-- to be relative to the *solution*, rather than the project doing the
-- to be relative to the *workspace*, rather than the project doing the
-- referencing. Which, in theory, would break if the project is included
-- in more than one solution. But that's how they do it.
-- in more than one workspace. But that's how they do it.
for i, dep in ipairs(deps) do
local relpath = vstudio.path(prj.solution, vstudio.projectfile(dep))
local relpath = vstudio.path(prj.workspace, vstudio.projectfile(dep))
-- Visual Studio wants the path to start with ./ or ../
if not relpath:startswith(".") then

View File

@ -21,6 +21,7 @@
["cfg.objdir"] = "$(IntDir)",
["prj.location"] = "$(ProjectDir)",
["sln.location"] = "$(SolutionDir)",
["wks.location"] = "$(SolutionDir)",
["cfg.buildtarget.directory"] = "$(TargetDir)",
["cfg.buildtarget.name"] = "$(TargetFileName)",
["cfg.buildtarget.basename"] = "$(TargetName)",
@ -119,7 +120,7 @@
dotnet = { "msnet" },
},
-- Solution and project generation logic
-- Workspace and project generation logic
onWorkspace = function(wks)
vstudio.vs2005.generateSolution(wks)

View File

@ -35,7 +35,7 @@
dotnet = { "msnet" },
},
-- Solution and project generation logic
-- Workspace and project generation logic
onWorkspace = function(wks)
vstudio.vs2005.generateSolution(wks)

View File

@ -37,7 +37,7 @@
dotnet = { "msnet" },
},
-- Solution and project generation logic
-- Workspace and project generation logic
onWorkspace = function(wks)
vstudio.vs2005.generateSolution(wks)

View File

@ -37,7 +37,7 @@
dotnet = { "msnet" },
},
-- Solution and project generation logic
-- Workspace and project generation logic
onWorkspace = function(wks)
vstudio.vs2005.generateSolution(wks)

View File

@ -79,13 +79,13 @@
a.onStart()
end
for sln in p.global.eachSolution() do
local onSolution = a.onWorkspace or a.onSolution or a.onsolution
if onSolution and not sln.external then
onSolution(sln)
for wks in p.global.eachWorkspace() do
local onWorkspace = a.onWorkspace or a.onSolution or a.onsolution
if onWorkspace and not wks.external then
onWorkspace(wks)
end
for prj in p.solution.eachproject(sln) do
for prj in p.workspace.eachproject(wks) do
local onProject = a.onProject or a.onproject
if onProject and not prj.external then
onProject(prj)

View File

@ -1,6 +1,6 @@
--
-- api.lua
-- Implementation of the solution, project, and configuration APIs.
-- Implementation of the workspace, project, and configuration APIs.
-- Author Jason Perkins
-- Copyright (c) 2002-2015 Jason Perkins and the Premake project
--
@ -15,7 +15,7 @@
---
-- Set up a place to store the current active objects in each configuration
-- scope (e.g. solutions, projects, groups, and configurations). This likely
-- scope (e.g. wprkspaces, projects, groups, and configurations). This likely
-- ought to be internal scope, but it is useful for testing.
---
@ -27,15 +27,15 @@
-- Define a new class of configuration container. A container can receive and
-- store configuration blocks, which are what hold the individial settings
-- from the scripts. A container can also hold one or more kinds of child
-- containers; a solution can contain projects, for instance.
-- containers; a workspace can contain projects, for instance.
--
-- @param containerName
-- The name of the new container type, e.g. "solution". Used to define a
-- corresponding global function, e.g. solution() to create new instances
-- The name of the new container type, e.g. "workspace". Used to define a
-- corresponding global function, e.g. workspace() to create new instances
-- of the container.
-- @param parentContainer (optional)
-- The container that can contain this one. For a project, this would be
-- the solution container class.
-- the workspace container class.
-- @param extraScopes (optional)
-- Each container can hold fields scoped to itself (by putting the container's
-- class name into its scope attribute), or any of the container's children.
@ -112,12 +112,12 @@
---
-- Activate a new configuration container, making it the target for all
-- subsequent configuration settings. When you call solution() or project()
-- subsequent configuration settings. When you call workspace() or project()
-- to active a container, that call comes here (see api.container() for the
-- details on how that happens).
--
-- @param class
-- The container class being activated, e.g. a project or solution.
-- The container class being activated, e.g. a project or workspace.
-- @param name
-- The name of the container instance to be activated. If a container
-- (e.g. project) with this name does not already exist it will be
@ -211,8 +211,8 @@
--
-- The available field scopes are:
--
-- project The field applies to solutions and projects.
-- config The field applies to solutions, projects, and individual build
-- project The field applies to workspaces and projects.
-- config The field applies to workspaces, projects, and individual build
-- configurations.
--
-- The available field kinds are:

View File

@ -250,9 +250,9 @@
local item
-- Sort the links into "sibling" (is another project in this same
-- solution) and "system" (is not part of this solution) libraries.
-- workspace) and "system" (is not part of this workspace) libraries.
local prj = premake.solution.findproject(cfg.solution, link)
local prj = p.workspace.findproject(cfg.workspace, link)
if prj and kind ~= "system" then
-- Sibling; is there a matching configuration in this project that

View File

@ -212,7 +212,7 @@
-- The name of the class to be checked against. If the container
-- class matches this scope (i.e. class is a project and the
-- scope is "project"), or if it is a parent object of it (i.e.
-- class is a solution and scope is "project"), then returns
-- class is a workspace and scope is "project"), then returns
-- true.
---

View File

@ -1,7 +1,7 @@
---
-- global.lua
-- The global container holds solutions and rules.
-- Copyright (c) 2014 Jason Perkins and the Premake project
-- The global container holds workspaces and rules.
-- Copyright (c) 2014-2015 Jason Perkins and the Premake project
---
local p = premake
@ -34,17 +34,19 @@
---
-- Iterate over the collection of solutions in a session.
-- Iterate over the collection of workspaces in a session.
--
-- @returns
-- An iterator function.
-- A workspace iterator function.
---
function global.eachSolution()
function global.eachWorkspace()
local root = p.api.rootContainer()
return p.container.eachChild(root, p.solution)
return p.container.eachChild(root, p.workspace)
end
p.alias(global, "eachWorkspace", "eachSolution")
---
@ -90,15 +92,17 @@
---
-- Retrieve a solution by name or index.
-- Retrieve a workspace by name or index.
--
-- @param key
-- The solution key, either a string name or integer index.
-- The workspace key, either a string name or integer index.
-- @returns
-- The solution with the provided key.
-- The workspace with the provided key.
---
function global.getSolution(key)
function global.getWorkspace(key)
local root = p.api.rootContainer()
return root.solutions[key]
end
p.alias(global, "getWorkspace", "getSolution")

View File

@ -5,7 +5,7 @@
---
local p = premake
p.group = p.api.container("group", p.solution)
p.group = p.api.container("group", p.workspace)
local group = p.group

View File

@ -1,7 +1,7 @@
--
-- base/oven.lua
--
-- Process the solutions, projects, and configurations that were specified
-- Process the workspaces, projects, and configurations that were specified
-- by the project script, and make them suitable for use by the exporters
-- and actions. Fills in computed values (e.g. object directories) and
-- optimizes the layout of the data for faster fetches.
@ -39,24 +39,26 @@
--
-- This call replaces the existing the container objects with their
-- processed replacements. If you are using the provided container APIs
-- (p.global.*, p.solution.*, etc.) this will be transparent.
-- (p.global.*, p.workspace.*, etc.) this will be transparent.
---
function oven.bake()
p.container.bakeChildren(p.api.rootContainer())
end
function oven.bakeSolution(sln)
return p.container.bake(sln)
function oven.bakeWorkspace(wks)
return p.container.bake(wks)
end
p.alias(oven, "bakeWorkspace", "bakeSolution")
---
-- Bakes a specific solution object.
-- Bakes a specific workspace object.
---
function p.solution.bake(self)
function p.workspace.bake(self)
-- Add filtering terms to the context and then compile the results. These
-- terms describe the "operating environment"; only results contained by
-- configuration blocks which match these terms will be returned.
@ -83,31 +85,31 @@
-- Set up my token expansion environment
self.environ = {
sln = self,
wks = self,
sln = self,
}
context.compile(self)
-- Specify the solution's file system location; when path tokens are
-- expanded in solution values, they will be made relative to this.
-- Specify the workspaces's file system location; when path tokens are
-- expanded in workspace values, they will be made relative to this.
self.location = self.location or self.basedir
context.basedir(self, self.location)
-- Now bake down all of the projects contained in the solution, and
-- Now bake down all of the projects contained in the workspace, and
-- store that for future reference
p.container.bakeChildren(self)
-- I now have enough information to assign unique object directories
-- to each project configuration in the solution.
-- to each project configuration in the workspace.
oven.bakeObjDirs(self)
-- Build a master list of configuration/platform pairs from all of the
-- projects contained by the solution; I will need this when generating
-- solution files in order to provide a map from solution configurations
-- projects contained by the workspace; I will need this when generating
-- workspace files in order to provide a map from workspace configurations
-- to project configurations.
self.configs = oven.bakeConfigs(self)
@ -116,12 +118,13 @@
function p.project.bake(self)
local sln = self.solution
self.workspace = self.solution
local wks = self.workspace
-- Add filtering terms to the context to make it as specific as I can.
-- Start with the same filtering that was applied at the solution level.
-- Start with the same filtering that was applied at the workspace level.
context.copyFilters(self, sln)
context.copyFilters(self, wks)
-- Now filter on the current system and architecture, allowing the
-- values that might already in the context to override my defaults.
@ -142,8 +145,8 @@
-- Populate the token expansion environment
self.environ = {
sln = sln,
wks = sln,
wks = wks,
sln = wks,
prj = self,
}
@ -157,11 +160,11 @@
-- location. Any path tokens which are expanded in non-path fields
-- are made relative to this, ensuring a portable generated project.
self.location = self.location or sln.location or self.basedir
self.location = self.location or wks.location or self.basedir
context.basedir(self, self.location)
-- This bit could use some work: create a canonical set of configurations
-- for the project, along with a mapping from the solution's configurations.
-- for the project, along with a mapping from the workspace's configurations.
-- This works, but it could probably be simplified.
local cfgs = table.fold(self.configurations or {}, self.platforms or {})
@ -181,7 +184,7 @@
for _, pairing in ipairs(self._cfglist) do
local buildcfg = pairing[1]
local platform = pairing[2]
local cfg = oven.bakeConfig(sln, self, buildcfg, platform)
local cfg = oven.bakeConfig(wks, self, buildcfg, platform)
if premake.action.supportsconfig(premake.action.current(), cfg) then
self.configs[(buildcfg or "*") .. (platform or "")] = cfg
@ -217,7 +220,7 @@
--
-- Assigns a unique objects directory to every configuration of every project
-- in the solution, taking any objdir settings into account, to ensure builds
-- in the workspace, taking any objdir settings into account, to ensure builds
-- from different configurations won't step on each others' object files.
-- The path is built from these choices, in order:
--
@ -226,11 +229,11 @@
-- [3] -> [2] + the build configuration name
-- [4] -> [3] + the project name
--
-- @param sln
-- The solution to process. The directories are modified inline.
-- @param wks
-- The workspace to process. The directories are modified inline.
--
function oven.bakeObjDirs(sln)
function oven.bakeObjDirs(wks)
-- function to compute the four options for a specific configuration
local function getobjdirs(cfg)
-- the "!" prefix indicates the directory is not to be touched
@ -260,12 +263,12 @@
return dirs
end
-- walk all of the configs in the solution, and count the number of
-- walk all of the configs in the workspace, and count the number of
-- times each obj dir gets used
local counts = {}
local configs = {}
for prj in p.solution.eachproject(sln) do
for prj in p.workspace.eachproject(wks) do
for cfg in p.project.eachconfig(prj) do
-- get the dirs for this config, and associate them together,
-- and increment a counter for each one discovered
@ -292,18 +295,18 @@
--
-- Create a list of solution-level build configuration/platform pairs.
-- Create a list of workspace-level build configuration/platform pairs.
--
function oven.bakeConfigs(sln)
local buildcfgs = sln.configurations or {}
local platforms = sln.platforms or {}
function oven.bakeConfigs(wks)
local buildcfgs = wks.configurations or {}
local platforms = wks.platforms or {}
local configs = {}
local pairings = table.fold(buildcfgs, platforms)
for _, pairing in ipairs(pairings) do
local cfg = oven.bakeConfig(sln, nil, pairing[1], pairing[2])
local cfg = oven.bakeConfig(wks, nil, pairing[1], pairing[2])
if premake.action.supportsconfig(premake.action.current(), cfg) then
table.insert(configs, cfg)
end
@ -364,7 +367,7 @@
--
-- Builds a list of build configuration/platform pairs for a project,
-- along with a mapping between the solution and project configurations.
-- along with a mapping between the workspace and project configurations.
--
-- @param ctx
-- The project context information.
@ -407,8 +410,8 @@
-- Flattens out the build settings for a particular build configuration and
-- platform pairing, and returns the result.
--
-- @param sln
-- The solution which contains the configuration data.
-- @param wks
-- The workpace which contains the configuration data.
-- @param prj
-- The project which contains the configuration data. Can be nil.
-- @param buildcfg
@ -420,7 +423,7 @@
-- this configuration
---
function oven.bakeConfig(sln, prj, buildcfg, platform, extraFilters)
function oven.bakeConfig(wks, prj, buildcfg, platform, extraFilters)
-- Set the default system and architecture values; if the platform's
-- name matches a known system or architecture, use that as the default.
@ -441,15 +444,16 @@
-- values are used when expanding tokens.
local environ = {
sln = sln,
wks = sln,
wks = wks,
sln = wks,
prj = prj,
}
local ctx = context.new(prj or sln, environ)
local ctx = context.new(prj or wks, environ)
ctx.project = prj
ctx.solution = sln
ctx.workspace = wks
ctx.solution = wks
ctx.buildcfg = buildcfg
ctx.platform = platform
ctx.action = _ACTION
@ -462,10 +466,10 @@
-- Add filtering terms to the context and then compile the results. These
-- terms describe the "operating environment"; only results contained by
-- configuration blocks which match these terms will be returned. Start
-- by copying over the top-level environment from the solution. Don't
-- by copying over the top-level environment from the workspace. Don't
-- copy the project terms though, so configurations can override those.
context.copyFilters(ctx, sln)
context.copyFilters(ctx, wks)
context.addFilter(ctx, "configurations", buildcfg)
context.addFilter(ctx, "platforms", platform)
@ -603,7 +607,7 @@
--
-- Finish the baking process for a solution or project level configurations.
-- Finish the baking process for a workspace or project level configurations.
-- Doesn't bake per se, just fills in some calculated values.
--

View File

@ -1,16 +1,11 @@
--
-- premake.lua
-- High-level helper functions for the project exporters.
-- Copyright (c) 2002-2014 Jason Perkins and the Premake project
-- Copyright (c) 2002-2015 Jason Perkins and the Premake project
--
local p = premake
local solution = p.solution
local project = p.project
local config = p.config
local field = p.field
-- Store captured output text for later testing
@ -140,14 +135,14 @@
--
-- Open a file for output, and call a function to actually do the writing.
-- Used by the actions to generate solution and project files.
-- Used by the actions to generate workspace and project files.
--
-- @param obj
-- A solution or project object; will be passed to the callback function.
-- A workspace or project object; will be passed to the callback function.
-- @param ext
-- An optional extension for the generated file, with the leading dot.
-- @param callback
-- The function responsible for writing the file, should take a solution
-- The function responsible for writing the file, should take a workspace
-- or project as a parameters.
--
@ -171,7 +166,7 @@
---
-- Returns the full path a file generated from any of the project
-- objects (project, solution, rule).
-- objects (project, workspace, rule).
--
-- @param obj
-- The project object being generated.

View File

@ -6,7 +6,7 @@
---
local p = premake
p.project = p.api.container("project", p.solution, { "config" })
p.project = p.api.container("project", p.workspace, { "config" })
local project = p.project
local tree = p.tree
@ -44,7 +44,7 @@
--
-- Returns an iterator function for the configuration objects contained by
-- the project. Each configuration corresponds to a build configuration/
-- platform pair (i.e. "Debug|x86") as specified in the solution.
-- platform pair (i.e. "Debug|x86") as specified in the workspace.
--
-- @param prj
-- The project object to query.
@ -56,7 +56,7 @@
local configs = prj._cfglist
local count = #configs
-- Once the configurations are mapped into the solution I could get
-- Once the configurations are mapped into the workspace I could get
-- the same one multiple times. Make sure that doesn't happen.
local seen = {}
@ -152,9 +152,9 @@
---
-- Returns a list of sibling projects on which the specified project depends.
-- This is used to list dependencies within a solution or workspace. Must
-- consider all configurations because Visual Studio does not support per-config
-- project dependencies.
-- This is used to list dependencies within a workspace. Must consider all
-- configurations because Visual Studio does not support per-config project
-- dependencies.
--
-- @param prj
-- The project to query.
@ -169,7 +169,7 @@
if not prj.dependencies then
local result = {}
local function add_to_project_list(cfg, depproj, result)
local dep = premake.solution.findproject(cfg.solution, depproj)
local dep = p.workspace.findproject(cfg.workspace, depproj)
if dep and not table.contains(result, dep) then
table.insert(result, dep)
end

View File

@ -22,18 +22,18 @@
---
-- Validate a solution and its projects.
-- Validate a workspace and its projects.
---
function p.solution.validate(self)
function p.workspace.validate(self)
-- there must be at least one build configuration
if not self.configurations or #self.configurations == 0 then
p.error("solution '%s' does not contain any configurations", self.name)
p.error("workspace '%s' does not contain any configurations", self.name)
end
-- all project UUIDs must be unique
local uuids = {}
for prj in p.solution.eachproject(self) do
for prj in p.workspace.eachproject(self) do
if uuids[prj.uuid] then
p.error("projects '%s' and '%s' have the same UUID", uuids[prj.uuid], prj.name)
end

View File

@ -39,7 +39,7 @@
--
function workspace.eachconfig(self)
self = premake.oven.bakeSolution(self)
self = p.oven.bakeWorkspace(self)
local i = 0
return function()
@ -135,7 +135,7 @@
--
function workspace.getproject(self, idx)
self = p.oven.bakeSolution(self)
self = p.oven.bakeWorkspace(self)
return self.projects[idx]
end

View File

@ -1,11 +1,10 @@
--
-- tests/actions/make/solution/test_group_rule.lua
-- Validate generation of group rules
-- Copyright (c) 2012-2014 Jason Perkins and the Premake project
-- Copyright (c) 2012-2015 Jason Perkins and the Premake project
--
T.make_group_rule = {}
local suite = T.make_group_rule
local suite = test.declare("make_group_rule")
local make = premake.make
@ -27,7 +26,7 @@
end
local function prepare()
sln = premake.oven.bakeSolution(sln)
sln = test.getsolution(sln)
end

View File

@ -1,12 +1,10 @@
--
-- tests/actions/make/test_help_rule.lua
-- Validate generation of help rule and configurations list.
-- Copyright (c) 2012-2013 Jason Perkins and the Premake project
-- Copyright (c) 2012-2015 Jason Perkins and the Premake project
--
T.make_help_rule = {}
local suite = T.make_help_rule
local make = premake.make
local suite = test.declare("make_help_rule")
--
@ -20,8 +18,8 @@
end
local function prepare()
sln = premake.oven.bakeSolution(sln)
make.helprule(sln)
sln = test.getsolution(sln)
premake.make.helprule(sln)
end

View File

@ -1,12 +1,10 @@
--
-- tests/actions/make/solution/test_project_rule.lua
-- Validate generation of project rules in solution makefile.
-- Copyright (c) 2012-2013 Jason Perkins and the Premake project
-- Copyright (c) 2012-2015 Jason Perkins and the Premake project
--
T.make_project_rule = {}
local suite = T.make_project_rule
local make = premake.make
local suite = test.declare("make_project_rule")
--
@ -21,8 +19,8 @@
local function prepare()
premake.oven.bake()
sln = premake.global.getSolution(sln.name)
make.projectrules(sln)
sln = test.getsolution(sln)
premake.make.projectrules(sln)
end

View File

@ -24,7 +24,7 @@
local function prepare(lang)
filter {}
uuid "C9135098-6047-8142-B10E-D27E7F73FCB3"
sln = premake.oven.bakeSolution(sln)
sln = test.getsolution(sln)
sln2005.configurationPlatforms(sln)
end

View File

@ -12,10 +12,10 @@
-- Setup and teardown
--
local sln
local wks
function suite.setup()
sln = solution("MySolution")
wks = workspace("MyWorkspace")
end
@ -24,12 +24,12 @@
--
function suite.solution_createsOnFirstUse()
test.isnotnil(premake.global.getSolution("MySolution"))
test.isnotnil(premake.global.getWorkspace("MyWorkspace"))
end
function suite.project_createsOnFirstUse()
project("MyProject")
test.isnotnil(premake.solution.getproject(sln, "MyProject"))
test.isnotnil(premake.solution.getproject(wks, "MyProject"))
end
@ -38,7 +38,7 @@
--
function suite.solution_setsActiveScope()
test.issame(api.scope.solution, sln)
test.issame(api.scope.solution, wks)
end
function suite.project_setsActiveScope()
@ -56,7 +56,7 @@
project("MyProject")
group("MyGroup")
solution()
test.issame(sln, api.scope.solution)
test.issame(wks, api.scope.solution)
test.isnil(api.scope.project)
test.isnil(api.scope.group)
end
@ -88,6 +88,6 @@
group("MyGroup")
filter("Debug")
project "*"
test.issame(sln, api.scope.solution)
test.issame(wks, api.scope.solution)
test.isnil(api.scope.project)
end

View File

@ -10,6 +10,7 @@
local sln, prj
--
-- Setup
--
@ -19,8 +20,8 @@
end
local function prepare()
sln = oven.bakeSolution(sln)
prj = solution.getproject(sln, 1)
sln = test.getsolution(sln)
prj = test.getproject(sln, 1)
end

View File

@ -1,7 +1,7 @@
--
-- tests/solution/test_location.lua
-- Test handling of the solution's location field.
-- Copyright (c) 2013 Jason Perkins and the Premake project
-- Copyright (c) 2013-2015 Jason Perkins and the Premake project
--
local suite = test.declare("solution_location")
@ -18,7 +18,7 @@
end
local function prepare()
sln = premake.oven.bakeSolution(sln)
sln = test.getsolution(sln)
end

View File

@ -272,8 +272,8 @@
function test.getsolution(sln)
premake.oven.bake()
return premake.global.getSolution(sln.name)
p.oven.bake()
return p.global.getWorkspace(sln.name)
end