Skip to content

Instantly share code, notes, and snippets.

@harmo
Last active December 18, 2016 09:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save harmo/9cca674052d228048f5c to your computer and use it in GitHub Desktop.
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
<?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