Skip to content

Commit

Permalink
add auto detect vs version
Browse files Browse the repository at this point in the history
  • Loading branch information
OpportunityLiu committed Jul 17, 2019
1 parent 0f9361c commit 8acb6d6
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 2 deletions.
21 changes: 20 additions & 1 deletion xmake/plugins/project/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
-- imports
import("core.base.option")
import("core.base.task")
import("core.project.config")
import("core.platform.environment")
import("make.makefile")
import("cmake.cmakelists")
Expand All @@ -30,6 +31,22 @@ import("vsxmake.vsxmake")
import("clang.compile_flags")
import("clang.compile_commands")

function _vs(outputdir)
local vsver = assert(tonumber(config.get("vs")), "invalid vs version, run `xmake f --vs=2015`")
vprint("using project kind vs%d", vsver)
if vsver < 2010 then
return vs.make(vsver)(outputdir)
else
return vsx.make(vsver)(outputdir)
end
end

function _vsxmake(outputdir)
local vsver = assert(tonumber(config.get("vs")), "invalid vs version, run `xmake f --vs=2015`")
vprint("using project kind vsxmake%d", vsver)
return vsxmake.make(vsver)(outputdir)
end

-- make project
function _make(kind)

Expand All @@ -48,17 +65,19 @@ function _make(kind)
, vs2015 = vsx.make(2015)
, vs2017 = vsx.make(2017)
, vs2019 = vsx.make(2019)
, vs = _vs
, vsxmake2010 = vsxmake.make(2010)
, vsxmake2012 = vsxmake.make(2012)
, vsxmake2013 = vsxmake.make(2013)
, vsxmake2015 = vsxmake.make(2015)
, vsxmake2017 = vsxmake.make(2017)
, vsxmake2019 = vsxmake.make(2019)
, vsxmake = _vsxmake
, compile_flags = compile_flags.make
, compile_commands = compile_commands.make
}
assert(maps[kind], "the project kind(%s) is not supported!", kind)

-- make it
maps[kind](option.get("outputdir"))
end
Expand Down
2 changes: 1 addition & 1 deletion xmake/plugins/project/vstudio/impl/vsinfo.lua
Original file line number Diff line number Diff line change
Expand Up @@ -89,5 +89,5 @@ local vsinfo =

function main(version)
assert(version)
return assert(vsinfo[version]);
return assert(vsinfo[version], "unsupported vs version (%d)", version);
end
5 changes: 5 additions & 0 deletions xmake/plugins/project/vsxmake/vsxmake.lua
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,11 @@ end
-- make
function make(version)

-- check
if version < 2010 then
raise("vsxmake does not support vs version lower than 2010")
end

return function(outputdir)
local info = getinfo(outputdir, vsinfo(version))
local paramsprovidersln = _buildparams(info)
Expand Down

0 comments on commit 8acb6d6

Please sign in to comment.