[Scons-users] Shared library in bin subdirectory

William Deegan bill at baddogconsulting.com
Fri Dec 28 02:32:54 EST 2012


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, 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: (UGH.. you
snipped the meat of the message.. please don't do that).


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().

-Bill



More information about the Scons-users mailing list