[Scons-users] Shared library in bin subdirectory
    LRN 
    lrn1986 at gmail.com
       
    Fri Dec 28 03:04:12 EST 2012
    
    
  
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On 28.12.2012 11:32, William Deegan wrote:
> On 12/27/2012 11:26 PM, LRN wrote:
>> 
>>>>>> Here's what i do:
>>>>>> 
>>>>>> prefix = ARGUMENTS.get ('prefix', None) destdir = 
>>>>>> ARGUMENTS.get ('destdir', None) if prefix == None: prefix
>>>>>> = '/usr/local'
>>>>>> 
>>>>>> foo = env.SharedLibrary (target = "foo", source =
>>>>>> ["foo.c"], SHLIBPREFIX = 'lib', LIBSUFFIX='.dll.a') if
>>>>>> destdir is not None: destprefix = destdir + prefix
>>>>>> env.Install (os.path.join (destprefix, 'bin'), [foo]) 
>>>>>> env.Alias('install', destprefix)
>>>>>> 
>>>>>> And when i do `scons prefix=/ destdir=c:/bar install', i
>>>>>> end up having libfoo.dll.a import library in c:/bar/bin/ 
>>>>>> directory instead of c:/bar/lib. How do i make
>>>>>> SharedLibrary or Install put the import library into /lib
>>>>>> subdirectory?
>>>>>> 
>>>>> Here's your problem: env.Install (os.path.join
>>>>> (destprefix, 'bin'), [foo])
>>>>> 
>>>>> Change 'bin' to 'lib'...
>>>> Thank you for your quick response.
>>>> 
>>>> I've tried that, and it works - libfoo.dll.a is installed
>>>> into /lib subdir!
>>>> 
>>>> However, a completely unrelated problem has cropped up: Now
>>>> when i do `scons prefix=/ destdir=c:/bar install', i end up
>>>> having libfoo.dll shared library in c:/bar/lib/ directory
>>>> instead of c:/bar/bin. How do i make SharedLibrary or Install
>>>> put the shared library into /bin subdirectory?
>>>> 
>>> Any builder only specifies 1 target dir. If you want to have
>>> the output(s) go to more than one, then you'll have to use 
>>> env.Install() to do so.
>>> 
>> And how do i do that? According to the man,
>>> Installs one or more source files or directories in the
>>> specified target, which must be a directory. The names of the
>>> specified source files or directories remain the same within
>>> the destination directory. env.Install('/usr/local/bin', source
>>> = ['foo', 'bar'])
>> only one directory is passed to Install. And even if it accepted
>> two directories, i wouldn't want to have .dll and .dll.a in BOTH
>> /bin and /lib subdirs. So, how do i put .dll in /bin and .dll.a.
>> in /lib?
> 
> All env.BLAH's return a list of Node's. so: 
> libs=env.SharedLibrary('blah',[sources]) On windows will return a
> list with more than one Nodes. Now you could iterate through that
> list and get the file names and install the .dll one place and the
> .dll.a another place
Yeah, that worked! Thanks! I did:
foo = env.SharedLibrary (target = "foo", source = ["foo.c"],
SHLIBPREFIX = 'lib', LIBSUFFIX='.dll.a')
str_foo = {}
for x in foo:
  str_foo[str(x)] = x
if destdir is not None:
  destprefix = destdir + prefix
  for s_x, x in str_foo.items ():
    if s_x[-2:] == '.a':
      env.Install (os.path.join (destprefix, 'lib'), x)
    else:
      env.Install (os.path.join (destprefix, 'bin'), x)
  env.Alias('install', destprefix)
Now, the library is not supposed to build on anything that does not
provide W32API, and so, it not being portable, i don't have to worry
about SharedLibrary NOT returning a list, but i'm just curious: what
does SharedLibrary return when it builds only one .so file? Single
node? Or a list with one item? And how would i have to deal with that,
if the library was portable, and SConstruct would have had to work on
different OSes?
> (UGH.. you snipped the meat of the message.. please don't do
> that).
Uh, what?
> , or you could just tell SCons to install the .dll from the target
> dir of the SharedLibrary() to /bin and the .dll.a to /lib as such:
> 
> foo = env.SharedLibrary (target = "foo", source = ["foo.c"],
> SHLIBPREFIX = 'lib', LIBSUFFIX='.dll.a') 
> env.Install('/bin','libfoo.dll') 
> env.Install('/lib','libfoo.dll.a')
> 
> SCons will then connect the dots. (change the second arguments of
> the installs to match the directory you're building them into via
> your SharedLibrary().
...and for that i need to somehow know where the builddir is, and
where the .dll and .dll.a files end up, and how they are named. Ok,
the naming part should be obvious, since i did provide prefix and
suffix. But the rest is not so obvious.
I i would prefer to stick with the explicit extension check.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (MingW32)
Comment: Using GnuPG with undefined - http://www.enigmail.net/
iQEcBAEBAgAGBQJQ3VJ8AAoJEOs4Jb6SI2CwmiMH/27mgaZLTOxdd9o4ucn1SBU5
Zkxb8RZBTuulLCoO6s7uoTNHhONHjU/nMi86ZTnPlwtQZClaUxj6x1OZko1BTm/Y
jphNGtNmyDSeoY5XkkDEL8BVBBVrIY9TSrcvbd3i1R6oHiP+OP5We7fN2WpOfYZJ
dZaJUSWHrm8QwCGpoSJdfLZZkbumd0mGVwB4zkp288aF4VjPqRVawmFwROk8cIIx
x1KU/NKqKATWTjFxrDEprahBtqYVkGibNUx6DIt5jMbOL89fDNJdaQ0GChCGQt0n
pQs0zvxwzeAN0S/rbyui0ca68T7yLULzN8LvwMIZInO0hfA3177TH1o1RmEbuXc=
=wwGn
-----END PGP SIGNATURE-----
    
    
More information about the Scons-users
mailing list