Allow "!" prefix to force an explicit object directory, disregarding project or configuration overlaps
This commit is contained in:
parent
ce0e8f8e90
commit
ccfc2b8b66
@ -259,9 +259,17 @@
|
||||
function oven.bakeObjDirs(sln)
|
||||
-- function to compute the four options for a specific configuration
|
||||
local function getobjdirs(cfg)
|
||||
-- the "!" prefix indicates the directory is not to be touched
|
||||
local objdir = cfg.objdir or "obj"
|
||||
local i = objdir:find("!", 1, true)
|
||||
if i then
|
||||
cfg.objdir = objdir:sub(1, i - 1) .. objdir:sub(i + 1)
|
||||
return nil
|
||||
end
|
||||
|
||||
local dirs = {}
|
||||
|
||||
local dir = path.getabsolute(path.join(cfg.project.location, cfg.objdir or "obj"))
|
||||
local dir = path.getabsolute(path.join(cfg.project.location, objdir))
|
||||
table.insert(dirs, dir)
|
||||
|
||||
if cfg.platform then
|
||||
@ -285,12 +293,14 @@
|
||||
|
||||
for prj in solution.eachproject(sln) do
|
||||
for cfg in project.eachconfig(prj) do
|
||||
-- get the dirs for this config, and remember the association
|
||||
-- get the dirs for this config, and associate them together,
|
||||
-- and increment a counter for each one discovered
|
||||
local dirs = getobjdirs(cfg)
|
||||
configs[cfg] = dirs
|
||||
|
||||
for _, dir in ipairs(dirs) do
|
||||
counts[dir] = (counts[dir] or 0) + 1
|
||||
if dirs then
|
||||
configs[cfg] = dirs
|
||||
for _, dir in ipairs(dirs or {}) do
|
||||
counts[dir] = (counts[dir] or 0) + 1
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
86
tests/oven/test_objdirs.lua
Normal file
86
tests/oven/test_objdirs.lua
Normal file
@ -0,0 +1,86 @@
|
||||
---
|
||||
-- tests/oven/test_objdirs.lua
|
||||
-- Test the per-configuration object directory assignments.
|
||||
-- Copyright (c) 2014 Jason Perkins and the Premake project
|
||||
---
|
||||
|
||||
local suite = test.declare("oven_objdirs")
|
||||
local oven = premake.oven
|
||||
|
||||
local sln, prj
|
||||
|
||||
---
|
||||
-- Setup
|
||||
---
|
||||
|
||||
function suite.setup()
|
||||
end
|
||||
|
||||
local function result(buildcfg, platform)
|
||||
local cfg = test.getconfig(prj, buildcfg, platform)
|
||||
return path.getrelative(os.getcwd(), cfg.objdir)
|
||||
end
|
||||
|
||||
|
||||
|
||||
function suite.singleProject_noPlatforms()
|
||||
sln = solution "MySolution"
|
||||
configurations { "Debug", "Release" }
|
||||
prj = project "MyProject"
|
||||
|
||||
test.isequal("obj/Debug", result("Debug"))
|
||||
test.isequal("obj/Release", result("Release"))
|
||||
end
|
||||
|
||||
|
||||
function suite.multipleProjects_noPlatforms()
|
||||
sln = solution "MySolution"
|
||||
configurations { "Debug", "Release" }
|
||||
prj = project "MyProject"
|
||||
project "MyProject2"
|
||||
|
||||
test.createproject(sln)
|
||||
test.isequal("obj/Debug/MyProject", result("Debug"))
|
||||
end
|
||||
|
||||
|
||||
function suite.singleProject_withPlatforms()
|
||||
sln = solution "MySolution"
|
||||
configurations { "Debug", "Release" }
|
||||
platforms { "x32", "x64" }
|
||||
prj = project "MyProject"
|
||||
|
||||
test.isequal("obj/x32/Debug", result("Debug", "x32"))
|
||||
end
|
||||
|
||||
|
||||
function suite.singleProject_uniqueByTokens_noPlatforms()
|
||||
sln = solution "MySolution"
|
||||
configurations { "Debug", "Release" }
|
||||
prj = project "MyProject"
|
||||
objdir "obj/%{cfg.buildcfg}"
|
||||
|
||||
test.isequal("obj/Debug", result("Debug"))
|
||||
end
|
||||
|
||||
|
||||
function suite.singleProject_uniqueByTokens_withPlatforms()
|
||||
sln = solution "MySolution"
|
||||
configurations { "Debug", "Release" }
|
||||
platforms { "x32", "x64" }
|
||||
prj = project "MyProject"
|
||||
objdir "obj/%{cfg.buildcfg}_%{cfg.platform}"
|
||||
|
||||
test.isequal("obj/Debug_x32", result("Debug", "x32"))
|
||||
end
|
||||
|
||||
|
||||
function suite.allowOverlap_onPrefixCode()
|
||||
sln = solution "MySolution"
|
||||
configurations { "Debug", "Release" }
|
||||
platforms { "x32", "x64" }
|
||||
prj = project "MyProject"
|
||||
objdir "!obj/%{cfg.buildcfg}"
|
||||
|
||||
test.isequal("obj/Debug", result("Debug", "x32"))
|
||||
end
|
@ -63,6 +63,7 @@
|
||||
|
||||
-- Baking tests
|
||||
dofile("oven/test_filtering.lua")
|
||||
dofile("oven/test_objdirs.lua")
|
||||
|
||||
-- API tests
|
||||
dofile("api/test_containers.lua")
|
||||
|
@ -219,7 +219,7 @@
|
||||
-- Some helper functions
|
||||
--
|
||||
|
||||
test.createsolution = function()
|
||||
function test.createsolution()
|
||||
local sln = solution "MySolution"
|
||||
configurations { "Debug", "Release" }
|
||||
|
||||
@ -231,7 +231,7 @@
|
||||
end
|
||||
|
||||
|
||||
test.createproject = function(sln)
|
||||
function test.createproject(sln)
|
||||
local n = #sln.projects + 1
|
||||
if n == 1 then n = "" end
|
||||
|
||||
@ -242,13 +242,13 @@
|
||||
end
|
||||
|
||||
|
||||
test.getproject = function(sln, i)
|
||||
function test.getproject(sln, i)
|
||||
local sln = premake.oven.bakeSolution(sln)
|
||||
return premake.solution.getproject(sln, i or 1)
|
||||
end
|
||||
|
||||
|
||||
test.getconfig = function(prj, buildcfg, platform)
|
||||
function test.getconfig(prj, buildcfg, platform)
|
||||
local sln = premake.oven.bakeSolution(prj.solution)
|
||||
prj = premake.solution.getproject(sln, prj.name)
|
||||
return premake.project.getconfig(prj, buildcfg, platform)
|
||||
|
Loading…
Reference in New Issue
Block a user