コード例 #1
0
ファイル: Item.cpp プロジェクト: iangodin/constructor
std::shared_ptr<BuildItem>
Item::transform( TransformSet &xform ) const
{
	std::shared_ptr<BuildItem> ret = xform.getTransform( this );
	if ( ret )
		return ret;

	DEBUG( "transform Item " << getName() );
	ret = std::make_shared<BuildItem>( getName(), getDir() );
	ret->setDefaultTarget( isDefaultTarget() );
	ret->setUseName( isUseNameAsInput() );
	ret->setTopLevel( isTopLevel(), myPseudoName );

	VariableSet buildvars;
	extractVariables( buildvars );
	ret->setVariables( std::move( buildvars ) );

	if ( myForceToolAll == "<pseudo>" )
	{
		ret->addExternalOutput( getName() );
		ret->setOutputDir( getDir()->reroot( xform.getArtifactDir() ) );
	}
	else
	{
		std::shared_ptr<Tool> t = getTool( xform );

		if ( t )
		{
			DEBUG( getName() << " transformed by tool '" << t->getTag() << "' (" << t->getName() << ")" );
			if ( t->getGeneratedExecutable() )
			{
				std::shared_ptr<BuildItem> x = t->getGeneratedExecutable()->transform( xform );
				ret->addDependency( DependencyType::IMPLICIT, x );
			}
			ret->setTool( t );
			ret->setOutputDir( getDir()->reroot( xform.getArtifactDir() ) );
			std::string overOpt;
			for ( auto &i: t->allOptions() )
			{
				if ( hasToolOverride( i.first, overOpt ) )
					ret->setVariable( t->getOptionVariable( i.first ),
									  t->getOptionValue( i.first, overOpt ) );
			}
		}
		else
			WARNING( "No tools found for " << getName() );
	}

	xform.recordTransform( this, ret );
	return ret;
}
コード例 #2
0
ファイル: ConfigUtils.cpp プロジェクト: Brackets/rstudio
Error extractVariables(const FilePath& file, Variables* pVariables)
{
   // read in the file
   std::string contents;
   Error error = readStringFromFile(file,
                                    &contents,
                                    string_utils::LineEndingPosix);
   if (error)
      return error;

   extractVariables(contents, pVariables);

   return Success();
}
コード例 #3
0
ファイル: CodeFilter.cpp プロジェクト: iangodin/constructor
std::shared_ptr<BuildItem>
CodeFilter::transform( TransformSet &xform ) const
{
	std::shared_ptr<BuildItem> ret = xform.getTransform( this );
	if ( ret )
		return ret;

	DEBUG( "transform CodeFilter " << getName() );
	ret = std::make_shared<BuildItem>( getName(), getDir() );
	ret->setUseName( false );

	VariableSet buildvars;
	extractVariables( buildvars );
	ret->setVariables( std::move( buildvars ) );

	if ( myTool )
	{
		ItemPtr genExe = myTool->getGeneratedExecutable();
		if ( genExe )
		{
			std::shared_ptr<BuildItem> exeDep = genExe->transform( xform );
			ret->addDependency( DependencyType::IMPLICIT, exeDep );
		}

		for ( const ItemPtr &i: myItems )
		{
			// huh, we can't call transform on these because then
			// cpp files we're going to filter will be transformed to
			// .o files.
			auto inp = std::make_shared<BuildItem>( i->getName(), i->getDir() );
			inp->setUseName( false );
			inp->setOutputDir( getDir() );
			inp->setOutputs( { i->getName() } );
			ret->addDependency( DependencyType::EXPLICIT, inp );
		}
		
		ret->setTool( myTool );
		auto outd = getDir()->reroot( xform.getArtifactDir() );
		ret->setOutputDir( outd );
		ret->setVariable( "current_output_dir", outd->fullpath() );
		ret->setOutputs( myOutputs );
	}

	xform.recordTransform( this, ret );

	return ret;
}
コード例 #4
0
ファイル: ConfigUtils.cpp プロジェクト: AlanCal/rstudio
Error extractVariables(const FilePath& file, Variables* pVariables)
{
   // return path not found if necessary
   if (!file.exists())
      return core::pathNotFoundError(file.absolutePath(), ERROR_LOCATION);

   // read in the file
   std::string contents;
   Error error = readStringFromFile(file,
                                    &contents,
                                    string_utils::LineEndingPosix);
   if (error)
      return error;

   extractVariables(contents, pVariables);

   return Success();
}