Last active
December 18, 2016 09:30
-
-
Save harmo/9cca674052d228048f5c to your computer and use it in GitHub Desktop.
Function for create a MANIFEST file since makefile content
Based on the first # before each target
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$salt = 'zo5pro$1pvkhj6*cz4a8ùtvb#ui4oeuio'; | |
$aFunctions = array(); | |
$file = explode("\n", file_get_contents('makefile')); | |
if(!empty($file)){ | |
foreach ($file as $key => $line) { | |
if(preg_match('/^#(.+)$/', $line, $matches) !== false && !empty($matches)){ | |
$aFunctions[] = array( | |
'label' => $matches[1], | |
'target' => $file[$key + 1], | |
'crypted' => sha1(sha1($file[$key + 1]) . $salt) | |
); | |
} | |
} | |
} | |
$manifest = fopen(dirname(__FILE__).'/MANIFEST', 'w'); | |
fwrite($manifest, '{'."\n"); | |
foreach($aFunctions as $key => $aFunction){ | |
$crypt = substr($aFunction['crypted'], 0, (strlen($aFunction['crypted']) / 2)); | |
$target = substr($aFunction['target'], 0, -1); | |
$endline = $key < count($aFunctions) - 1 ? ',' : null; | |
fwrite($manifest, "\t".'"'.$crypt.'": "'.$target.'"'.$endline."\n"); | |
} | |
fwrite($manifest, '}'); | |
fclose($manifest); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment