[svn:parrot] r48179 - in trunk/config: gen init

chromatic at svn.parrot.org chromatic at svn.parrot.org
Mon Jul 26 02:50:55 UTC 2010


Author: chromatic
Date: Mon Jul 26 02:50:55 2010
New Revision: 48179
URL: https://trac.parrot.org/parrot/changeset/48179

Log:
[config] Allow spaces in build directory.

This is the first step to allow people with spaces in their build directories
to build Parrot.  pbc_to_exe needs additional logic to escape spaces in paths,
but that's a bigger challenge for later.  Tests pass for me on a checkout
without spaces too.

Modified:
   trunk/config/gen/config_pm.pm
   trunk/config/init/defaults.pm

Modified: trunk/config/gen/config_pm.pm
==============================================================================
--- trunk/config/gen/config_pm.pm	Sun Jul 25 23:44:29 2010	(r48178)
+++ trunk/config/gen/config_pm.pm	Mon Jul 26 02:50:55 2010	(r48179)
@@ -65,6 +65,10 @@
     open( my $OUT, ">", $gen_pm )
         or die "Can't open $gen_pm: $!";
 
+    # escape spaces in current directory
+    my $cwd = cwd();
+    $cwd =~ s{ }{\\ }g;
+
     my $pkg = __PACKAGE__;
     print {$OUT} <<"END";
 # ex: set ro:
@@ -117,7 +121,8 @@
                         die "type of '$k' is not supported : $type\n";
                     }
                     # String
-                    $v =~ s/(["\\])/\\$1/g;
+                    # escape unescaped double quotes
+                    $v =~ s/(?<!\\)"/\\"/g;
                     $v =~ s/\n/\\n/g;
                     my $charset = q{};
                     if ($v =~ /[^[:ascii:]]/) {
@@ -131,7 +136,7 @@
                 }
             }
         }
-        elsif (s/\@PWD\@/cwd/e) {
+        elsif (s/\@PWD\@/$cwd/) {
             print {$OUT} $_;
         }
         else {

Modified: trunk/config/init/defaults.pm
==============================================================================
--- trunk/config/init/defaults.pm	Sun Jul 25 23:44:29 2010	(r48178)
+++ trunk/config/init/defaults.pm	Mon Jul 26 02:50:55 2010	(r48179)
@@ -80,13 +80,17 @@
     my $ccdlflags = $Config{ccdlflags};
     $ccdlflags =~ s/\s*-Wl,-rpath,\S*//g if $conf->options->get('disable-rpath');
 
+    # escape spaces in build directory
+    my $build_dir =  abs_path($FindBin::Bin);
+    $build_dir    =~ s{ }{\\ }g;
+
     my $cc_option = $conf->options->get('cc');
     # We need a Glossary somewhere!
     $conf->data->set(
         debugging => $conf->options->get('debugging') ? 1 : 0,
         optimize  => '',
         verbose   => $conf->options->get('verbose'),
-        build_dir => abs_path($FindBin::Bin),
+        build_dir => $build_dir,
         configured_from_file =>
             $conf->options->get('configured_from_file') || '',
         configuration_steps => ( join q{ } => $conf->get_list_of_steps() ),


More information about the parrot-commits mailing list