[Scons-users] Dependency missed when the included filename is defined by a preprocessor macro

Tom Tanner trtanner at btinternet.com
Fri Mar 17 17:59:31 EDT 2017


I believe its because if you have a header file that needs building, the 
preprocessor will give you an error rather than outputting it as an 
included file. Admittedly this somewhat depends on your compiler as 
well. Not all compilers are gcc and some don't even have that functionality.

On 14/3/17 16:29, Bill Deegan wrote:
> I can't speak to the why.
> That decision predates me.
>
> I think there is/was some code started to implement such.
>
> On Tue, Mar 14, 2017 at 12:18 PM, Andrew C. Morrow 
> <andrew.c.morrow at gmail.com <mailto:andrew.c.morrow at gmail.com>> wrote:
>
>
>     I've wondered this at times, and I presume there is a good reason,
>     but for my own edification I'd like to understand it. Why doesn't
>     SCons, on platforms that support it, simply invoke the
>     pre-processor with -MG -MDD or whatever and consume the output?
>     That would be a fully faithful preprocessor pass, rather than
>     re-implementing the semantics in python.
>
>     Thanks,
>     Andrew
>
>
>     On Tue, Mar 14, 2017 at 11:24 AM, Bill Deegan
>     <bill at baddogconsulting.com <mailto:bill at baddogconsulting.com>> wrote:
>
>         I beleive you asked this question on stackoverflow and I
>         pointed you at a pull request which has much of the
>         preprocessor functionality in it.
>         We've not yet merged it, its a work in progress.
>
>         Please give that a try.
>         -Bill
>         SCons Project co-manager
>
>         On Tue, Mar 14, 2017 at 8:04 AM, Jean-Baptiste Lab
>         <jeanbaptiste.lab at gmail.com
>         <mailto:jeanbaptiste.lab at gmail.com>> wrote:
>
>             Hi Julien,
>
>             That would require that SCons implements a fully-fledged
>             preprocessor... It is not the case now and I don't think
>             this is on the roadmap.
>
>             However, you could maybe wrap the Program builder in a
>             function that would automatically add the HELLO_H value to
>             the dependencies with env.Depends(), using a new env
>             variable like PREPOC_HEADERS?
>
>             Hope this helps,
>
>             JB
>
>
>             On 2017-03-14 11:16, Julien Pommier wrote:
>>             Hi,
>>
>>             I’m using a library that #includes a header file whose
>>             name is defined by a preprocessor macro. Unfortunately,
>>             scons does not seem to add this file to the dependency
>>             list of the file that does the #include
>>
>>             Here is a short example:
>>
>>             I have a hello.c file that is:
>>
>>             #include HELLO_H
>>             #include <stdio.h>
>>             int main() {
>>             printf(MESSAGE);
>>             return 0;
>>             }
>>
>>             and a hello.h file that is:
>>
>>             #define MESSAGE "HELLO\n”
>>
>>             My SConstruct is:
>>
>>             env=Environment()
>>             env.Append(CPPDEFINES={'HELLO_H':'\'"hello.h"\'’})
>>             env.Program('hello.c’)
>>
>>
>>             The hello program is not rebuilt when I edit the content
>>             of ‘hello.h’.
>>
>>             Is there a workaround for that ? I know I can add a
>>             Depends(‘hello.c’, ‘hello.h’) , but that is not a very
>>             convenient solution for me, as I would have to do it in
>>             many places.
>>
>>             Best regards,
>>             Julien
>>
>>
>>             _______________________________________________
>>             Scons-users mailing list
>>             Scons-users at scons.org <mailto:Scons-users at scons.org>
>>             https://pairlist4.pair.net/mailman/listinfo/scons-users
>>             <https://pairlist4.pair.net/mailman/listinfo/scons-users>
>
>             _______________________________________________
>             Scons-users mailing list Scons-users at scons.org
>             <mailto:Scons-users at scons.org>
>             https://pairlist4.pair.net/mailman/listinfo/scons-users
>             <https://pairlist4.pair.net/mailman/listinfo/scons-users> 
>
>         _______________________________________________ Scons-users
>         mailing list Scons-users at scons.org
>         <mailto:Scons-users at scons.org>
>         https://pairlist4.pair.net/mailman/listinfo/scons-users
>         <https://pairlist4.pair.net/mailman/listinfo/scons-users> 
>
>     _______________________________________________ Scons-users
>     mailing list Scons-users at scons.org <mailto:Scons-users at scons.org>
>     https://pairlist4.pair.net/mailman/listinfo/scons-users
>     <https://pairlist4.pair.net/mailman/listinfo/scons-users> 
>
> _______________________________________________
> 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/20170317/f7d0a85a/attachment.html>


More information about the Scons-users mailing list