[Scons-users] Re-2: Re-2: Code generation dependency problem

Roman Karlstetter Roman.Karlstetter at ifta.com
Mon Dec 8 03:50:07 EST 2014


Hi,

thanks for pointing me to this thread, I obviously should follow the list more closely :)

I'm using variantDir, too, so this might be part of the problem I'm facing.

Apart from that, after reading the thread, I'm a bit confused why scons finds the generated *.cpp file in my case. I'm confused because I collect the source files with the Glob() function, but the generated file actually does not already exist when the parsing is done (this is my understanding at least). 

What's the magic that is happening here?

Regards,
Roman


 Original Message processed by david®  
Re: [Scons-users] Re-2: Code generation dependency problem (05-Dez-2014 14:48)
From:   Stijn De Ruyck
To:SCons users mailing list


Hi,

Could be totally wrong, but if parallelism really is the problem, have a look at SideEffect, I’ve seen it being used to do certain things “in order”.
I had a similar problem btw, but using variantDirs. See https://pairlist4.pair.net/pipermail/scons-users/2014-December/003242.html

Regards,
Stijn

From: Scons-users [mailto:scons-users-bounces at scons.org] On Behalf Of Roman Karlstetter
Sent: Friday, December 05, 2014 1:29 PM
To: scons-users at scons.org
Subject: [Scons-users] Re-2: Code generation dependency problem

Hi,

ok, thanks.

Code generation is performed with a Builder, which is implemented as a python function, which gets
*.xsd (XML Schema definition) files as input and generates one *.cpp and one *.hpp.

env.CodeFromXSDSchema('myfile', ['first.xsd', 'second.xsd'])

This builder is defined as follows:

bld = env.Builder(action = generate_code_wrapper, src_suffix = '.xsd', emitter = emit)
env.Append(BUILDERS = {'CodeFromXSDSchema' : bld})

which is based on these two functions (a wrapper which calls the actual code generation function and an emitter-function)

def generate_schema_wrapper(target, source, env): 
    source_filenames = [s.abspath for s in source]
    target_header = target[0].abspath
    target_impl = target[1].abspath
    codegen.generate(source_filenames, target_header, target_impl) # function doing actual code generation

def emit(target, source, env):
    target = [target[0].abspath + '.hpp', target[0].abspath + '.cpp']
    return target, source


Perhaps one additional thing I noticed: when building with only one job (no parallelism), the case where I delete both of the generated files does not lead to any problems, the build run fine then (by chance?).

Regards,
Roman




 Original Message processed by david®  


Re: [Scons-users] Code generation dependency problem (05-Dez-2014 12:50)
From:   Laurent Marchelli
To:SCons users mailing list


Hello Romain,

 
In our case, *.cpp file seems to be intermediate files, ensure that your source files (template for cpp generation) do not have the *.cpp extension and create your own builder. 
Have a look to http://www.scons.org/doc/production/HTML/scons-user.html#chap-builders-writing.

 
Regards,
Laurent

2014-12-05 10:58 GMT+01:00 Roman Karlstetter <Roman.Karlstetter at ifta.com>:
Hi,

I have a problem with dependencies and generated code in my project using scons.

I want to do the following:
 1. Generate some code which results in a *.cpp and a corresponding *.hpp file.
 2. Compile my project, including the generated files.

In most cases (especially when the generated files are up to date), everything works fine. But sometimes, scons cannot find the generated file, I assume that it is regenerating the file and at the same time trying to compile it as an object file (I can provoke the error by deleting the generated files, doing a clean build is no problem).
This is the error that I get:

scons: *** [my_file.obj] Source `my_file.cpp' not found, needed by target `my_file.obj'.

Is there a way to tell scons to wait for the cpp-file to be generated and only after that start compiling an object file from it?

Kind regards,
Roman

PS: The generated file lies next to all the other cpp-files of the project, I collect them via Glob('*.cpp')



_______________________________________________
Scons-users mailing list
Scons-users at scons.org
https://pairlist4.pair.net/mailman/listinfo/scons-users

 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://pairlist4.pair.net/pipermail/scons-users/attachments/20141208/76c6e9be/attachment-0001.html>


More information about the Scons-users mailing list