[Scons-users] ??: Scons don't build target with absolute

yangsc yangsc2009 at gmail.com
Mon Jul 14 22:16:45 EDT 2014


Here's my SConstruct File(The resRoot is the absolute path dir):

 

import os,sys

#the resmgr lib would modify the import path

#restore it later

oldPath=sys.path

import fxbuilder

import SCons.Scanner

import ResMgr

sys.path=oldPath

import fxconfig

import string

 

 

 

env = Environment(ENV = os.environ)

fxBuilder = Builder(action     = fxbuilder.FxBuilder,

                    src_suffix = ['.fx','.fxo'],

                                               emitter    =
fxbuilder.FxEmitter)

expr = '^[ \t]*#[ \t]*(?:include)[ \t]*(<|")([^>"]+)(>|")'

fxscan = SCons.Scanner.ClassicCPP("MyInputScan", [".fx",".fxo"], "CPPPATH",
expr)

env = Environment(BUILDERS = {'scfxBuilder' : fxBuilder})

env.Append(SCANNERS = fxscan)

Decider('MD5-timestamp')

 

oldPath=sys.path

docRoot = minidom.parse('paths.xml').documentElement

resRoot = docRoot.getElementsByTagName('Path')[0].childNodes[0].nodeValue

print '---------resRoot:', resRoot

sys.path=oldPath

 

fxconfig.fxPath=os.path.join(resRoot,fxconfig.fxPath)

fxconfig.fxmPath=os.path.join(resRoot,fxconfig.fxmPath)

fxconfig.fbiPath=os.path.join(resRoot,fxconfig.fbiPath)

 

#add the include paths

env.Append(CPPPATH=fxconfig.fxhPath)

 

def ListBuild(listFileName):

         rootSec=ResMgr.openSection(listFileName)

         if (rootSec==None):

                   print "list file not found"

         else:

                   for x in rootSec.values():

                            fileName=x.asString

                            fileName=os.path.join(resRoot,fileName)

                            if (os.path.exists(fileName)==True):

                                     env.scfxBuilder(fileName)

                            else:

                                     print "list build error:
\""+fileName+"\" not found"

 

ListBuild(fxconfig.listFile)

 

And my Builder and Emitter

import string

import fxexporter

import fxconfig

def FxBuilder(target, source, env):

         fxFile=str(source[0])

         fxmFile=str(target[0])

         fbiFile=str(target[1])

         fxFile=string.replace(fxFile,'\\','/')

         fxmFile=string.replace(fxmFile,'\\','/')

         fbiFile=string.replace(fbiFile,'\\','/')

         print "Building "+fxFile

         incPathList=env['CPPPATH']

         fxexporter.ExportEffect(fxFile,fxmFile,fbiFile,incPathList,

 
fxconfig.preMacros,

 
fxconfig.EXPORT_DESC)

         return None

 

#the emitter modify the target list to be generated

def FxEmitter(target, source, env):

         target=[] 

         for x in source:

#format source's and fxPath and elimite the fxPath's part in source's path.

#e.g: source="x/y/source.fx" and fxPath="x"

#then sx should be y/source.fx

                   sx=string.replace(str(x),'\\','/')

                   fxPath=string.replace(fxconfig.fxPath,'\\','/')

                   sx=string.replace(sx,fxPath,'',1)

                   if (len(sx)>0):

                            if (sx[0]=='/'):

                                     sx=string.replace(sx,'/','',1)

#elimite the suffix: '.fx'

                   words=string.split(sx,'.')

                   fxName=""

                   for i in range(len(words)-1):

                            fxName=fxName+words[i]

                   fxmName=fxconfig.fxmPath+"/"+fxName+".fxm"

                   fbiName=fxconfig.fbiPath+"/"+fxName+".fbi"

                   fxmName=fxmName.encode('utf-8')

                   fbiName=fbiName.encode('utf-8')

                   target.append(fxmName)

                   target.append(fbiName)

         print target

         print str(source[0])

         return target, source

#-----------------------------------------------------------

 

The Building Output

ocessor>scons

scons: Reading SConscript files ...

---------resRoot: D:\testRoot

['D:\\testRoot\\object/std_effects/branch.fxm',
'D:\\testRoot\\object/std_effecs/branch.fbi']

D:\testRoot\shaders\std_effects\branch.fx

scons: done reading SConscript files.

scons: Building targets ...

scons: `.' is up to date.

scons: done building targets.

 

 

In the source and target dir "D:\testRoot", the
"D:\testRoot\shaders\std_effects\branch.fx" exists and the object file
doesn't exist. I'm sure this emitter can work with a relative path resRoot.

I Added some output inside the builder which shows the builder never called.
It seems scons implicit dependency check is wrong when passing target file
an absolute path.

----------------------------------------------------------------------------
----------------------------------------------------------------------------
-----------------------

 

Message: 1

Date: Fri, 11 Jul 2014 09:16:59 +0200

From: Dirk B?chle <tshortik at gmx.de>

To: scons-users at scons.org

Subject: Re: [Scons-users] ??: Scons don't build target with absolute

         file path.

Message-ID: <53BF8F6B.8090503 at gmx.de>

Content-Type: text/plain; charset="utf-8"; Format="flowed"

 

Hi,

 

On 11.07.2014 03:40, yangsc wrote:

> 

> Hi,

> 

> In construct file I used my own builder and emmiter. My source file 

> has an absolute path like ?D:/testDir? which is different with the dir 

> of construct script file.

> 

> And my emitter also generated the target based on the source file Path 

> which is also an absolute path.

> 

> #the emitter modify the target list to be generated

> 

> def FxEmitter(target, source, env):

> 

> target=[]

> 

> for x in source:

> 

> ?

> 

> target.append(*target1Name*)

> 

> target.append(*target2Name*)

> 

> return target, source

> 

> My problem is the target is not exist, but scons always tell ?done 

> building targets?. And when I change the target to relative path, it 

> worked.

> 

> Is this a bug of scons? And is there any solution?

> 

> 

this is very difficult to tell, without seeing your full example. This would
include your Builder, Emitter and SConstruct/SConscripts. Do you have your
project checked in to a public repository (github, bitbucket, ...)? Then an
URL to your current development version/commit would help us to be able to
reproduce your error.

You can also try to create a minimal working example, compress the files
into a single archive, and attach it to your next email.

 

If you have not already done so, when writing Tools and Builders you should
have a short look at our http://www.scons.org/wiki/ToolsForFools

guide.

 

Your error might be similar to this issue: 

http://scons.tigris.org/issues/show_bug.cgi?id=2958

but that's just a wild guess.

 

Best regards,

 

Dirk

 

 

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://four.pairlist.net/pipermail/scons-users/attachments/20140715/ea348b85/attachment-0001.html>


More information about the Scons-users mailing list