More easy solution to workspace renames

This commit is contained in:
Jason Perkins 2015-08-12 14:53:12 -04:00
parent 1eb38c9fc1
commit bf3e68287c
19 changed files with 83 additions and 87 deletions

View File

@ -271,7 +271,7 @@
function m.postBake()
local function shouldLoad(func)
for wks in p.global.eachWorkspace() do
for prj in p.solution.eachproject(wks) 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

@ -55,9 +55,10 @@
--
-- 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)
@ -93,7 +94,7 @@
--
-- 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.
--
@ -126,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
@ -152,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,17 +1,17 @@
--
-- 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)
@ -32,14 +32,14 @@
--
-- 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
for cfg in p.workspace.eachconfig(sln) do
_p('ifeq ($(config),%s)', cfg.shortname)
for prj in solution.eachproject(sln) do
for prj in p.workspace.eachproject(sln) do
local prjcfg = project.getconfig(prj, cfg.buildcfg, cfg.platform)
if prjcfg then
_p(' %s_config = %s', make.tovar(prj.name), prjcfg.shortname)
@ -57,7 +57,7 @@
function make.cleanrules(sln)
_p('clean:')
for prj in solution.eachproject(sln) do
for prj in p.workspace.eachproject(sln) do
local prjpath = premake.filename(prj, make.getmakefilename(prj, true))
local prjdir = path.getdirectory(path.getrelative(sln.location, prjpath))
local prjname = path.getname(prjpath)
@ -77,7 +77,7 @@
_p(1,'@echo ""')
_p(1,'@echo "CONFIGURATIONS:"')
for cfg in solution.eachconfig(sln) do
for cfg in p.workspace.eachconfig(sln) 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(sln) do
_p(1,'@echo " %s"', prj.name)
end
@ -97,7 +97,7 @@
--
-- Write out the list of projects that comprise the solution.
-- Write out the list of projects that comprise the workspace.
--
function make.projects(sln)
@ -106,12 +106,12 @@
end
--
-- Write out the solution PHONY rule
-- Write out the workspace PHONY rule
--
function make.solutionPhonyRule(sln)
local groups = {}
local tr = solution.grouptree(sln)
local tr = p.workspace.grouptree(sln)
tree.traverse(tr, {
onbranch = function(n)
table.insert(groups, n.path)
@ -128,8 +128,8 @@
-- Write out the phony rules representing project groups
--
function make.groupRules(sln)
-- Transform solution groups into target aggregate
local tr = solution.grouptree(sln)
-- Transform workspace groups into target aggregate
local tr = p.workspace.grouptree(sln)
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
for prj in p.workspace.eachproject(sln) do
local deps = project.getdependencies(prj)
deps = table.extract(deps, "name")
_p('%s:%s', premake.esc(prj.name), make.list(deps))

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

@ -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,15 +1,16 @@
--
-- 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
--
@ -70,7 +71,7 @@
function sln2005.reorderProjects(sln)
if sln.startproject then
local np
local tr = solution.grouptree(sln)
local tr = p.workspace.grouptree(sln)
tree.traverse(tr, {
onleaf = function(n)
if n.project.name == sln.startproject then
@ -95,14 +96,14 @@
--
function sln2005.projects(sln)
local tr = solution.grouptree(sln)
local tr = p.workspace.grouptree(sln)
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.
@ -146,7 +147,7 @@
local descriptors = {}
local sorted = {}
for cfg in solution.eachconfig(sln) do
for cfg in p.workspace.eachconfig(sln) 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
@ -193,7 +194,7 @@
_p(1,"GlobalSection(ProjectConfigurationPlatforms) = postSolution")
local tr = solution.grouptree(sln)
local tr = p.workspace.grouptree(sln)
tree.traverse(tr, {
onleaf = function(n)
local prj = n.project
@ -253,7 +254,7 @@
--
function sln2005.NestedProjects(sln)
local tr = solution.grouptree(sln)
local tr = p.workspace.grouptree(sln)
if tree.hasbranches(tr) then
_p(1,'GlobalSection(NestedProjects) = preSolution')
tree.traverse(tr, {
@ -281,7 +282,7 @@
--
-- Write out all of the solution sections.
-- Write out all of the workspace sections.
--
function sln2005.sections(sln)

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

@ -85,7 +85,7 @@
onWorkspace(wks)
end
for prj in p.solution.eachproject(wks) 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

@ -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,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