#!/usr/local/bin/perl -w =head1 NAME build_vcp_executable.pl =head1 SYNOPSIS cd VCP bin\build_vcp_executable.pl =head1 DESCRIPTION Builds vcp binaries using PAR's pp command. Make sure you have all the VCP prereqs installed because pp silently won't include any not found. =cut use strict; use lib "lib"; use VCP::Utils qw( scan_pm_files_in ); use VCP::TestUtils qw( run ); ## VCP uses lazy loading extensively... my @modules = sort( ( scan_pm_files_in( "VCP" ), scan_pm_files_in( "VCP::Source" ), scan_pm_files_in( "VCP::Filter" ), scan_pm_files_in( "VCP::Dest" ), scan_pm_files_in( "VCP::Utils" ), scan_pm_files_in( "VCP::UI" ), ) ); my $exe_name = "vcp.exe"; if ( 1 ) { if ( -e $exe_name ) { unlink $exe_name or die $!; } my @cmd = ( "pp", # "-p", "-o", "vcp.par", "-o", $exe_name, "-lib=lib", map( "--add=$_", @modules ), "bin/vcp" ); warn join( " ", @cmd ), "\n"; system @cmd and die $!; } warn "Testing generated executable\n"; delete $ENV{$_} for grep /p4|perl/i, keys %ENV; my $ok = 1; { my $zip_list = "\n"; eval { run [ "wzunzip", "-v", $exe_name ], \undef, \$zip_list; warn "DB_File.pm not in $exe_name, patch the pp perl script\n" unless $zip_list =~ /DB_File\.pm/; 1; } or do { $ok = 0; warn $@, $zip_list; } } unless ( -e "tmp" ) { mkdir "tmp" or die "$!: tmp/"; } use File::Spec; my $abs_exe_name = File::Spec->rel2abs( $exe_name ); chdir "tmp" or die "$!: tmp/"; { my $vcp_output = "\n"; eval { run [ $abs_exe_name, "help" ], \undef, \$vcp_output; 1; } or do { $ok = 0; warn $@, $vcp_output; } } die "$exe_name fails test(s).\n" unless $ok; print "$exe_name seems ok, please test in a real application.\n";