aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHisham Muhammad <hisham@gobolinux.org>2024-03-05 22:13:12 -0300
committerHisham Muhammad <hisham@gobolinux.org>2024-03-06 15:14:36 +0000
commit8d30fc5bd2b352897b81756400ab50d2be859209 (patch)
treef71fe388bf942a8675b011e377c55587da2133f0
parentc3345ac3c416d5f0eb229258262b112f33bf0441 (diff)
downloadluarocks-8d30fc5bd2b352897b81756400ab50d2be859209.tar.gz
luarocks-8d30fc5bd2b352897b81756400ab50d2be859209.tar.bz2
luarocks-8d30fc5bd2b352897b81756400ab50d2be859209.zip
fix(windows): output native slashes on fs.find
-rw-r--r--spec/unit/build_spec.lua6
-rw-r--r--spec/unit/fs_spec.lua6
-rw-r--r--src/luarocks/build/builtin.lua7
-rw-r--r--src/luarocks/fs/win32/tools.lua4
4 files changed, 13 insertions, 10 deletions
diff --git a/spec/unit/build_spec.lua b/spec/unit/build_spec.lua
index 3ef8eece..e8f13940 100644
--- a/spec/unit/build_spec.lua
+++ b/spec/unit/build_spec.lua
@@ -128,15 +128,15 @@ describe("LuaRocks build #unit", function()
128 128
129 local modules = build_builtin.autodetect_modules(libs, incdirs, libdirs) 129 local modules = build_builtin.autodetect_modules(libs, incdirs, libdirs)
130 assert.same(modules, { 130 assert.same(modules, {
131 module1 = location .. "/module1.lua", 131 module1 = P(location .. "/module1.lua"),
132 ["dir1.module2"] = { 132 ["dir1.module2"] = {
133 sources = location .. "/dir1/module2.c", 133 sources = P(location .. "/dir1/module2.c"),
134 libraries = libs, 134 libraries = libs,
135 incdirs = incdirs, 135 incdirs = incdirs,
136 libdirs = libdirs 136 libdirs = libdirs
137 }, 137 },
138 my_module = { 138 my_module = {
139 sources = location .. "/dir1/dir2/module3.c", 139 sources = P(location .. "/dir1/dir2/module3.c"),
140 libraries = libs, 140 libraries = libs,
141 incdirs = incdirs, 141 incdirs = incdirs,
142 libdirs = libdirs 142 libdirs = libdirs
diff --git a/spec/unit/fs_spec.lua b/spec/unit/fs_spec.lua
index 621a7727..c2a842bf 100644
--- a/spec/unit/fs_spec.lua
+++ b/spec/unit/fs_spec.lua
@@ -1063,9 +1063,9 @@ describe("luarocks.fs #unit", function()
1063 end 1063 end
1064 assert.same(count, 3) 1064 assert.same(count, 3)
1065 assert.is_not.same(contents[tmpdir], true) 1065 assert.is_not.same(contents[tmpdir], true)
1066 assert.same(contents["intfile1"], true) 1066 assert.same(contents[P"intfile1"], true)
1067 assert.same(contents["intdir"], true) 1067 assert.same(contents[P"intdir"], true)
1068 assert.same(contents["intdir/intfile2"], true) 1068 assert.same(contents[P"intdir/intfile2"], true)
1069 end) 1069 end)
1070 1070
1071 it("uses the current working directory if the argument is nil", function() 1071 it("uses the current working directory if the argument is nil", function()
diff --git a/src/luarocks/build/builtin.lua b/src/luarocks/build/builtin.lua
index c55b61a0..4c15d2bf 100644
--- a/src/luarocks/build/builtin.lua
+++ b/src/luarocks/build/builtin.lua
@@ -8,6 +8,7 @@ local builtin = {}
8builtin.skip_lua_inc_lib_check = true 8builtin.skip_lua_inc_lib_check = true
9 9
10local unpack = unpack or table.unpack 10local unpack = unpack or table.unpack
11local dir_sep = package.config:sub(1, 1)
11 12
12local fs = require("luarocks.fs") 13local fs = require("luarocks.fs")
13local path = require("luarocks.path") 14local path = require("luarocks.path")
@@ -59,7 +60,7 @@ do
59 for _, parent in ipairs({"src", "lua", "lib"}) do 60 for _, parent in ipairs({"src", "lua", "lib"}) do
60 if fs.is_dir(parent) then 61 if fs.is_dir(parent) then
61 fs.change_dir(parent) 62 fs.change_dir(parent)
62 prefix = parent.."/" 63 prefix = parent .. dir_sep
63 break 64 break
64 end 65 end
65 end 66 end
@@ -69,7 +70,7 @@ do
69 if not skiplist[base] then 70 if not skiplist[base] then
70 local luamod = file:match("(.*)%.lua$") 71 local luamod = file:match("(.*)%.lua$")
71 if luamod then 72 if luamod then
72 modules[path.path_to_module(file)] = prefix..file 73 modules[path.path_to_module(file)] = prefix .. file
73 else 74 else
74 local cmod = file:match("(.*)%.c$") 75 local cmod = file:match("(.*)%.c$")
75 if cmod then 76 if cmod then
@@ -89,7 +90,7 @@ do
89 fs.pop_dir() 90 fs.pop_dir()
90 end 91 end
91 92
92 local bindir = (fs.is_dir("src/bin") and "src/bin") 93 local bindir = (fs.is_dir(dir.path("src", "bin")) and dir.path("src", "bin"))
93 or (fs.is_dir("bin") and "bin") 94 or (fs.is_dir("bin") and "bin")
94 if bindir then 95 if bindir then
95 install = { bin = {} } 96 install = { bin = {} }
diff --git a/src/luarocks/fs/win32/tools.lua b/src/luarocks/fs/win32/tools.lua
index be63063b..86cbb45b 100644
--- a/src/luarocks/fs/win32/tools.lua
+++ b/src/luarocks/fs/win32/tools.lua
@@ -10,6 +10,8 @@ local cfg = require("luarocks.core.cfg")
10 10
11local vars = setmetatable({}, { __index = function(_,k) return cfg.variables[k] end }) 11local vars = setmetatable({}, { __index = function(_,k) return cfg.variables[k] end })
12 12
13local dir_sep = package.config:sub(1, 1)
14
13--- Adds prefix to command to make it run from a directory. 15--- Adds prefix to command to make it run from a directory.
14-- @param directory string: Path to a directory. 16-- @param directory string: Path to a directory.
15-- @param cmd string: A command-line string. 17-- @param cmd string: A command-line string.
@@ -132,7 +134,7 @@ function tools.find(at)
132 local first_two = file:sub(1,2) 134 local first_two = file:sub(1,2)
133 if first_two == ".\\" or first_two == "./" then file=file:sub(3) end 135 if first_two == ".\\" or first_two == "./" then file=file:sub(3) end
134 if file ~= "." then 136 if file ~= "." then
135 table.insert(result, (file:gsub("\\", "/"))) 137 table.insert(result, (file:gsub("[\\/]", dir_sep)))
136 end 138 end
137 end 139 end
138 pipe:close() 140 pipe:close()