summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2019-07-17 17:47:47 +0800
committerGitHub <[email protected]>2019-07-17 17:47:47 +0800
commit9f84b5d75dc8966f61a25bebf11b2e1ed59ba24d (patch)
treeb32ecc997505dbee0975ba10e093113845f21574
parenta4468e2a9a0685c3c3d53b976130e5acb0852828 (diff)
parenta6396622cdb3af334c1ec044d5a699affa0dccc2 (diff)
Merge pull request #495 from OpportunityLiu/pch
fix #494
-rw-r--r--tests/projects/c++/console/xmake.lua24
-rw-r--r--tests/projects/c++/precompiled_header/xmake.lua3
-rw-r--r--tests/projects/c++/shared_library/xmake.lua24
-rw-r--r--tests/projects/c++/static_library/xmake.lua24
-rw-r--r--tests/projects/cuda/console/xmake.lua2
-rw-r--r--tests/projects/dlang/console/xmake.lua24
-rw-r--r--tests/projects/dlang/shared_library/xmake.lua24
-rw-r--r--tests/projects/dlang/static_library/xmake.lua24
-rw-r--r--tests/projects/go/console/xmake.lua24
-rw-r--r--tests/projects/go/static_library/xmake.lua24
-rw-r--r--tests/projects/objc++/console/xmake.lua24
-rw-r--r--tests/projects/objc/console/xmake.lua24
-rw-r--r--tests/projects/other/merge_object/xmake.lua24
-rw-r--r--tests/projects/other/merge_static_library/xmake.lua24
-rw-r--r--tests/projects/rust/console/xmake.lua24
-rw-r--r--tests/projects/rust/static_library/xmake.lua24
-rw-r--r--tests/projects/swift/console/xmake.lua24
-rw-r--r--xmake/modules/core/tools/cl.lua92
-rw-r--r--xmake/modules/core/tools/nvcc.lua72
19 files changed, 115 insertions, 414 deletions
diff --git a/tests/projects/c++/console/xmake.lua b/tests/projects/c++/console/xmake.lua
index 7f2076db5..f6beb31d8 100644
--- a/tests/projects/c++/console/xmake.lua
+++ b/tests/projects/c++/console/xmake.lua
@@ -1,25 +1,5 @@
--- the debug mode
-if is_mode("debug") then
-
- -- enable the debug symbols
- set_symbols("debug")
-
- -- disable optimization
- set_optimize("none")
-end
-
--- the release mode
-if is_mode("release") then
-
- -- set the symbols visibility: hidden
- set_symbols("hidden")
-
- -- enable fastest optimization
- set_optimize("fastest")
-
- -- strip all symbols
- set_strip("all")
-end
+-- add rules
+add_rules("mode.debug", "mode.release")
-- add target
target("console_c++")
diff --git a/tests/projects/c++/precompiled_header/xmake.lua b/tests/projects/c++/precompiled_header/xmake.lua
index 337f7a7fe..3f4c34507 100644
--- a/tests/projects/c++/precompiled_header/xmake.lua
+++ b/tests/projects/c++/precompiled_header/xmake.lua
@@ -1,3 +1,6 @@
+-- add rules
+add_rules("mode.debug", "mode.release")
+
-- define target
target("main")
diff --git a/tests/projects/c++/shared_library/xmake.lua b/tests/projects/c++/shared_library/xmake.lua
index 6c2d4deea..cd423db3b 100644
--- a/tests/projects/c++/shared_library/xmake.lua
+++ b/tests/projects/c++/shared_library/xmake.lua
@@ -1,25 +1,5 @@
--- the debug mode
-if is_mode("debug") then
-
- -- enable the debug symbols
- set_symbols("debug")
-
- -- disable optimization
- set_optimize("none")
-end
-
--- the release mode
-if is_mode("release") then
-
- -- set the symbols visibility: hidden
- set_symbols("hidden")
-
- -- enable fastest optimization
- set_optimize("fastest")
-
- -- strip all symbols
- set_strip("all")
-end
+-- add rules
+add_rules("mode.debug", "mode.release")
-- add target
target("shared_library_c++")
diff --git a/tests/projects/c++/static_library/xmake.lua b/tests/projects/c++/static_library/xmake.lua
index 2e3950d4a..b084aab18 100644
--- a/tests/projects/c++/static_library/xmake.lua
+++ b/tests/projects/c++/static_library/xmake.lua
@@ -1,25 +1,5 @@
--- the debug mode
-if is_mode("debug") then
-
- -- enable the debug symbols
- set_symbols("debug")
-
- -- disable optimization
- set_optimize("none")
-end
-
--- the release mode
-if is_mode("release") then
-
- -- set the symbols visibility: hidden
- set_symbols("hidden")
-
- -- enable fastest optimization
- set_optimize("fastest")
-
- -- strip all symbols
- set_strip("all")
-end
+-- add rules
+add_rules("mode.debug", "mode.release")
-- add target
target("static_library_c++")
diff --git a/tests/projects/cuda/console/xmake.lua b/tests/projects/cuda/console/xmake.lua
index d7267fb0d..bf69c8c1e 100644
--- a/tests/projects/cuda/console/xmake.lua
+++ b/tests/projects/cuda/console/xmake.lua
@@ -1,3 +1,5 @@
+-- add rules
+add_rules("mode.debug", "mode.release")
-- define target
target("cuda_console")
diff --git a/tests/projects/dlang/console/xmake.lua b/tests/projects/dlang/console/xmake.lua
index 2f040a763..474c15ec2 100644
--- a/tests/projects/dlang/console/xmake.lua
+++ b/tests/projects/dlang/console/xmake.lua
@@ -1,25 +1,5 @@
--- the debug mode
-if is_mode("debug") then
-
- -- enable the debug symbols
- set_symbols("debug")
-
- -- disable optimization
- set_optimize("none")
-end
-
--- the release mode
-if is_mode("release") then
-
- -- set the symbols visibility: hidden
- set_symbols("hidden")
-
- -- enable fastest optimization
- set_optimize("fastest")
-
- -- strip all symbols
- set_strip("all")
-end
+-- add rules
+add_rules("mode.debug", "mode.release")
-- add target
target("console_dlang")
diff --git a/tests/projects/dlang/shared_library/xmake.lua b/tests/projects/dlang/shared_library/xmake.lua
index c7fac23ca..ced757e5e 100644
--- a/tests/projects/dlang/shared_library/xmake.lua
+++ b/tests/projects/dlang/shared_library/xmake.lua
@@ -1,25 +1,5 @@
--- the debug mode
-if is_mode("debug") then
-
- -- enable the debug symbols
- set_symbols("debug")
-
- -- disable optimization
- set_optimize("none")
-end
-
--- the release mode
-if is_mode("release") then
-
- -- set the symbols visibility: hidden
- set_symbols("hidden")
-
- -- enable fastest optimization
- set_optimize("fastest")
-
- -- strip all symbols
- set_strip("all")
-end
+-- add rules
+add_rules("mode.debug", "mode.release")
-- add target
target("interfaces")
diff --git a/tests/projects/dlang/static_library/xmake.lua b/tests/projects/dlang/static_library/xmake.lua
index 1fd0d1ee9..238aa1197 100644
--- a/tests/projects/dlang/static_library/xmake.lua
+++ b/tests/projects/dlang/static_library/xmake.lua
@@ -1,25 +1,5 @@
--- the debug mode
-if is_mode("debug") then
-
- -- enable the debug symbols
- set_symbols("debug")
-
- -- disable optimization
- set_optimize("none")
-end
-
--- the release mode
-if is_mode("release") then
-
- -- set the symbols visibility: hidden
- set_symbols("hidden")
-
- -- enable fastest optimization
- set_optimize("fastest")
-
- -- strip all symbols
- set_strip("all")
-end
+-- add rules
+add_rules("mode.debug", "mode.release")
-- add target
target("interfaces")
diff --git a/tests/projects/go/console/xmake.lua b/tests/projects/go/console/xmake.lua
index d69c3d457..cae347a8d 100644
--- a/tests/projects/go/console/xmake.lua
+++ b/tests/projects/go/console/xmake.lua
@@ -1,25 +1,5 @@
--- the debug mode
-if is_mode("debug") then
-
- -- enable the debug symbols
- set_symbols("debug")
-
- -- disable optimization
- set_optimize("none")
-end
-
--- the release mode
-if is_mode("release") then
-
- -- set the symbols visibility: hidden
- set_symbols("hidden")
-
- -- enable fastest optimization
- set_optimize("fastest")
-
- -- strip all symbols
- set_strip("all")
-end
+-- add rules
+add_rules("mode.debug", "mode.release")
-- add target
target("console_go")
diff --git a/tests/projects/go/static_library/xmake.lua b/tests/projects/go/static_library/xmake.lua
index b0c3d20ce..560d67292 100644
--- a/tests/projects/go/static_library/xmake.lua
+++ b/tests/projects/go/static_library/xmake.lua
@@ -1,25 +1,5 @@
--- the debug mode
-if is_mode("debug") then
-
- -- enable the debug symbols
- set_symbols("debug")
-
- -- disable optimization
- set_optimize("none")
-end
-
--- the release mode
-if is_mode("release") then
-
- -- set the symbols visibility: hidden
- set_symbols("hidden")
-
- -- enable fastest optimization
- set_optimize("fastest")
-
- -- strip all symbols
- set_strip("all")
-end
+-- add rules
+add_rules("mode.debug", "mode.release")
-- add target
target("module")
diff --git a/tests/projects/objc++/console/xmake.lua b/tests/projects/objc++/console/xmake.lua
index a9229c7f3..8fba2d568 100644
--- a/tests/projects/objc++/console/xmake.lua
+++ b/tests/projects/objc++/console/xmake.lua
@@ -1,25 +1,5 @@
--- the debug mode
-if is_mode("debug") then
-
- -- enable the debug symbols
- set_symbols("debug")
-
- -- disable optimization
- set_optimize("none")
-end
-
--- the release mode
-if is_mode("release") then
-
- -- set the symbols visibility: hidden
- set_symbols("hidden")
-
- -- enable fastest optimization
- set_optimize("fastest")
-
- -- strip all symbols
- set_strip("all")
-end
+-- add rules
+add_rules("mode.debug", "mode.release")
-- add frameworks
add_frameworks("Foundation", "CoreFoundation")
diff --git a/tests/projects/objc/console/xmake.lua b/tests/projects/objc/console/xmake.lua
index 146262351..440ce0ffb 100644
--- a/tests/projects/objc/console/xmake.lua
+++ b/tests/projects/objc/console/xmake.lua
@@ -1,25 +1,5 @@
--- the debug mode
-if is_mode("debug") then
-
- -- enable the debug symbols
- set_symbols("debug")
-
- -- disable optimization
- set_optimize("none")
-end
-
--- the release mode
-if is_mode("release") then
-
- -- set the symbols visibility: hidden
- set_symbols("hidden")
-
- -- enable fastest optimization
- set_optimize("fastest")
-
- -- strip all symbols
- set_strip("all")
-end
+-- add rules
+add_rules("mode.debug", "mode.release")
-- add frameworks
add_frameworks("Foundation", "CoreFoundation")
diff --git a/tests/projects/other/merge_object/xmake.lua b/tests/projects/other/merge_object/xmake.lua
index b8f971536..39e41be3e 100644
--- a/tests/projects/other/merge_object/xmake.lua
+++ b/tests/projects/other/merge_object/xmake.lua
@@ -1,25 +1,5 @@
--- the debug mode
-if is_mode("debug") then
-
- -- enable the debug symbols
- set_symbols("debug")
-
- -- disable optimization
- set_optimize("none")
-end
-
--- the release mode
-if is_mode("release") then
-
- -- set the symbols visibility: hidden
- set_symbols("hidden")
-
- -- enable fastest optimization
- set_optimize("fastest")
-
- -- strip all symbols
- set_strip("all")
-end
+-- add rules
+add_rules("mode.debug", "mode.release")
-- add target
target("merge_object")
diff --git a/tests/projects/other/merge_static_library/xmake.lua b/tests/projects/other/merge_static_library/xmake.lua
index bd36a983a..729648ca2 100644
--- a/tests/projects/other/merge_static_library/xmake.lua
+++ b/tests/projects/other/merge_static_library/xmake.lua
@@ -1,25 +1,5 @@
--- the debug mode
-if is_mode("debug") then
-
- -- enable the debug symbols
- set_symbols("debug")
-
- -- disable optimization
- set_optimize("none")
-end
-
--- the release mode
-if is_mode("release") then
-
- -- set the symbols visibility: hidden
- set_symbols("hidden")
-
- -- enable fastest optimization
- set_optimize("fastest")
-
- -- strip all symbols
- set_strip("all")
-end
+-- add rules
+add_rules("mode.debug", "mode.release")
-- add target
target("add")
diff --git a/tests/projects/rust/console/xmake.lua b/tests/projects/rust/console/xmake.lua
index 57d18582b..b2c8efd39 100644
--- a/tests/projects/rust/console/xmake.lua
+++ b/tests/projects/rust/console/xmake.lua
@@ -1,25 +1,5 @@
--- the debug mode
-if is_mode("debug") then
-
- -- enable the debug symbols
- set_symbols("debug")
-
- -- disable optimization
- set_optimize("none")
-end
-
--- the release mode
-if is_mode("release") then
-
- -- set the symbols visibility: hidden
- set_symbols("hidden")
-
- -- enable fastest optimization
- set_optimize("fastest")
-
- -- strip all symbols
- set_strip("all")
-end
+-- add rules
+add_rules("mode.debug", "mode.release")
-- add target
target("console_rust")
diff --git a/tests/projects/rust/static_library/xmake.lua b/tests/projects/rust/static_library/xmake.lua
index d665e86e9..b873a4c9e 100644
--- a/tests/projects/rust/static_library/xmake.lua
+++ b/tests/projects/rust/static_library/xmake.lua
@@ -1,25 +1,5 @@
--- the debug mode
-if is_mode("debug") then
-
- -- enable the debug symbols
- set_symbols("debug")
-
- -- disable optimization
- set_optimize("none")
-end
-
--- the release mode
-if is_mode("release") then
-
- -- set the symbols visibility: hidden
- set_symbols("hidden")
-
- -- enable fastest optimization
- set_optimize("fastest")
-
- -- strip all symbols
- set_strip("all")
-end
+-- add rules
+add_rules("mode.debug", "mode.release")
-- add target
target("interfaces")
diff --git a/tests/projects/swift/console/xmake.lua b/tests/projects/swift/console/xmake.lua
index 8a368c0af..e792b81f0 100644
--- a/tests/projects/swift/console/xmake.lua
+++ b/tests/projects/swift/console/xmake.lua
@@ -1,25 +1,5 @@
--- the debug mode
-if is_mode("debug") then
-
- -- enable the debug symbols
- set_symbols("debug")
-
- -- disable optimization
- set_optimize("none")
-end
-
--- the release mode
-if is_mode("release") then
-
- -- set the symbols visibility: hidden
- set_symbols("hidden")
-
- -- enable fastest optimization
- set_optimize("fastest")
-
- -- strip all symbols
- set_strip("all")
-end
+-- add rules
+add_rules("mode.debug", "mode.release")
-- add target
target("console_swift")
diff --git a/xmake/modules/core/tools/cl.lua b/xmake/modules/core/tools/cl.lua
index 7d4fda764..8e3c0bd1b 100644
--- a/xmake/modules/core/tools/cl.lua
+++ b/xmake/modules/core/tools/cl.lua
@@ -11,7 +11,7 @@
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
---
+--
-- Copyright (C) 2015 - 2019, TBOOX Open Source Group.
--
-- @author ruki
@@ -20,13 +20,12 @@
-- imports
import("core.base.option")
-import("core.base.hashset")
import("core.project.project")
import("core.language.language")
-- init it
function init(self)
-
+
-- init cxflags
self:set("cxflags", "-nologo")
@@ -88,21 +87,41 @@ end
-- make the symbol flag
function nf_symbol(self, level, target)
- -- the maps
- local maps =
- {
- debug = "-Zi"
- }
+ -- debug? generate *.pdb file
+ local flags = nil
+ if level == "debug" then
+ local symbolfile = nil
+ if target and target.symbolfile then
+ symbolfile = target:symbolfile()
+ end
+ if symbolfile then
- return maps[level]
+ -- ensure the object directory
+ local symboldir = path.directory(symbolfile)
+ if not os.isdir(symboldir) then
+ os.mkdir(symboldir)
+ end
+
+ -- check and add symbol output file
+ flags = "-Zi -Fd" .. path.join(symboldir, "compile." .. path.filename(symbolfile))
+ if self:has_flags({"-Zi", "-FS", "-Fd" .. os.tmpfile() .. ".pdb"}, "cxflags") then
+ flags = "-FS " .. flags
+ end
+ else
+ flags = "-Zi"
+ end
+ end
+
+ -- none
+ return flags
end
-- make the warning flag
function nf_warning(self, level)
-- the maps
- local maps =
- {
+ local maps =
+ {
none = "-W0"
, less = "-W1"
, more = "-W3"
@@ -112,15 +131,15 @@ function nf_warning(self, level)
}
-- make it
- return maps[level]
+ return maps[level]
end
-- make the optimize flag
function nf_optimize(self, level)
-- the maps
- local maps =
- {
+ local maps =
+ {
none = "-Od"
, faster = "-O2"
, fastest = "-Ox -fp:fast"
@@ -137,7 +156,7 @@ function nf_vectorext(self, extension)
-- the maps
local maps =
- {
+ {
sse = "-arch:SSE"
, sse2 = "-arch:SSE2"
, avx = "-arch:AVX"
@@ -156,7 +175,7 @@ function nf_language(self, stdname)
-- the stdc maps
if _g.cmaps == nil then
- _g.cmaps =
+ _g.cmaps =
{
-- stdc
c99 = "-TP" -- compile as c++ files because msvc only support c89
@@ -168,7 +187,7 @@ function nf_language(self, stdname)
-- the stdc++ maps
if _g.cxxmaps == nil then
- _g.cxxmaps =
+ _g.cxxmaps =
{
cxx11 = "-std:c++11"
, gnuxx11 = "-std:c++11"
@@ -197,7 +216,7 @@ function nf_language(self, stdname)
-- not support it?
if flag and flag:find("std:c++", 1, true) and not self:has_flags(flag, "cxflags") then
- return
+ return
end
-- ok
@@ -319,42 +338,11 @@ function _include_deps(self, outdata)
return results
end
--- add if we need -Fd flags
-function _patch_pdbflags(objectfile, flags)
-
- local compflags = flags
-
- local _pdbflags = _g._pdbflags or hashset.of("-ZI", "-Zi", "/ZI", "/Zi")
- _g._pdbflags = _pdbflags
-
- -- check if we need -Fd flags
- local need_pdb = false
- local has_pdb = false
- for _, flag in ipairs(flags) do
- if _pdbflags:has(flag) then
- need_pdb = true
- end
- if flag:find("-Fd", 1, true) or flag:find("/Fd", 1, true) then
- has_pdb = true
- end
- if need_pdb and has_pdb then
- break
- end
- end
-
- -- add pdb output
- if need_pdb and not has_pdb then
- compflags = table.join(flags, "-Fd" .. objectfile .. ".pdb")
- end
-
- return compflags
-end
-
-- make the complie arguments list for the precompiled header
function _compargv1_pch(self, pcheaderfile, pcoutputfile, flags)
- local pchflags = {}
-- remove "-Yuxxx.h" and "-Fpxxx.pch"
+ local pchflags = {}
for _, flag in ipairs(flags) do
if not flag:find("-Yu", 1, true) and not flag:find("-Fp", 1, true) then
table.insert(pchflags, flag)
@@ -375,8 +363,6 @@ end
-- make the complie arguments list
function _compargv1(self, sourcefile, objectfile, flags)
- flags = _patch_pdbflags(objectfile, flags)
-
-- precompiled header?
local extension = path.extension(sourcefile)
if (extension:startswith(".h") or extension == ".inl") then
@@ -428,7 +414,7 @@ function _compile1(self, sourcefile, objectfile, dependinfo, flags)
local results = ""
for _, line in ipairs(tostring(errors):split("\n", {plain = true})) do
line = line:rtrim()
- if not _include_note(self, line) then
+ if not _include_note(self, line) then
results = results .. line .. "\r\n"
end
end
diff --git a/xmake/modules/core/tools/nvcc.lua b/xmake/modules/core/tools/nvcc.lua
index 856e5c47c..35318f37b 100644
--- a/xmake/modules/core/tools/nvcc.lua
+++ b/xmake/modules/core/tools/nvcc.lua
@@ -11,7 +11,7 @@
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
---
+--
-- Copyright (C) 2015 - 2019, TBOOX Open Source Group.
--
-- @author ruki
@@ -60,21 +60,46 @@ end
-- make the symbol flag
function nf_symbol(self, level, target)
- -- the maps
- local maps =
- {
- debug = "-g -G"
- }
+ -- debug? generate *.pdb file
+ local flags = nil
+ if level == "debug" then
+ flags = "-g -G"
+ if is_plat("windows") then
+ local host_flags = nil
+ local symbolfile = nil
+ if target and target.symbolfile then
+ symbolfile = target:symbolfile()
+ end
+ if symbolfile then
- return maps[level]
+ -- ensure the object directory
+ local symboldir = path.directory(symbolfile)
+ if not os.isdir(symboldir) then
+ os.mkdir(symboldir)
+ end
+
+ -- check and add symbol output file
+ host_flags = "-Zi -Fd" .. path.join(symboldir, "compile." .. path.filename(symbolfile))
+ if self:has_flags({'-Xcompiler "-Zi -FS -Fd' .. os.tmpfile() .. '.pdb"'}, "cuflags") then
+ host_flags = "-FS " .. host_flags
+ end
+ else
+ host_flags = "-Zi"
+ end
+ flags = flags .. ' -Xcompiler "' .. host_flags .. '"'
+ end
+ end
+
+ -- none
+ return flags
end
-- make the warning flag
function nf_warning(self, level)
-- the maps
- local maps =
- {
+ local maps =
+ {
none = "-w"
, everything = "-Wreorder"
, error = "-Werror"
@@ -82,7 +107,7 @@ function nf_warning(self, level)
-- for cl.exe on windows
local cl_maps =
- {
+ {
none = "-W0"
, less = "-W1"
, more = "-W3"
@@ -90,19 +115,19 @@ function nf_warning(self, level)
, everything = "-Wall"
, error = "-WX"
}
-
+
-- for gcc & clang on linux, may be work for other gnu compatible compilers such as icc
--
-- gcc dosen't support `-Weverything`, use `-Wall -Wextra -Weffc++` for it
-- no warning will emit for unsupoorted `-W` flags by clang/gcc
--
local gcc_clang_maps =
- {
+ {
none = "-w"
, less = "-Wall"
, more = "-Wall"
- , all = "-Wall"
- , everything = "-Weverything -Wall -Wextra -Weffc++"
+ , all = "-Wall"
+ , everything = "-Weverything -Wall -Wextra -Weffc++"
, error = "-Werror"
}
@@ -150,7 +175,7 @@ function nf_language(self, stdname)
-- the stdc++ maps
if _g.cxxmaps == nil then
- _g.cxxmaps =
+ _g.cxxmaps =
{
cxx03 = "--std c++03"
, cxx11 = "--std c++11"
@@ -261,21 +286,6 @@ function _compargv1(self, sourcefile, objectfile, flags)
-- make argv
local argv = table.join("-c", flags, "-o", objectfile, sourcefile)
- -- insert -Fd flags
- if is_plat("windows") then
- local need_pdb = false
- for _, flag in ipairs(flags) do
- if flag:find("-g", 1, true) then
- need_pdb = true
- break
- end
- end
- if need_pdb then
- table.insert(argv, "-Xcompiler")
- table.insert(argv, "-Fd" .. objectfile .. ".pdb")
- end
- end
-
-- uses cache?
local program = self:program()
if ccache then
@@ -304,7 +314,7 @@ function _compile1(self, sourcefile, objectfile, dependinfo, flags)
try
{
function ()
- -- support `-M -MF depfile.d`?
+ -- support `-M -MF depfile.d`?
if depfile and _g._HAS_M_MF == nil then
_g._HAS_M_MF = self:has_flags({"-M", "-MF", os.nuldev()}, "cuflags") or false
end