0

I'm having sconscript that has a line like this:

EXT_SHADERS = shader_env.SharedLibrary('scrubs', source_files, LIBPREFIX='')

And the source_files is "abbreviated" from:

src_base_dir  = os.path.join(shader_env['ROOT_DIR'], 'contrib', 'extensions', 'scrubs', 'shaders')
source_files  = [os.path.join('shaders', x) for x in find_files_recursive(src_base_dir, ['.c', '.cpp'])]

Now I know from the docs this builds one shared library named scrubs but what need is for each .cpp file in source folder one shared library built only from it's corresponding source file (.cpp) and option to add more sources later without changing the build script, is anything like this possible cause.I'm not seeing anything in the docs or elsewhere,

Thanks in advance

Avner Shahar-Kashtan
  • 14,492
  • 3
  • 37
  • 63
im-i0dum
  • 474
  • 1
  • 5
  • 13
  • Are the source files under the same directory as the root SConsctruct? Scons does not build files that are considered to be out of the directory tree. – Brady Jan 06 '13 at 12:46
  • hi, if i understood you corectly, no, you can see path to the folder with source files in src_base_dir line, and sconscript file is just outside that folder, SConstruct in in ROOT_DIR, this builds nice as one shared lib but that's not what i need ... – im-i0dum Jan 06 '13 at 12:51

1 Answers1

1

If you want one shared library per source file and that the library name has the same base-name as the source file (fileName1.cc => libfileName1.so, fileName2.cc => libfileName2.so) then you'll have to write some more python code, preferably using the os.path.splitext() function.

Here is an example.

Also, from your answer, I see the possibility that the source files are not in the same directory structure as the root SConsctruct, which is not supported by SCons. Here are two examples (one supported, the other not)

Supported dir structure

topDir/
  SConstruct
  srcDir/
     srcFile1.cc
     srcFile2.cc

Not supported dir structure

topDir/
  subDir1/
     SConstruct
  subDir2/
     srcFile1.cc
     srcFile2.cc
Community
  • 1
  • 1
Brady
  • 10,207
  • 2
  • 20
  • 59
  • yes, this is what i was thinking, thanks for the example, and yes my dir structure was your second example but i didn't create that (i'm only editing to my own needs) and it works that way so let's leave that aside cause mechanism is that you put your optional stuff into extensions folder and it only builds if you call it as option to sconstruct, hope that makes some sense – im-i0dum Jan 06 '13 at 13:09