#!/usr/bin/perl use File::Basename; print <\"; };\n" } print "/* End PBXFileReference section */\n\n"; print "/* Begin PBXGroup section */\n"; my $sourcesUID = uid(); printGroup("Sources",$sourcesUID,\%sourceTree,"./"); my $headersUID = uid(); printGroup("Headers",$headersUID,\%headerTree,"./"); my $mainUID = uid(); print <) { chomp($f); my ($filename, $dummydir, $suffix) = fileparse($f); my @dirs = split(/\//,$f); shift(@dirs); pop(@dirs); my $treeP; if ($type =~ m/sourcecode\..*\.h/) { $treeP = \%headerTree; } else { $treeP = \%sourceTree; } foreach my $d (@dirs) { if (not exists $treeP->{$d}) { my %subTree = (); my @child = (uid(), \%subTree); $treeP->{$d} = [@child]; } $treeP = $treeP->{$d}[1]; } $treeP->{$filename} = ""; my @r = (uid(), $filename, $type); $files{$f} = [@r]; } close (F); } sub uid { my $uid = `uuidgen`; $uid =~ /[A-Z0-9]+-([A-Z0-9]+)-([A-Z0-9]+)-([A-Z0-9]+)-([A-Z0-9]+)/; return $1.$2.$3.$4; } sub printGroup { my $g = $_[0]; my $id = $_[1]; my $treeP = $_[2]; my $path = $_[3]; print " ".$id. " /* ".$g." */ = {\n"; print " isa = PBXGroup;\n"; print " children = (\n"; foreach my $k (sort keys %{$treeP}) { if (exists $treeP->{$k}[0]) { print " ".$treeP->{$k}[0]." /* ".$k." */,\n"; } else { print " ".$files{$path.$k}[0]." /* ".$k." */,\n"; } } print " );\n"; if ($path eq "./") { print " path = \".\";\n"; print " name = \"$g\";\n"; } else { print " path = \"$g\";\n"; } print " sourceTree = \"\";\n };\n"; foreach my $k (keys %{$treeP}) { if (exists $treeP->{$k}[0]) { printGroup($k, $treeP->{$k}[0], $treeP->{$k}[1], $path.$k."/"); } } }