]> git.lizzy.rs Git - metalua.git/commitdiff
smarter lib regeneration under win32
authorFabien Fleutot <metalua@gmail.com>
Tue, 3 Feb 2009 19:27:48 +0000 (20:27 +0100)
committerFabien Fleutot <metalua@gmail.com>
Tue, 3 Feb 2009 19:27:48 +0000 (20:27 +0100)
src/build-utils/precompile.lua

index 957154c50d7058e8310879318568efe162736e32..bf8aef9282d139217ba25a908a36db4da7051feb 100644 (file)
@@ -14,13 +14,23 @@ if not cfg.command or not cfg.directory then
    error ("Usage: "..arg[0].." command=<metalua command> directory=<library root>")
 end
 
-local f = io.popen ("dir /S /b " .. cfg.directory)
+-- List all files, recursively, from newest to oldest
+local f = io.popen ("dir /S /b /o-D " .. cfg.directory)
+
+local file_seen = { }
 for src in f:lines() do
+   file_seen[src] = true
    local base = src:match "^(.+)%.mlua$"
    if base then
-      local cmd = cfg.command.." "..src.." -o "..base..".luac"
-      print (cmd)
-      os.execute (cmd)
+      local target = base..".luac"
+      if file_seen[target] then 
+        -- the target file has been listed before the source ==> it's newer
+        print ("("..target.." up-to-date)")
+      else
+        local cmd = cfg.command.." "..src.." -o "..target
+        print (cmd)
+        os.execute (cmd)
+      end
    end
 end