[Scons-users] build dependencies question(s)

Nikola Radovanovic nikola.radovanovic at schneider-electric-dms.com
Fri Nov 16 09:45:04 EST 2012


hi,
first of all - thank you for the answer. I can provide example (of what I did so far) if that will make situation bit clearer.
basically, I want to achive following:

in company, we have LARGE source tree with various languages (talking about millions of lines-of-code) with C++, JAVA, PASCAL, Python, C# code. we also have linux/windows builds (gmake/nmake, msbuild, etc.). I'm experimenting with build tools, trying to create some basic python scripts/classes adopted to our needs, so that (regular) developer does not need to know SCons (or some other build system) itself, but to do in its own SConscript somehing like this:
srcs = ['funcs.cpp', 'common.cpp', 'static_lib.cpp']
src_path = [os.path.join(args['root_dir'], 'common'), os.path.join(args['root_dir'], 'additions'), os.path.join(args['root_dir'], 'test_lib')]
rc_file = os.path.join(args['root_dir'], 'test_lib', 'Win32', 'test_lib.rc')
Builder = cpp_build_helper.StaticBuilder(args, srcs, rc_file, src_path, [], [])
Builder.execute_build('test_lib')

My plan is to create helper python classes for EXE/DLL(SO)/LIB (for various languages) which will be used in aid to developers.
I managed to create following chain: LIB <-- DLL(SO) <-- EXE. and i think thats ok.

problems arised when i added omniORB IDL builder. I have created IDL compiler, but there should be different stubs-build procedure for windows and linux: on windows i need to create static library first, export symbols, generate def file and than link all to DLL. on linux i should normally create SO from objects. i wanted this 'stubs builder' to be split in two parts: IDL and stub builder itself and those two to be exectued before any other (first IDL than STUB builder). i will try what you told me and will report back :)


On 11/16/2012 02:50 PM, Dirk Bächle wrote:
Hi Nikola,

you should be able to achieve your goals without having to use special methods like Depends().

On 16.11.2012 12:52, Nikola Radovanovic wrote:
hi,
i have a few question(s) regarding build order in SCons:

if i have multiple Environments: say e1 and e2; where for example e1 is a C++ dll and e2 is say PASCAL exe consuming C++ dll


* is it possible to have 2 different SConscript files, each holding one of e's and SConstruct file calling SConscripts and synchronizing results. ie:

s1 SConscript:
e1 = Environment(...) # C++ dll build
res = e1.SharedLibrary('test.dll', ...)
Return('res')

s2 SConscript:
e2 = Environment(...) # PASCAL exe build
res = e2.Program('test.exe', ...)
Return('res')

SConstruct
res_2 = SConscript('s2')
res_1 = SConscript('s1')
Depends(res_2, res_1) # this will not help i presume?


You shouldn't have to use Depends() here and don't need the Return() stuff either. If you have the following structure:

project
- SConstruct
mylib
- SConscript
- lib.cpp
myexe
- SConscript
- main.cpp

your build files could look like this:

SConstruct
---------------

SConscript('mylib/SConscript')
SConscript('myexe/SConscript')


mylib/SConscript
----------------------

e = Environment(...) # C++ dll build
e.SharedLibrary('mylib', 'lib.cpp')

myexe/SConscript
----------------------

e = Environment(...) # PASCAL exe build
e.Program('myprog', 'main.cpp', LIBS=['mylib'], LIBPATH=['#mylib'])


Like this, SCons automatically detects that it has to compile the 'mylib' library before trying to link against it.
Regard how I didn't use any suffixes for the SharedLibrary, I removed the ".dll". Now SCons adds a ".dll" under Windows, but a ".so" under Linux...the same holds for the name of the executable.

i have deliberately wrote res_2 before res_1, but in reallity, i want s1 to be called and finished before s2. cant that be done?


* is there any way to force execution order of different Environments()?

Don't try to enforce a special order for the single build steps. Try to think of your build process as a large graph of dependencies and tell SCons which targets depend on which sources. Then let SCons figure out the rest...


for some time i'm experimenting with SCons trying to find the way to improve our linux/windows build constisting out of C++, Delphi, JAVA code but with not much luck.

If you encounter more problems during your experiments, please continue to ask questions. Regard that providing simple and working examples will make it easier for us to understand your problems, so we can help you much faster and better.


Best regards,

Dirk




_______________________________________________
Scons-users mailing list
Scons-users at scons.org<mailto:Scons-users at scons.org>
http://four.pairlist.net/mailman/listinfo/scons-users



--
__________________________________________________________________________________________________________________

Nikola Radovanovic | Schneider Electric DMS NS | Smart Grid IT | SERBIA | CPASv2 team deputy
Phone: +381 (0)21 488 3633 | Fax: +381 (0)21 488 3789 | Mobile: +381 (0)64 29 74 528
Email: nikola.radovanovic at schneider-electric-dms.com<mailto:nikola.radovanovic at schneider-electric-dms.com> | Site: www.schneider-electric-dms.com<http://www.schneider-electric-dms.com/> | Address: Narodnog fronta 25A-D, 21000 Novi Sad
*** Please consider the environment before printing this e-mail

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://four.pairlist.net/pipermail/scons-users/attachments/20121116/d569a40e/attachment.html>


More information about the Scons-users mailing list