summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2016-08-09 13:12:13 +0800
committerruki <[email protected]>2016-08-09 13:12:13 +0800
commit6e02e2c5281889a5e335ae70b825a61054f279cf (patch)
tree9d11c91dd678dd5e41f08e24ad4bcf10ef23a3b1
parentc140b6fc0d0783dfce13532bde4cb87c2d5201d1 (diff)
fix flags bug for vcproj
-rw-r--r--xmake/core/sandbox/modules/import/core/tool/compiler.lua5
-rw-r--r--xmake/core/tool/compiler.lua19
-rw-r--r--xmake/core/tool/linker.lua17
-rwxr-xr-xxmake/plugins/project/main.lua25
-rwxr-xr-xxmake/plugins/project/vstudio/impl/vs200x_vcproj.lua73
-rwxr-xr-xxmake/tools/cl.lua5
6 files changed, 99 insertions, 45 deletions
diff --git a/xmake/core/sandbox/modules/import/core/tool/compiler.lua b/xmake/core/sandbox/modules/import/core/tool/compiler.lua
index e99abcc04..46803b444 100644
--- a/xmake/core/sandbox/modules/import/core/tool/compiler.lua
+++ b/xmake/core/sandbox/modules/import/core/tool/compiler.lua
@@ -70,5 +70,10 @@ function sandbox_core_tool_compiler.compile(sourcefile, objectfile, incdepfile,
end
end
+-- get kind of the compiling source file
+function sandbox_core_tool_compiler.kind_of_file(sourcefile)
+ return compiler.kind_of_file(sourcefile)
+end
+
-- return module
return sandbox_core_tool_compiler
diff --git a/xmake/core/tool/compiler.lua b/xmake/core/tool/compiler.lua
index d14b4dcbd..81c6c5da8 100644
--- a/xmake/core/tool/compiler.lua
+++ b/xmake/core/tool/compiler.lua
@@ -322,14 +322,14 @@ end
function compiler:compile(sourcefile, objectfile, incdepfile, target)
-- compile it
- return sandbox.load(self:_tool().compile, sourcefile, objectfile, incdepfile, self:compflags(target))
+ return sandbox.load(self:_tool().compile, sourcefile, objectfile, incdepfile, (self:compflags(target)))
end
-- get the compile command
function compiler:compcmd(sourcefile, objectfile, target)
-- get it
- return self:_tool().compcmd(sourcefile, objectfile, self:compflags(target))
+ return self:_tool().compcmd(sourcefile, objectfile, (self:compflags(target)))
end
-- get the compling flags
@@ -337,7 +337,7 @@ function compiler:compflags(target)
-- no target?
if not target then
- return ""
+ return "", {}
end
-- get the target key
@@ -345,8 +345,9 @@ function compiler:compflags(target)
-- get it directly from cache dirst
self._FLAGS = self._FLAGS or {}
- if self._FLAGS[key] then
- return self._FLAGS[key]
+ local flags_cached = self._FLAGS[key]
+ if flags_cached then
+ return flags_cached[1], flags_cached[2]
end
-- add flags from the configure
@@ -365,14 +366,14 @@ function compiler:compflags(target)
-- remove repeat
flags = table.unique(flags)
- -- merge flags
- flags = table.concat(flags, " "):trim()
+ -- concat
+ local flags_str = table.concat(flags, " "):trim()
-- save flags
- self._FLAGS[key] = flags
+ self._FLAGS[key] = {flags_str, flags}
-- get it
- return flags
+ return flags_str, flags
end
-- make the symbol flag
diff --git a/xmake/core/tool/linker.lua b/xmake/core/tool/linker.lua
index 9f638034a..c4bbd767a 100644
--- a/xmake/core/tool/linker.lua
+++ b/xmake/core/tool/linker.lua
@@ -289,14 +289,14 @@ end
function linker:link(objectfiles, targetfile, target)
-- link it
- return sandbox.load(self:_tool().link, table.concat(table.wrap(objectfiles), " "), targetfile, self:linkflags(target))
+ return sandbox.load(self:_tool().link, table.concat(table.wrap(objectfiles), " "), targetfile, (self:linkflags(target)))
end
-- get the link command
function linker:linkcmd(objectfiles, targetfile, target)
-- get it
- return self:_tool().linkcmd(table.concat(table.wrap(objectfiles), " "), targetfile, self:linkflags(target))
+ return self:_tool().linkcmd(table.concat(table.wrap(objectfiles), " "), targetfile, (self:linkflags(target)))
end
-- get the link flags
@@ -304,7 +304,7 @@ function linker:linkflags(target)
-- no target?
if not target then
- return ""
+ return "", {}
end
-- get the target key
@@ -312,8 +312,9 @@ function linker:linkflags(target)
-- get it directly from cache dirst
self._FLAGS = self._FLAGS or {}
- if self._FLAGS[key] then
- return self._FLAGS[key]
+ local flags_cached = self._FLAGS[key]
+ if flags_cached then
+ return flags_cached[1], flags_cached[2]
end
-- add flags from the configure
@@ -336,13 +337,13 @@ function linker:linkflags(target)
flags = table.unique(flags)
-- merge flags
- flags = table.concat(flags, " "):trim()
+ local flags_str = table.concat(flags, " "):trim()
-- save flags
- self._FLAGS[key] = flags
+ self._FLAGS[key] = {flags_str, flags}
-- get it
- return flags
+ return flags_str, flags
end
-- make the strip flag
diff --git a/xmake/plugins/project/main.lua b/xmake/plugins/project/main.lua
index 69ac16a8e..62ce0f253 100755
--- a/xmake/plugins/project/main.lua
+++ b/xmake/plugins/project/main.lua
@@ -22,10 +22,8 @@
-- imports
import("core.base.option")
-import("core.project.config")
-import("core.project.global")
-import("core.project.project")
-import("core.platform.platform")
+import("core.project.task")
+import("core.platform.environment")
import("makefile.makefile")
import("vstudio.vs2005")
import("vstudio.vs2008")
@@ -49,23 +47,18 @@ end
-- main
function main()
- -- check xmake.lua
- if not os.isfile(project.file()) then
- raise("xmake.lua not found!")
- end
+ -- config it first
+ task.run("config")
- -- load project configure
- config.load()
-
- -- load platform
- platform.load(config.plat())
-
- -- load project
- project.load()
+ -- enter toolchains environment
+ environment.enter("toolchains")
-- make project
_make(option.get("kind"))
+ -- leave toolchains environment
+ environment.leave("toolchains")
+
-- trace
cprint("${bright}create ok!${ok_hand}")
end
diff --git a/xmake/plugins/project/vstudio/impl/vs200x_vcproj.lua b/xmake/plugins/project/vstudio/impl/vs200x_vcproj.lua
index 623b914b4..78f96d934 100755
--- a/xmake/plugins/project/vstudio/impl/vs200x_vcproj.lua
+++ b/xmake/plugins/project/vstudio/impl/vs200x_vcproj.lua
@@ -22,11 +22,68 @@
-- imports
import("core.tool.linker")
-import("core.tool.archiver")
import("core.tool.compiler")
import("core.project.config")
import("vsfile")
+-- make compiling flags
+function _make_compflags(sourcefile, target, vcprojdir)
+
+ -- make the compiling flags
+ local _, compflags = compiler.compflags(sourcefile, target)
+
+ -- replace -Idir or /Idir
+ local flags = {}
+ for _, flag in ipairs(compflags) do
+ flag = flag:gsub("[%-|/]I(.*)", function (dir)
+ dir = dir:trim()
+ if not path.is_absolute(dir) then
+ dir = path.relative(path.absolute(dir), vcprojdir)
+ end
+ return "/I" .. dir
+ end)
+ table.insert(flags, flag)
+ end
+
+ -- concat flags
+ flags = table.concat(flags, " "):trim()
+
+ -- replace " => &quot;
+ flags = flags:gsub("\"", "&quot;")
+
+ -- ok?
+ return flags
+end
+
+-- make linking flags
+function _make_linkflags(target, vcprojdir)
+
+ -- make the linking flags
+ local _, linkflags = linker.linkflags(target)
+
+ -- replace -libpath:dir or /libpath:dir
+ local flags = {}
+ for _, flag in ipairs(linkflags) do
+ flag = flag:gsub("[%-|/]libpath:(.*)", function (dir)
+ dir = dir:trim()
+ if not path.is_absolute(dir) then
+ dir = path.relative(path.absolute(dir), vcprojdir)
+ end
+ return "/libpath:" .. dir
+ end)
+ table.insert(flags, flag)
+ end
+
+ -- concat flags
+ flags = table.concat(flags, " "):trim()
+
+ -- replace " => &quot;
+ flags = flags:gsub("\"", "&quot;")
+
+ -- ok?
+ return flags
+end
+
-- make header
function _make_header(vcprojfile, vsinfo, target)
@@ -113,7 +170,7 @@ end
-- SubSystem="1"
-- TargetMachine="1"
-- />
-function _make_VCLinkerTool(vcprojfile, vsinfo, target)
+function _make_VCLinkerTool(vcprojfile, vsinfo, target, vcprojdir)
-- need not linker?
local kind = target:get("kind")
@@ -136,7 +193,7 @@ function _make_VCLinkerTool(vcprojfile, vsinfo, target)
-- make it
vcprojfile:enter("<Tool")
vcprojfile:print("Name=\"VCLinkerTool\"")
- vcprojfile:print("AdditionalOptions=\"%s\"", (linker.linkflags(target):gsub("\"", "&quot;")))
+ vcprojfile:print("AdditionalOptions=\"%s\"", _make_linkflags(target, vcprojdir))
vcprojfile:print("AdditionalDependencies=\"\"")
vcprojfile:print("AdditionalLibraryDirectories=\"\"")
vcprojfile:print("LinkIncremental=\"2\"") -- enable: 2, disable: 1
@@ -147,7 +204,7 @@ function _make_VCLinkerTool(vcprojfile, vsinfo, target)
end
-- make configurations
-function _make_configurations(vcprojfile, vsinfo, target)
+function _make_configurations(vcprojfile, vsinfo, target, vcprojdir)
-- init configuration type
local configuration_types =
@@ -163,7 +220,7 @@ function _make_configurations(vcprojfile, vsinfo, target)
-- make configuration for the current mode
vcprojfile:enter("<Configuration")
vcprojfile:print("Name=\"$(mode)|Win32\"")
- vcprojfile:print("OutputDirectory=\"$(buildir)\\%s\"", target:name())
+ vcprojfile:print("OutputDirectory=\"%s\"", path.relative(path.absolute(config.get("buildir")), vcprojdir))
vcprojfile:print("IntermediateDirectory=\"%$(ConfigurationName)\"")
vcprojfile:print("ConfigurationType=\"%d\"", assert(configuration_types[target:get("kind")]))
vcprojfile:print("CharacterSet=\"2\"") -- mbc: 2, wcs: 1
@@ -213,7 +270,7 @@ function _make_configurations(vcprojfile, vsinfo, target)
vcprojfile:leave("/>")
-- make VCLinkerTool
- _make_VCLinkerTool(vcprojfile, vsinfo, target)
+ _make_VCLinkerTool(vcprojfile, vsinfo, target, vcprojdir)
-- make VCALinkTool
vcprojfile:enter("<Tool")
@@ -296,7 +353,7 @@ function _make_file(vcprojfile, vsinfo, target, sourcefile, vcprojdir)
-- add compiling options
vcprojfile:enter("<Tool")
vcprojfile:print("Name=\"VCCLCompilerTool\"")
- vcprojfile:print("AdditionalOptions=\"%s\"", (compiler.compflags(sourcefile, target):gsub("\"", "&quot;")))
+ vcprojfile:print("AdditionalOptions=\"%s\"", _make_compflags(sourcefile, target, vcprojdir))
vcprojfile:leave("/>")
vcprojfile:leave("</FileConfiguration>")
@@ -381,7 +438,7 @@ function make(vsinfo, target)
_make_toolfiles(vcprojfile, vsinfo, target)
-- make configurations
- _make_configurations(vcprojfile, vsinfo, target)
+ _make_configurations(vcprojfile, vsinfo, target, vcprojdir)
-- make references
_make_references(vcprojfile, vsinfo, target)
diff --git a/xmake/tools/cl.lua b/xmake/tools/cl.lua
index b7ce6b9e1..63ac12253 100755
--- a/xmake/tools/cl.lua
+++ b/xmake/tools/cl.lua
@@ -161,11 +161,8 @@ function vectorext(extension)
-- the maps
local maps =
{
- mmx = "-arch:MMX"
- , sse = "-arch:SSE"
+ sse = "-arch:SSE"
, sse2 = "-arch:SSE2"
- , sse3 = "-arch:SSE3"
- , ssse3 = "-arch:SSSE3"
, avx = "-arch:AVX"
, avx2 = "-arch:AVX2"
}