From: <rha...@us...> - 2003-08-05 01:47:09
|
Update of /cvsroot/binaryphp/binaryphp In directory sc8-pr-cvs1:/tmp/cvs-serv1011 Modified Files: convert.php Log Message: Index: convert.php =================================================================== RCS file: /cvsroot/binaryphp/binaryphp/convert.php,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** convert.php 5 Aug 2003 00:49:04 -0000 1.20 --- convert.php 5 Aug 2003 01:47:06 -0000 1.21 *************** *** 1,5 **** #!/usr/bin/php <?php ! function showUsage() { --- 1,5 ---- #!/usr/bin/php <?php ! function showUsage() { *************** *** 11,15 **** for($i = 1; $i <= $_SERVER['argc']; ++$i) { if(@$_SERVER['argv'][$i] == '-v' OR @$_SERVER['argv'][$i] == '--verbose') { ! define('DEBUG', true); } if(@$_SERVER['argv'][$i] == '--if') { --- 11,15 ---- for($i = 1; $i <= $_SERVER['argc']; ++$i) { if(@$_SERVER['argv'][$i] == '-v' OR @$_SERVER['argv'][$i] == '--verbose') { ! $debug = true; } if(@$_SERVER['argv'][$i] == '--if') { *************** *** 20,23 **** --- 20,24 ---- $output = ''; $output = $_SERVER['argv'][$i + 1]; + $outputfile = $output . '.cpp'; } if(@$_SERVER['argv'][$i] == '--help' OR @$_SERVER['argv'][$i] == '-h') { *************** *** 39,42 **** --- 40,49 ---- } + if($debug == true) { + define('DEBUG', true); + } else { + define('DEBUG', false); + } + if (substr(PHP_OS, 0, 3) == 'WIN') { define('BINARYPHP_OS', 'Windows'); *************** *** 45,52 **** } error_reporting(E_ALL); - if(@$_SERVER['argv'][1]=='debug') - define('DEBUG', true); - else - define('DEBUG', false); if(!empty($_SERVER['DOCUMENT_ROOT'])) header('Content-Type: text/plain'); --- 52,55 ---- *************** *** 60,66 **** list($code, $flags) = $gen->Convert(); $lines = explode("\n", $code); foreach($lines as $line => $cod) echo $line + 1, ': ', $cod, "\n"; ! $fp = fopen('test.cpp', 'wt'); fwrite($fp, $code); fclose($fp); --- 63,71 ---- list($code, $flags) = $gen->Convert(); $lines = explode("\n", $code); + if(DEBUG == true) { foreach($lines as $line => $cod) echo $line + 1, ': ', $cod, "\n"; ! } ! $fp = fopen($output . '.cpp', 'wt'); fwrite($fp, $code); fclose($fp); *************** *** 68,72 **** touch('log'); if(BINARYPHP_OS == 'Windows') { ! $comp = 'cl -c /nologo /MT /W3 /GX /FD -DWIN32 /Fotest.obj test.cpp >> log'; echo $comp, "\n\n"; shell_exec($comp); --- 73,77 ---- touch('log'); if(BINARYPHP_OS == 'Windows') { ! $comp = 'cl -c /nologo /MT /W3 /GX /FD -DWIN32 /Fotest.obj ' . $outputfile . ' >> log'; echo $comp, "\n\n"; shell_exec($comp); *************** *** 75,83 **** else $opt='-$comp'; ! $release = 'link test.obj -nologo ' .$opt .' -incremental:no -opt:ref '.$flags.' -out:' . $output . ' >> log'; echo $comp, "\n\n"; shell_exec($comp); } else { ! $comp = 'g++ -o ' . $output . ' test.cpp ' . $flags . ' >> log 2>> log'; echo $comp, "\n\n"; shell_exec($comp); --- 80,88 ---- else $opt='-$comp'; ! $release = 'link ' .$output . '.obj -nologo ' .$opt .' -incremental:no -opt:ref '.$flags.' -out:' . $output . ' >> log'; echo $comp, "\n\n"; shell_exec($comp); } else { ! $comp = 'g++ -o ' . $output . ' ' .$outputfile. ' '. $flags . ' >> log 2>> log'; echo $comp, "\n\n"; shell_exec($comp); *************** *** 85,104 **** echo implode(null, file('log')); unlink('log'); - echo "\n\n", 'Running:', "\n"; - if(BINARYPHP_OS == 'Windows') { - passthru('test.exe'); - if(!DEBUG) { - unlink('test.exe'); - shell_exec('del *.obj'); - shell_exec('del *.idb'); - if(is_file('test.pdb')) - unlink('test.pdb'); - } - } else { - passthru('./' . $output); - if(!DEBUG) - unlink($output); - } - if(!DEBUG) - unlink('test.cpp'); ?> --- 90,92 ---- |