/** @} */ # End job queue }
+/************************************************************************//**
+ * @name HipHop compilation
+ * @{
+ */
+
+/**
+ * The HipHop build type. Can be either "Debug" or "Release".
+ */
+$wgHipHopBuildType = 'Debug';
+
+/**
+ * Number of parallel processes to use during HipHop compilation, or "detect"
+ * to guess from system properties.
+ */
+$wgHipHopCompilerProcs = 'detect';
+
+/** @} */ # End of HipHop compilation }
+
+
/************************************************************************//**
* @name Miscellaneous
* @{
}
return $r !== false;
}
+
+ /**
+ * Call a static method of a class with variable arguments without causing
+ * it to become volatile.
+ */
+ static function callStaticMethod( $className, $methodName, $args ) {
+ $r = new ReflectionMethod( $className, $methodName );
+ return $r->invokeArgs( null, $args );
+ }
}
require_once( "$IP/includes/Hooks.php" );
require_once( "$IP/includes/ProxyTools.php" );
require_once( "$IP/includes/ImageFunctions.php" );
+ require_once( "$IP/includes/normal/UtfNormalDefines.php" );
wfProfileOut( $fname . '-includes' );
}
-require_once( MWInit::compiledPath( 'includes/normal/UtfNormalDefines.php' ) );
wfProfileIn( $fname . '-misc1' );
function newFatal( $message /*, parameters...*/ ) {
$params = func_get_args();
array_unshift( $params, $this );
- return call_user_func_array( array( 'FileRepoStatus', 'newFatal' ), $params );
+ return MWInit::callStaticMethod( 'FileRepoStatus', 'newFatal', $params );
}
/**
}
if( $return === true ) {
# True (treat as plain link) was returned, call the defaultLinkHook
- $args = array( $parser, $holders, $markers, $title, $titleText, &$paramText, &$leadingColon );
- $return = call_user_func_array( array( 'CoreLinkFunctions', 'defaultLinkHook' ), $args );
+ $return = CoreLinkFunctions::defaultLinkHook( $parser, $holders, $markers, $title,
+ $titleText, $paramText, $leadingColon );
}
if( $return === false ) {
# False (no link) was returned, output plain wikitext
);
}
- $this->mMaxUploadSize['file'] = min(
- wfShorthandToInteger( ini_get( 'upload_max_filesize' ) ),
- UploadBase::getMaxUploadSize( 'file' ) );
+ $this->mMaxUploadSize['file'] = UploadBase::getMaxUploadSize( 'file' );
+ # Limit to upload_max_filesize unless we are running under HipHop and
+ # that setting doesn't exist
+ if ( !wfIsHipHop() ) {
+ $this->mMaxUploadSize['file'] = min( $this->mMaxUploadSize['file'],
+ wfShorthandToInteger( ini_get( 'upload_max_filesize' ) ) );
+ }
$descriptor['UploadFile'] = array(
'class' => 'UploadSourceField',
}
# Check php's file_uploads setting
- if( !wfIniGetBool( 'file_uploads' ) ) {
+ if( !wfIsHipHop() && !wfIniGetBool( 'file_uploads' ) ) {
return false;
}
return true;
# does *not* load $wgTitle
require ( dirname( __FILE__ ) . '/includes/WebStart.php' );
-wfIndexMain();
+try {
+ wfIndexMain();
+} catch ( Exception $e ) {
+ wfExceptionHandler( $e );
+}
function wfIndexMain() {
global $wgRequest, $wgShowHostnames, $mediaWiki, $wgTitle, $wgUseAjax, $wgUseFileCache;
require( dirname( __FILE__ ) . '/../Maintenance.php' );
class MakeHipHop extends Maintenance {
-
function execute() {
$startTime = time();
' --parse-on-demand=false' .
' --program=mediawiki-hphp' .
' --output-dir=' . wfEscapeShellArg( $outDir ) .
- ' --log=3' );
+ ' --log=3', $ret );
+
+ if ( $ret ) {
+ $this->error( "hphp hit an error. Stopping build.\n" );
+ exit( 1 );
+ }
# Sanity check, quickly make sure we've got an output directory
if( !is_dir( $outDir ) ) {
$this->error( "No output directory", true );
}
+ # Warn about volatile classes
+ $this->checkVolatileClasses( $outDir );
+
# Copy the generated C++ files into the source directory for cmake
$iter = new RecursiveIteratorIterator(
new RecursiveDirectoryIterator( $outDir ),
}
$cmd = 'cmake' .
- ' -D CMAKE_BUILD_TYPE:string=Debug' .
+ " -D CMAKE_BUILD_TYPE:string=" . wfEscapeShellArg( $GLOBALS['wgHipHopBuildType'] ) .
' -D PROGRAM_NAME:string=mediawiki-hphp';
if ( file_exists( '/usr/bin/ccache' ) ) {
# Determine appropriate make concurrency
# Compilation can take a lot of memory, let's assume that that is limiting.
- $mem = false;
- foreach ( file( '/proc/meminfo' ) as $line ) {
- if ( preg_match( '/^MemTotal:\s+(\d+)\s+kB/', $line, $m ) ) {
- $mem = intval( $m[1] );
- break;
- }
- }
- if ( $mem ) {
- $procs = floor( $mem / 1000000 );
- $procs = $procs >= 1 ? $procs : 1; // No less than 1
- } else {
- $procs = 1;
- }
+ $procs = $this->getNumProcs();
# Run make. This is the slow step.
passthru( 'make -j' . wfEscapeShellArg( $procs ) );
echo $elapsed . "s\n";
echo "The MediaWiki executable is at build/persistent/mediawiki-hphp\n";
}
+
+ function checkVolatileClasses( $dir ) {
+ $lines = file( "$dir/sys/dynamic_table_class.cpp" );
+ $classes = array();
+ foreach ( $lines as $line ) {
+ if ( preg_match( '/^\s+\(const char \*\)"([^"]*)", \(const char \*\)-1/', $line, $m ) ) {
+ $classes[] = $m[1];
+ }
+ }
+ if ( !count( $classes ) ) {
+ print "No volatile classes found\n";
+ return;
+ }
+ sort( $classes );
+ $classes = array_unique( $classes );
+ print "WARNING: The following classes are volatile: " . implode( ', ', $classes ) . "\n";
+ }
+
+ function getNumProcs() {
+ global $wgHipHopCompilerProcs;
+ if ( $wgHipHopCompilerProcs !== 'detect' ) {
+ return intval( $wgHipHopCompilerProcs );
+ }
+
+ if ( !file_exists( '/proc/meminfo' ) ) {
+ return 1;
+ }
+ $mem = false;
+ foreach ( file( '/proc/meminfo' ) as $line ) {
+ if ( preg_match( '/^MemTotal:\s+(\d+)\s+kB/', $line, $m ) ) {
+ $mem = intval( $m[1] );
+ break;
+ }
+ }
+ if ( $mem ) {
+ // At least one process
+ return max( 1, floor( $mem / 1000000 ) );
+ } else {
+ return 1;
+ }
+ }
}
$maintClass = 'MakeHipHop';
* @access private
*/
function newSchema() {
- return class_exists( 'Revision' );
+ return MWInit::classExists( 'Revision' );
}
/**