From 5ff368bb0b3990c1ff6d360cd27cd4d4e24da511 Mon Sep 17 00:00:00 2001 From: 夕伽 Date: Mon, 3 Sep 2018 11:13:34 +0800 Subject: 1 string.lower(xxx) -> xxx:lower() 2 -DUNICODE -> [%-|/]DUNICODE --- .../plugins/project/vstudio/impl/vs200x_vcproj.lua | 88 +++------------------- xmake/plugins/project/vstudio/impl/vs201x.lua | 8 +- .../project/vstudio/impl/vs201x_vcxproj.lua | 25 ++---- 3 files changed, 18 insertions(+), 103 deletions(-) diff --git a/xmake/plugins/project/vstudio/impl/vs200x_vcproj.lua b/xmake/plugins/project/vstudio/impl/vs200x_vcproj.lua index 2b6af017f..393c3d43e 100644 --- a/xmake/plugins/project/vstudio/impl/vs200x_vcproj.lua +++ b/xmake/plugins/project/vstudio/impl/vs200x_vcproj.lua @@ -279,17 +279,11 @@ function _make_configurations(vcprojfile, vsinfo, target, vcprojdir) end end - -- set default mfc, not used: 0, static:1, dynamic:2 - local mfc = ifelse(target:values("mfc"), 2, 0) - -- set unicode and mfc + -- set unicode local unicode = false for _, flag in pairs(compflags) do if flag:find("[%-|/]DUNICODE") then unicode = true - elseif flag:find("[%-|/]MT") then - mfc = ifelse(mfc ~= 0, 1, 0) - elseif flag:find("[%-|/]MD") then - mfc = ifelse(mfc ~= 0, 2, 0) end end @@ -303,7 +297,6 @@ function _make_configurations(vcprojfile, vsinfo, target, vcprojdir) vcprojfile:print("IntermediateDirectory=\"%s\"", path.relative(path.absolute(target:objectdir()), vcprojdir)) vcprojfile:print("ConfigurationType=\"%d\"", assert(configuration_types[target:get("kind")])) vcprojfile:print("CharacterSet=\"%d\"", ifelse(unicode, 1, 2)) -- mbc: 2, wcs: 1 - vcprojfile:print("UseOfMFC=\"%d\"", mfc) vcprojfile:print(">") -- make VCPreBuildEventTool @@ -401,7 +394,7 @@ function _make_references(vcprojfile, vsinfo, target) vcprojfile:leave("") end --- make cxfile +-- make file -- -- .e.g -- -- -- -function _make_cxfile(vcprojfile, vsinfo, target, sourcefile, objectfile, vcprojdir) +function _make_file(vcprojfile, vsinfo, target, sourcefile, objectfile, vcprojdir) -- get the target key local key = tostring(target) @@ -457,48 +450,6 @@ function _make_cxfile(vcprojfile, vsinfo, target, sourcefile, objectfile, vcproj vcprojfile:leave("") end --- make file --- --- .e.g --- --- --- --- --- -function _make_rcfile(vcprojfile, vsinfo, target, sourcefile, objectfile, vcprojdir) - - -- enter file - vcprojfile:enter("") - - -- add file configuration - vcprojfile:enter("") - - -- add compiling options - vcprojfile:enter("") - vcprojfile:leave("") - - -- leave file - vcprojfile:leave("") -end - -- make files -- -- .e.g @@ -534,35 +485,18 @@ function _make_files(vcprojfile, vsinfo, target, vcprojdir) -- enter files vcprojfile:enter("") - local sourcebatches = target:sourcebatches() - -- *.rc files - vcprojfile:enter("") - 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 files - vcprojfile:leave("") + vcprojfile:enter("") - -- *.rc files - vcprojfile:enter("") - 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 + -- add files + local objectfiles = target:objectfiles() + for idx, sourcefile in ipairs(target:sourcefiles()) do + _make_file(vcprojfile, vsinfo, target, sourcefile, objectfiles[idx], vcprojdir) end - -- leave *.rc files + -- leave files vcprojfile:leave("") - vcprojfile:leave("") end diff --git a/xmake/plugins/project/vstudio/impl/vs201x.lua b/xmake/plugins/project/vstudio/impl/vs201x.lua index 8671ea508..65c4d1d2a 100644 --- a/xmake/plugins/project/vstudio/impl/vs201x.lua +++ b/xmake/plugins/project/vstudio/impl/vs201x.lua @@ -93,16 +93,10 @@ function _make_targetinfo(mode, arch, target) local linkflags = linker.linkflags(target:get("kind"), target:sourcekinds(), {target = target}) targetinfo.linkflags = linkflags - -- set default mfc - targetinfo.mfc = ifelse(target:values("mfc"), "Dynamic", nil) - -- set unicode and mfc + -- set unicode for _, flag in pairs(firstcompflags) do if flag:find("[%-|/]DUNICODE") then targetinfo.unicode = true - elseif flag:find("[%-|/]MT") then - targetinfo.mfc = ifelse(targetinfo.mfc, "Static", false) - elseif flag:find("[%-|/]MD") then - targetinfo.mfc = ifelse(targetinfo.mfc, "Dynamic", false) end end diff --git a/xmake/plugins/project/vstudio/impl/vs201x_vcxproj.lua b/xmake/plugins/project/vstudio/impl/vs201x_vcxproj.lua index 575e339ae..547414307 100644 --- a/xmake/plugins/project/vstudio/impl/vs201x_vcxproj.lua +++ b/xmake/plugins/project/vstudio/impl/vs201x_vcxproj.lua @@ -416,7 +416,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" or sourcekind == "mrc") then + if not sourcebatch.rulename and (sourcekind == "cc" or sourcekind == "cxx" or sourcekind == "as") then for _, sourcefile in ipairs(sourcebatch.sourcefiles) do -- make compiler flags @@ -485,9 +485,8 @@ 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\">", nodename, sourcefile) + vcxprojfile:enter("<%s Include=\"%s\">", ifelse(sourcekind == "as", "CustomBuild", "ClCompile"), sourcefile) -- for *.asm files if sourcekind == "as" then @@ -499,13 +498,6 @@ function _make_source_file_forall(vcxprojfile, vsinfo, target, sourcefile, sourc vcxprojfile:print("%s /nologo /c %s -Fo%s %s", 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("%s",info.mode,info.arch,objectfile) - end - -- for *.c/cpp files else @@ -590,7 +582,7 @@ function _make_source_file_forall(vcxprojfile, vsinfo, target, sourcefile, sourc end -- leave it - vcxprojfile:leave("", nodename) + vcxprojfile:leave("", ifelse(sourcekind == "as", "CustomBuild", "ClCompile")) end -- make source file for specific modes @@ -601,8 +593,7 @@ function _make_source_file_forspec(vcxprojfile, vsinfo, target, sourcefile, sour for _, info in ipairs(sourceinfo) do -- enter it - 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) + vcxprojfile:enter("<%s Condition=\"\'%$(Configuration)|%$(Platform)\'==\'%s|%s\'\" Include=\"%s\">", ifelse(info.sourcekind == "as", "CustomBuild", "ClCompile"), info.mode, info.arch, sourcefile) -- for *.asm files local objectfile = path.relative(path.absolute(info.objectfile), vcxprojdir) @@ -612,10 +603,6 @@ function _make_source_file_forspec(vcxprojfile, vsinfo, target, sourcefile, sour vcxprojfile:print("%s", objectfile) vcxprojfile:print("%s /nologo /c %s -Fo%s %s", ifelse(info.arch == "x64", "ml64", "ml"), os.args(info.flags), objectfile, sourcefile) - -- for *.rc files - elseif sourcekind == "mrc" then - vcxprojfile:print("%s",info.mode,info.arch,objectfile) - -- for *.c/cpp files else @@ -629,7 +616,7 @@ function _make_source_file_forspec(vcxprojfile, vsinfo, target, sourcefile, sour end -- leave it - vcxprojfile:leave("", nodename) + vcxprojfile:leave("", ifelse(info.sourcekind == "as", "CustomBuild", "ClCompile")) end end @@ -671,7 +658,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" or sourcekind == "mrc") then + if not sourcebatch.rulename and (sourcekind == "cc" or sourcekind == "cxx" or sourcekind == "as") then local objectfiles = sourcebatch.objectfiles for idx, sourcefile in ipairs(sourcebatch.sourcefiles) do local objectfile = objectfiles[idx] -- cgit v1.3.1