diff options
| author | ruki <[email protected]> | 2021-10-14 22:48:47 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2021-10-14 22:48:47 +0800 |
| commit | 0a3c4a6489810afdacfc1c362d0e223bf6f6bfbf (patch) | |
| tree | b08c46d83a8cf13618356623f29be3f3d14f1c25 /xmake/rules/c++/modules/build_modulefiles.lua | |
| parent | 767f57b2e281a62f87d4e254cd93a41af00b55a8 (diff) | |
support ifc search for msvc
Diffstat (limited to 'xmake/rules/c++/modules/build_modulefiles.lua')
| -rw-r--r-- | xmake/rules/c++/modules/build_modulefiles.lua | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/xmake/rules/c++/modules/build_modulefiles.lua b/xmake/rules/c++/modules/build_modulefiles.lua index c0a5ae381..873a8dfdd 100644 --- a/xmake/rules/c++/modules/build_modulefiles.lua +++ b/xmake/rules/c++/modules/build_modulefiles.lua @@ -116,9 +116,14 @@ function _build_modulefiles_msvc(target, sourcebatch, opt) assert(modulesflag, "compiler(msvc): does not support c++ module!") -- get output flag + local cachedir local outputflag if compinst:has_flags("/ifcOutput") then outputflag = "/ifcOutput" + cachedir = path.join(target:autogendir(), "rules", "modules", "cache") + if not os.isdir(cachedir) then + os.mkdir(cachedir) + end elseif compinst:has_flags("/module:output") then outputflag = "/module:output" end @@ -151,11 +156,14 @@ function _build_modulefiles_msvc(target, sourcebatch, opt) for _, sourcefile in ipairs(sourcebatch.sourcefiles) do local objectfile = target:objectfile(sourcefile) local dependfile = target:dependfile(objectfile) - local modulefile = objectfile .. ".ifc" + local modulefile = (cachedir and path.join(cachedir, path.basename(sourcefile)) or objectfile) .. ".ifc" -- compile module file to *.pcm local singlebatch = {sourcekind = "cxx", sourcefiles = {sourcefile}, objectfiles = {objectfile}, dependfiles = {dependfile}} opt.configs.cxxflags = {modulesflag, interfaceflag, outputflag .. " " .. os.args(modulefile), "/TP"} + if cachedir then + table.insert(opt.configs.cxxflags, "/ifcSearchDir " .. os.args(cachedir)) + end import("private.action.build.object").build(target, singlebatch, opt) table.insert(modulefiles, modulefile) table.insert(sourcebatch.objectfiles, objectfile) @@ -164,7 +172,12 @@ function _build_modulefiles_msvc(target, sourcebatch, opt) -- add module files for _, modulefile in ipairs(modulefiles) do - target:add("cxxflags", modulesflag, referenceflag .. " " .. os.args(modulefile)) + target:add("cxxflags", modulesflag) + if cachedir then + target:add("cxxflags", "/ifcSearchDir " .. os.args(cachedir)) + else + target:add("cxxflags", referenceflag .. " " .. os.args(modulefile)) + end end end |
