int main (int argc, char* argv[]) { cpp0x::shared_ptr<TargetRunner> runner (new TargetRunner("config.xml")); bool status = runner->Load(); if (status == false) { return 1; } if (argc <= 1) { LOG(LERROR) << Constants::HELP; return 2; } std::string command(argv[argc-1]); Target target = ProcessCommandLineArguments(argc, argv); std::string name (target.GetTargetName()->c_str()); if (command.compare(Constants::COMMAND_GENERATE) == 0) { status = runner->Generate(name); } else if (command.compare(Constants::COMMAND_UPDATE) == 0) { status = runner->Update(name); } else if (command.compare(Constants::COMMAND_COMPILE) == 0) { status = runner->Compile(name); } else if (command.compare(Constants::COMMAND_CLEAN) == 0) { status = runner->Clean(name); } else { LOG(LERROR) << "No valid command was issued!"; LOG(LERROR) << Constants::HELP; } if (!status) { return 1; } return 0; }
// The main entry point int APIENTRY _tWinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow ) { // Avoid any compiler warnings for an unused variable UNREFERENCED_PARAMETER( hPrevInstance ); // Default configuration will be with one thread g_LaunchInfo.numberOfThreads = 1; // Process the command line arguments and write valid results to globals ProcessCommandLineArguments(); // Build and get a pointer to our application title g_LaunchInfo.applicationTitle = GetApplicationTitle(); // Register our main window ATOM nWindowClassID = RegisterWindowClass( hInstance ); // Check that our registration was successful if( nWindowClassID != 0 ) { // CreateWindow accepts either a class name string or a class ID // Convert our class ID to a 32 bit class string name pointer LPCTSTR pClassName = reinterpret_cast<LPCTSTR>( MAKELRESULT( nWindowClassID, 0 ) ); // Create and initialize our main window HWND hWindow = CreateAndInitializeWindow( hInstance, pClassName, nCmdShow ); // Check that our window creation was successful if( hWindow != NULL ) { // Initialize the game and shutdown if failure if( g_Framework.Init( hInstance, hWindow, g_LaunchInfo ) ) { MSG theMessage; BOOL bGotMessage; // Drive the main windows pump until the application shuts down while( true ) { // Use PeekMessage when running so it doesn't wait. // Retrieve all window or thread messages for the current thread // and removes them from the queue. bGotMessage = PeekMessage( &theMessage, 0, 0, 0, PM_REMOVE ); // If there was a windows message, process it now if( bGotMessage ) { // Received equest to quit the application if( theMessage.message == WM_QUIT ) { // Break from the main loop and shut down break; } // Translate virtual-key messages into character messages. // If the message is translated, the return value is nonzero. // If the message is WM_KEYDOWN, WM_KEYUP, WM_SYSKEYDOWN, or WM_SYSKEYUP, // the return value is nonzero, regardless of the translation. // If the message is not translated, the return value is zero. TranslateMessage( &theMessage ); // Dispatch the message to a window procedure. // Return value is whatever the window procedure returns. DispatchMessage( &theMessage ); } // Pump the framework g_Framework.Update(); } } else { OutputDebugString( _T("Could not initialize the game framework\n") ); } // Shutdown the game object g_Framework.Shutdown(); } else { OutputDebugString( _T("Could not create window\n") ); } UnregisterClass( pClassName, hInstance ); } else { OutputDebugString( _T("Could not register window\n") ); } return 0; }