diff options
| author | ruki <[email protected]> | 2022-08-04 00:47:15 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2022-08-04 00:47:15 +0800 |
| commit | 739e62f633aa8307d0c1ab6f33b35d08560a58fe (patch) | |
| tree | 727549d6e3cbab52bc8046fc05071915ef314f75 /xmake/rules/c++/modules | |
| parent | 110a916cfc9e9a95bc2c3784725cb47c3fd1c762 (diff) | |
rename some apis
Diffstat (limited to 'xmake/rules/c++/modules')
| -rw-r--r-- | xmake/rules/c++/modules/modules_support/clang.lua | 16 | ||||
| -rw-r--r-- | xmake/rules/c++/modules/modules_support/common.lua | 36 | ||||
| -rw-r--r-- | xmake/rules/c++/modules/modules_support/gcc.lua | 8 | ||||
| -rw-r--r-- | xmake/rules/c++/modules/modules_support/msvc.lua | 14 |
4 files changed, 35 insertions, 39 deletions
diff --git a/xmake/rules/c++/modules/modules_support/clang.lua b/xmake/rules/c++/modules/modules_support/clang.lua index 666eb2135..3cb79ac40 100644 --- a/xmake/rules/c++/modules/modules_support/clang.lua +++ b/xmake/rules/c++/modules/modules_support/clang.lua @@ -29,12 +29,12 @@ import("common") -- load parent target with modules files function load_parent(target, opt) - local cachedir = common.get_cache_dir(target) + local cachedir = common.get_modules_cachedir(target) local prebuiltmodulepathflag = get_prebuiltmodulepathflag(target) for _, dep in ipairs(target:orderdeps()) do - cachedir = common.get_cache_dir(dep) + cachedir = common.get_modules_cachedir(dep) target:add("cxxflags", prebuiltmodulepathflag .. cachedir, {force = true}) end end @@ -42,8 +42,8 @@ end -- check C++20 module support function check_module_support(target) local compinst = compiler.load("cxx", {target = target}) - local cachedir = common.get_cache_dir(target) - local stlcachedir = common.get_stlcache_dir(target) + local cachedir = common.get_modules_cachedir(target) + local stlcachedir = common.get_stlmodules_cachedir(target) -- get module and module cache flags local modulesflag = get_modulesflag(target) @@ -87,7 +87,7 @@ function toolchain_include_directories(target) end function generate_dependencies(target, sourcebatch, opt) - local cachedir = common.get_cache_dir(target) + local cachedir = common.get_modules_cachedir(target) for _, sourcefile in ipairs(sourcebatch.sourcefiles) do local dependfile = target:dependfile(sourcefile) @@ -114,8 +114,8 @@ end -- generate target header units function generate_headerunits(target, batchcmds, sourcebatch, opt) local compinst = target:compiler("cxx") - local cachedir = common.get_cache_dir(target) - local stlcachedir = common.get_stlcache_dir(target) + local cachedir = common.get_modules_cachedir(target) + local stlcachedir = common.get_stlmodules_cachedir(target) assert(has_headerunitsupport(target), "compiler(clang): does not support c++ header units!") @@ -190,7 +190,7 @@ end -- build module files function build_modules(target, batchcmds, objectfiles, modules, opt) local compinst = target:compiler("cxx") - local cachedir = common.get_cache_dir(target) + local cachedir = common.get_modules_cachedir(target) -- get modules flags local modulecachepathflag = get_modulecachepathflag(target) diff --git a/xmake/rules/c++/modules/modules_support/common.lua b/xmake/rules/c++/modules/modules_support/common.lua index b86ad8f1f..8ef1877f0 100644 --- a/xmake/rules/c++/modules/modules_support/common.lua +++ b/xmake/rules/c++/modules/modules_support/common.lua @@ -26,7 +26,8 @@ import("core.tool.compiler") import("core.project.project") import("lib.detect.find_file") -function get_stlcache_dir(target) +-- get stl modules cache directory +function get_stlmodules_cachedir(target) local stlcachedir = path.join(target:autogendir(), "stlmodules", "cache") if target:has_tool("cxx", "clang", "clangxx") then stlcachedir = path.join(config.buildir(), "stlmodules", "cache") @@ -34,24 +35,24 @@ function get_stlcache_dir(target) if not os.isdir(stlcachedir) then os.mkdir(stlcachedir) end - return path.translate(stlcachedir) + return stlcachedir end -function get_cache_dir(target) +-- get modules cache directory +function get_modules_cachedir(target) local cachedir = path.join(target:autogendir(), "rules", "modules", "cache") if not os.isdir(cachedir) then os.mkdir(cachedir) end - return path.translate(cachedir) + return cachedir end +-- patch sourcebatch function patch_sourcebatch(target, sourcebatch, opt) - local cachedir = get_cache_dir(target) - + local cachedir = get_modules_cachedir(target) sourcebatch.sourcekind = "cxx" sourcebatch.objectfiles = sourcebatch.objectfiles or {} sourcebatch.dependfiles = sourcebatch.dependfiles or {} - for _, sourcefile in ipairs(sourcebatch.sourcefiles) do local objectfile = target:objectfile(sourcefile) local dependfile = target:dependfile(objectfile) @@ -60,17 +61,7 @@ function patch_sourcebatch(target, sourcebatch, opt) end end -function get_bmi_ext(target) - if target:has_tool("cxx", "gcc", "gxx") then - return import("gcc").get_bmi_ext() - elseif target:has_tool("cxx", "cl") then - return import("msvc").get_bmi_ext() - elseif target:has_tool("cxx", "clang", "clangxx") then - return import("clang").get_bmi_ext() - end - assert(false) -end - +-- get modules support function modules_support(target) local module_builder if target:has_tool("cxx", "clang", "clangxx") then @@ -86,6 +77,11 @@ function modules_support(target) return module_builder end +-- get bmi extension +function get_bmi_ext(target) + return modules_support(target).get_bmi_ext() +end + function contains_modules(target) local target_with_modules = target:sourcebatches()["c++.build.modules"] and true or false @@ -100,7 +96,7 @@ function contains_modules(target) end function load(target, sourcebatch, opt) - local cachedir = get_cache_dir(target) + local cachedir = get_modules_cachedir(target) local moduleinfos for _, sourcefile in ipairs(sourcebatch.sourcefiles) do @@ -123,7 +119,7 @@ function load(target, sourcebatch, opt) end function parse_dependency_data(target, moduleinfos, opt) - local cachedir = get_cache_dir(target) + local cachedir = get_modules_cachedir(target) local modules for _, moduleinfo in ipairs(moduleinfos) do diff --git a/xmake/rules/c++/modules/modules_support/gcc.lua b/xmake/rules/c++/modules/modules_support/gcc.lua index db29c1bef..1053eb56a 100644 --- a/xmake/rules/c++/modules/modules_support/gcc.lua +++ b/xmake/rules/c++/modules/modules_support/gcc.lua @@ -99,7 +99,7 @@ end -- generate dependency files function generate_dependencies(target, sourcebatch, opt) - local cachedir = common.get_cache_dir(target) + local cachedir = common.get_modules_cachedir(target) local compinst = target:compiler("cxx") local common_args = {"-E", "-x", "c++"} @@ -141,8 +141,8 @@ end function generate_headerunits(target, batchcmds, sourcebatch, opt) local compinst = target:compiler("cxx") - local cachedir = common.get_cache_dir(target) - local stlcachedir = common.get_stlcache_dir(target) + local cachedir = common.get_modules_cachedir(target) + local stlcachedir = common.get_stlmodules_cachedir(target) local mapper_file = get_module_mapper() @@ -209,7 +209,7 @@ end -- build module files function build_modules(target, batchcmds, objectfiles, modules, opt) - local cachedir = common.get_cache_dir(target) + local cachedir = common.get_modules_cachedir(target) local compinst = target:compiler("cxx") diff --git a/xmake/rules/c++/modules/modules_support/msvc.lua b/xmake/rules/c++/modules/modules_support/msvc.lua index ca7ca19e7..6f004ee5f 100644 --- a/xmake/rules/c++/modules/modules_support/msvc.lua +++ b/xmake/rules/c++/modules/modules_support/msvc.lua @@ -31,7 +31,7 @@ function load_parent(target, opt) local ifcsearchdirflag = get_ifcsearchdirflag(target) for _, dep in ipairs(target:orderdeps()) do - cachedir = common.get_cache_dir(dep) + cachedir = common.get_modules_cachedir(dep) target:add("cxxflags", {ifcsearchdirflag, cachedir}, {force = true, expand = false}) end end @@ -39,8 +39,8 @@ end -- check C++20 module support function check_module_support(target) local compinst = target:compiler("cxx") - local cachedir = common.get_cache_dir(target) - local stlcachedir = common.get_stlcache_dir(target) + local cachedir = common.get_modules_cachedir(target) + local stlcachedir = common.get_stlmodules_cachedir(target) -- get flags local modulesflag = get_modulesflag(target) @@ -89,7 +89,7 @@ function generate_dependencies(target, sourcebatch, opt) local scandependenciesflag = get_scandependenciesflag(target) - local cachedir = common.get_cache_dir(target) + local cachedir = common.get_modules_cachedir(target) local common_args = {"/TP", scandependenciesflag} for _, sourcefile in ipairs(sourcebatch.sourcefiles) do @@ -133,8 +133,8 @@ function generate_headerunits(target, batchcmds, sourcebatch, opt) assert(headerunitflag and headernameflag and exportheaderflag, "compiler(msvc): does not support c++ header units!") - local cachedir = common.get_cache_dir(target) - local stlcachedir = common.get_stlcache_dir(target) + local cachedir = common.get_modules_cachedir(target) + local stlcachedir = common.get_stlmodules_cachedir(target) -- build headerunits local common_args = {"/TP", exportheaderflag, "/c"} @@ -197,7 +197,7 @@ end -- build module files function build_modules(target, batchcmds, objectfiles, modules, opt) - local cachedir = common.get_cache_dir(target) + local cachedir = common.get_modules_cachedir(target) local compinst = target:compiler("cxx") local toolchain = target:toolchain("msvc") |
