[Scons-users] Dependency issues, always builds certain executables

William Roberts bill.c.roberts at gmail.com
Thu Sep 13 00:18:11 EDT 2012


Please bear with me as I am new to scons...I have read the user manual
and tools for fools.

Every time I type scons, one of my custom builders always runs, which
then causes all my assembly files to be rebuilt:

This is for wrapping the lemon tool, and it generates two files,
assembler.c and assembler.h, I add those as sideffects

The builder is wrapped up in a class and set in the env on the classes
init function, and it looks like:

__init__(self, env ...):

... snip...
bld = SCons.Builder.Builder(action='0x1_lemon $SOURCE')
self._env.Append(BUILDERS={'Lemon': bld})
...snip...

the wrapping methods looks like:

..snip..

def lemon(self, SRC):

(dirName, fileName) = os.path.split(SRC)
(fileBaseName, fileExtension) = os.path.splitext(fileName)
l = self._env.Lemon(SRC)
outHeaderName = os.path.join(dirName, fileBaseName + '.h')
outSrcName = os.path.join(dirName, fileBaseName + '.c')
s = self._env.SideEffect([outHeaderName, outSrcName], l)
return [s, l]


def executable(
self,
NAME=None,
INCLUDES=[],
SRC_FILES=[],
LIBS=[],
):

p = self._env.Program(NAME, SRC_FILES, CPPPATH=INCLUDES,
LIBS=LIBS, LIBPATH=self._libdir)
x = self._env.Install(self._exedir, p)
return [p, x]

..snip..

The SConstruct file finds all SConscripts, make a list of them and
calls them passing in this custom builder as an export under 'miniat'

The SConscript file that builds lemon looks like:

Import('miniat')

env = miniat.getenv()

c = miniat.executable('0x1_lemon', [ '#/vm/inc', 'inc' ], SRC_FILES= [
'src/0x1_lemon.c' ] )

f = miniat.flex('src/lex.yy.c', 'src/0x1_assembler.lex')
l = miniat.lemon('./src/0x1_assembler.y')

p = miniat.buildMasm([ '#/vm/inc', '#/tools/assembler/inc' ],
['src/0x1_assembler.c', 'src/lex.yy.c'])

env.Depends(l, c)
env.Depends(l, f)
env.Depends(p, l)


This lemon tool is then used to build my assembler that gets used in
other parts of the build process.

I cannot figure out why scons keeps invoking lemon, even when nothing
changes..... I only want it to invoke lemon when the SRC to lemon
changes, which that is made off of flex, and the flex tool isn't
running before lemon.

Example first build (It calls flex and 0x1_lemon which makes the
assembler files and then makes 0x1_masm which is my assembler):

scons: done reading SConscript files.
scons: Building targets ...
gcc -o out/tools/assembler/src/0x1_lemon.o -c -Ivm/inc
-Iout/tools/assembler/inc out/tools/assembler/src/0x1_lemon.c
gcc -o out/tools/assembler/0x1_lemon
out/tools/assembler/src/0x1_lemon.o -Lout/lib
Install file: "out/tools/assembler/0x1_lemon" as "out/exe/0x1_lemon"
flex -i -o out/tools/assembler/src/lex.yy.c
out/tools/assembler/src/0x1_assembler.lex
0x1_lemon out/tools/assembler/src/0x1_assembler.y
gcc -o out/tools/assembler/src/0x1_assembler.o -c -Ivm/inc
-Itools/assembler/inc out/tools/assembler/src/0x1_assembler.c
gcc -o out/tools/assembler/src/lex.yy.o -c -Ivm/inc
-Itools/assembler/inc out/tools/assembler/src/lex.yy.c
gcc -o out/tools/assembler/0x1_masm
out/tools/assembler/src/0x1_assembler.o
out/tools/assembler/src/lex.yy.o -Lout/lib
Install file: "out/tools/assembler/0x1_masm" as "out/exe/0x1_masm"
0x1_masm out/asms/branch.asm

--
Respectfully,

William C Roberts


More information about the Scons-users mailing list