Пример #1
0
// DoDynamicDependencies
//------------------------------------------------------------------------------
/*virtual*/ bool ObjectListNode::DoDynamicDependencies( NodeGraph & nodeGraph, bool forceClean )
{
    if ( GatherDynamicDependencies( nodeGraph, forceClean ) == false )
    {
        return false; // GatherDynamicDependencies will have emitted error
    }

    // make sure we have something to build!
    if ( m_DynamicDependencies.GetSize() == 0 )
    {
        FLOG_ERROR( "No files found to build '%s'", GetName().Get() );
        return false;
    }

    if ( m_ExtraASMPath.IsEmpty() == false )
    {
        if ( !FileIO::EnsurePathExists( m_ExtraASMPath ) )
        {
            FLOG_ERROR( "Failed to create folder for .asm file '%s'", m_ExtraASMPath.Get() );
            return false;
        }
    }

    if ( m_ExtraPDBPath.IsEmpty() == false )
    {
        if ( !FileIO::EnsurePathExists( m_ExtraPDBPath ) )
        {
            FLOG_ERROR( "Failed to create folder for .pdb file '%s'", m_ExtraPDBPath.Get() );
            return false;
        }
    }

    return true;
}
Пример #2
0
// DoDynamicDependencies
//------------------------------------------------------------------------------
/*virtual*/ bool CSNode::DoDynamicDependencies( bool UNUSED( forceClean ) )
{
	ASSERT( m_DynamicDependencies.GetSize() == 0 );

	NodeGraph & ng = FBuild::Get().GetDependencyGraph();

	// preallocate a reasonable amount of space
	m_DynamicDependencies.SetCapacity( m_StaticDependencies.GetSize() );

	// convert static deps to dynamic deps
	// (ignore the extra refs here)
	size_t numDeps = m_StaticDependencies.GetSize() - m_ExtraRefs.GetSize();
	for ( size_t i=0; i<numDeps; ++i ) 
	{
		Node * n = m_StaticDependencies[ i ].GetNode();

		if ( n->IsAFile() )
		{
			m_DynamicDependencies.Append( Dependency( n ) );
			continue;
		}

		if ( n->GetType() == Node::DIRECTORY_LIST_NODE )
		{
			// get the list of files
			DirectoryListNode * dln = n->CastTo< DirectoryListNode >();
			const Array< FileIO::FileInfo > & files = dln->GetFiles();
			m_DynamicDependencies.SetCapacity( m_DynamicDependencies.GetSize() + files.GetSize() );
			for ( Array< FileIO::FileInfo >::Iter fIt = files.Begin();
					fIt != files.End();
					fIt++ )
			{
				// Create the file node (or find an existing one)
				Node * sn = ng.FindNode( fIt->m_Name );
				if ( sn == nullptr )
				{
					sn = ng.CreateFileNode( fIt->m_Name );
				}
				else if ( sn->IsAFile() == false )
				{
					FLOG_ERROR( "CSAssembly() .CompilerInputFile '%s' is not a FileNode (type: %s)", n->GetName().Get(), n->GetTypeName() );
					return false;
				}

				m_DynamicDependencies.Append( Dependency( sn ) );
			}
			continue;
		}

		FLOG_ERROR( "'%s' is not a supported node type (type: %s)", n->GetName().Get(), n->GetTypeName() );
		return false;
	}

	return true;
}
Пример #3
0
// DoBuild
//------------------------------------------------------------------------------
/*virtual*/ Node::BuildResult ExecNode::DoBuild( Job * job )
{
    // If the workingDir is empty, use the current dir for the process
    const char * workingDir = m_WorkingDir.IsEmpty() ? nullptr : m_WorkingDir.Get();

    AStackString<> fullArgs( m_Arguments );
    fullArgs.Replace( "%1", m_SourceFile->GetName().Get() );
    fullArgs.Replace( "%2", GetName().Get() );

    EmitCompilationMessage( fullArgs );

    // spawn the process
    Process p;
    bool spawnOK = p.Spawn( m_Executable->GetName().Get(),
                            fullArgs.Get(),
                            workingDir,
                            FBuild::Get().GetEnvironmentString() );

    if ( !spawnOK )
    {
        FLOG_ERROR( "Failed to spawn process for '%s'", GetName().Get() );
        return NODE_RESULT_FAILED;
    }

    // capture all of the stdout and stderr
    AutoPtr< char > memOut;
    AutoPtr< char > memErr;
    uint32_t memOutSize = 0;
    uint32_t memErrSize = 0;
    p.ReadAllData( memOut, &memOutSize, memErr, &memErrSize );

    ASSERT( !p.IsRunning() );
    // Get result
    int result = p.WaitForExit();

    // did the executable fail?
    if ( result != m_ExpectedReturnCode )
    {
        // something went wrong, print details
        Node::DumpOutput( job, memOut.Get(), memOutSize );
        Node::DumpOutput( job, memErr.Get(), memErrSize );

        FLOG_ERROR( "Execution failed (error %i) '%s'", result, GetName().Get() );
        return NODE_RESULT_FAILED;
    }

    // update the file's "last modified" time
    m_Stamp = FileIO::GetFileLastWriteTime( m_Name );
    return NODE_RESULT_OK;
}
Пример #4
0
		void addFragment(IpHeaderStruct *ipHeader) {
			try {
				if(!_packetDataRef) {
					if (ipHeader->offset()!=0) {
						_drop = true;
						return;
					}
					_packetDataRef.reset(new SizedBuffer((u_char*)ipHeader, ipHeader->packetLen()));
				}
				else {
					unsigned char* payload = reinterpret_cast<unsigned char*>(ipHeader)+ipHeader->headerLen();
					IpHeaderStruct* ipHeaderOriginal = reinterpret_cast<IpHeaderStruct*>(_packetDataRef->get());
					if (ipHeaderOriginal->payloadLen() != ipHeader->offset()) {
						_drop = true;
						return;
					}
					_packetDataRef->append(payload, ipHeader->payloadLen());
					ipHeaderOriginal = reinterpret_cast<IpHeaderStruct*>(_packetDataRef->get());
					ipHeaderOriginal->setPacketLen(ipHeaderOriginal->headerLen()+ipHeaderOriginal->payloadLen()+ipHeader->payloadLen());
				}

				if (ipHeader->isLastFragment()) {
					_isComplete = true;
				}
				_lastUpdate = time(NULL);
			}
			catch (const std::exception& ex) {
				FLOG_ERROR(s_log,"Caught exception will drop fragment id:%u, offset:%u, description: %s",ipHeader->packetId(), ipHeader->offset(), ex.what());
				_drop = true;
			}
		}
Пример #5
0
void VertexBufferText::log() {
	for (auto it : mDataVertices) {
		for (int i = 0; i < mDataVertices.size(); i++) {
			FLOG_ERROR("Vertex written: %f %f %f %f", it.position[0],
					it.position[1], it.uv[0], it.uv[1]);
		}
	}
}
Пример #6
0
bool androidExtract( const std::string& name ) {
	const char* pFile = name.c_str();
	std::string newPath = androidGetPath(pFile);
	AAssetDir* a;
	if ( androidExtracted(name.c_str()) ) {
		FLOG_DEBUG("File %s already extracted", name.c_str());
		return true;
	}

	AAsset* asset = AAssetManager_open(gActivity->assetManager, name.c_str(),
	                                   AASSET_MODE_STREAMING);
	std::string assetContent;

	if (asset != NULL) {
		// Find size
		off_t assetSize = AAsset_getLength(asset);

		// Prepare input buffer
		assetContent.resize(assetSize);

		// Store input buffer
		AAsset_read(asset, &assetContent[0], assetSize);

		// Close
		AAsset_close(asset);

		// Prepare output buffer
		std::ofstream assetExtracted(newPath.c_str(),
		                             std::ios::out | std::ios::binary);
		if (!assetExtracted) {
			FLOG_ERROR("File %s not extracted", newPath.c_str());
			return false;
		}

		// Write output buffer into a file
		assetExtracted.write(assetContent.c_str(), assetSize);
		assetExtracted.close();

		FLOG_DEBUG("File extracted");
		return true;
	} else {
		FLOG_ERROR("File %s not extracted. Returning empty string", name.c_str());
		return false;
	}
}
Пример #7
0
void Model::setActiveAnimation(GLint animationID) {
	if (mAnimator->getAnimations() > animationID) {
		mActiveAnimation = animationID;
	} else {
		FLOG_ERROR("There is no animation for slot: %d", animationID);
		FLOG_DEBUG("Maximum number of animations: %d",
		           mAnimator->getAnimations());
	}
}
Пример #8
0
// LoadFile
//------------------------------------------------------------------------------
bool ToolManifest::LoadFile( const AString & fileName, void * & content, uint32_t & contentSize ) const
{
	// read the file into memory
	FileStream fs;
	if ( fs.Open( fileName.Get(), FileStream::READ_ONLY ) == false )
	{
		FLOG_ERROR( "Error opening file '%s' in Compiler ToolManifest\n", fileName.Get() );
		return false;
	}
	contentSize = (uint32_t)fs.GetFileSize();
	AutoPtr< void > mem( ALLOC( contentSize ) );
	if ( fs.Read( mem.Get(), contentSize ) != contentSize )
	{
		FLOG_ERROR( "Error reading file '%s' in Compiler ToolManifest\n", fileName.Get() );
		return false;
	}

	content = mem.Release();
	return true;
}
Пример #9
0
inline void Entity::detachCallback(
		std::vector<actions::ItemCallback*>& callbacks,
		actions::ItemCallback* callback) {
	auto _compare_function =
			[callback](const actions::ItemCallback* m) -> bool {bool found = (m == callback); if (found) delete m; return found;};
	auto _begin = callbacks.begin();
	auto _end = callbacks.end();
	auto it = std::remove_if(_begin, _end, _compare_function);
	callbacks.erase(it, _end);
	FLOG_ERROR("Detachment of callback failed");
}
Пример #10
0
void setLogPath(std::string path) {
	FILE *fp = fopen(path.c_str(), "w");
	if (fp) {
		fclose(fp);
		fileValid = true;
		logFilePath = path;
	} else {
		FLOG_ERROR("Can not write to %s file", path.c_str());
		fileValid = false;
	}
}
Пример #11
0
// EnsurePathExistsForFile
//------------------------------------------------------------------------------
/*static*/ bool Node::EnsurePathExistsForFile( const AString & name )
{
	const char * lastSlash = name.FindLast( NATIVE_SLASH );
	ASSERT( PathUtils::IsFullPath( name ) ); // should be guaranteed to be a full path
	AStackString<> pathOnly( name.Get(), lastSlash );
	if ( FileIO::EnsurePathExists( pathOnly ) == false )
	{
		FLOG_ERROR( "Failed to create path '%s'", pathOnly.Get() );
		return false;
	}
	return true;
}
Пример #12
0
RFSMvalueEval ModelBinder::getGlobalValue(LogFile* lf, std::string name)
{
	ValueMap::iterator it = m_gVarTAB.find(name);
	if(it != m_gVarTAB.end()){
		RFSMvalueEval eval = it->second;
		FLOG_TRACE(lf, "  (RUNNING:GVar, Read) %s, %s", name.c_str(), eval.getStrValue().c_str());
		return eval;
	}
	else{
		FLOG_ERROR(lf, "  (RUNNING:GVar, Read) %s, Not initialized", name.c_str());
		return RFSMvalueEval();
	}
}
Пример #13
0
void ProcServerHandler::ReqSaveMixItemNumber(BaseSession* pBaseSession, const NetMsgHead* pMsg,int32 nSize)
{

	const S2DSaveMixItemNumber* packet = static_cast<const S2DSaveMixItemNumber*>(pMsg);
	// 做简单检查 
	if(packet->nType <= E_MIXITEM_NUMBER_TYPE_NULL || packet->nType >= E_MIXITEM_NUMBER_TYPE_MAX )
	{
		FLOG_ERROR(__FUNCTION__,__LINE__,"ReqSaveMixItemNumber Args Error!");
		return ;
	}

	RsyncTools::Instance()->SaveMixItemNumber(packet->nType,packet->nValue);
}
Пример #14
0
void TransformFeedback::begin(GLenum primitiveMode) {
	if (primitiveMode != GL_POINTS && primitiveMode != GL_LINES
			&& primitiveMode != GL_TRIANGLES
#ifndef __ANDROID__
			&& primitiveMode != GL_TRIANGLES_ADJACENCY
			&& primitiveMode != GL_TRIANGLE_STRIP_ADJACENCY
			&& primitiveMode != GL_LINES_ADJACENCY
			&& primitiveMode != GL_LINE_STRIP_ADJACENCY
#endif
	)
		FLOG_ERROR("not valid primitive type");
	else
		glBeginTransformFeedback(primitiveMode);
}
Пример #15
0
bool androidExtracted(const char* pFile) {
	FILE* file = ::fopen( androidGetPath(pFile).c_str(), "rb");
	if (!file) {
		AAsset* asset = AAssetManager_open(gActivity->assetManager, pFile,
		                                   AASSET_MODE_UNKNOWN);
		if (!asset) {
			FLOG_ERROR("Could not find %s in asset manager", pFile);
		} else {
			FLOG_DEBUG("%s is not extracted", pFile);
		}
		return false;
	} else {
		::fclose(file);
		return true;
	}
}
Пример #16
0
// DoDynamicDependencies
//------------------------------------------------------------------------------
/*virtual*/ bool ObjectListNode::DoDynamicDependencies( bool forceClean )
{
    if ( GatherDynamicDependencies( forceClean ) == false )
    {
        return false; // GatherDynamicDependencies will have emitted error
    }

	// make sure we have something to build!
	if ( m_DynamicDependencies.GetSize() == 0 )
	{
		FLOG_ERROR( "No files found to build '%s'", GetName().Get() );
		return false;
	}

	return true;
}
Пример #17
0
RFSMvalueEval ExeTask::getWorkerVar(std::string varName)
{
	pthread_mutex_lock(&m_lmu);

	ValueMap::iterator it = m_wVarTAB->find(varName);
	if(it != m_wVarTAB->end()){
		RFSMvalueEval eval = it->second;
		FLOG_TRACE(m_logFile, "  (RUNNING:WVAR, Read) %s, %s", varName.c_str(), eval.getStrValue().c_str());
	pthread_mutex_unlock(&m_lmu);		
		return eval;
	}
	else{
		FLOG_ERROR(m_logFile, "  (RUNNING:WVAR, Read) %s, Not initialized", varName.c_str());
	pthread_mutex_unlock(&m_lmu);		
		return RFSMvalueEval();
	}
}
Пример #18
0
bool androidExtractAll() {
	AAssetDir* assetDir = AAssetManager_openDir(gActivity->assetManager, "");
	const char* filename = (const char*)NULL;
	std::string assetContent;
	while ((filename = AAssetDir_getNextFileName(assetDir)) != NULL) {
		std::string newPath = androidGetPath(filename);
		AAsset* asset = AAssetManager_open(gActivity->assetManager, filename,
		                                   AASSET_MODE_STREAMING);
		FLOG_DEBUG("File %s opened for extraction ...", filename );
		// Find size
		off_t assetSize = AAsset_getLength(asset);

		// Prepare input buffer
		assetContent.resize(assetSize);

		// Store input buffer
		AAsset_read(asset, &assetContent[0], assetSize);

		// Close
		AAsset_close(asset);

		// Check if file exists
		std::ifstream f(newPath.c_str());
		if (f.good()) {
			f.close();
			FLOG_DEBUG("Asset %s already extracted", filename);
		} else {
			// Prepare output buffer
			std::ofstream assetExtracted(newPath.c_str(),
			                             std::ios::out | std::ios::binary);
			if (!assetExtracted) {
				FLOG_ERROR("File %s not extracted", newPath.c_str());
				return false;
			}

			// Write output buffer into a file
			assetExtracted.write(assetContent.c_str(), assetSize);
			assetExtracted.close();

			FLOG_DEBUG("File %s extracted", filename);
		}
	}
	return true;
	AAssetDir_close(assetDir);
}
Пример #19
0
void ExeTask::cbackBy_Timerfunc(PVOID param, bool timerOrWaitFired)
{

  	QueryPerformanceFrequency(&liFrequency);  // retrieves the frequency of the high-resolution performance counter    
	QueryPerformanceCounter(&liCounter1);         // Start
	litemp = (double)(liCounter1.QuadPart - liCounter0.QuadPart) / (double)liFrequency.QuadPart;
	liCounter0 = liCounter1;

	if(m_stop){
		SetEvent(m_DoneEvent);
		//m_running = false; //이건 RThread에게 있는 멤버 데이터
		return;
	}
		
	try{
		if(m_runner->isDebugMode() && !m_isDbgCondCreated){
			//디버깅인데 cond가 아직 생성이 안되면 아무것도 안한다.
		}
		else{
			m_runner->enterTask(this, m_task);
			if(isCompleted()) {
				SetEvent(m_DoneEvent);
				return;
			}
		}
	}
	catch(RuntimeEH& runEH){
		//runEH.printError();
		FLOG_ERROR(m_logFile, "  (RUNNING:%d) 값을 획득하는데 실패하였습니다.", runEH.getErrorCode());
		//return runEH.getErrorCode();
	}

	FLOG_TRACE(m_logFile, "  (RUNNING:CYCLE) This is the end of a cycle.\n");
	m_iterCount++;			

	QueryPerformanceCounter(&liCounter2);
	PeRecord rec;
	rec.name = getInstanceName();
	rec.cycle = litemp;
	rec.proc = (double)(liCounter2.QuadPart - liCounter1.QuadPart) / (double)liFrequency.QuadPart;
	PerformTable::addPeRecord(rec);

	//printf("<%s> Cycle Time : %f, Process Time : %f\n", getInstanceName().c_str(), litemp, (double)(liCounter2.QuadPart - liCounter1.QuadPart) / (double)liFrequency.QuadPart);
	
}
Пример #20
0
// Error
//------------------------------------------------------------------------------
void Job::Error( const char * format, ... )
{
	AStackString< 8192 > buffer;

	va_list args;
	va_start(args, format);
	buffer.VFormat( format, args );
	va_end( args );

	if ( IsLocal() )
	{
		FLOG_ERROR( buffer.Get() );
	}
	else
	{
		m_Messages.Append( buffer );
	}
}
Пример #21
0
void androidReadToString(const char* pFileName, std::string& fileContent) {
	assert( gActivity->assetManager );

	AAsset* pFile = AAssetManager_open(gActivity->assetManager, pFileName,
	                                   AASSET_MODE_UNKNOWN);

	if (pFile != NULL) {
		off_t fileSize = AAsset_getLength(pFile);

		fileContent.resize(fileSize);
		char* pData = new char[fileSize];
		AAsset_read(pFile, &fileContent[0], fileSize);

		AAsset_close(pFile);
		FLOG_DEBUG("File %s found", pFileName);
	} else {
		FLOG_ERROR("File %s not found", pFileName);
	}
}
Пример #22
0
		virtual void QueryResult(IDbRecordSet* pSet, int32 nCount)
		{
			const DbRecordSet* pRecordSet = static_cast<const DbRecordSet*>(pSet);
			D2LCharacterList sMsg;
			sMsg.nCount = 0;
			for (int32 i = 0; i < pRecordSet->Rows(); ++i)
			{
				if (i < MAX_ROLE_TYPE_COUNT)
				{
					memcpy(&sMsg.arrInfo[i], pRecordSet->GetRecordData(i), sizeof(D2LCharacterList::StCharacterInfo));
					sMsg.nCount++;
				}
				else
				{
					FLOG_ERROR(__FUNCDNAME__, __LINE__, "Role number too more!");
				}
			}
			pClientSession->SendMsgToLs(&sMsg, sMsg.GetPackLength());
		}
Пример #23
0
// DoBuild
//------------------------------------------------------------------------------
/*virtual*/ Node::BuildResult RemoveDirNode::DoBuild( Job * UNUSED( job ) )
{
    ASSERT( !m_StaticDependencies.IsEmpty() );

    m_Stamp = 0; // Trigger DoBuild() every time

    // Iterate all the DirectoryListNodes
    const Dependency * const depEnd = m_StaticDependencies.End();
    for ( const Dependency * dep = m_StaticDependencies.Begin();
          dep != depEnd;
          ++dep )
    {
        // Grab the files
        DirectoryListNode * dln = dep->GetNode()->CastTo< DirectoryListNode >();
        const Array< FileIO::FileInfo > & files = dln->GetFiles();
        const FileIO::FileInfo * const fEnd = files.End();
        for ( const FileIO::FileInfo * fIt = files.Begin();
              fIt != fEnd;
              ++fIt )
        {
            // source file (full path)
            const AString & srcFile = fIt->m_Name;

            // remove the file
            if ( FileIO::FileDelete( srcFile.Get() ) == false )
            {
                FLOG_ERROR( "Remove failed (error %i) '%s'", Env::GetLastErr(), srcFile.Get() );
                return NODE_RESULT_FAILED; // remove failed
            }

            // we combine everything into one string to ensure it is contiguous in
            // the output
            AStackString<> output;
            output += "Remove: ";
            output += srcFile;
            output += '\n';
            FLOG_BUILD_DIRECT( output.Get() );
        }
    }

    return NODE_RESULT_OK;
}
Пример #24
0
		void addFragment(IpHeaderStruct *ipHeader) {
			try {
				// Find where the fragment belongs to and insert
				std::list<SizedBufferRef>::iterator it;
				for(it=_orderedFragments.begin();it!=_orderedFragments.end();it++) {
					IpHeaderStruct* header = (IpHeaderStruct*)(*it)->get();
					if (header->offset() == ipHeader->offset()) return; // retransmission
					if (header->offset() > ipHeader->offset()) break;
				}
				_orderedFragments.insert(it,SizedBufferRef(new SizedBuffer(reinterpret_cast<unsigned char*>(ipHeader),ipHeader->packetLen())));

				if (ipHeader->isLastFragment()) {
					_finalSize = ipHeader->offset() + ipHeader->payloadLen();
				}
				_currentSize += ipHeader->payloadLen();

				if (_finalSize != 0 && _currentSize > _finalSize) { // Possible overlap
					_drop = true;
					return;
				}

				if (_currentSize == _finalSize) {
					ForwardSequentialAlgorithm simpleHandler;
					for(std::list<SizedBufferRef>::iterator it=_orderedFragments.begin();it!=_orderedFragments.end();it++) {
						IpHeaderStruct* ipHeader = (IpHeaderStruct*)(*it)->get();
						simpleHandler.addFragment(ipHeader);
						if (simpleHandler.drop()) {
							_drop = true;
							return;
						}
					}
					_packetDataRef = simpleHandler.packetData();
					_isComplete = true;
				}
				_lastUpdate = time(NULL);
			}
			catch (const std::exception& ex) {
				FLOG_ERROR(s_log,"Caught exception will drop fragment id:%u, offset:%u, description: %s",ipHeader->packetId(), ipHeader->offset(), ex.what());
				_drop = true;
			}
		}
Пример #25
0
// DoBuild
//------------------------------------------------------------------------------
/*virtual*/ Node::BuildResult AliasNode::DoBuild( Job * UNUSED( job ) )
{
	const Dependencies::Iter end = m_StaticDependencies.End();
	for ( Dependencies::Iter it = m_StaticDependencies.Begin();
		  it != end;
		  ++it )
	{
		// If any nodes are file nodes ...
		const Node * n = it->GetNode();
		if ( n->GetType() == Node::FILE_NODE )
		{
			// ... and the file is missing ...
			if ( n->GetStamp() == 0 )
			{
				// ... the build should fail
				FLOG_ERROR( "Alias: %s\nFailed due to missing file: %s\n", GetName().Get(), n->GetName().Get() );
				return Node::NODE_RESULT_FAILED;
			}
		}
	}
	return NODE_RESULT_OK;
}
Пример #26
0
void Scene::registerPickable(Entity* entity) {
	GLint rand_r, rand_g, rand_b;
	glm::vec3 color;

	for (GLint i = 0; i < MAXIMUM_TRIALS_TO_PICK_COLOR; i++) {

		rand_r = (GLfloat) (rand() % 256);
		rand_g = (GLfloat) (rand() % 256);
		rand_b = (GLfloat) (rand() % 256);

		color = glm::vec3(rand_r / 255.0, rand_g / 255.0, rand_b / 255.0);
		GLint name = (GLint) (rand_r) + (GLint) (rand_g) + (GLint) (rand_b);

		auto it = mPickingTable.find(name);
		if (it == mPickingTable.end()) {
			mPickingTable[name] = entity;
			entity->pick(color);
			return;
		}
	}
	FLOG_ERROR("Failed to register pickable entity");
}
Пример #27
0
// DESTRUCTOR
//------------------------------------------------------------------------------
FBuild::~FBuild()
{
    PROFILE_FUNCTION

	Function::Destroy();

	FDELETE m_DependencyGraph;
	FDELETE m_Client;
	FREE( m_EnvironmentString );

	if ( m_Cache )
	{
		m_Cache->Shutdown();
		FDELETE m_Cache;
	}

	// restore the old working dir to restore
	ASSERT( !m_OldWorkingDir.IsEmpty() );
	if ( !FileIO::SetCurrentDir( m_OldWorkingDir ) )
	{
		FLOG_ERROR( "Failed to restore working dir: '%s' (error: %u)", m_OldWorkingDir.Get(), Env::GetLastErr() );
	}
}
Пример #28
0
void    _test_log(){
    system("rm -f ./test_log.log");

    FLOG_DEBUG(log_handler, "debug log test\n");
    FLOG_ERROR(log_handler, "error log test\n");
    flog_set_level(LOG_LEVEL_ERROR);
    sleep(2);   // wait for log system

    int fd = open("test_log.log", O_RDONLY);
    FTU_ASSERT_GREATER_THAN_INT(0, fd);

    char assert_info[100];
    memset(assert_info, 0, 100);
    int bytes_read = read(fd, assert_info, 100);
    FTU_ASSERT_GREATER_THAN_INT(0, bytes_read);

    printf("read log info:%s\n", assert_info);
    char* ptr = strstr(assert_info, "error log test");
    printf("find ptr=%p\n", ptr);
    FTU_ASSERT_EXPRESS(ptr!=NULL);

    close(fd);
}
Пример #29
0
VertexBufferText::VertexBufferText(
		std::vector<GLfloat> positions,
		std::vector<GLfloat> textureCoords,
		GLuint dataStoreModification)
		: VertexBuffer(dataStoreModification) {
	GLuint size = positions.size();
	if (size == textureCoords.size()) {
		mDataVertices.reserve(size / 2);
		VertexText vertex;
		for (int i = 0; i < size / 2; i++) {
			vertex.position[0] = positions[i * 2];
			vertex.position[1] = positions[i * 2 + 1];
			vertex.uv[0] = textureCoords[i * 2];
			vertex.uv[1] = textureCoords[i * 2 + 1];
			mDataVertices.push_back(vertex);
		}
	} else {
		FLOG_ERROR("Wrong buffer sizes");
		return;
	}
	mTotalElements = mDataVertices.size();
	mData = mDataVertices.data();
	mSize = mTotalElements * sizeof(VertexText);
}
Пример #30
0
// Finalize
//------------------------------------------------------------------------------
bool Args::Finalize( const AString & exe, const AString & nodeNameForError, bool canUseResponseFile )
{
	ASSERT( !m_Finalized );

	#if defined( __WINDOWS__ ) || defined( __OSX__ )
		#if defined( __WINDOWS__ )
			// Windows has a 32KiB (inc null terminator) command line length limit with CreateProcess
			// https://msdn.microsoft.com/en-us/library/windows/desktop/ms682425(v=vs.85).aspx
			const uint32_t argLimit( 32767 );
		#elif defined( __OSX__ )
			const uint32_t argLimit( ARG_MAX - 1 );		
		#endif
	
		// Calculate final length of args (including exe name)
		const uint32_t exeLen = exe.GetLength();
		const uint32_t extraLen = 3; // quotes around exe name and space
		const uint32_t argLen = m_Args.GetLength();

		// We need to consider the executable, quotes around the exe and a space 
		// as well as the args: "%exe%" %args%
		const uint32_t totalLen = ( argLen + exeLen + extraLen );

		// Small enough?
		if ( totalLen <= argLimit )
		{
			#if defined( ASSERTS_ENABLED )
				m_Finalized = true;
			#endif
			return true; // Ok to proceed
		}

		// Args are too long. Can we cope using a Response File?
		if ( canUseResponseFile )
		{
			// Handle per-line limit within response files (e.g. link.exe)
			#if defined( __WINDOWS__ )
				if ( argLen >= 131071 ) // From LNK1170
				{
					// Change spaces to carriage returns
					for ( uint32_t i : m_DelimiterIndices )
					{
						ASSERT( m_Args[ i ] == ' ' );
						m_Args[ i ] = '\n';
					}
				}
			#endif

			#if defined( ASSERTS_ENABLED )
				m_Finalized = true;
			#endif

			// Write args to response file
			{
				PROFILE_SECTION( "CreateResponseFile" )
				m_ResponseFile.Create( *this );
			}

			// Create new args referencing response file
			m_ResponseFileArgs = "@\"";
			m_ResponseFileArgs += m_ResponseFile.GetResponseFilePath();
			m_ResponseFileArgs += "\"";

			return true; // Ok to proceed
		}

		// Need response file but not supported
		FLOG_ERROR( "FBuild: Error: Command Line Limit Exceeded (len: %u, limit: %u) '%s'\n", argLen, argLimit, nodeNameForError.Get() );
		return false;
	#elif defined( __LINUX__ )
		// TODO:LINUX Difficult to reliable determine this due to complex interaction with environment
		#if defined( ASSERTS_ENABLED )
			m_Finalized = true;
		#endif
		return true; // Ok to proceed
	#endif
}