[Omake] symlink (FAT filesystem)
Aleksey Nogin
nogin at metaprl.org
Tue Oct 17 09:37:59 PDT 2006
Hi Matthieu,
On 11.10.2006 04:10, Matthieu Dubuget wrote:
> Hello,
>
> in order to test my project on different platforms, I put everything on
> my USB key, which allow me to switch between windows and linux easily.
> Of course, the filesystem of my key is FAT: files cannot be symlinked,
> even if connected to my linux box.
>
> The problem is that Common.om <http://Common.om> uses $(OSTYPE) in
> order to modify symlink definition.
>
> This is incorrect: the right test should be related to the filesystem
> which seems not to be a trivial problem: there are a lot of different
> filesystems for only one computer...
This is true - assuming that any Unix-like system can do symlinks is
very simplistic, thanks for pointing it out. I've filed a bug report
outlining this and related issues and proposing a solution -
http://bugzilla.metaprl.org/show_bug.cgi?id=602 .
> As a workaround, I added this in my OMakeroot:
> symlink(src, dst) =
> return(cp -f $(src) $(dst))
>
> Is there any better solution?
One option would be to try ln first and revert to cp if ln fails.
For example,
Shell. +=
ln-or-cp(argv) =
src = $(file $(nth 0, $(argv)))
dst = $(file $(nth 1, $(argv)))
ln -sf $(in $(dirof $(dst)), $(src)) $(dst) || cp -f $(src) $(dst)
symlink(src, dst) =
return(ln-or-cp $(src) $(dst))
A slightly cleaner (and probably more efficient) option would be to
define myln using the built-in symlink function.
Shell. +=
ln-or-cp(argv) =
src = $(file $(nth 0, $(argv)))
dst = $(file $(nth 1, $(argv)))
try
src.symlink($(dst))
default
cp -f $(src) $(dst)
Unfortunately, the built-in symlink function is currently shadowed by
the Common.om (not sure how this happened) so this would not work unless
the Common.om itself is fixed and/or one of the two different "symlink"
functions is renamed. As I proposed in bug 602, one solution would be to
implement the ln-or-cp using the built-in symlink function and then get
rid of the other symlink function (the one defined in Common.om) and use
the new ln-or-cp in rules directly.
Aleksey
P.S. Sorry for the slow response.
More information about the Omake
mailing list