diff options
| author | Arthur LAURENT <[email protected]> | 2023-01-07 19:18:18 +0100 |
|---|---|---|
| committer | Arthur LAURENT <[email protected]> | 2023-01-07 19:50:23 +0100 |
| commit | d20bf041ae327176e2105ceca24b0089798477a1 (patch) | |
| tree | ebc703f594d888c4b6a7e457ca5cb841a5e51323 | |
| parent | 3755a6f67399b8e42df9f39ec7c506918dbb433a (diff) | |
fix on macos
fix on macos
| -rw-r--r-- | tests/projects/c++/modules/test_base.lua | 12 | ||||
| -rw-r--r-- | tests/projects/c++/modules/test_stdmodules.lua | 14 | ||||
| -rw-r--r-- | xmake/rules/c++/modules/modules_support/clang.lua | 24 |
3 files changed, 25 insertions, 25 deletions
diff --git a/tests/projects/c++/modules/test_base.lua b/tests/projects/c++/modules/test_base.lua index 6ac816d66..efef15520 100644 --- a/tests/projects/c++/modules/test_base.lua +++ b/tests/projects/c++/modules/test_base.lua @@ -14,19 +14,17 @@ function main(t) if is_subhost("windows") then os.exec("xmake f -c") _build() - elseif is_host("linux") or is_host("macos") then + elseif is_host("linux") then local gcc = find_tool("gcc", {version = true}) - if gcc and gcc.version and semver.compare(gcc.version, "11.0") >= 0 then + if is_host("linux") and gcc and gcc.version and semver.compare(gcc.version, "11.0") >= 0 then os.exec("xmake f -c") _build() end local clang = find_tool("clang", {version = true}) if clang and clang.version and semver.compare(clang.version, "14.0") >= 0 then - if is_host("linux") then - os.exec("xmake clean -a") - os.exec("xmake f --toolchain=clang -c") - _build() - end + os.exec("xmake clean -a") + os.exec("xmake f --toolchain=clang -c") + _build() os.exec("xmake clean -a") os.exec("xmake f --toolchain=clang --cxxflags=\"-stdlib=libc++\" -c") _build() diff --git a/tests/projects/c++/modules/test_stdmodules.lua b/tests/projects/c++/modules/test_stdmodules.lua index 2d8861d09..621f0b1d4 100644 --- a/tests/projects/c++/modules/test_stdmodules.lua +++ b/tests/projects/c++/modules/test_stdmodules.lua @@ -24,21 +24,19 @@ function main(t) end end end - elseif is_host("linux") or is_host("macos") then + elseif is_host("linux") then -- or is_host("macos") then -- gcc don't support std modules atm -- local gcc = find_tool("gcc", {version = true}) - -- if gcc and gcc.version and semver.compare(gcc.version, "11.0") >= 0 then + -- if is_host("linux") and gcc and gcc.version and semver.compare(gcc.version, "11.0") >= 0 then -- os.exec("xmake f -c") -- _build() -- end local clang = find_tool("clang", {version = true}) if clang and clang.version and semver.compare(clang.version, "14.0") >= 0 then - if is_host("linux") then - -- clang don't support libstdc++ std modules atm - -- os.exec("xmake clean -a") - -- os.exec("xmake f --toolchain=clang -c") - -- _build() - end + -- clang don't support libstdc++ std modules atm + -- os.exec("xmake clean -a") + -- os.exec("xmake f --toolchain=clang -c") + -- _build() os.exec("xmake clean -a") os.exec("xmake f --toolchain=clang --cxxflags=\"-stdlib=libc++\" -c") _build() diff --git a/xmake/rules/c++/modules/modules_support/clang.lua b/xmake/rules/c++/modules/modules_support/clang.lua index 7a63c027d..129221e5d 100644 --- a/xmake/rules/c++/modules/modules_support/clang.lua +++ b/xmake/rules/c++/modules/modules_support/clang.lua @@ -66,13 +66,16 @@ end -- load module support for the current target function load(target) - local modulesflag = get_modulesflag(target) + local modulesflag, modulestsflag = get_modulesflag(target) local builtinmodulemapflag = get_builtinmodulemapflag(target) local implicitmodulesflag = get_implicitmodulesflag(target) local noimplicitmodulemapsflag = get_noimplicitmodulemapsflag(target) -- add module flags target:add("cxxflags", modulesflag) + if not modulesflag or is_host("macos") then + target:add("cxxflags", modulestsflag) + end if not target:values("c++.clang.modules.strict") then target:add("cxxflags", builtinmodulemapflag, {force = true}) @@ -583,20 +586,20 @@ end function get_modulesflag(target) local modulesflag = _g.modulesflag - if modulesflag == nil then + local modulestsflag = _g.modulestsflag + if modulesflag == nil and modulestsflag == nil then local compinst = target:compiler("cxx") if compinst:has_flags("-fmodules", "cxxflags", {flagskey = "clang_modules"}) then modulesflag = "-fmodules" end - if not modulesflag then - if compinst:has_flags("-fmodules-ts", "cxxflags", {flagskey = "clang_modules_ts"}) then - modulesflag = "-fmodules-ts" - end + if compinst:has_flags("-fmodules-ts", "cxxflags", {flagskey = "clang_modules_ts"}) then + modulestsflag = "-fmodules-ts" end - assert(modulesflag, "compiler(clang): does not support c++ module!") + assert(modulesflag or modulestsflag, "compiler(clang): does not support c++ module!") _g.modulesflag = modulesflag or false + _g.modulestsflag = modulestsflag or false end - return modulesflag or nil + return modulesflag or nil, modulestsflag or nil end function get_builtinmodulemapflag(target) @@ -698,8 +701,9 @@ function has_headerunitsupport(target) local support_headerunits = _g.support_headerunits if support_headerunits == nil then local compinst = target:compiler("cxx") - if compinst:has_flags(get_modulesflag(target) .. " -std=c++20 -x c++-user-header", "cxxflags", {flagskey = "clang_user_header_unit_support", tryrun = true}) and - compinst:has_flags(get_modulesflag(target) .. " -std=c++20 -x c++-system-header", "cxxflags", {flagskey = "clang_system_header_unit_support", tryrun = true}) then + local modulesflag, modulestsflag = get_modulesflag(target) + if compinst:has_flags(modulesflag or moduletsflag .. " -std=c++20 -x c++-user-header", "cxxflags", {flagskey = "clang_user_header_unit_support", tryrun = true}) and + compinst:has_flags(modulesflag or moduletsflag .. " -std=c++20 -x c++-system-header", "cxxflags", {flagskey = "clang_system_header_unit_support", tryrun = true}) then support_headerunits = true end _g.support_headerunits = support_headerunits or false |
