Exemplo n.º 1
0
std::shared_ptr<BuildItem>
PackageConfig::transform( TransformSet &xform ) const
{
	std::shared_ptr<BuildItem> ret = xform.getTransform( this );
	if ( ret )
		return ret;

	DEBUG( "transform PackageConfig " << getName() );
	if ( myPackageFile.empty() )
		ret = std::make_shared<BuildItem>( getName(), getDir() );
	else
	{
		ret = std::make_shared<BuildItem>( getName(), std::shared_ptr<Directory>() );
		ret->addExternalOutput( myPackageFile );
	}
	ret->addToVariable( "cflags", getCFlags() );
	ret->addToVariable( "cflags", getVariable( "cflags" ) );
	ret->addToVariable( "ldflags", getLibs() );
	ret->addToVariable( "ldflags", getVariable( "ldflags" ) );

	if ( myPackageFile.empty() )
	{
		ret->addToVariable( "libdirs", getVariable( "libdirs" ) );
		ret->addToVariable( "includes", getVariable( "includes" ) );
	}

	xform.recordTransform( this, ret );
	return ret;
}
Exemplo n.º 2
0
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;
}
Exemplo n.º 3
0
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;
}