From c140b6fc0d0783dfce13532bde4cb87c2d5201d1 Mon Sep 17 00:00:00 2001 From: ruki Date: Mon, 8 Aug 2016 21:56:23 +0800 Subject: fix source file path error for vcproj --- .../sandbox/modules/import/core/tool/compiler.lua | 2 +- xmake/plugins/project/vstudio/impl/vs200x.lua | 7 +- .../project/vstudio/impl/vs200x_solution.lua | 4 +- .../plugins/project/vstudio/impl/vs200x_vcproj.lua | 99 ++++++++++++++++++++-- 4 files changed, 99 insertions(+), 13 deletions(-) diff --git a/xmake/core/sandbox/modules/import/core/tool/compiler.lua b/xmake/core/sandbox/modules/import/core/tool/compiler.lua index 77eb51ad1..e99abcc04 100644 --- a/xmake/core/sandbox/modules/import/core/tool/compiler.lua +++ b/xmake/core/sandbox/modules/import/core/tool/compiler.lua @@ -42,7 +42,7 @@ function sandbox_core_tool_compiler.compcmd(sourcefile, objectfile, target) end -- make compiling flags for the given target -function sandbox_core_tool_compiler.compflags(sourcefile) +function sandbox_core_tool_compiler.compflags(sourcefile, target) -- get the compiler instance local instance, errors = compiler.load(compiler.kind_of_file(sourcefile)) diff --git a/xmake/plugins/project/vstudio/impl/vs200x.lua b/xmake/plugins/project/vstudio/impl/vs200x.lua index e9f5d9eb8..51292fe03 100755 --- a/xmake/plugins/project/vstudio/impl/vs200x.lua +++ b/xmake/plugins/project/vstudio/impl/vs200x.lua @@ -31,12 +31,15 @@ function make(outputdir, vsinfo) -- enter project directory local olddir = os.cd(project.directory()) + -- init solution directory + vsinfo.solution_dir = path.join(outputdir, "vs" .. vsinfo.vstudio_version) + -- make solution - vs200x_solution.make(outputdir, vsinfo) + vs200x_solution.make(vsinfo) -- make vsprojs for _, target in pairs(project.targets()) do - vs200x_vcproj.make(outputdir, vsinfo, target) + vs200x_vcproj.make(vsinfo, target) end -- leave project directory diff --git a/xmake/plugins/project/vstudio/impl/vs200x_solution.lua b/xmake/plugins/project/vstudio/impl/vs200x_solution.lua index 90f0434da..ebfb45dc4 100755 --- a/xmake/plugins/project/vstudio/impl/vs200x_solution.lua +++ b/xmake/plugins/project/vstudio/impl/vs200x_solution.lua @@ -84,13 +84,13 @@ function _make_global(slnfile, vsinfo) end -- make solution -function make(outputdir, vsinfo) +function make(vsinfo) -- init solution name vsinfo.solution_name = project.name() or "vs" .. vsinfo.vstudio_version -- open solution file - local slnfile = vsfile.open(format("%s/vs%s/%s.sln", outputdir, vsinfo.vstudio_version, vsinfo.solution_name), "w") + local slnfile = vsfile.open(path.join(vsinfo.solution_dir, vsinfo.solution_name .. ".sln"), "w") -- make header _make_header(slnfile, vsinfo) diff --git a/xmake/plugins/project/vstudio/impl/vs200x_vcproj.lua b/xmake/plugins/project/vstudio/impl/vs200x_vcproj.lua index dca5ee419..623b914b4 100755 --- a/xmake/plugins/project/vstudio/impl/vs200x_vcproj.lua +++ b/xmake/plugins/project/vstudio/impl/vs200x_vcproj.lua @@ -136,7 +136,7 @@ function _make_VCLinkerTool(vcprojfile, vsinfo, target) -- make it vcprojfile:enter("") vcprojfile:leave("") end +-- make file +-- +-- .e.g +-- +-- +-- +-- +-- +function _make_file(vcprojfile, vsinfo, target, sourcefile, vcprojdir) + + -- enter file + vcprojfile:enter("") + + -- add file configuration + vcprojfile:enter("") + + -- add compiling options + vcprojfile:enter("") + vcprojfile:leave("") + + -- leave file + vcprojfile:leave("") +end + -- make files -function _make_files(vcprojfile, vsinfo, target) - +-- +-- .e.g +-- +-- +-- +-- +-- +-- +-- +-- +-- +-- +-- +-- +-- +function _make_files(vcprojfile, vsinfo, target, vcprojdir) + + -- enter files vcprojfile:enter("") + vcprojfile:enter("") + + -- add files + for _, sourcefile in ipairs(target:sourcefiles()) do + _make_file(vcprojfile, vsinfo, target, sourcefile, vcprojdir) + end + + -- leave files + vcprojfile:leave("") vcprojfile:leave("") end -- make globals function _make_globals(vcprojfile, vsinfo, target) - vcprojfile:enter("") vcprojfile:leave("") end -- make vcproj -function make(outputdir, vsinfo, target) +function make(vsinfo, target) -- the target name local targetname = target:name() + -- the vcproj directory + local vcprojdir = path.join(vsinfo.solution_dir, targetname) + -- open vcproj file - local vcprojfile = vsfile.open(format("%s/vs%s/%s/%s.vcproj", outputdir, vsinfo.vstudio_version, targetname, targetname), "w") + local vcprojfile = vsfile.open(path.join(vcprojdir, targetname .. ".vcproj"), "w") -- make header _make_header(vcprojfile, vsinfo, target) @@ -304,7 +387,7 @@ function make(outputdir, vsinfo, target) _make_references(vcprojfile, vsinfo, target) -- make files - _make_files(vcprojfile, vsinfo, target) + _make_files(vcprojfile, vsinfo, target, vcprojdir) -- make globals _make_globals(vcprojfile, vsinfo, target) -- cgit v1.3.1