Perl5-Alien / Alien-Base

Base classes for Alien:: modules (deprecated, see Alien-Build)
Other
35 stars 19 forks source link

alien_helper does not work as expected #182

Closed MaxPerl closed 7 years ago

MaxPerl commented 7 years ago

I tried alien_helpers, but They didn't work as expected. I think the problem is that the code is executed twice. Here a little code snippet (I just want to change the dir before building becaus the source archive has several subdirectories for different OSes):

use Alien::Base::ModuleBuild;
# See perldoc Module::Build for details of how this works

my $builder = Alien::Base::ModuleBuild->new
    ( module_name     => 'Alien::Tcl',
      license         => 'perl',
      alien_repository => {
                protocol => 'local',
                location => 'src',
                exact_filename => 'tcl866-src.zip',             
      },
      alien_helper => {
        'chdir' => 'chdir "$CWD/win"'
      },
      alien_build_commands => ['%{chdir}', '%c --prefix=%s --enable-64bit', 'make'],
    )->create_build_script;

The error message is as follow:

  • 1 Can't exec "1": No such file or directory at /usr/share/perl5/Module/Build/Base.pm line 5538. External command (1) failed! Error: -1 at ./Build line 60. Failed Build not completed at ./Build line 60.

By the way: If I pass a code ref alien_helper => sub {...} I get the following error as early as I execute perl Build.PL:

Encountered CODE ref, using dummy placeholder at /usr/lib/x86_64-linux-gnu/perl/5.22/Data/Dumper.pm line 231.

plicease commented 7 years ago

helpers are used to help render commands, so what is happening, the string chdir "$CWD/win" is being evaluated, and it returns 1 for success, which it then tries to execute. It is a little awkward, but what you want to do is probably something like this:

  alien_build_commands => [ 'cd win; %c --prefix=%s --enable-64bit', 'make -C win' ],

The reason code references do not work is because the configuration is serialized between running Build.PL and ./Build by Module::Build which doesn't allow code references to be saved.

An option to change the base directory for build commands would be a useful feature. This is also handled better by Alien::Build which is under development and allows you to provide code references in command sequences like this.

edit: fixed capitalization

MaxPerl commented 7 years ago

Dear plicease, Thank you very much for your help. I got it with following command: alien_build_commands => [ 'cd win; %c --prefix=%s --enable-64bit', 'make -C win' ],

Nevertheless I am a little bit confused. Because the following don't work. And I don't know why: alien_build_Commands => [ 'cd win; %c --prefix=%s --enable-64bit', 'make -C win' ], With this the cd part is simply bypassed. and with alien_build_commands => [ 'cd win', '%c --prefix=%s --enable-64bit', 'make -C win' ], I get the error, that the command cd was not found.

Has anyone an idea why the first works and the others don't?

Anyway thank you very much for your help...

plicease commented 7 years ago

The second was my bad, I believe I accidentally capitalized Commands which is wrong!

I wouldn't expect the third version to work, but I am puzzled by the error that you got.

MaxPerl commented 7 years ago

Okay next problem. I test it no on windows (before I worked on Linux). On Windows I get the error that the filename, the directory name or the volume label syntax is incorrect.

plicease commented 7 years ago

Try "cd win && %c --prefix=%s --enable-64bit" that should work in both windows and linux unix.

MaxPerl commented 7 years ago

Thanks for your help. Now cd win is executed before ./configure. Unfortunately the Build script now stopped after configure. With ["cd win && %c --prefix=%s --enable-64bit && make"] it stopped after the make process and the script doesn't enter in the installation stage.

plicease commented 7 years ago

If you have the Alien dist you are working on somewhere public that I can see (preferably GitHub) I may be able to help. Also useful if there are any diagnostics emitted from either make or perl or AB::MB.

MaxPerl commented 7 years ago

Hi Plicease, Thanks for your help. Herel you can find the repo. It is in a very early stadium. It concerns the following bug report. My target was to develop the same for Tk and so on. But at the moment I think that this is perhaps over my abilities...

plicease commented 7 years ago

Thank you for the detail. I am adding myself as a CC: on the RT issue in case I can help there. It doesn't look like a bug in AB atm, so I am going to close this one.

plicease commented 7 years ago

btw- I will take a look at this when I get home and have my PC to test on but that won't be for two weeks at least.