[Scons-users] Question on custom builder
syost at triad.rr.com
syost at triad.rr.com
Wed Dec 27 14:04:34 EST 2017
---- Bill Deegan <bill at baddogconsulting.com> wrote:
> Can you share udb_precompile?
> Also please share your emitter.
>
> On Fri,
Sorry for the delay - holidays and all. The builder used to create a script file on the fly with all the sources and commands and then execute that; saving lots of time. But once I added the emitter, the targets are wrong if I pass more than one source file to the builder. So now I execute the builder for each source in a for-in loop.
def udb_precompile( target, source, env ):
stringTargets=', '.join(map(lambda f: str(f), target))
stringSources=', '.join(map(lambda f: str(f), source))
myDebugPrint("udb precompile parameters:",target=stringTargets, source=stringSources)
######################
# target isnt real here - emiiter below really modifies it
######################
for udbFile in source:
rootPath,fileName = os.path.split(str(udbFile))
rootName,suffix = os.path.splitext(fileName)
udbPackageName = dirname(str(udbFile))+"/"+rootName
udbBindFileName = dirname(str(udbFile))+"/"+ rootName + ".bnd"
myFileName = str(udbFile)
myDebugPrint("=======>>> UDB Precompiling ===>>> ", myFileName=myFileName )
subprocess.call([ '/home/db2inst1/sql_udb_prep', myFileName, udbPackageName, udbBindFileName, str(uuid.uuid4())])
return None
def udb_emitter( target, source, env ):
#Check empty sources here - emitter will see it before the builder
if 0 == len(source):
print("UDBPrepcompile called without sources - probably an error in your SConscript")
sys.exit(-1)
freshStart = True
for udbFile in source:
rootPath,fileName = os.path.split(str(udbFile))
rootName,suffix = os.path.splitext(fileName)
udbBindFileName = rootName+".bnd"
myDebugPrint("=======>>> UDB Emitter ===>>> ", udbBindFileName=udbBindFileName, udbfile=str(udbFile) )
target.append(udbBindFileName)
return target, source
---- Bill Deegan <bill at baddogconsulting.com> wrote:
> Can you share udb_precompile?
> Also please share your emitter.
>
> On Fri, Dec 22, 2017 at 8:45 AM, <syost at triad.rr.com> wrote:
>
> > I have the following code
> >
> > myBld = Builder(action = udb_precompile,
> > suffix='.c',
> > src_suffix='.sc',
> > emitter = udb_emitter)
> > rootEnv.Append( BUILDERS = {'UDBPrep' : myBld } )
> >
> > I call it like so:
> > newlyCreatedTargets = UDBPrep(Glob('*.sc'))
> >
> > The builder function simply calls a script with each source as a parameter
> > and the emitter simply adds the secondary target that is also created
> > ("*.bnd" suffix) by the script using target.append(). The target list ends
> > up like this:
> >
> > source=[files.sc, file2.sc, file3.sc]
> > target=[file1.c, file1.bnd, file2.bnd, file3,bnd]
> >
> > as you can see, I don't have all my *.c targets in the target list - just
> > the first one (they do get created by the script). If I call the builder
> > individually for each source file it works perfect but I take a performance
> > hit for this. Any ideas?
> >
> > Thanks in advance!!!!
> >
> > Spencer
> > _______________________________________________
> > Scons-users mailing list
> > Scons-users at scons.org
> > https://pairlist4.pair.net/mailman/listinfo/scons-users
> >
More information about the Scons-users
mailing list