Build failing on Darwin due to sed differences
This issue has to do with the sed command in qsrc/tools/qcc.sh:35. Darwin (OSX) uses the BSD sed, but I assume that others are using GNU sed. This issue is to help nail down the exact nature of the behavior difference, get advice on how to proceed, and eventually implement a fix.
To the best of my understanding, this process takes in progs.inc and outputs to $mode_macros.txt, mode_includes.txt, and .tmp/mode.txt, where $mode is one of (client, menu, server). The following examples will use "client" as the mode.
The sed command which is malfunctioning takes in client.txt and is intended to match lines of the following shape:
# 1 "client/progs.inc"
# 1 "<built-in>" 1
...
That is the first few lines of my client.txt. Looks suspicious. If someone could verify that against their own copy, that would be great.
Currently the sed command is:
sed 's/^# \(line\)\? \([[:digit:]]\+\) "\(.*\)".*/\n#pragma file(\3)\n#pragma line(\2)/g' "${WORKDIR}/${MODE}.txt"
and on Darwin the resulting client.qc is
# 1 "client/progs.inc"
# 1 "<built-in>" 1
...
(no change as sed does not match any lines)
changed to
sed -E 's/^# (line )?([[:digit:]]+) "(.*)".*/#pragma file(\3)'$'\\\n''#pragma line(\2)'$'\\\n/g' "${WORKDIR}/${MODE}.txt"
(removed extra blackslashes, did some tricks to escape newlines, added -E to enable extended ("modern") regexes)
Resulting client.qc with this change:
#pragma file(client/progs.inc)
#pragma line(1)
#pragma file(<built-in>)
#pragma line(1)
...
Is this correct? I am suspicious of the <built-in> lines. Again, if someone could verify this against their local copy I would appreciate it.
Possible solutions:
- find regex that works for both versions of sed
- forgo sed for another command with consistent behavior
- I run the build in a VM like a normal person lul