Make [was Re: SCons and gdc]

Rob T rob at ucora.com
Tue Oct 30 02:08:14 PDT 2012


On Tuesday, 30 October 2012 at 01:22:17 UTC, H. S. Teoh wrote:
> To each his own, but I honestly don't see what's so difficult 
> about
> this:
>
> 	# src/SConscript
> 	Import('env')
> 	env.Program('mydprogram', ['main.d', 'abc.d', 'def.cc'])
>
> 	# lib1/SConscript
> 	Import('env')
> 	env.Library('mylib1', ['mod1.d', 'mod2.d'])
>
> 	# lib2/SConscript
> 	Import('env')
> 	env.Library('mylib2', ['mod2.d', 'mod3.d'])
>
> 	# SConstruct
> 	objdir = 'build'
> 	env = Environment()
> 	Export(env)
> 	env.SConscript('src/SConscript',  build_dir=objdir)
> 	env.SConscript('lib1/SConscript', build_dir=objdir)
> 	env.SConscript('lib2/SConscript', build_dir=objdir)
>
> Main program in src/, two libraries in lib1, lib2, and 
> everything builds
> in build/ instead of the respective source trees. No problem. I 
> even
> threw in a C++ file for kicks.

You are right, Make cannot do something like that in a reasonable 
way, and it looks great.

You are describing one main project, with sub-level projects 
inside, so the build dump is still going into the project tree. 
This may work for some people, but it is frustrating for someone 
who wishes to dump the build files outside of the project tree. I 
guess there's just no solution to do different at this time. Not 
what I want, but not a terminal problem either.

Also scons has no built-in ability to scan subfolders for source 
files. You can manually specify sub-level source files, but 
that's unreasonable to do for large projects. You can write 
custom Python code to scan subfolders, but that is a lot more 
complicated than it should be. Do you know of a decent solution 
to scan sub-folders?

Scons does look like a very powerful tool, and I really do 
appreciate your input and the other posters as well. I am 
determined not to continue with Make, so maybe I will have to 
keep trying to get scons to do what I want.

One more question: I am wondering how the scons D support locates 
dependencies from the imports specfied in the source files? So 
far I have not been able to get automatic dependency inclusions 
to work, so I end up manually specifying the import files. With 
C++ and Make, I could get gcc to scan source files for the 
#include files, and dump the list to a dependency file (.dep), 
and then I could include the .dep file(s) into the make process. 
Can scons with D support do something similar, or deal with it 
better?

--rt



More information about the Digitalmars-d mailing list