[Scons-users] What is the best approach with SConstruct calling SConscript
Pierre-Luc Boily
pierreluc.boily at gmail.com
Thu Nov 3 16:40:53 EDT 2016
I have a philosophical question.
How should I call my 160 SConscript?
1 - Call all 160 one by one, hard-coded?
2 - Have a function that find them and iterate over it?
Right now, we are using idea number 2, it looks like that :
|def buildSpeech(common_env):
| ListOfSConscriptFiles, ListOfRelativePaths = findAllSconscriptFiles()
| i = 0
| for file in ListOfSConscriptFiles:
| variantDir = os.path.join(common_env['ENV']['VARIANTDIRROOT'],
ListOfRelativePaths[i][2:], common_env['ENV']['CONFIG'])
| sconsScript = os.path.join(ListOfRelativePaths[i], file)
| SConscript(sconsScript, {'common_env' : common_env},
variant_dir=variantDir, duplicate=0)
| i = i+1
|
|common_env = environmentCreator.EnvironmentCreator().get_env()
But soon, I will need other environments. I might need to do something line
this :
|def buildSpeech(common_env):
| ListOfSConscriptFiles, ListOfRelativePaths = findAllSconscriptFiles()
| i = 0
| for file in ListOfSConscriptFiles:
| variantDir = os.path.join(win32_env['ENV']['VARIANTDIRROOT'],
ListOfRelativePaths[i][2:], win32_env['ENV']['CONFIG'])
| sconsScript = os.path.join(ListOfRelativePaths[i], file)
| SConscript(sconsScript,
| {'win32_env' : win32_env, 'win64_env' : win64_env,
'java_env' : java_env},
| variant_dir=variantDir,
| duplicate=0)
| i = i+1
|
|win32_env = environmentCreator.EnvironmentCreator('win32')
|win64_env = environmentCreator.EnvironmentCreator('win64')
|java_env = environmentCreator.EnvironmentCreator('java')
I can cleary see a problem with this approach with my variantDir not correct
for all environment. There is 2 solutions:
a - List manually all SConscript and passing them the correct varianDir and
correct environment. Like this :
| variantDir = os.path.join(win32_env['ENV']['VARIANTDIRROOT'],
other_path, win32_env['ENV']['CONFIG'])
| SConscript(sconsScriptA, {'env' : win32_env},variantDir,0)
| variantDir = os.path.join(win64_env['ENV']['VARIANTDIRROOT'],
other_path, win64_env['ENV']['CONFIG'])
| SConscript(sconsScriptA, {'env' : win64_env},variantDir,0)
b - Still iterate over all of them like before, but set the variantDir
inside the SConscript (but I see somewhere else that it is not recommended
to set variantDir inside SConscript)
Which approach should I favor?
One last thing. I would like to create my environment like this :
|win32_env = environmentCreator.EnvironmentCreator('win32')
Doing this means that EnvironmentCreator has to inheritate from
SCons.Environement (Or SCons.Base, I am not sure)
Can I do this? If yes, from which class should I need to inherit?
--
View this message in context: http://scons.1086193.n5.nabble.com/What-is-the-best-approach-with-SConstruct-calling-SConscript-tp40704.html
Sent from the Users mailing list archive at Nabble.com.
More information about the Scons-users
mailing list