]> Dogcows Code - chaz/yoink/commitdiff
better gcc support in compile.lua
authorCharles McGarvey <chazmcgarvey@brokenzipper.com>
Fri, 11 Jun 2010 16:14:12 +0000 (10:14 -0600)
committerCharles McGarvey <chazmcgarvey@brokenzipper.com>
Fri, 11 Jun 2010 16:14:12 +0000 (10:14 -0600)
build/compile.lua
configure

index 31b20fd1743c428661886ee8b11257cfa1e0a528..575096d20142da5b9832085d44e758d1575d2014 100755 (executable)
@@ -3,7 +3,8 @@
 --
 -- Yoink
 -- This script wraps around the compiler command to handle the creation of
--- dependency files.  It works with new versions of GCC.
+-- dependency files.  It works with GCC.  The script is based off of Emile
+-- van Bergen's `ccdeps-gcc' script.
 --
 
 
@@ -19,12 +20,20 @@ end
 -- The compiler command is the first argument.
 compiler       = shift()
 arguments      = ""
+paths          = {}
 
 
 -- Consume each compiler argument, appending it to the arguments variable.
 while 0 < #arg do
-       local v = shift(arg)
-       if v == "-o" then product = shift(arg) end
+       local v = shift()
+       if v == "-o" then
+               product = shift()
+       elseif v:match("%-[xubV]$") then
+               shift()         -- Shift an extra one for the option's payload.
+       else
+               path = v:match("([^-].*)/")
+               if path then paths[path] = true end
+       end
 end
 if not product then print("No output file specified.") os.exit(1) end
 
@@ -46,17 +55,24 @@ dep = product..".d"
 os.remove(dep)
 
 
--- GCC outputs file.d for a product named file.o.
-gccdep = product:gsub("^.*/(.*)%.o$", "%1.d")
-tmpname = gccdep..".tmp"
+-- GCC outputs file.d for a product named file.o, either in the current
+-- directory or in the directory where the source is.
+depname = product:gsub("^.*/(.*)%.o$", "%1.d")
+depfiles = {}
+table.insert(depfiles, depname)
+for path in pairs(paths) do table.insert(depfiles, path.."/"..depname) end
 
--- Fix up the dependency file with correct paths.
-if os.execute("test -f "..gccdep) == 0 and os.rename(gccdep, tmpname) then
-       os.execute(string.format("sed -e 's|.*:|%s %s:|' <%s >>%s", product, dep, tmpname, dep))
-       os.execute(string.format("sed -e 's/^.*://' -e 's/^ *//' -e 's/ *\\\\$//' -e 's/$/:/' <%s >>%s", tmpname, dep))
-       os.remove(tmpname)
-else
-       print("Couldn't find the dependency file at "..gccdep..".")
-       os.exit(1)
+for _,gccdep in ipairs(depfiles) do
+       tmpname = gccdep..".tmp"
+       -- Fix up the dependency file with correct paths.
+       if os.execute("test -f "..gccdep) == 0 and os.rename(gccdep, tmpname) then
+               os.execute(string.format("sed -e 's|.*:|%s %s:|' <%s >>%s", product, dep, tmpname, dep))
+               os.execute(string.format("sed -e 's/^.*://' -e 's/^ *//' -e 's/ *\\\\$//' -e 's/$/:/' <%s >>%s", tmpname, dep))
+               os.remove(tmpname)
+               os.exit()
+       end
 end
 
+print("Couldn't find the dependency file.")
+os.exit(1)
+
index 5e691c171eacb6b4b11a9f02aba5e4285de63638..f69a93a81dec0b0720222cbd878ee13b1fd6d52d 100755 (executable)
--- a/configure
+++ b/configure
@@ -40,7 +40,7 @@ Program options:
       --enable-threads    use threads for concurrency
       --enable-hotloading watch assets for automatic reloading
 
-      --with-gtk          use gtk2 toolkit (overrides --with-qt4)
+      --with-gtk          use the gtk2 toolkit (overrides --with-qt4)
       --with-qt4          use the qt4 gui toolkit
 ]])
 end
@@ -263,7 +263,8 @@ int main()
 {
        printf("Hello world!\n");
        return 0;
-}]])
+}
+]])
        tmpfile:close()
 
        function extra() if not cross_compile then return "gcc", "cc" end end
@@ -291,7 +292,8 @@ int main()
 {
        std::cout << "Hello world!" << std::endl;
        return 0;
-}]])
+}
+]])
        tmpfile:close()
 
        function extra() if not cross_compile then return "g++", "c++" end end
This page took 0.020338 seconds and 4 git commands to generate.