Skip to content

Commit

Permalink
fix headerunit path for msvc #3730
Browse files Browse the repository at this point in the history
  • Loading branch information
waruqi committed Jul 7, 2023
1 parent fc57698 commit 4749f41
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 7 deletions.
5 changes: 3 additions & 2 deletions xmake/modules/core/tools/gcc.lua
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import("core.language.language")
import("utils.progress")
import("private.cache.build_cache")
import("private.service.distcc_build.client", {alias = "distcc_build_client"})
import("rules.c++.modules.modules_support.common", {rootdir = os.programdir(), alias = "modules_common"})

function init(self)

Expand Down Expand Up @@ -666,8 +667,8 @@ end

-- get modules cache directory
function _modules_cachedir(target)
if target and target.autogendir and target:data("cxx.has_modules") then -- we need ignore option instance
return path.join(target:autogendir(), "rules", "modules", "cache")
if target and target:type() == "target" and target:data("cxx.has_modules") then -- we need ignore option instance
return modules_common.modules_cachedir(target)
end
end

Expand Down
14 changes: 11 additions & 3 deletions xmake/rules/c++/modules/modules_support/common.lua
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ end
-- get modules cache directory
function modules_cachedir(target, opt)
opt = opt or {}
local cachedir = path.join(target:autogendir(), "rules", "modules", "cache")
local cachedir = path.join(config.buildir(), "modules", "cache", config.mode() or "release")
if opt.mkdir and not os.isdir(cachedir) then
os.mkdir(cachedir)
end
Expand Down Expand Up @@ -717,8 +717,16 @@ function install_module_target(target)
end

function get_modulehash(target, modulepath)
local key = path.directory(modulepath) .. target:name()
return hash.uuid(key):split("-", {plain = true})[1]:lower()
local projectdir = project.directory()
if path.is_absolute(modulepath) then
modulepath = path.normalize(path.absolute(modulepath, projectdir))
else
modulepath = path.normalize(modulepath)
end
if modulepath:startswith(projectdir) then
modulepath = path.relative(modulepath, projectdir)
end
return hash.uuid(modulepath):split("-", {plain = true})[1]:lower()
end

function get_metafile(target, modulefile)
Expand Down
5 changes: 3 additions & 2 deletions xmake/rules/c++/modules/modules_support/msvc.lua
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,13 @@ import("common")
-- /reference Foo=build/.gens/Foo/rules/modules/cache/Foo.ifc
-- /headerUnit:angle glm/mat4x4.hpp=Users\arthu\AppData\Local\.xmake\packages\g\glm\0.9.9+8\91454f3ee0be416cb9c7452970a2300f\include\glm\mat4x4.hpp.ifc
--
function _add_module_to_mapper(target, argument, namekey, path, objectfile, bmifile, deps)
function _add_module_to_mapper(target, argument, namekey, modulepath, objectfile, bmifile, deps)
local modulemap = _get_modulemap_from_mapper(target)
if modulemap[namekey] then
return
end
local mapflag = {argument, path .. "=" .. bmifile}
modulepath = path.normalize(modulepath)
local mapflag = {argument, modulepath .. "=" .. bmifile}
modulemap[namekey] = {flag = mapflag, objectfile = objectfile, deps = deps}
common.localcache():set2(_mapper_cachekey(target), "modulemap", modulemap)
end
Expand Down

0 comments on commit 4749f41

Please sign in to comment.