diff options
| author | ruki <[email protected]> | 2024-02-18 21:50:09 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2024-02-18 21:52:03 +0800 |
| commit | dd27e3773f45ba36579c293078a254c81ff56611 (patch) | |
| tree | 71f59ae09146081a81acfd799ff9d8c215fac194 | |
| parent | aa1cb2c4b615aa41f232187b6769afee49a6890d (diff) | |
use path.unix
| -rw-r--r-- | xmake/plugins/project/cmake/cmakelists.lua | 8 | ||||
| -rw-r--r-- | xmake/rules/c++/modules/modules_support/gcc/builder.lua | 12 |
2 files changed, 10 insertions, 10 deletions
diff --git a/xmake/plugins/project/cmake/cmakelists.lua b/xmake/plugins/project/cmake/cmakelists.lua index 4402f080f..98a94338d 100644 --- a/xmake/plugins/project/cmake/cmakelists.lua +++ b/xmake/plugins/project/cmake/cmakelists.lua @@ -67,7 +67,7 @@ end -- escape path function _escape_path(filepath) if is_host("windows") then - filepath = filepath:gsub('\\', '/') + filepath = path.unix(filepath) filepath = filepath:gsub(' ', '\\ ') end return filepath @@ -96,7 +96,7 @@ end -- @see https://github.com/xmake-io/xmake/issues/2026 function _get_relative_unix_path_to_cmake(filepath, outputdir) filepath = _translate_path(filepath, outputdir) - filepath = path.translate(filepath):gsub('\\', '/') + filepath = path.unix(path.translate(filepath)) if filepath and not path.is_absolute(filepath) then filepath = "${CMAKE_SOURCE_DIR}/" .. filepath end @@ -265,7 +265,7 @@ function _set_target_compiler(cmakelists, target) if config.get("toolchain") or target:get("toolchains") then local cc = target:tool("cc") if cc then - cc = cc:gsub("\\", "/") + cc = path.unix(cc) cmakelists:print("set(CMAKE_C_COMPILER \"%s\")", cc) end local cxx, cxx_name = target:tool("cxx") @@ -283,7 +283,7 @@ function _set_target_compiler(cmakelists, target) cxx = name end end - cxx = cxx:gsub("\\", "/") + cxx = path.unix(cxx) cmakelists:print("set(CMAKE_CXX_COMPILER \"%s\")", cxx) end end diff --git a/xmake/rules/c++/modules/modules_support/gcc/builder.lua b/xmake/rules/c++/modules/modules_support/gcc/builder.lua index 9b8ed1212..f290ed262 100644 --- a/xmake/rules/c++/modules/modules_support/gcc/builder.lua +++ b/xmake/rules/c++/modules/modules_support/gcc/builder.lua @@ -83,9 +83,9 @@ end function _generate_headerunit_modulemapper_file(module) local mapper_path = os.tmpfile() local mapper_file = io.open(mapper_path, "wb") - mapper_file:write("root " .. os.projectdir():replace("\\", "/")) + mapper_file:write("root " .. path.unix(os.projectdir())) mapper_file:write("\n") - mapper_file:write(mapper_file, module.name:replace("\\", "/") .. " " .. module.bmifile:replace("\\", "/")) + mapper_file:write(mapper_file, path.unix(module.name) .. " " .. path.unix(module.bmifile)) mapper_file:write("\n") mapper_file:close() return mapper_path @@ -107,13 +107,13 @@ function _get_maplines(target, module) if dep_module.aliasof then local aliased = get_from_target_mapper(target, dep_module.aliasof) bmifile = aliased.bmi - mapline = dep_module.headerunit.path:replace("\\", "/") .. " " .. bmifile:replace("\\", "/") + mapline = path.unix(dep_module.headerunit.path) .. " " .. path.unix(bmifile) -- headerunit elseif dep_module.headerunit then - mapline = dep_module.headerunit.path:replace("\\", "/") .. " " .. bmifile:replace("\\", "/") + mapline = path.unix(dep_module.headerunit.path) .. " " .. path.unix(bmifile) -- named module else - mapline = required .. " " .. bmifile:replace("\\", "/") + mapline = required .. " " .. path.unix(bmifile) end table.insert(maplines, mapline) @@ -137,7 +137,7 @@ function _generate_modulemapper_file(target, module, cppfile) local maplines = _get_maplines(target, module) local mapper_path = path.join(os.tmpdir(), target:name():replace(" ", "_"), name or cppfile:replace(" ", "_")) local mapper_file = io.open(mapper_path, "wb") - mapper_file:write("root " .. os.projectdir():replace("\\", "/")) + mapper_file:write("root " .. path.unix(os.projectdir())) mapper_file:write("\n") for _, mapline in ipairs(maplines) do mapper_file:write(mapline) |
