diff --git a/src/base/api.lua b/src/base/api.lua index a32a75b8..080e1906 100644 --- a/src/base/api.lua +++ b/src/base/api.lua @@ -372,6 +372,20 @@ end +-- +-- Set a new value into a mixed value field, which contain both +-- simple strings and paths. +-- + + function api.setmixed(target, name, field, value) + -- if the value contains a '/' treat it as a path + if type(value) == "string" and value:find('/', nil, true) then + value = path.getabsolute(value) + end + return api.setstring(target, name, field, value) + end + + -- -- Set a new object value on an API field. -- @@ -712,14 +726,7 @@ api.register { name = "links", scope = "config", - kind = "string-list", - allowed = function(value) - -- if library name contains a '/' then treat it as a path to a local file - if value:find('/', nil, true) then - value = path.getabsolute(value) - end - return value - end, + kind = "mixed-list", tokens = true, } diff --git a/src/base/context.lua b/src/base/context.lua index a01764eb..d624289d 100644 --- a/src/base/context.lua +++ b/src/base/context.lua @@ -39,11 +39,11 @@ ctx.environ = environ or {} ctx._filename = { filename } or {} ctx.terms = {} - + -- when a missing field is requested, fetch it from my config -- set, and then cache the value for future lookups setmetatable(ctx, context.__mt) - + return ctx end @@ -96,7 +96,7 @@ -- --- Check to see if a context's underlying configuration set is empty; that +-- Check to see if a context's underlying configuration set is empty; that -- is, it does not contain any configuration blocks. -- -- @param ctx @@ -129,17 +129,18 @@ -- do I need to expand tokens? local field = premake.fields[key] if field and field.tokens then - local ispath = field.kind:startswith("path") + local kind = field.kind + local ispath = kind:startswith("path") or kind:startswith("mixed") value = premake.detoken.expand(value, ctx.environ, ispath) end - + -- store the result for later lookups ctx[key] = value end return value end - + context.__mt = { __index = context.fetchvalue } diff --git a/tests/actions/vstudio/cs2005/test_assembly_refs.lua b/tests/actions/vstudio/cs2005/test_assembly_refs.lua index 2e00a029..67327fe1 100644 --- a/tests/actions/vstudio/cs2005/test_assembly_refs.lua +++ b/tests/actions/vstudio/cs2005/test_assembly_refs.lua @@ -14,7 +14,7 @@ -- local sln, prj - + function suite.setup() _ACTION = "vs2008" sln = test.createsolution() @@ -69,4 +69,22 @@ ]] - end \ No newline at end of file + end + + +-- +-- Assemblies referenced via a token that expands to an absolute +-- path should still end up with a relative hint path. +-- + + function suite.assemblyRef_onAbsoluteToken() + links { "%{path.getdirectory(os.getcwd())}/Libraries/nunit.framework" } + prepare() + test.capture [[ + + + ..\Libraries\nunit.framework.dll + + + ]] + end