[Scons-users] Scons deleting output files it does not know about

Pico Geyer picogeyer at gmail.com
Wed Oct 2 17:06:42 EDT 2013


On Wed, Oct 2, 2013 at 9:06 PM, Dirk Bächle <tshortik at gmx.de> wrote:


> Hi Pico,



Hi Dirk, thanks for your response.


>

>

> it would help if you could show us how the Builder actually looks like.

> Did you define a customized Emitter for it?

>

Yes I did. I started off with a Command builder that simply created a
.boost_build target to track if boost had been built or not. But then I
thought I'd expand it to not have the list of libraries to build so hard
coded in the command builder, so I created the following wrapper/builder (A
bit simplified to omit boring details of the project):
def Boost(target, source, env, boost_src, boost_dest, boost_ver, libs,
**kw):
'''Wrapper that looks like a builder but takes a few extra args to
simplify
things'''
def boost_links_emitter(target, source, env):
'Creates the library links as targets so that scons doesn't delete
them'
links = []
for t in target:
base = os.path.basename(t.path)
dir_name = os.path.dirname(t.path)
newt = base.rstrip(boost_ver)
full = os.path.join(dir_name, newt)
links.append(full)
target.append(links)
return target, source

libs = map(lambda x: '--with-' + x, libs)
bld = Builder(action = [
('cd {src_dir} && ./bootstrap.sh --prefix={dest_dir} && ./b2 ' +
'--layout=tagged {libs} debug-symbols=off variant=release' +
' optimization=speed install').format(libs=' '.join(libs),
src_dir=boost_src, dest_dir=boost_dest)
],
prefix = '{}boost_'.format(env.subst('$SHLIBPREFIX')),
suffix = '{}.{}'.format(env.subst('$SHLIBSUFFIX'), boost_ver),
emitter = [boost_links_emitter], #Could add an emitter for boost
includes but boost has way to many include files
)
return bld(env, target, source, **kw)

The above would be called like so:
boost_lib_list = ['system', 'thread', ] #etc etc
t_boost_libs = Boost(boost_tgt_list, [], env,
boost_src=boost_src_dir.abspath, boost_dest=boost_build_dir.path,
boost_ver='1.54.0', libs=boost_lib_list)
I realize that the above is a bit rough and leaves plenty of room for
improvement but I hope it illustrates what I'm trying to achieve.





> [...]

>>

>>

>> After some digging, I found the --debug=duplicate option that actually

>> shows this happening:

>> dup: no src for <path_to>/variant_dir/boost/**build/include/boost/thread.

>> **hpp, unlinking old variant copy

>> After this my builds fail because the required header file has now

>> vanished.

>> If I understand correctly one ugly solution would be add every header

>> file that the boost build creates to my boost builder so that scons knows

>> that the include file was an output of my boost builder.

>>

>> So my question is:

>> 1) Why is scons deleting that file when it doesn't know how to recreate

>> it?

>>

>>

> SCons doesn't see where the thread.hpp header comes from, so it tries to

> cleanup your variant build dir by removing possible leftovers. This

> wouldn't happen in a "normal" source folder...



Yes, I guess after posting my message I realized that scons is justified in
removing such files and there are scenarios where just leaving files lying
around could be dangerous.


>

>

> 2) Is there a recommended way to protect the files in the output dir from

>> being removed by scons?

>>

>>

> You'll have to correct the dependencies, such that SCons can make the

> connection between your built files and their sources. Where from do you

> build the boost stuff? Do you use "duplicate=0" or "duplicate=1" for your

> variant build?

>

I've not played with the duplicate=0 option too much but in the above
example I am careful to make sure that my boost_src_dir points to the real
source dir and not to the variant dir.


> Is it really necessary to install boost into every variant dir, or

> wouldn't it be sufficient to have one single version for all of them in the

> source folder and then use "duplicate=0"?

>

The only reason that I'm using a variant dir at this stage is to keep a
nice separation between source and build directory.
I use the VariantDir function at the top level SConstruct and expect all
build output to appear in some builddir
I only need one build (and installation) of boost.
So I think what you're suggesting is that I just don't install boost into
the variant dir at all.
I'm not sure why that didn't occur to me.
So perhaps I'll have:
./src
./build_dir (The variant_dir)
./ext_build/boost

I'm going to play around with this option.

Many thanks for your input.

Regards,
Pico
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://four.pairlist.net/pipermail/scons-users/attachments/20131002/90dc307a/attachment.htm


More information about the Scons-users mailing list