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

Julien Pommier pommier at pianoteq.com
Tue Mar 14 12:50:00 EDT 2017


Thanks Jean-Baptiste, that’s what I was expecting , unfortunately. I thought I would just put the md5 hash of the “hello.h” file content into a dummy preprocessor macro to force the recompilation when the hello.h is modified , with  something like:

 env.Append(CPPDEFINES={“HELLO_HASH":File(‘hello.h').get_content_hash()})

But that does not work when the file "hello.h" is itself including other h files, I would need to retrieve a hash of “hello.h" with all its dependencies, is that possible ? I can’t figure how to do that.

—
Julien


> On 14 Mar 2017, at 13:04, Jean-Baptiste Lab <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
> https://pairlist4.pair.net/mailman/listinfo/scons-users

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://pairlist4.pair.net/pipermail/scons-users/attachments/20170314/4d408bb1/attachment.html>


More information about the Scons-users mailing list