From: <bru...@us...> - 2009-11-03 23:32:14
|
Revision: 1125 http://panotools.svn.sourceforge.net/panotools/?rev=1125&view=rev Author: brunopostle Date: 2009-11-03 23:32:03 +0000 (Tue, 03 Nov 2009) Log Message: ----------- More refactoring and tests... Modified Paths: -------------- trunk/Panotools-Script/Changes trunk/Panotools-Script/MANIFEST trunk/Panotools-Script/bin/panostart trunk/Panotools-Script/lib/Panotools/Makefile/Rule.pm trunk/Panotools-Script/lib/Panotools/Makefile.pm Added Paths: ----------- trunk/Panotools-Script/lib/Panotools/Makefile/Variable.pm trunk/Panotools-Script/lib/Panotools/Photos.pm trunk/Panotools-Script/t/104.metachars.t trunk/Panotools-Script/t/105.vars.t Modified: trunk/Panotools-Script/Changes =================================================================== --- trunk/Panotools-Script/Changes 2009-11-02 21:11:16 UTC (rev 1124) +++ trunk/Panotools-Script/Changes 2009-11-03 23:32:03 UTC (rev 1125) @@ -5,6 +5,7 @@ - support for i-line TrX, TrY, TrZ 'XYZ transform' parameters in libpano13-2.9.15 - Fix for crash in Subset() when project has no image metadata - Split Makefile generator from panostart to Panotools::Makefile::Rule + - Split utilities for querying list of photos to Panotools::Photos - erect2cubic --face option to optionally specify cubeface pixel size 0.23 Modified: trunk/Panotools-Script/MANIFEST =================================================================== --- trunk/Panotools-Script/MANIFEST 2009-11-02 21:11:16 UTC (rev 1124) +++ trunk/Panotools-Script/MANIFEST 2009-11-03 23:32:03 UTC (rev 1125) @@ -47,7 +47,9 @@ dos/make_exe.pl lib/Panotools/Makefile.pm lib/Panotools/Makefile/Rule.pm +lib/Panotools/Makefile/Variable.pm lib/Panotools/Matrix.pm +lib/Panotools/Photos.pm lib/Panotools/Script.pm lib/Panotools/Script/Line.pm lib/Panotools/Script/Line/Control.pm @@ -80,6 +82,8 @@ t/101.makerule.t t/102.platform.t t/103.platform.t +t/104.metachars.t +t/105.vars.t t/data/cemetery/dscn4905.jpg t/data/cemetery/dscn4906.jpg t/data/cemetery/dscn4907.jpg Modified: trunk/Panotools-Script/bin/panostart =================================================================== --- trunk/Panotools-Script/bin/panostart 2009-11-02 21:11:16 UTC (rev 1124) +++ trunk/Panotools-Script/bin/panostart 2009-11-03 23:32:03 UTC (rev 1125) @@ -7,6 +7,8 @@ use Pod::Usage; use Panotools::Script; use Panotools::Makefile::Rule; +use Panotools::Makefile::Variable; +use Panotools::Photos; my $path_makefile; my $d_inc = 15; @@ -18,6 +20,7 @@ my $nostacks = 0; my @argv_save = @ARGV; +my @makefile; GetOptions ('o|output=s' => \$path_makefile, 't|time=s' => \$d_inc, @@ -68,6 +71,17 @@ my $rule_movs = new Panotools::Makefile::Rule; $rule_movs->Targets ('qtvr'); +# define some variables + +my $make_extra_args = new Panotools::Makefile::Variable ('MAKE_EXTRA_ARGS', 'shell'); +$make_extra_args->Values ('clean'); + +my $hugindatadir = new Panotools::Makefile::Variable ('HUGINDATADIR', 'shell'); +$hugindatadir->Values ('/usr/share/hugin'); + +my $ap_extra_args = new Panotools::Makefile::Variable ('AP_EXTRA_ARGS', 'shell'); +$ap_extra_args->Values ('--clean'); + my @rules_pto; my @rules_mk; my @rules_ldr_blended; @@ -78,45 +92,43 @@ for my $group (@{$groups}) { - next if scalar @{$group} == 1; + my $temp_images = new Panotools::Photos (@{$group}); + next if scalar $temp_images->Paths == 1; - my $a = $group->[0]; - my $b = $group->[-1]; - $a =~ s/\.[[:alnum:]]+$//; - $b =~ s/\.[[:alnum:]]+$//; - $b =~ s/.*[\/\\]//; - my $stub = "$a-$b"; + my $stub = $temp_images->Stub; $rule_ptos->Prerequisites ("$stub.pto"); $rule_mks->Prerequisites ("$stub.pto.mk"); my $path_img; my $path_mov; - if (is_stacks (@{$group})) + + if ($nostacks or $temp_images->Bracketed == 0) { - $path_img = $stub ."_fused.tif"; - $path_mov = $stub ."_fused.mov"; + $path_img = $stub .".tif"; + $path_mov = $stub .".mov"; } else { - $path_img = $stub .".tif"; - $path_mov = $stub .".mov"; + $path_img = $stub ."_fused.tif"; + $path_mov = $stub ."_fused.mov"; } + $rule_imgs->Prerequisites ($path_img); $rule_movs->Prerequisites ($path_mov); - print STDERR "$path_img: ". scalar @{$group} ." images\n" if $verbose; + print STDERR "$path_img: ". scalar $temp_images->Paths ." images\n" if $verbose; my $rule_pto = new Panotools::Makefile::Rule; $rule_pto->Targets ("$stub.pto"); - $rule_pto->Prerequisites (@{$group}); + $rule_pto->Prerequisites ($temp_images->Paths); my @command = ('match-n-shift'); push @command, ('--stacks') unless $nostacks; push @command, ('--align', '$(AP_EXTRA_ARGS)', '--output', "$stub.pto"); push @command, ('--projection', $projection) if defined $projection; push @command, ('--fov', $deg_fov) if defined $deg_fov; push @command, ('--selection', $crop_s) if defined $crop_s; - $rule_pto->Command (@command, @{$group}); + $rule_pto->Command (@command, $temp_images->Paths); push @rules_pto, $rule_pto; @@ -128,40 +140,40 @@ push @rules_mk, $rule_mk; my $rule_ldr_blended = new Panotools::Makefile::Rule; - $rule_ldr_blended->Targets ($stub .".tif"); - $rule_ldr_blended->Prerequisites ("$stub.pto", "$stub.pto.mk", @{$group}); - $rule_ldr_blended->Command ('make', '-e', '-f', "$stub.pto.mk", $stub .".tif", '$(MAKE_EXTRA_ARGS)'); + $rule_ldr_blended->Targets ("$stub.tif"); + $rule_ldr_blended->Prerequisites ("$stub.pto", "$stub.pto.mk", $temp_images->Paths); + $rule_ldr_blended->Command ('$(MAKE)', '-e', '-f', "$stub.pto.mk", "$stub.tif", '$(MAKE_EXTRA_ARGS)'); push @rules_ldr_blended, $rule_ldr_blended; + my $stub_f = $stub .'_fused'; my $rule_ldr_stacked_blended = new Panotools::Makefile::Rule; - $rule_ldr_stacked_blended->Targets ($stub ."_fused.tif"); - $rule_ldr_stacked_blended->Prerequisites ("$stub.pto", "$stub.pto.mk", @{$group}); - $rule_ldr_stacked_blended->Command ('make', '-e', '-f', "$stub.pto.mk", $stub ."_fused.tif", '$(MAKE_EXTRA_ARGS)'); + $rule_ldr_stacked_blended->Targets ("$stub_f.tif"); + $rule_ldr_stacked_blended->Prerequisites ("$stub.pto", "$stub.pto.mk", $temp_images->Paths); + $rule_ldr_stacked_blended->Command ('$(MAKE)', '-e', '-f', "$stub.pto.mk", "$stub_f.tif", '$(MAKE_EXTRA_ARGS)'); push @rules_ldr_stacked_blended, $rule_ldr_stacked_blended; my $rule_ldr_blended_equirect = new Panotools::Makefile::Rule; $rule_ldr_blended_equirect->Targets ("$stub.mov", "$stub-sky.jpg", "$stub-planet.jpg", "$stub-mercator.jpg"); $rule_ldr_blended_equirect->Prerequisites ("$stub.pto", "$stub.pto.mk", "$stub.tif"); - $rule_ldr_blended_equirect->Command ('make', '-e', '-f', '$(HUGINDATADIR)/Makefile.equirect.mk', + $rule_ldr_blended_equirect->Command ('$(MAKE)', '-e', '-f', '$(HUGINDATADIR)/Makefile.equirect.mk', 'equirect_all', 'equirect_clean', "PTO=$stub.pto", 'FUSED_SUFFIX='); push @rules_ldr_blended_equirect, $rule_ldr_blended_equirect; - my $stub_f = $stub .'_fused'; my $rule_ldr_stacked_blended_equirect = new Panotools::Makefile::Rule; $rule_ldr_stacked_blended_equirect->Targets ("$stub_f.mov", "$stub_f-sky.jpg", "$stub_f-planet.jpg", "$stub_f-mercator.jpg"); $rule_ldr_stacked_blended_equirect->Prerequisites ("$stub.pto", "$stub.pto.mk", "$stub_f.tif"); - $rule_ldr_stacked_blended_equirect->Command ('make', '-e', '-f', '$(HUGINDATADIR)/Makefile.equirect.mk', + $rule_ldr_stacked_blended_equirect->Command ('$(MAKE)', '-e', '-f', '$(HUGINDATADIR)/Makefile.equirect.mk', 'equirect_all', 'equirect_clean', "PTO=$stub.pto", 'FUSED_SUFFIX=_fused'); push @rules_ldr_stacked_blended_equirect, $rule_ldr_stacked_blended_equirect; my $rule_hdr_blended = new Panotools::Makefile::Rule; $rule_hdr_blended->Targets ($stub ."_hdr.exr"); - $rule_hdr_blended->Prerequisites ("$stub.pto", "$stub.pto.mk", @{$group}); - $rule_hdr_blended->Command ('make', '-e', '-f', "$stub.pto.mk", $stub ."_hdr.exr", '$(MAKE_EXTRA_ARGS)'); + $rule_hdr_blended->Prerequisites ("$stub.pto", "$stub.pto.mk", $temp_images->Paths); + $rule_hdr_blended->Command ('$(MAKE)', '-e', '-f', "$stub.pto.mk", $stub ."_hdr.exr", '$(MAKE_EXTRA_ARGS)'); push @rules_hdr_blended, $rule_hdr_blended; } @@ -179,46 +191,17 @@ $rule_self->Prerequisites (@ARGV); $rule_self->Command ($0, @argv_save); -open MAKE, ">", $path_makefile or die "cannot write-open $path_makefile"; +push @makefile, $rule_phony, $rule_all, $rule_ptos, $rule_mks, $rule_imgs, $rule_movs; +push @makefile, $make_extra_args, $hugindatadir, $ap_extra_args; +push @makefile, @rules_pto, @rules_mk, @rules_ldr_blended, @rules_ldr_stacked_blended, + @rules_ldr_blended_equirect, @rules_ldr_stacked_blended_equirect, @rules_hdr_blended; +push @makefile, $rule_self; +open MAKE, ">", $path_makefile or die "cannot write-open $path_makefile"; print MAKE "# Created by Panotools::Script $Panotools::Script::VERSION\n"; -print MAKE $rule_phony->Assemble; -print MAKE $rule_all->Assemble; -print MAKE $rule_ptos->Assemble; -print MAKE $rule_mks->Assemble; -print MAKE $rule_imgs->Assemble; -print MAKE $rule_movs->Assemble; -print MAKE "MAKE_EXTRA_ARGS=clean\n"; -print MAKE "HUGINDATADIR=/usr/share/hugin\n"; -print MAKE "AP_EXTRA_ARGS=--clean\n\n"; -print MAKE map {$_->Assemble} @rules_pto; -print MAKE map {$_->Assemble} @rules_mk; -print MAKE map {$_->Assemble} @rules_ldr_blended; -print MAKE map {$_->Assemble} @rules_ldr_stacked_blended; -print MAKE map {$_->Assemble} @rules_ldr_blended_equirect; -print MAKE map {$_->Assemble} @rules_ldr_stacked_blended_equirect; -print MAKE map {$_->Assemble} @rules_hdr_blended; -print MAKE $rule_self->Assemble; - +print MAKE map {$_->Assemble} @makefile; close MAKE; -sub is_stacks -{ - return 0 if $nostacks; - my $speeds = {}; - for my $path_photo (@_) - { - my $exif_info = Image::ExifTool::ImageInfo ($path_photo, 'ExposureTime', 'ShutterSpeed'); - my $et = $exif_info->{ExposureTime} || $exif_info->{ShutterSpeed} || 0; - $speeds->{$et} = 'TRUE'; - } - - my $brackets = scalar keys (%{$speeds}); - return 0 if (scalar (@_) % $brackets); - return 0 if ($brackets < 2); - return 1; -} - __END__ =head1 NAME Modified: trunk/Panotools-Script/lib/Panotools/Makefile/Rule.pm =================================================================== --- trunk/Panotools-Script/lib/Panotools/Makefile/Rule.pm 2009-11-02 21:11:16 UTC (rev 1124) +++ trunk/Panotools-Script/lib/Panotools/Makefile/Rule.pm 2009-11-03 23:32:03 UTC (rev 1125) @@ -19,7 +19,7 @@ use strict; use warnings; -use Panotools::Makefile qw/platform/; +use Panotools::Makefile qw/quotetarget quoteprerequisite quoteshell/; =head1 USAGE @@ -110,59 +110,16 @@ return 0 unless scalar @{$self->{targets}}; my $text; - $text .= join ' ', (map { _quotetargets ($_)} @{$self->{targets}}); + $text .= join ' ', (map { quotetarget ($_)} @{$self->{targets}}); $text .= ' : '; - $text .= join ' ', (map { _quoteprerequisites ($_)} @{$self->{prerequisites}}); + $text .= join ' ', (map { quoteprerequisite ($_)} @{$self->{prerequisites}}); for my $command (@{$self->{command}}) { $text .= "\n\t"; - $text .= join ' ', (map { _quoteshell ($_)} @{$command}); + $text .= join ' ', (map { quoteshell ($_)} @{$command}); } $text .= "\n\n"; return $text; } -sub _quotetargets -{ - my $string = shift; - # Transform all C:\foo\bar paths to C:/foo/bar - $string =~ s/\\/\//g if (platform =~ /^(MSWin|dos)/); - $string =~ s/([ #|\\])/\\$1/g; - return $string; -} - -sub _quoteprerequisites -{ - my $string = shift; - # Transform all C:\foo\bar paths to C:/foo/bar - $string =~ s/\\/\//g if (platform =~ /^(MSWin|dos)/); - $string =~ s/([ #|\\])/\\$1/g; - return $string; -} - -sub _quoteshell -{ - my $string = shift; - if (platform =~ /^(MSWin|dos)/) - { - # ?<>:*|"^ are unusable in Windows filenames - # so the only thing we can quote is a space - $string =~ s/^(.* .*)$/"$1"/g; - # Transform all C:\foo\bar paths to C:/foo/bar - $string =~ s/\\/\//g; - } - else - { - # some shell char sequences are useful shell commands - # others are automatic variables $(<D) $(<F) $< - unless ($string =~ /^([&<>|]|2>|\|\||&&|2>&1|`.+`|\$\(<D\)|\$\(<F\)|\$<)$/) - { - $string =~ s/([#'"() `&<>|\\])/\\$1/g; - # unquote $(FOO) variables - $string =~ s/\$\\\(([^)]+)\\\)/\$($1)/g; - } - } - return $string; -} - 1; Added: trunk/Panotools-Script/lib/Panotools/Makefile/Variable.pm =================================================================== --- trunk/Panotools-Script/lib/Panotools/Makefile/Variable.pm (rev 0) +++ trunk/Panotools-Script/lib/Panotools/Makefile/Variable.pm 2009-11-03 23:32:03 UTC (rev 1125) @@ -0,0 +1,127 @@ +package Panotools::Makefile::Variable; + +=head1 NAME + +Panotools::Makefile::Variable - Assemble Makefile Variable definitions + +=head1 SYNOPSIS + +Simple interface for generating Makefile syntax + +=head1 DESCRIPTION + +Writing Makefiles directly from perl scripts with print and "\t" etc... is +prone to error, this library provides a simple perl interface for assembling +Makefiles. + +=cut + +use strict; +use warnings; + +use Panotools::Makefile qw/quotetarget quoteprerequisite quoteshell/; + +=head1 USAGE + + my $var = new Panotools::Makefile::Variable; + +..or define the 'variable name' and quoting style at the same time: + + my $var = new Panotools::Makefile::Variable ('USERS', 'shell'); + +=cut + +sub new +{ + my $class = shift; + $class = ref $class || $class; + my $self = bless {name => shift, value => [], quoting => shift}, $class; + return $self; +} + +=pod + +Set or query the name: + + $var->Name ('USERS'); + $text = $var->Name; + +=cut + +sub Name +{ + my $self = shift; + $self->{name} = shift if @_; + return $self->{name}; +} + +=pod + + $var->Values ('James Brine', 'George Loveless'); + $var->Values ('Thomas Standfield'); + +=cut + +sub Values +{ + my $self = shift; + push @{$self->{value}}, @_; + return $self->{value}; +} + +=pod + +By default spaces and special characters in values will be quoted/escaped +suitably for use within a Makefile 'command', other valid quoting styles are +'prerequisite' and 'target': + + $var->Quoting ('target'); + +(See L<Panotools::Makefile> for description of quoting styles) + +The variable name should not require escaping and should consist of safe +letters, numbers and the underscore: A-Z a-z 0-9 _ + +=cut + +sub Quoting +{ + my $self = shift; + $self->{quoting} = shift if @_; + return $self->{quoting}; +} + +=pod + +Construct a text fragment that defines this variable suitable for use in a +Makefile like so: + + $text = $var->Assemble; + +=cut + +sub Assemble +{ + my $self = shift; + return 0 unless defined $self->{name}; + + my $text; + $text .= quotetarget ($self->{name}); + $text .= ' = '; + if ($self->{quoting} eq 'target') + { + $text .= join ' ', (map { quotetarget ($_)} @{$self->{value}}); + } + elsif ($self->{quoting} eq 'prerequisite') + { + $text .= join ' ', (map { quoteprerequisite ($_)} @{$self->{value}}); + } + else + { + $text .= join ' ', (map { quoteshell ($_)} @{$self->{value}}); + } + $text .= "\n"; + return $text; +} + +1; Modified: trunk/Panotools-Script/lib/Panotools/Makefile.pm =================================================================== --- trunk/Panotools-Script/lib/Panotools/Makefile.pm 2009-11-02 21:11:16 UTC (rev 1124) +++ trunk/Panotools-Script/lib/Panotools/Makefile.pm 2009-11-03 23:32:03 UTC (rev 1125) @@ -22,13 +22,13 @@ use Exporter; use vars qw /@ISA @EXPORT_OK/; @ISA = qw /Exporter/; -@EXPORT_OK = qw /platform/; +@EXPORT_OK = qw /platform quotetarget quoteprerequisite quoteshell/; our $PLATFORM; =head1 USAGE - use Panotools::Makefile qw/platform/; + use Panotools::Makefile qw/platform quotetarget quoteprerequisite quoteshell/; Access the current platform name (MSWin32, linux, etc...): @@ -52,4 +52,76 @@ return $^O; } +=pod + +Take a text string (typically a single filename or path) and quote/escape +spaces and special characters to make it suitable for use as a Makefile +'target' or 'prerequisite': + + $escaped_target = quotetarget ('My Filename.txt'); + $escaped_prerequisite = quoteprerequisite ('My Filename.txt'); + +Note that the =;:%$ characters are not usable as filenames, they may be used as +control characters in a target or prerequisite. An exception is the : in +Windows paths such as C:\WINDOWS which is understood by gnu make. + +Additionally the ?<>*|"^\ characters are not portable across filesystems (e.g. +USB sticks, CDs, Windows) and should be avoided in filenames. + +=cut + +sub quotetarget +{ + my $string = shift; + # Transform all C:\foo\bar paths to C:/foo/bar + $string =~ s/\\/\//g if (platform =~ /^(MSWin|dos)/); + $string =~ s/([ #|\\])/\\$1/g; + return $string; +} + +sub quoteprerequisite +{ + my $string = shift; + # Transform all C:\foo\bar paths to C:/foo/bar + $string =~ s/\\/\//g if (platform =~ /^(MSWin|dos)/); + $string =~ s/([ #|\\])/\\$1/g; + return $string; +} + +=pod + +Take a text string, typically a command-line token, and quote/escape spaces and +special characters to make it suitable for use in a Makefile command: + + $escaped_token = quoteshell ('Hello World'); + +=cut + +sub quoteshell +{ + my $string = shift; + if (platform =~ /^(MSWin|dos)/) + { + # ?<>:*|"^ are unusable in Windows filenames, + # other unix shell characters are unspecial in Windows + # so the only thing we can quote is a space + $string = '"'.$string.'"' if $string =~ / /; + # Transform all C:\foo\bar paths to C:/foo/bar + # Not all token are file paths, so \:-) will become /:-) + $string =~ s/\\/\//g; + } + else + { + # some shell char sequences are useful shell commands + # others are automatic variables $(<D) $(<F) $< + unless ($string =~ /^([&<>|]|2>|\|\||&&|2>&1|`.+`|\$\(<D\)|\$\(<F\)|\$<)$/) + { + $string =~ s/([#'"() `&<>|\\])/\\$1/g; + # unquote $(FOO) variables + $string =~ s/\$\\\(([^)]+)\\\)/\$($1)/g; + } + } + return $string; +} + 1; Added: trunk/Panotools-Script/lib/Panotools/Photos.pm =================================================================== --- trunk/Panotools-Script/lib/Panotools/Photos.pm (rev 0) +++ trunk/Panotools-Script/lib/Panotools/Photos.pm 2009-11-03 23:32:03 UTC (rev 1125) @@ -0,0 +1,112 @@ +package Panotools::Photos; + +=head1 NAME + +Panotools::Photos - Photo groups + +=head1 SYNOPSIS + +Query lists of photos + +=head1 DESCRIPTION + +A collection of photos has possiblities, it could be one or more panoramas or a +bracketed set. This module provides some methods for describing grups of +photos based on available metadata + +=cut + +use strict; +use warnings; + +use File::Spec; +use Image::ExifTool; + +=head1 USAGE + +=cut + +sub new +{ + my $class = shift; + $class = ref $class || $class; + my $self = bless {images => [@_]}, $class; + return $self; +} + +=pod + +Construct a stub filename from the names of the first and last images in the +list. + + my $stub = $photos->Stub; + +e.g. DSC_0001.JPG DSC_0002.JPG DSC_0003.JPG -> DSC_0001-DSC_0003 + +=cut + +sub Stub +{ + my $self = shift; + my $path_a = $self->{images}->[0]; + my $path_b = $self->{images}->[-1]; + # strip any suffixes + $path_a =~ s/\.[[:alnum:]]+$//; + $path_b =~ s/\.[[:alnum:]]+$//; + # strip all but filename + $path_b =~ s/.*[\/\\]//; + return $path_a .'-'. $path_b; +} + +=pod + +Add to or get the list of image filenames: + + $photos->Paths ('DSC_0001.JPG', 'DSC_0002.JPG'); + my @paths = $photos->Paths; + +=cut + +sub Paths +{ + my $self = shift; + push @{$self->{images}}, @_; + return @{$self->{images}}; +} + +=pod + +Query to discover if this is a likely bracketed set. i.e. is the total number +of photos divisible by the number of different exposures: + + &do_stuff if ($photos->Bracketed); + +Note this can't tell the difference between a single bracketed stack and a +series of photos taken on auto-exposure. + +=cut + +sub Bracketed +{ + my $self = shift; + my $speeds = {}; + for my $path_photo ($self->Paths) + { + my $exif_info = Image::ExifTool::ImageInfo ($path_photo, 'ExposureTime', 'ShutterSpeed'); + my $et = $exif_info->{ExposureTime} || $exif_info->{ShutterSpeed} || 0; + $speeds->{$et} = 'TRUE'; + } + + my $brackets = scalar keys (%{$speeds}); + return 0 if (scalar (@_) % $brackets); + return 0 if ($brackets < 2); + return 1; +} + +sub SplitDate +{ + my $self = shift; + # TODO +} + +1; Added: trunk/Panotools-Script/t/104.metachars.t =================================================================== --- trunk/Panotools-Script/t/104.metachars.t (rev 0) +++ trunk/Panotools-Script/t/104.metachars.t 2009-11-03 23:32:03 UTC (rev 1125) @@ -0,0 +1,28 @@ +#!/usr/bin/perl +#Editor vim:syn=perl + +use strict; +use warnings; +use Test::More 'no_plan'; +use lib 'lib'; + +use Panotools::Makefile::Rule; +use Panotools::Makefile qw/platform/; +ok (1); + +my $rule = new Panotools::Makefile::Rule; + +$rule->Targets ('%.1'); +$rule->Prerequisites ('%.pod'); +$rule->Command ('pod2man', '--center', '$(PACKAGE)', '--release', '$(PACKAGE_VERSION)', '$<', '$@'); +$rule->Command ('echo', '`uname -a`', '>', '$(TMPDIR)/foo'); +$rule->Command ('uname', '-a', '>', '${TMPDIR}/bar', '&&', 'echo', '" ### (woo!) ### "'); + +platform ('linux'); + +print $rule->Assemble; + +ok ($rule->Assemble =~ /%.1 : %.pod/); +ok ($rule->Assemble =~ /\tpod2man --center \$\(PACKAGE\) --release \$\(PACKAGE_VERSION\) \$< \$@/); +ok ($rule->Assemble =~ /\techo `uname -a` > \$\(TMPDIR\)\/foo/); +ok ($rule->Assemble =~ /\tuname -a > \${TMPDIR}\/bar && echo \\"\\ \\#\\#\\#\\ \\\(woo!\\\)\\ \\#\\#\\#\\ \\"/); Added: trunk/Panotools-Script/t/105.vars.t =================================================================== --- trunk/Panotools-Script/t/105.vars.t (rev 0) +++ trunk/Panotools-Script/t/105.vars.t 2009-11-03 23:32:03 UTC (rev 1125) @@ -0,0 +1,43 @@ +#!/usr/bin/perl +#Editor vim:syn=perl + +use strict; +use warnings; +use Test::More 'no_plan'; +use lib 'lib'; + +use Panotools::Makefile::Variable; +use Panotools::Makefile qw/platform/; +ok (1); + +my $var = new Panotools::Makefile::Variable; + +$var->Name ('USERS'); + +$var->Values ('James Brine', 'George Loveless'); +$var->Values ('Thomas Standfield'); +$var->Quoting ('shell'); + +platform ('MSWin32'); + +ok ($var->Assemble =~ /USERS = "James Brine" "George Loveless" "Thomas Standfield"/); + +platform ('linux'); + +ok ($var->Assemble =~ /USERS = James\\ Brine George\\ Loveless Thomas\\ Standfield/); + +undef $var; + +my $var2 = new Panotools::Makefile::Variable ('USERS', 'shell'); + +$var2->Values ('James Brine', 'George Loveless'); +$var2->Values ('Thomas Standfield'); + +platform ('MSWin32'); + +ok ($var2->Assemble =~ /USERS = "James Brine" "George Loveless" "Thomas Standfield"/); + +platform ('linux'); + +ok ($var2->Assemble =~ /USERS = James\\ Brine George\\ Loveless Thomas\\ Standfield/); + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |