[Scons-users] Error while refreshing build settings
Michael Potter
michael at potter.name
Thu Feb 14 14:45:36 EST 2013
On Thu, Feb 14, 2013 at 1:34 PM, Russel Winder <russel at winder.org.uk> wrote:
> On Wed, 2013-02-13 at 22:04 -0500, Michael Potter wrote:
> […]
>> After rearranging the code, I am having other problems and decided to
>> make a mini version of my code to test with. I have attached that as
>> a .zip file. If you care to reproduce the problems I am having you
>> can use it to test. What I am doing that is unusual is generating
>> code AND using VariantDir().
>
> I have to say I would not structure the project in this way. I think you
> have an extra level of directories adding to the complexity that is not
> needed.
I don't like the source directory either. I added it because I was
trying to solve the problem of having the gensrc directory at the same
level as the src folder.
>
> Unless you need to keep the generated source I would not have a
> directory under source for it.
I only need to keep the gensrc directory because Eclipse will complain
if it cannot find the generated source code. By complain, I mean that
it will have red underlines in the source view for all the things that
are not defined.
I see you eliminated the gensrc directory in your sample code. That
is all good if Eclipse does not complain.
>
>> I started to move my code around and am not stuck with a problem
>> compiling on the command line. I have to resolve that before figuring
>> out what is wrong with Eclipse.
>
> What is wrong with Eclipse is a very long list indeed, but I suspect we
> do not want to go there :-)
>
> Are you using SConsolidator to use SCons in Eclipse?
Yes, I am using SConsolidator in Eclipse. It was working as far as I
could tell except it was throwing an error message when it ran.
Despite the error message it was configuring Eclipse.
>
>> Here is the error I am getting when doing the out-of-source build:
>>
>> [pottmi at CentOS6-3 sconstest]$ scons -u
>> scons: Reading SConscript files ...
>> scons: done reading SConscript files.
>> scons: Building targets ...
>> gcc -o build/src/diamond.o -c -I. -Isource build/src/diamond.c
>> build/src/diamond.c:3:26: error: gensrc/joker.h: No such file or directory
>> build/src/diamond.c: In function 'main':
>> build/src/diamond.c:7: error: 'joker' undeclared (first use in this function)
>> build/src/diamond.c:7: error: (Each undeclared identifier is reported only once
>> build/src/diamond.c:7: error: for each function it appears in.)
>> scons: *** [build/src/diamond.o] Error 1
>> scons: building terminated because of errors.
>
> You do not have the generated joker.h in the build tree so it is not
> being created and hence the compilations fail. You need to ensure
> joker.h is listed as a dependency of the compilation products.
>
I have a #include "gensrc/joker.h" in diamond.c, so that should signal
scons that it is a dependency. That dependency detection works if I
do in-source build, but does not work if I do a out-of-source build.
As a test, I removed this line from your proposed solution:
environment.Depends('diamond.o', 'joker.h')
Dependency detection still worked. So I think that line was redundant
with the automatic dependency detection. That is good.
>> Here is a successful run doing an in-source build:
>> [pottmi at CentOS6-3 sconstest]$ scons -u
>> scons: Reading SConscript files ...
>> scons: done reading SConscript files.
>> scons: Building targets ...
>> make_define(["source/gensrc/joker.h"], ["source/src/joker.txt"])
>> gcc -o source/src/diamond.o -c -I. -Isource source/src/diamond.c
>> gcc -o source/src/queen.o -c -I. -Isource source/src/queen.c
>> gcc -o source/diamond source/src/diamond.o source/src/queen.o
>> scons: done building targets.
>
> To be honest I have no idea why this worked!
>
> (But that may be that I didn't look for long enough.)
>
>> Once the in-source build runs, the out-of-source build will work
>> (because the code is generated):
>> [pottmi at CentOS6-3 sconstest]$ scons -u
>> scons: Reading SConscript files ...
>> scons: done reading SConscript files.
>> scons: Building targets ...
>> gcc -o build/src/diamond.o -c -I. -Isource build/src/diamond.c
>> gcc -o build/src/queen.o -c -I. -Isource build/src/queen.c
>> gcc -o build/diamond build/src/diamond.o build/src/queen.o
>> make_define(["build/gensrc/joker.h"], ["build/src/joker.txt"])
>> scons: done building targets.
>
> This is just a side effect of not having cleaned things first.
>
> Personally I am not sure having in-tree builds is worth worrying about,
> just support out-of-tree builds.
I agree completely. I only want to have out-of-source builds; I am
only doing in-source builds for debugging purposes.
>
>> SConstruct for in-source build:
>> SConscript('source/SConscript')
>>
>> SConstruct for out-of-source build:
>> VariantDir('build', 'source')
>> SConscript('build/SConscript')
>
> I think the last line should always be:
>
> SConscript('source/SConscript')
I could not get that to work. It insisted on doing an in-source build
without the 'build/SConscript'.
Your proposed solution uses source/SConscript and supports
out-of-source builds, so I am just going to use your proposed
solution.
Despite these minor problems, I am still very impressed with scons.
I am planning on continuing to enhance this sample project and using
it as a basis for a presentation. I will start with the most simple
case and keep adding features and implementing the build in scons. I
will keep the list posted with my progress.
Thanks for you help. I think you have put me on the right track for success.
I will be reporting back with what I learn and get feedback on my techniques.
>
> I had a play with your files, rearranged, and made work as I would want
> it. This may of course bear no relationship to what you actually want to
> do :-)
>
> --
> Russel.
> =============================================================================
> Dr Russel Winder t: +44 20 7585 2200 voip: sip:russel.winder at ekiga.net
> 41 Buckmaster Road m: +44 7770 465 077 xmpp: russel at winder.org.uk
> London SW11 1EN, UK w: www.russel.org.uk skype: russel_winder
>
> _______________________________________________
> Scons-users mailing list
> Scons-users at scons.org
> http://four.pairlist.net/mailman/listinfo/scons-users
>
--
Michael Potter
Tapp Solutions, LLC
Replatform Technologies, LLC
+1 770 815 6142 ** Atlanta ** michael at potter.name **
www.linkedin.com/in/michaelpotter
More information about the Scons-users
mailing list