#-------------------------------------------------------------------------------------------------- # Standard modularization template # -------------------------------- # # The script will start execution from . # # Available variables: # $qtdir = or where you started the modularize script from # $basepath = path for the modularize script, and basepath for the modularization repo # $OStype = where is one of 0 = Windows, 1 = Unix, 2 = Mac # # To execute a command: # run("git mv foo bar") # runs command, reports error possition and dies # runNotDie("git mv foo bar") # runs command, reports error possition, returns error code # and continues. Use ($? >> 8) to get the real exit code. # ensureDir("qtbase") # Ensures that qtbase exists and is a directory. Will create # it if it does not exist. #-------------------------------------------------------------------------------------------------- ensureDir("qtdeclarative/doc/src"); ensureDir("qtbase/doc/src"); ensureDir("qtactiveqt/doc/src"); ensureDir("qtscript/doc/src"); ensureDir("qt3support/doc/src"); ensureDir("qtxmlpatterns/doc/src"); ensureDir("qtxmlpatterns/doc/src/snippets"); run("git mv doc/src/declarative qtdeclarative/doc/src/"); run("git mv doc/src/files-and-resources qtbase/doc/src/"); run("git mv doc/src/frameworks-technologies/activeqt* qtactiveqt/doc/src/"); # run("git mv doc/src/frameworks-technologies qtbase/doc/src/"); # run("git mv doc/src/internationalization qtbase/doc/src/"); run("git mv doc/src/network-programming qtbase/doc/src/"); run("git mv doc/src/objectmodel qtbase/doc/src/"); run("git mv doc/src/painting-and-printing qtbase/doc/src/"); run("git mv doc/src/porting qt3support/doc/src/"); run("git mv doc/src/scripting qtscript/doc/src/"); run("git mv doc/src/widgets-and-layouts qtbase/doc/src/"); run("git mv doc/src/windows-and-dialogs qtbase/doc/src/"); run("git mv doc/src/xml-processing qtxmlpatterns/doc/src/"); run("git mv doc/src/sql-programming qtbase/doc/src/"); run("git mv doc/src/tutorials qtbase/doc/src/"); run("git mv doc/src/snippets/patternist qtxmlpatterns/doc/src/snippets/"); #TODO: to be completed run("git mv doc/src/examples/activeqt qtactiveqt/doc/src/examples"); my @processed; sub processFileRecursive { my $module = $_[0]; my $file = $_[1]; my $recursive = $_[2]; if (grep ($_ eq $file, @processed)) { return; } push @processed, $file; my $readFd; open($readFd, "< $file") or die("Could not open $file"); while (<$readFd>) { if (/(doc\/src\/[a-zA-Z_\-0-9\.\/]+)/) { $candidate = $1; if (-e "$candidate") { ensureDir(dirname("$module/$candidate")); run("git mv $candidate $module/$candidate"); processFileRecursive($module, "$module/$candidate", 1) if $recursive; } elsif (!-e "$module/$candidate"){ print("NOT FOUND! $candidate for $module ($file)\n") } } elsif (/\\image ([a-zA-Z_\-0-9\.\/]+.png)/) { $candidate = "doc/src/images/$1"; if (-e "$candidate") { ensureDir(dirname("$module/$candidate")); run("git mv $candidate $module/$candidate"); } elsif (!-e "$module/$candidate"){ print("NOT FOUND! $candidate for $module ($file)\n") } } } close($readFd); } sub processModule { my $module = $_[0]; # 1) parse all .cpp files (and .qdoc) in the module src/ folder # to find references to doc files. foreach my $file (findFiles("$module/src", ".*\\.(cpp|qdoc|mm)", 1)) { processFileRecursive($module, $file, 0); } # 2) look at the examples foreach my $example (findFiles("$module/examples", ".*\\.pro", 1)) { $fn = basename(dirname($example)); $candidate = "doc/src/examples/$fn.qdoc"; if (-e "$candidate") { ensureDir(dirname("$module/$candidate")); run("git mv $candidate $module/$candidate"); } } # 3) look at the demos foreach my $demo (findFiles("$module/demos", ".*\\.pro", 1)) { $fn = basename(dirname($demo)); $candidate = "doc/src/demos/$fn.qdoc"; if (-e "$candidate") { ensureDir(dirname("$module/$candidate")); run("git mv $candidate $module/$candidate"); } } # 4) look up in the docs recursively for more references foreach my $file (findFiles("$module/doc", ".*\\.(cpp|qdoc)", 1)) { processFileRecursive($module, $file, 1); } } processModule("qtbase"); processModule("qtsvg"); processModule("qtxmlpatterns"); processModule("qtscript"); processModule("qtdeclarative"); processModule("qtactiveqt"); processModule("qt3support"); processModule("qtphonon"); #this one is only referenced by the test file run("git mv doc/src/snippets/code/src_xmlpatterns_api_qsimplexmlnodemodel.cpp qtxmlpatterns/doc/src/snippets/code/"); #move the remaining run("git mv doc qtdoc/"); #profiles createSubdirProfile("qtdoc/tools"); open PRO, ">qtdoc/qtdoc.pro" || die "Could not open qtqdoc.pro for writing!\n"; print PRO "TEMPLATE = subdirs \n"; print PRO "SUBDIRS = tools demos\n"; print PRO "include(doc/doc.pri)\n"; close PRO; run("git add qtdoc/qtdoc.pro"); return 1;