On 09/12/2010, at 3:26 AM, Erick Tryzelaar wrote:

> On Mon, Dec 6, 2010 at 8:36 PM, john skaller
> <[email protected]> wrote:
>> Erick, I'm stiff having trouble understanding some fbuild functions:
>> Consider:
>> 
>>    buildsystem.copy_dir_to(ctx, ctx.buildroot, 'src/config',
>>        pattern='*.{fpc, hpp}')
>> 
>> what does this actually do? I can tell you it copies files from
>> src/config to build/release/config .. but I don't understand why.
> 
> It is supposed to be analogous to "cp -r src/config build/release".

Yes, but "cp" is screwed. It's a very bad program. "cp" on OSX
treats this differently if the src name has a trailing "/" or not.
And the man page doesn't help: look at this bad wording:


" In the first synopsis form, the cp utility copies the contents of the 
source_file to the
     target_file. "

 "In the second synopsis form, the contents of each named source_file is copied 
to the
     destination target_directory."

This is BSD cp, on OSX. What does "to" mean? Does it mean "onto the top of"?
Or "underneath"? Or is this context sensitive depending on whether the target
is a directory? what about the source?

And now with -R ... note -r works but isn't documented ...

   -R    If source_file designates a directory, cp copies the directory and the 
entire subtree con-
           nected at that point.  If the source_file ends in a /, the contents 
of the directory are
           copied rather than the directory itself.  This option also causes 
symbolic links to be
           copied, rather than indirected through, and for cp to create special 
files rather than copy-
           ing them as normal files.  Created directories have the same mode as 
the corresponding
           source directory, unmodified by the process' umask.


So now you see, how completely screwed up the program is. The docs are very 
poor.
The Unix concept is very bad.

I am very confused about how to copy a directory ONTO another directory
or INTO another directory.. an crucial distinction. Different again, copying
the contents of a directory INTO another directory.

Note there's no mention of wildcards either..

The docs for gnu cp are even worse:

The full documentation for cp is maintained as a Texinfo manual. 

Texinfo is an unusable piece of crud.

however at least there's a sane option:

      -t, --target-directory=DIRECTORY
              copy all SOURCE arguments into DIRECTORY


Ah, finally someone woke up. At least in this form it is clear, the sources
are copied INTO the target directory. One guesses a regular file
is a regular file, and directories become subdirectories .. all with
their original basenames. With this concept, the copy is a top level
copy only, it isn't recursive... its just that directories get copied
as directories...

well maybe. That means if the target of a copy is a directory IT
SHOULD BE DELETED before the copying, after all the source
could be an ordinary file.. and if the src is a directory it should
*clobber* the target as well. Errr .. well I have no idea, I can't
experiment easilyt on slicehost because the line editing
etc is way too slow to be useable over my link.



>> 
>> 
>>    buildsystem.copy_to(ctx, ctx.buildroot/'config/target',
>>        Path('src/config/target/*.hpp').glob())
>> 
>> which works .. but requires that I name the subdirectory "target".
>> 
>> What am I doing wrong?
> 
> Well that's no good, it's supposed to do that. I'll look into it later today.



The problem is not in your code: the problem is that a two argument copy
of Unix style is unprincipled. You can make a well founded copy,
for example:

copy INTO directory FROM directory pattern=...

and it is clear this copies files IN directory whose names in the
directory match pattern INTO the target with the same names.
The pattern cannot have paths in it. If a pattern matches a directory name,
it is copied too. This interpretation is not good but it is consistent:
it will copy subdirectories if the *subdirectory* name matches the pattern.

Another rule would be, the pattern matches all files in the source,
including ones in subdirectories, and the copy preserves the names
including parent names. So the pattern never matches directories,
only regular files, but includes those in subdirs.

Another approach is probably better: directories simply don't exist.
All files live in the root, they just have structured names.
This interpretation is the most consistent and easiest to work with.

You'd so something like:

copy fred/(.*\.flx) joe/\1

which clearly descends into subdirectories of the src, or if that isn't wanted:

copy fred/([^/]*\.flx) joe/\1

because here the regex can't match a path name with a / in it.

It's a bit messy because "." means "any character" and so you have to
use "\." when you mean the "." character.

I plan to implement this :)


--
john skaller
[email protected]





------------------------------------------------------------------------------
This SF Dev2Dev email is sponsored by:

WikiLeaks The End of the Free Internet
http://p.sf.net/sfu/therealnews-com
_______________________________________________
Felix-language mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/felix-language

Reply via email to