Exemple #1
0
//----------------------------------------------------------------//
int GlutHost ( int argc, char** argv ) {

	_printMoaiVersion ();

	#ifdef _DEBUG
		printf ( "DEBUG BUILD\n" );
	#endif

	// TODO: integrate this nicely with host
	//AKUInitMemPool ( 100 * 1024 * 1024 );
	atexit ( _cleanup );

	glutInit ( &argc, argv );

	GlutRefreshContext ();

	char* lastScript = NULL;

	if ( argc < 2 ) {
		AKURunScript ( "main.lua" );
	}
	else {

		AKUSetArgv ( argv );

		for ( int i = 1; i < argc; ++i ) {
			char* arg = argv [ i ];
			if ( strcmp( arg, "-e" ) == 0 ) {
        // sDynamicallyReevaluateLuaFiles = true;
			}
			else if ( strcmp( arg, "-s" ) == 0 && ++i < argc ) {
				char* script = argv [ i ];
				AKURunString ( script );
			}
			else {
				AKURunScript ( arg );
				lastScript = arg;
			}
		}
	}
	
	//assuming that the last script is the entry point we watch for that directory and its subdirectories
	#if MOAI_WITH_FOLDER_WATCHER
		if ( lastScript && sDynamicallyReevaluateLuaFiles ) {
			#ifdef _WIN32
				winhostext_WatchFolder ( lastScript );
			#elif __APPLE__
				FWWatchFolder( lastScript );
			#endif
		}
	#endif
	
	if ( sHasWindow ) {
		glutTimerFunc ( 0, _onTimer, 0 );
		glutMainLoop ();
	}
	return 0;
}
Exemple #2
0
//----------------------------------------------------------------//
int main ( int argc, char *argv []) {

	AKUAppInitialize ();
	AKUModulesAppInitialize ();

	AKUCreateContext ();
	AKUModulesContextInitialize ();

	// Setup signal handler: quit on Ctrl-C
	signal ( SIGTERM, signal_handler );
	signal ( SIGINT, signal_handler );
	
	AKUSetArgv ( argv );
	
	for ( int i = 1; i < argc; ++i ) {
		char* arg = argv [ i ];
		if ( strcmp( arg, "-s" ) == 0 && ++i < argc ) {
			AKURunString ( argv [ i ]);
		}
		else {
			AKURunScript ( arg );
		}
	}
	
	while ( sExitFlag == 0 ) {
		sleep ( 1 );
	}
	printf ( "Exiting on signal %d, waiting for all threads to finish...", sExitFlag );
	fflush ( stdout );
	
	AKUModulesAppFinalize ();
	AKUAppFinalize ();
	
	printf ( "%s", " done.\n" );

	return EXIT_SUCCESS;
}
Exemple #3
0
//----------------------------------------------------------------//
void AKUModulesParseArgs ( int argc, char** argv ) {

	#if AKU_WITH_TEST

		int total = argc - 1;
		int i = 1;

		for ( ; i < total; ++i ) {
		
			char* arg = argv [ i ];
		
			if ( arg [ 0 ] != '-' ) break;
		
			// filter file
			if ( strcmp ( arg, "-f" ) == 0 ) {
				AKUTestSetFilterFile ( argv [ ++i ]);
			}
		
			// filter
			if ( strcmp ( arg, "-F" ) == 0 ) {
				AKUTestSetFilter ( argv [ ++i ]);
			}
		
			// results
			if ( strcmp ( arg, "-r" ) == 0 ) {
				AKUTestSetResultsFile ( argv [ ++i ]);
			}
		
			// staging
			if ( strcmp ( arg, "-s" ) == 0 ) {
				AKUTestSetStaging ();
			}
		
			// test
			if ( strcmp ( arg, "-t" ) == 0 ) {
				AKUTestRunTest ( argv [ ++i ]);
			}

			// xml results
			if ( strcmp ( arg, "-x" ) == 0 ) {
				AKUTestSetXmlResultsFile ( argv [ ++i ]);
			}
		}

		for ( ; i < argc; ++i ) {
			AKUTestRunScript ( argv [ i ]);
		}
		
	#else
	
		if ( argc < 2 ) {
			AKURunScript ( "main.lua" );
		}
		else {

			AKUSetArgv ( argv );

			for ( int i = 1; i < argc; ++i ) {
				char* arg = argv [ i ];
				if (( strcmp ( arg, "-s" ) == 0 ) && ( ++i < argc )) {
					char* script = argv [ i ];
					AKURunString ( script );
				}
				else {
					AKURunScript ( arg );
				}
			}
		}
	
	#endif
}