Search Unity

Problem with a PostProcessBuildPlayer perl script

Discussion in 'Editor & General Support' started by recon, Apr 8, 2011.

  1. recon

    recon

    Joined:
    Nov 28, 2009
    Posts:
    119
    Hey all, Im trying to run a post process script when im building our android project that is supposed to copy a folder and all it's contents using the following code:

    Code (csharp):
    1.  
    2. File::Copy::Recursive::dircopy($source, $target);
    3.  
    but I get the following error when I build:

    Code (csharp):
    1.  
    2. Undefined subroutine &File::Copy::Recursive::dircopy called at Assets/Editor/PostprocessBuildPlayer_Android
    3. line 70.
    4.  
    I really suck at perl scripting, this is the first time I've ever tried it.
    The code reference I used is at: http://kobesearch.cpan.org/htdocs/File-Copy-Recursive/File/Copy/Recursive.pm.html#dircopy

    Thanks!
     
  2. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,601
    Sure that the perl function is present in the pearl interpreter installed and hooked up as standard for perl?

    Also, is the File::Copy::Recursive extension installed for that perl environment?
     
  3. recon

    recon

    Joined:
    Nov 28, 2009
    Posts:
    119
    I guess probably not then since it can't find it. I have no idea how to check what extensions are available, or if I can/how to install external ones to use with unity.
    This is why Im asking for help, all I really want to do is copy a folder (all its contents subfolders) into the data folder (on android in "MyUnityProject/Temp/StagingArea/assets/bin/Data/")

    This is my script so far:

    Code (csharp):
    1.  
    2. #!/usr/bin/perl
    3.  
    4. use File::Copy;
    5. use File::Find;
    6. use File::Path;
    7. use File::Basename qw(basename dirname fileparse);
    8. use warnings;
    9.  
    10. #if( $ARGV[1] ne "android" )
    11. #{
    12. #   exit;
    13. #}
    14.  
    15. my $currDir = `pwd`;
    16. chomp $currDir;
    17. my $source = $currDir . "/images/*";
    18. my $target = $currDir . "/Temp/StagingArea/assets/bin/Data/images";
    19.  
    20. mkdir($target) or die "Could not mkdir $target: $!";
    21.  
    22. File::Copy::Recursive::dircopy($source, $target);
    23.  
     
  4. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,601
    to find out if you have the extension, just add a

    use File::Copy::Recursive; at the top. if it works nothing happens, if its not present it will fail already there.

    if you do that you can also save yourself the long worm later in the code
     
  5. recon

    recon

    Joined:
    Nov 28, 2009
    Posts:
    119
    I added use File::Copy::Recursive; at the top and I get the following error:

    Code (csharp):
    1.  
    2. Can't locate File/Copy/Recursive.pm in @INC (@INC contains: /Library/Perl/Updates/5.10.0 /System/Library/Perl/5.10.0/darwin-thread-multi-2level /System/Library/Perl/5.10.0 /Library/Perl/5.10.0/darwin-thread-multi-2level /Library/Perl/5.10.0 /Network/Library/Perl/5.10.0/darwin-thread-multi-2level /Network/Library/Perl/5.10.0 /Network/Library/Perl /System/Library/Perl/Extras/5.10.0/darwin-thread-multi-2level /System/Library/Perl/Extras/5.10.0 .) at Assets/Editor/PostprocessBuildPlayer_Android line 11.
    3. BEGIN failed--compilation aborted at Assets/Editor/PostprocessBuildPlayer_Android line 11.
    4.  
    Do you have any suggestions on how I can install that module, if it's possible?
    Alternatively using a workaround, but none of the ones I have found online so far has worked =/

    Here's another solution I tried, but didn't work http://perlmeme.org/faqs/system/rcopy.html
     
  6. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,601
    You would have to lookup the documentation on how to install extensions for your OS and perl (depending on OS its present or not)
    There are some rather good and easy to follow tutorials on it.

    I only did it some years ago on linux so not enough current experience / fresh memories to help you I fear
     
  7. recon

    recon

    Joined:
    Nov 28, 2009
    Posts:
    119
    Okey, well thanks for your advice, I will experiment some more with perl and see what I can come up with!