stevedonovan / Lake

A Lua-based Build Tool
MIT License
132 stars 16 forks source link

Several question about copy file #7

Closed moteus closed 11 years ago

moteus commented 12 years ago

file.copy - read and write in text mode. I cant copy binary files. file.group{...} - create directory tree, but target(...., "$(COPY) ...") - do not.

In file.group base jouins with odir Following code produce: copy src\mime.lua src\lib\lua\mime.lua

  file.group{
    base='src';
    src = {'mime.lua', 'socket.lua', 'ltn12.lua'},
    odir=J('lib', 'lua');
  };

clean target ignore -t How i can clean only one target? And how i can add extra action to clean target?

stevedonovan commented 12 years ago

I recently 'fixed' an issue with incdir - it was also combining with base. I think in this case as well that odir should not combine with base, and then we can always work with paths to relative to current path.

Cleaning one target would be useful - I will look at this.

Thanks for picking up binary file issue, easy to fix. I am thinking of always using $COPY to do this?

Yes, file.group will create directory (part of odir mechanism) but target() is dumb...

moteus commented 12 years ago

to copy i use:

MD = function(...) 
  local target = J(...)
  if path.isdir(target) then return end
  if path.exists(target) and not TESTING then
    quit("can not create directory: %s", target)
  end
  print("md " .. target)
  if not TESTING then path.mkdir(target)  end
end

local CP_ACTION = function(src, target)
  MD(path.dirname(target))
  print('copy ' .. src .. ' ' .. target)
  if not TESTING then
    local ok, err = file.copy(src, target)
    if not ok then quit("can not copy file %s :$s", src, err) end
  end
end

CP = function(t) CP_ACTION(t.deps[1], t.target) end

This ignore -b flag and use single thread. How i can use shell('COPY'...)?