//========= Copyright © 1996-2006, Valve Corporation, All rights reserved. ============// // // Purpose: VPC // //=====================================================================================// #include "vpc.h" //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- void CVPC::SetupDefaultConditionals() { // // PLATFORM Conditionals // { FindOrCreateConditional( "WIN32", true, CONDITIONAL_PLATFORM ); FindOrCreateConditional( "WIN64", true, CONDITIONAL_PLATFORM ); // LINUX is the platform but the VPC scripts use $LINUX and $DEDICATED // (which we automatically create later). FindOrCreateConditional( "LINUX32", true, CONDITIONAL_PLATFORM ); FindOrCreateConditional( "LINUX64", true, CONDITIONAL_PLATFORM ); FindOrCreateConditional( "CYGWIN", true, CONDITIONAL_PLATFORM ); FindOrCreateConditional( "OSX32", true, CONDITIONAL_PLATFORM ); FindOrCreateConditional( "OSX64", true, CONDITIONAL_PLATFORM ); FindOrCreateConditional( "X360", true, CONDITIONAL_PLATFORM ); FindOrCreateConditional( "PS3", true, CONDITIONAL_PLATFORM ); } // // CUSTOM conditionals // { // setup default custom conditionals FindOrCreateConditional( "PROFILE", true, CONDITIONAL_CUSTOM ); FindOrCreateConditional( "RETAIL", true, CONDITIONAL_CUSTOM ); FindOrCreateConditional( "CALLCAP", true, CONDITIONAL_CUSTOM ); FindOrCreateConditional( "FASTCAP", true, CONDITIONAL_CUSTOM ); FindOrCreateConditional( "CERT", true, CONDITIONAL_CUSTOM ); FindOrCreateConditional( "MEMTEST", true, CONDITIONAL_CUSTOM ); FindOrCreateConditional( "NOFPO", true, CONDITIONAL_CUSTOM ); FindOrCreateConditional( "POSIX", true, CONDITIONAL_CUSTOM ); FindOrCreateConditional( "LV", true, CONDITIONAL_CUSTOM ); FindOrCreateConditional( "DEMO", true, CONDITIONAL_CUSTOM ); FindOrCreateConditional( "NO_STEAM", true, CONDITIONAL_CUSTOM ); FindOrCreateConditional( "DVDEMU", true, CONDITIONAL_CUSTOM ); FindOrCreateConditional( "QTDEBUG", true, CONDITIONAL_CUSTOM ); FindOrCreateConditional( "NO_CEG", true, CONDITIONAL_CUSTOM ); FindOrCreateConditional( "UPLOAD_CEG", true, CONDITIONAL_CUSTOM ); } } //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- const char *CVPC::GetTargetPlatformName() { for ( int i = 0; i < m_Conditionals.Count(); i++ ) { conditional_t *pConditional = &m_Conditionals[i]; if ( pConditional->type == CONDITIONAL_PLATFORM && pConditional->m_bDefined ) { return pConditional->name.String(); } } // fatal - should have already been default set Assert( 0 ); VPCError( "Unspecified platform." ); return NULL; } //----------------------------------------------------------------------------- // Case Insensitive. Returns true if platform conditional has been marked // as defined. //----------------------------------------------------------------------------- bool CVPC::IsPlatformDefined( const char *pName ) { for ( int i=0; im_bDefined = bSet; } //----------------------------------------------------------------------------- // Returns true if string has a conditional of the specified type //----------------------------------------------------------------------------- bool CVPC::ConditionHasDefinedType( const char* pCondition, conditionalType_e type ) { char symbol[MAX_SYSTOKENCHARS]; for ( int i=0; itype == CONDITIONAL_GAME ) { if ( !pConditional->m_bDefined ) { return false; } pConditional->m_bGameConditionActive; } // all other type of conditions are gated by their 'defined' state return pConditional->m_bDefined; } // unknown conditional, defaults to false return false; } //----------------------------------------------------------------------------- // Callback for expression evaluator. //----------------------------------------------------------------------------- static bool ResolveSymbol( const char *pSymbol ) { return g_pVPC->ResolveConditionalSymbol( pSymbol ); } //----------------------------------------------------------------------------- // Callback for expression evaluator. //----------------------------------------------------------------------------- static void SymbolSyntaxError( const char *pReason ) { // invoke internal syntax error hndling which spews script stack as well g_pVPC->VPCSyntaxError( pReason ); } //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- bool CVPC::EvaluateConditionalExpression( const char *pExpression ) { char conditionalBuffer[MAX_SYSTOKENCHARS]; ResolveMacrosInString( pExpression, conditionalBuffer, sizeof( conditionalBuffer ) ); if ( !conditionalBuffer[0] ) { // empty string, same as not having a conditional return true; } bool bResult = false; CExpressionEvaluator ExpressionHandler; bool bValid = ExpressionHandler.Evaluate( bResult, conditionalBuffer, ::ResolveSymbol, ::SymbolSyntaxError ); if ( !bValid ) { g_pVPC->VPCSyntaxError( "VPC Conditional Evaluation Error" ); } return bResult; }