Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

what triggers scons to build files when I have a custom builder?

Tags:

scons

I'm going nuts trying to control when files are built in scons. I have a very simple example build tree (see below), with a Poem builder that just takes a .txt file and converts it to lower case in a corresponding .eectxt file.

In my SConstruct and SConscript files, I declare dependencies of 3 .txt files.

But I can't figure out what's putting these into the default build!

sconstest/
    SConstruct
    tiger.txt
    src/
        SConscript
        hope.txt
        jabberwocky.txt

where the *.txt files are poems and my SConstruct and SConscript look like this:

SConstruct:

env = Environment();

def eecummings(target, source, env):
  if (len(target) == 1 and len(source) == 1):
    with open(str(source[0]), 'r') as fin:
        with open(str(target[0]), 'w') as fout:
            for line in fin:
                fout.write(line.lower());
  return None

env['BUILDERS']['Poem'] = Builder(action=eecummings, suffix='.eectxt', src_suffix='.txt');

Export('env');
poems = SConscript('src/SConscript');
tigerPoem = env.Poem('tiger.txt');

src/SConscript:

Import('env');

input = ['jabberwocky.txt', 'hope.txt'];
output = [env.Poem(x) for x in input];
Return('output');

What I want to do is to declare the dependency of the .eectxt files from the corresponding .txt files, but not cause them to be built unless I explicitly put them into the Default() build in the SConstruct file, or I request them explicitly at the command line.

How can I do this?

like image 541
Jason S Avatar asked Oct 08 '10 22:10

Jason S


1 Answers

By default, a directory depends on all files and/or targets which reside in it. So running:

scons

Will then build all targets under the current directory.

like image 178
bdbaddog Avatar answered Oct 23 '22 06:10

bdbaddog