summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2018-09-04 11:23:38 +0800
committerGitHub <[email protected]>2018-09-04 11:23:38 +0800
commit9f330ff3c528cdda8718a0c086f1681322b13e80 (patch)
tree2293038b5c97a3dbe14b1301b57849293f3c1ee3
parent08e1b8a09835cba95ba25f40a5a9b4a2a2a55263 (diff)
parent05b6182def036b36c8e4aeac8cdc55441fc4a4db (diff)
Merge pull request #215 from xigalto/dev
add *.rc files to vsproject
-rw-r--r--xmake/plugins/project/vstudio/impl/vs200x_vcproj.lua78
-rw-r--r--xmake/plugins/project/vstudio/impl/vs201x_vcxproj.lua25
2 files changed, 87 insertions, 16 deletions
diff --git a/xmake/plugins/project/vstudio/impl/vs200x_vcproj.lua b/xmake/plugins/project/vstudio/impl/vs200x_vcproj.lua
index 393c3d43e..2e29b8281 100644
--- a/xmake/plugins/project/vstudio/impl/vs200x_vcproj.lua
+++ b/xmake/plugins/project/vstudio/impl/vs200x_vcproj.lua
@@ -394,7 +394,7 @@ function _make_references(vcprojfile, vsinfo, target)
vcprojfile:leave("</References>")
end
--- make file
+-- make cxfile
--
-- .e.g
-- <File
@@ -409,7 +409,7 @@ end
-- />
-- </FileConfiguration>
-- </File>
-function _make_file(vcprojfile, vsinfo, target, sourcefile, objectfile, vcprojdir)
+function _make_cxfile(vcprojfile, vsinfo, target, sourcefile, objectfile, vcprojdir)
-- get the target key
local key = tostring(target)
@@ -450,6 +450,47 @@ function _make_file(vcprojfile, vsinfo, target, sourcefile, objectfile, vcprojdi
vcprojfile:leave("</File>")
end
+-- make rcfile
+--
+-- .e.g
+-- <File
+-- RelativePath="..\..\..\src\resource.rc"
+-- >
+-- <FileConfiguration
+-- Name="Debug|Win32"
+-- >
+-- <Tool
+-- Name="VCResourceCompilerTool"
+-- ResourceOutputFileName="..\..\..\build\src\resource.res"
+-- />
+-- </FileConfiguration>
+-- </File>
+function _make_rcfile(vcprojfile, vsinfo, target, sourcefile, objectfile, vcprojdir)
+
+ -- enter file
+ vcprojfile:enter("<File")
+
+ -- add file path
+ vcprojfile:print("RelativePath=\"%s\"", path.relative(path.absolute(sourcefile), vcprojdir))
+ vcprojfile:print(">")
+
+ -- add file configuration
+ vcprojfile:enter("<FileConfiguration")
+ vcprojfile:print("Name=\"$(mode)|Win32\"")
+ vcprojfile:print(">")
+
+ -- add compiling options
+ vcprojfile:enter("<Tool")
+ vcprojfile:print("Name=\"VCResourceCompilerTool\"")
+ -- FIXME: multi rc files support
+ -- vcprojfile:print("ResourceOutputFileName=\"%s\"", path.relative(path.absolute(objectfile), vcprojdir))
+ vcprojfile:leave("/>")
+ vcprojfile:leave("</FileConfiguration>")
+
+ -- leave file
+ vcprojfile:leave("</File>")
+end
+
-- make files
--
-- .e.g
@@ -485,18 +526,35 @@ function _make_files(vcprojfile, vsinfo, target, vcprojdir)
-- enter files
vcprojfile:enter("<Files>")
- vcprojfile:enter("<Filter")
- vcprojfile:print("Name=\"Source Files\"")
- vcprojfile:print(">")
+ local sourcebatches = target:sourcebatches()
+ -- c/cxx files
+ vcprojfile:enter("<Filter Name=\"Source Files\">")
+ for sourcekind, sourcebatch in pairs(sourcebatches) do
+ if sourcekind ~= "mrc" then
+ local objectfiles = sourcebatch.objectfiles
+ for idx, sourcefile in ipairs(sourcebatch.sourcefiles) do
+ _make_cxfile(vcprojfile, vsinfo, target, sourcefile, objectfiles[idx], vcprojdir)
+ end
+ end
+ end
+
+ -- leave c/cxx files
+ vcprojfile:leave("</Filter>")
- -- add files
- local objectfiles = target:objectfiles()
- for idx, sourcefile in ipairs(target:sourcefiles()) do
- _make_file(vcprojfile, vsinfo, target, sourcefile, objectfiles[idx], vcprojdir)
+ -- *.rc files
+ vcprojfile:enter("<Filter Name=\"Resource Files\">")
+ for sourcekind, sourcebatch in pairs(sourcebatches) do
+ if sourcekind == "mrc" then
+ local objectfiles = sourcebatch.objectfiles
+ for idx, sourcefile in ipairs(sourcebatch.sourcefiles) do
+ _make_rcfile(vcprojfile, vsinfo, target, sourcefile, objectfiles[idx], vcprojdir)
+ end
+ end
end
- -- leave files
+ -- leave *.rc files
vcprojfile:leave("</Filter>")
+
vcprojfile:leave("</Files>")
end
diff --git a/xmake/plugins/project/vstudio/impl/vs201x_vcxproj.lua b/xmake/plugins/project/vstudio/impl/vs201x_vcxproj.lua
index a7f151abd..146e74a67 100644
--- a/xmake/plugins/project/vstudio/impl/vs201x_vcxproj.lua
+++ b/xmake/plugins/project/vstudio/impl/vs201x_vcxproj.lua
@@ -413,7 +413,7 @@ function _make_common_items(vcxprojfile, vsinfo, target, vcxprojdir)
local first_flags = nil
targetinfo.sourceflags = {}
for sourcekind, sourcebatch in pairs(targetinfo.sourcebatches) do
- if not sourcebatch.rulename and (sourcekind == "cc" or sourcekind == "cxx" or sourcekind == "as") then
+ if not sourcebatch.rulename and (sourcekind == "cc" or sourcekind == "cxx" or sourcekind == "as" or sourcekind == "mrc") then
for _, sourcefile in ipairs(sourcebatch.sourcefiles) do
-- make compiler flags
@@ -482,8 +482,9 @@ function _make_source_file_forall(vcxprojfile, vsinfo, target, sourcefile, sourc
end
-- enter it
+ local nodename = ifelse(sourcekind == "as", "CustomBuild", ifelse(sourcekind == "mrc", "ResourceCompile", "ClCompile"))
sourcefile = path.relative(path.absolute(sourcefile), vcxprojdir)
- vcxprojfile:enter("<%s Include=\"%s\">", ifelse(sourcekind == "as", "CustomBuild", "ClCompile"), sourcefile)
+ vcxprojfile:enter("<%s Include=\"%s\">", nodename, sourcefile)
-- for *.asm files
if sourcekind == "as" then
@@ -495,6 +496,13 @@ function _make_source_file_forall(vcxprojfile, vsinfo, target, sourcefile, sourc
vcxprojfile:print("<Command Condition=\"\'%$(Configuration)|%$(Platform)\'==\'%s\'\">%s /nologo /c %s -Fo%s %s</Command>", info.mode .. '|' .. info.arch, ifelse(info.arch == "x64", "ml64", "ml"), os.args(info.flags), objectfile, sourcefile)
end
+ -- for *.rc files
+ elseif sourcekind == "mrc" then
+ for _, info in ipairs(sourceinfo) do
+ local objectfile = path.relative(path.absolute(info.objectfile), vcxprojdir)
+ vcxprojfile:print("<ResourceOutputFileName Condition=\"\'%$(Configuration)|%$(Platform)\'==\'%s|%s\'\">%s</ResourceOutputFileName>",info.mode,info.arch,objectfile)
+ end
+
-- for *.c/cpp files
else
@@ -579,7 +587,7 @@ function _make_source_file_forall(vcxprojfile, vsinfo, target, sourcefile, sourc
end
-- leave it
- vcxprojfile:leave("</%s>", ifelse(sourcekind == "as", "CustomBuild", "ClCompile"))
+ vcxprojfile:leave("</%s>", nodename)
end
-- make source file for specific modes
@@ -590,7 +598,8 @@ function _make_source_file_forspec(vcxprojfile, vsinfo, target, sourcefile, sour
for _, info in ipairs(sourceinfo) do
-- enter it
- vcxprojfile:enter("<%s Condition=\"\'%$(Configuration)|%$(Platform)\'==\'%s|%s\'\" Include=\"%s\">", ifelse(info.sourcekind == "as", "CustomBuild", "ClCompile"), info.mode, info.arch, sourcefile)
+ local nodename = ifelse(info.sourcekind == "as", "CustomBuild", ifelse(info.sourcekind == "mrc", "ResourceCompile", "ClCompile"))
+ vcxprojfile:enter("<%s Condition=\"\'%$(Configuration)|%$(Platform)\'==\'%s|%s\'\" Include=\"%s\">", nodename, info.mode, info.arch, sourcefile)
-- for *.asm files
local objectfile = path.relative(path.absolute(info.objectfile), vcxprojdir)
@@ -600,6 +609,10 @@ function _make_source_file_forspec(vcxprojfile, vsinfo, target, sourcefile, sour
vcxprojfile:print("<Outputs>%s</Outputs>", objectfile)
vcxprojfile:print("<Command>%s /nologo /c %s -Fo%s %s</Command>", ifelse(info.arch == "x64", "ml64", "ml"), os.args(info.flags), objectfile, sourcefile)
+ -- for *.rc files
+ elseif sourcekind == "mrc" then
+ vcxprojfile:print("<ResourceOutputFileName Condition=\"\'%$(Configuration)|%$(Platform)\'==\'%s|%s\'\">%s</ResourceOutputFileName>",info.mode,info.arch,objectfile)
+
-- for *.c/cpp files
else
@@ -613,7 +626,7 @@ function _make_source_file_forspec(vcxprojfile, vsinfo, target, sourcefile, sour
end
-- leave it
- vcxprojfile:leave("</%s>", ifelse(info.sourcekind == "as", "CustomBuild", "ClCompile"))
+ vcxprojfile:leave("</%s>", nodename)
end
end
@@ -655,7 +668,7 @@ function _make_source_files(vcxprojfile, vsinfo, target, vcxprojdir)
local sourceinfos = {}
for _, targetinfo in ipairs(target.info) do
for sourcekind, sourcebatch in pairs(targetinfo.sourcebatches) do
- if not sourcebatch.rulename and (sourcekind == "cc" or sourcekind == "cxx" or sourcekind == "as") then
+ if not sourcebatch.rulename and (sourcekind == "cc" or sourcekind == "cxx" or sourcekind == "as" or sourcekind == "mrc") then
local objectfiles = sourcebatch.objectfiles
for idx, sourcefile in ipairs(sourcebatch.sourcefiles) do
local objectfile = objectfiles[idx]