require_once ABSPATH_MEGALIB . 'SourceCode.php'; require_once ABSPATH_MEGALIB . 'SourceFileSystem.php'; require_once ABSPATH_MEGALIB . 'FileSystemMatcher.php'; ini_set('memory_limit', '80182M'); echo "WARNING: this script is eager in term of memory.\n"; echo " Because of php poor memory managment, out of memory errors might occur.\n"; echo " In this case change the value of sourceDirectoryScanningMethod in Makefile.var to 'perSubDirectories' \n"; echo ""; echo "sourceDirectoryScanningMethod={$sourceDirectoryScanningMethod}\n"; echo "sourceDirectoryMatchingRules={$sourceDirectoryMatchingRules}\n"; $matcher = new RuleBasedFileSystemPatternMatcher($sourceDirectoryMatchingRules); echo $matcher->getRulesNumber() . " rules where found."; echo "In this module rules are particularily important to define the 'elementKind' and 'geshiLanguage' properties "; if ($sourceDirectoryScanningMethod === 'full') { echo "Scanning the whole directory {$mainDirectory} at once.\n"; echo "this has the benefit of generating top level summary in {$targetBaseDirectory}\n"; $srcdir = new SourceTopDirectory($baseDirectory, $mainDirectory, array(), $matcher); echo "generating the result in {$targetBaseDirectory}\n"; $srcdir->generate($targetBaseDirectory); } else { $subdirectories = listFileNames(addToPath($baseDirectory, $mainDirectory), 'dir'); echo "Scanning all " . count($subdirectories) . " subdirectories one by one.\n"; foreach ($subdirectories as $subdirectory) { $directoryToScan = addToPath($mainDirectory, basename($subdirectory)); echo "\n\n====== scanning subdirectory {$directoryToScan} ================\n"; $srcdir = new SourceTopDirectory($baseDirectory, $directoryToScan, array(), $matcher); echo "generating the result in {$targetBaseDirectory}\n"; $srcdir->generate($targetBaseDirectory); } } echo "generation was successfull\n";
<?php $n = 0; error_reporting(E_ALL); $thisScript = $argv[$n++]; $rulesFile = $argv[$n++]; $baseDirectory = $argv[$n++]; $targetDirectory = $argv[$n++]; $mainDirectory = $argv[$n++]; require_once '../../configs/main.config.local.php'; echo "Using megalib from " . ABSPATH_MEGALIB . "\n"; require_once ABSPATH_MEGALIB . 'SourceCode.php'; require_once ABSPATH_MEGALIB . 'Structures.php'; require_once ABSPATH_MEGALIB . 'FileSystemMatcher.php'; echo "Loading the rules from {$rulesFile}\n"; $json = file_get_contents($rulesFile); if ($json === false) { die("cannot open {$rulesFile}"); } $rules = jsonDecodeAsMap($json); echo "They are " . count($rules) . " rules\n"; $matcher = new RuleBasedFileSystemPatternMatcher($rules); $matchedFilesGrouping = array('languages' => array('select' => array('locator', 'geshiLanguage'), 'groupedBy' => 'language'), 'technologies' => array('select' => array('role'), 'groupedBy' => 'technology')); $sourceDir = addToPath($baseDirectory, $mainDirectory); $resultDir = addToPath(addToPath($targetDirectory, $mainDirectory), '.rulesMatches'); echo "Match directory {$sourceDir}. The results are generated in {$resultDir}\n"; $matcher->generate($sourceDir, $resultDir, $matchedFilesGrouping, array('language', 'technology')); echo "done";
<?php $n = 0; $thisScript = $argv[$n++]; $sourceBaseDirectory = $argv[$n++]; $targetBaseDirectory = $argv[$n++]; $mainDirectory = $argv[$n++]; $sourceDirectoryMatchingRules = $argv[$n++]; $tmpDirectory = $argv[$n++]; $commandsBaseDirectory = $argv[$n++]; require_once '../../configs/main.config.local.php'; echo "Using megalib from " . ABSPATH_MEGALIB; require_once ABSPATH_MEGALIB . 'Fragments.php'; echo "=== Creating the reader with rules from {$sourceDirectoryMatchingRules}\n"; $reader = new TaggedFragmentSetReader($sourceDirectoryMatchingRules); $sourceDirectory = addToPath($sourceBaseDirectory, $mainDirectory); echo "=== Reading tagged fragment definitions from {$sourceDirectory}\n"; $taggedFragmentSet = $reader->read($sourceDirectory); $nbErrors = count($reader->getErrors()); if ($nbErrors !== 0) { echo "--> {$nbErrors} error(s) found\n"; echo $reader->getErrorsAsJson(true); echo "\n"; } if (DEBUG > 10) { echo htmlAsIs($taggedFragmentSet->asJson(true)); } echo "=== Applying locators to find fragment location\n"; echo " using {$tmpDirectory} as a temporary directory and {$commandsBaseDirectory}\n"; $locatorIterator = new FragmentLocatorIterator($tmpDirectory, $commandsBaseDirectory); $locatorIterator->addLocationToAllFragments($taggedFragmentSet, true);