premake / premake/premake-core
forced slash replacement
Nobody has claimed this yet.
- Dominant language
- C
- Stars
- 3.6k
- Forks
- 654
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 13
Description
prerequisites
premake5.lua
local qt_bin_path = "C:/dev/mx/v1/dep/qt/qt_33_x64_bin"
solution "myTestSln"
location "testfiles/sln"
platforms "x64"
configurations "release"
project "myTestPrj1"
kind "Utility"
files (qt_bin_path.."/bin/QtDeclarative_sofistik33_x64_4.dll")
filter "files:**/*.dll"
buildmessage ([[%{file.name} (copy)]])
buildcommands [[xcopy /y "%{file.path:gsub("/","\\")}" "bla"]]
buildoutputs ("bla")
filter "*"
Problem
The resulting path can be an absolute and all "" in the path are replaced by "/". There is - afaik - no possibility to change the slashes and not all Windows tools - like xcopy - can handle paths with "/".
Cause
If premake is detecting absolute paths in non path variables, they are replaced by relative paths. This is not possible all the time (not sure but here can be a bug, too). It's never possible on Windows system where files are placed over different Partitions (C:; D:).
detoken.lua:66
local isAbs = path.isabsolute(result)
if isAbs and not field.paths and basedir then
result = path.getrelative(basedir, result)
end
The path.getrelative function calls path.normalize which replaces all the "" to "/". This is not the system specification but required for further processing in premake.
path_normalize.c:30
if (ch == '\\') {
ch = '/';
}
possible Solution
Allow avoiding path fixing.
detoken.lua:66
local isAbs = path.isabsolute(result)
if type(result) == "string" and result:find("!$") then
result = result:match("(.-)!$"):gsub("/","\\")
elseif isAbs and not field.paths and basedir then
result = path.getrelative(basedir, result)
end
premake5.lua (part replacement)
buildcommands [[xcopy /y "%{file.path.."!"}" "bla"]]
Or is there a way I didn't see?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the supplied premake5.lua reproduction, then inspect detoken.lua:66 and path_normalize.c:30 to trace where the absolute path becomes relative and Windows separators are changed. Compare the generated build command with the expected xcopy command and determine a narrowly scoped way to preserve the required path form without breaking normal path processing.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c, lua
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100