]>
Dogcows Code - chaz/yoink/blob - build/compile.lua
31b20fd1743c428661886ee8b11257cfa1e0a528
5 -- This script wraps around the compiler command to handle the creation of
6 -- dependency files. It works with new versions of GCC.
10 -- Get the next argument passed to the script.
14 arguments
= string.format("%s %q", tostring(arguments
), tostring(var
))
19 -- The compiler command is the first argument.
24 -- Consume each compiler argument, appending it to the arguments variable.
27 if v
== "-o" then product
= shift(arg
) end
29 if not product
then print("No output file specified.") os
.exit(1) end
32 -- Now try the actual compile WITH dependency generation.
33 if os
.execute(compiler
.." -MD"..arguments
) ~= 0 then
34 -- Try it without dependency generation.
35 if os
.execute(compiler
..arguments
) ~= 0 then
36 print("The compile failed. :-(")
39 print("The compile succeeded without dependency generation.")
44 -- Remove the old dependency file.
49 -- GCC outputs file.d for a product named file.o.
50 gccdep
= product
:gsub("^.*/(.*)%.o$", "%1.d")
51 tmpname = gccdep
..".tmp"
53 -- Fix up the dependency file with correct paths.
54 if os
.execute("test -f "..gccdep
) == 0 and os
.rename(gccdep
, tmpname) then
55 os
.execute(string.format("sed -e 's|.*:|%s %s:|' <%s >>%s", product
, dep
, tmpname, dep
))
56 os
.execute(string.format("sed -e 's/^.*://' -e 's/^ *//' -e 's/ *\\\\$//' -e 's/$/:/' <%s >>%s", tmpname, dep
))
59 print("Couldn't find the dependency file at "..gccdep
..".")
This page took 0.036786 seconds and 3 git commands to generate.