diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/luarocks/build.lua | 30 | ||||
-rw-r--r-- | src/luarocks/path.lua | 13 |
2 files changed, 37 insertions, 6 deletions
diff --git a/src/luarocks/build.lua b/src/luarocks/build.lua index e545d390..d5c474ca 100644 --- a/src/luarocks/build.lua +++ b/src/luarocks/build.lua | |||
@@ -129,7 +129,37 @@ local function process_dependencies(rockspec, opts) | |||
129 | 129 | ||
130 | if not opts.build_only_deps then | 130 | if not opts.build_only_deps then |
131 | if next(rockspec.build_dependencies) then | 131 | if next(rockspec.build_dependencies) then |
132 | |||
133 | local user_lua_version = cfg.lua_version | ||
134 | local running_lua_version = _VERSION:sub(5) | ||
135 | |||
136 | if running_lua_version ~= user_lua_version then | ||
137 | -- Temporarily flip the user-selected Lua version, | ||
138 | -- so that we install build dependencies for the | ||
139 | -- Lua version on which the LuaRocks program is running. | ||
140 | |||
141 | -- HACK: we have to do this by flipping a bunch of | ||
142 | -- global config settings, and this list may not be complete. | ||
143 | cfg.lua_version = running_lua_version | ||
144 | cfg.lua_modules_path = cfg.lua_modules_path:gsub(user_lua_version:gsub("%.", "%%."), running_lua_version) | ||
145 | cfg.lib_modules_path = cfg.lib_modules_path:gsub(user_lua_version:gsub("%.", "%%."), running_lua_version) | ||
146 | cfg.rocks_subdir = cfg.rocks_subdir:gsub(user_lua_version:gsub("%.", "%%."), running_lua_version) | ||
147 | path.use_tree(cfg.root_dir) | ||
148 | end | ||
149 | |||
132 | local ok, err, errcode = deps.fulfill_dependencies(rockspec, "build_dependencies", "all", opts.verify) | 150 | local ok, err, errcode = deps.fulfill_dependencies(rockspec, "build_dependencies", "all", opts.verify) |
151 | |||
152 | path.add_to_package_paths(cfg.root_dir) | ||
153 | |||
154 | if running_lua_version ~= user_lua_version then | ||
155 | -- flip the settings back | ||
156 | cfg.lua_version = user_lua_version | ||
157 | cfg.lua_modules_path = cfg.lua_modules_path:gsub(running_lua_version:gsub("%.", "%%."), user_lua_version) | ||
158 | cfg.lib_modules_path = cfg.lib_modules_path:gsub(running_lua_version:gsub("%.", "%%."), user_lua_version) | ||
159 | cfg.rocks_subdir = cfg.rocks_subdir:gsub(running_lua_version:gsub("%.", "%%."), user_lua_version) | ||
160 | path.use_tree(cfg.root_dir) | ||
161 | end | ||
162 | |||
133 | if err then | 163 | if err then |
134 | return nil, err, errcode | 164 | return nil, err, errcode |
135 | end | 165 | end |
diff --git a/src/luarocks/path.lua b/src/luarocks/path.lua index a9f04ef0..19657c83 100644 --- a/src/luarocks/path.lua +++ b/src/luarocks/path.lua | |||
@@ -219,13 +219,14 @@ function path.use_tree(tree) | |||
219 | cfg.deploy_bin_dir = path.deploy_bin_dir(tree) | 219 | cfg.deploy_bin_dir = path.deploy_bin_dir(tree) |
220 | cfg.deploy_lua_dir = path.deploy_lua_dir(tree) | 220 | cfg.deploy_lua_dir = path.deploy_lua_dir(tree) |
221 | cfg.deploy_lib_dir = path.deploy_lib_dir(tree) | 221 | cfg.deploy_lib_dir = path.deploy_lib_dir(tree) |
222 | end | ||
222 | 223 | ||
223 | -- TODO Do we want LuaRocks itself to use whatever tree is in use? | 224 | function path.add_to_package_paths(tree) |
224 | -- package.path = dir.path(path.deploy_lua_dir(tree), "?.lua") .. ";" | 225 | package.path = dir.path(path.deploy_lua_dir(tree), "?.lua") .. ";" |
225 | -- .. dir.path(path.deploy_lua_dir(tree), "?/init.lua") .. ";" | 226 | .. dir.path(path.deploy_lua_dir(tree), "?/init.lua") .. ";" |
226 | -- .. package.path | 227 | .. package.path |
227 | -- package.cpath = dir.path(path.deploy_lib_dir(tree), "?." .. cfg.lib_extension) .. ";" | 228 | package.cpath = dir.path(path.deploy_lib_dir(tree), "?." .. cfg.lib_extension) .. ";" |
228 | -- .. package.cpath | 229 | .. package.cpath |
229 | end | 230 | end |
230 | 231 | ||
231 | --- Get the namespace of a locally-installed rock, if any. | 232 | --- Get the namespace of a locally-installed rock, if any. |