[Scons-users] Java builder is rebuilds when not needed

Pierre-Luc Boily pierreluc.boily at gmail.com
Wed Jan 29 21:22:18 EST 2020


I tried to simplify much as possible my sconscript(
https://pastebin.com/yhE0FwAN).  But Java builder is still not creating the
target under correct folder.

I added taskmastertrace argument :
1- First build (java file doesn't exist)( https://pastebin.com/P5X24KrK)
I can see my .class file is created directly under "classes" folder,
instead of under "classes/adacel/speech" :  <https://pastebin.com/P5X24KrK>

2- Second build (java file exists)(https://pastebin.com/6zByD2dy)
I can see that .class file has to be build again

See this picture (
https://www.dropbox.com/s/vg0cifs50i9jxqz/sconsjava.png?dl=0)  .  As you
can see, class file is created under classes\adacel\speech.  Log files
above tell me that scons think that the .class file shall be under
"classes" folder

Sorry if I look dumb, but I don't understand how Java builder could create
target "classes\adacel\speech\file.class" in the first build, because
file.java doesn't exist yet :(  From my limited understanding, scons
creates "classes\file.class" because it is the best he can do.

Le mer. 29 janv. 2020, à 18 h 41, Bill Deegan <bill at baddogconsulting.com> a
écrit :

> run with --taskmastertrace=trace.log and take a look in there.
>
> On Wed, Jan 29, 2020 at 3:19 PM Bill Deegan <bill at baddogconsulting.com>
> wrote:
>
>> yacc creates c which get's compiled to o's.
>> SCons knows when a target is built (or not yet built) and won't scan the
>> file if it's not there.
>> If it's rebuilt. SCons knows to scan the file again.
>>
>> Assuming you have a correct list of files produced by the idl (emitter
>> and/or manually specified targets), it should do the right thing.
>>
>> -Bill
>>
>> On Wed, Jan 29, 2020 at 2:12 PM Pierre-Luc Boily <
>> pierreluc.boily at gmail.com> wrote:
>>
>>> So, how Java builder can create the targets when java files are not yet
>>> existing?
>>>
>>> this
>>> classes_tgt = env.Java(target='classes',
>>>                        source=java_files_to_be_generated_from_idl)
>>>
>>> Can`t create correctly classes_tgt because java files are not yet
>>> created from idl.  Is it possible without creating a custom builder?
>>>
>>> Le mer. 29 janv. 2020, à 16 h 12, Bill Deegan <bill at baddogconsulting.com>
>>> a écrit :
>>>
>>>> When a file is built, then it would get scanned.
>>>> So likely that's not the case.
>>>>
>>>> On Wed, Jan 29, 2020 at 10:17 AM Pierre-Luc Boily <
>>>> pierreluc.boily at gmail.com> wrote:
>>>>
>>>>> I think I know what the problem is.  At the first scons pass, java
>>>>> files that are generated from idl into the variant dir don't exist yet.
>>>>> So, scons can`t scan the java file for "package" statement.  That is why
>>>>> the target is
>>>>>
>>>>> classes/fileName.class
>>>>> instead of
>>>>> classes/adacel/speech/fileName.class
>>>>>
>>>>> For this understandable reason, I don't have the choice to create my
>>>>> own builder around the Java builder.  This builder will take care of
>>>>> creating java from idl and create the correct targets in the emitter.
>>>>>
>>>>> Le mer. 29 janv. 2020, à 11 h 32, Pierre-Luc Boily <
>>>>> pierreluc.boily at gmail.com> a écrit :
>>>>>
>>>>>> Hello,
>>>>>>
>>>>>> I have a case where
>>>>>> 1- I am creating java files from idl then
>>>>>> 2- Compile those java files
>>>>>>
>>>>>> All my java files starts with "package adacel.speech;"
>>>>>>
>>>>>> --------------------------------
>>>>>> generated_java_target += env.Command(
>>>>>>                                      target='ActivateGrammar.java',
>>>>>>
>>>>>> source='#sr/speech/common_dds/ActivateGrammar.idl',
>>>>>>                                      action=[idl_command])
>>>>>>
>>>>>> classes_tgt = env.Java(target='classes',
>>>>>>                        source=generated_java_target)
>>>>>> ---------------------------------
>>>>>>
>>>>>> The code above generates all my class files under
>>>>>> "classes/adacel/speech",
>>>>>> which is correct.
>>>>>>
>>>>>> But when I start another build with following code :
>>>>>> for i in classes_tgt:
>>>>>>     print(str(i))
>>>>>>
>>>>>> I can see that all my class targets looks like this :
>>>>>> classes\ActivateGrammar.class
>>>>>>
>>>>>> Which is incorrect.  scons tell me :
>>>>>> scons: building
>>>>>>
>>>>>> `build\sr\speech\ContextualPostProcessor\RulesEngine\DroolsGenericModel\classes\TimeValueHolder.class'
>>>>>> because it doesn't exist
>>>>>>
>>>>>> Scons should look under classes\adacel\speech
>>>>>>
>>>>>> Am I doing something incorrect?  Is this a bug in Java builder?  As a
>>>>>> workaround, I though doing my own builder that takes idl that
>>>>>> generates java
>>>>>> file and build it.  And within the emitter, generate all class
>>>>>> targets that
>>>>>> points to correct path.  It could be faster, because in that case, I
>>>>>> could
>>>>>> generate all java files and compile them at once.
>>>>>>
>>>>>>
>>>>>>
>>>>>> --
>>>>>> Sent from: http://scons.1086193.n5.nabble.com/Users-f16930.html
>>>>>> _______________________________________________
>>>>>> Scons-users mailing list
>>>>>> Scons-users at scons.org
>>>>>> 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
>>>>>
>>>> _______________________________________________
>>>> Scons-users mailing list
>>>> Scons-users at scons.org
>>>> 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
>>>
>> _______________________________________________
> 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/20200129/2f649b44/attachment.html>


More information about the Scons-users mailing list