Discussion:
[Scons-users] Does not copy/link my file target/lib when needed?
edA-qa mort-ora-y
2018-01-27 08:36:00 UTC
Permalink
I'm trying to get a library file linked in a variant_dir before the
configuration is complete (this is in order to get the rpath references
correct). It links the file once, but it does not copy it again if the
destination is deleted.

My SConstruct

baseEnv = Environment(
    BUILD_DIR='build'
    )
Export('baseEnv')
baseEnv.SConscript('src/SConscript', variant_dir=baseEnv['BUILD_DIR'], duplicate=0)
Default(baseEnv['BUILD_DIR'])


My src/SConscript

    import os

    Import('baseEnv')

    def SymLink():
        def Impl(target, source, env):
            print( "SymLink" )
            os.symlink(os.path.abspath(str(source[0])),
os.path.abspath(str(target[0])))
            return 0

        return Action(Impl, "linking file to $TARGET from $SOURCE" )


    env = baseEnv.Clone()
    env.Append( LIBPATH = './' )

    lib_some = 'some'
    lib_some_ref = 'libsome.so'

    env.Command( lib_some_ref, '../lib/' + lib_some_ref, SymLink() )

    conf = Configure(env)
    conf.CheckLib( lib_some )
    env = conf.Finish()

You can place any shared library into lib/libsome.so to test. I'm
testing on Linux at the moment.

I've tried env.Requires( '.', ... ) with the Command as well, but no luck.

It also doesn't appear to be an issue with the Symlink action since a
Copy action has the same problem:

env.Command( lib_some_ref, '../lib/' + lib_some_ref,
Copy("$TARGET","$SOURCE")
--
edA-qa mort-ora-y
http://mortoray.com/

Leaf - the language we always wanted
http://leaflang.org/
Bill Deegan
2018-01-27 21:00:02 UTC
Permalink
Configure contexts are usually evaluated first.

Why are you doing this?

If you're building the library, it's not clear why you need to have
Configure check if the library exists...
Is there some strange possibility that the library you build cannot be
linked against?

-Bill
Post by edA-qa mort-ora-y
I'm trying to get a library file linked in a variant_dir before the
configuration is complete (this is in order to get the rpath references
correct). It links the file once, but it does not copy it again if the
destination is deleted.
My SConstruct
baseEnv = Environment(
BUILD_DIR='build'
)
Export('baseEnv')
baseEnv.SConscript('src/SConscript', variant_dir=baseEnv['BUILD_DIR'], duplicate=0)
Default(baseEnv['BUILD_DIR'])
My src/SConscript
import os
Import('baseEnv')
print( "SymLink" )
os.symlink(os.path.abspath(str(source[0])),
os.path.abspath(str(target[0])))
return 0
return Action(Impl, "linking file to $TARGET from $SOURCE" )
env = baseEnv.Clone()
env.Append( LIBPATH = './' )
lib_some = 'some'
lib_some_ref = 'libsome.so'
env.Command( lib_some_ref, '../lib/' + lib_some_ref, SymLink() )
conf = Configure(env)
conf.CheckLib( lib_some )
env = conf.Finish()
You can place any shared library into lib/libsome.so to test. I'm
testing on Linux at the moment.
I've tried env.Requires( '.', ... ) with the Command as well, but no luck.
It also doesn't appear to be an issue with the Symlink action since a
env.Command( lib_some_ref, '../lib/' + lib_some_ref,
Copy("$TARGET","$SOURCE")
--
edA-qa mort-ora-y
http://mortoray.com/
Leaf - the language we always wanted
http://leaflang.org/
_______________________________________________
Scons-users mailing list
https://pairlist4.pair.net/mailman/listinfo/scons-users
edA-qa mort-ora-y
2018-01-27 21:43:35 UTC
Permalink
The library is built as part of an external build process (LLVM build
scripts). I specify the directory to it as part of my scons variables.

The reason to link it (or copy would be fine), is because I need the
linker to create a relative RPATH to the library (there are no flags to
configure this on Linux/OSX linkers other than just putting the library
beside the other libraries/EXEs).

I could possibly remove it from the Check step and do my own checking. 
Originally I wasn't concerned about RPATH, thus it was setup
differently.  I'm not sure why putting in it the check though prevents
the other step from updating it.
Post by Bill Deegan
Configure contexts are usually evaluated first.
Why are you doing this?
If you're building the library, it's not clear why you need to have
Configure check if the library exists...
Is there some strange possibility that the library you build cannot be
linked against?
-Bill
On Sat, Jan 27, 2018 at 12:36 AM, edA-qa mort-ora-y
I'm trying to get a library file linked in a variant_dir before the
configuration is complete (this is in order to get the rpath references
correct). It links the file once, but it does not copy it again if the
destination is deleted.
My SConstruct
        baseEnv = Environment(
            BUILD_DIR='build'
            )
        Export('baseEnv')
        baseEnv.SConscript('src/SConscript',
variant_dir=baseEnv['BUILD_DIR'], duplicate=0)
        Default(baseEnv['BUILD_DIR'])
My src/SConscript
    import os
    Import('baseEnv')
            print( "SymLink" )
            os.symlink(os.path.abspath(str(source[0])),
os.path.abspath(str(target[0])))
            return 0
        return Action(Impl, "linking file to $TARGET from $SOURCE" )
    env = baseEnv.Clone()
    env.Append( LIBPATH = './' )
    lib_some = 'some'
    lib_some_ref = 'libsome.so'
    env.Command( lib_some_ref, '../lib/' + lib_some_ref, SymLink() )
    conf = Configure(env)
    conf.CheckLib( lib_some )
    env = conf.Finish()
You can place any shared library into lib/libsome.so to test. I'm
testing on Linux at the moment.
I've tried env.Requires( '.', ... ) with the Command as well, but no luck.
It also doesn't appear to be an issue with the Symlink action since a
env.Command( lib_some_ref, '../lib/' + lib_some_ref,
Copy("$TARGET","$SOURCE")
--
edA-qa mort-ora-y
http://mortoray.com/
Leaf - the language we always wanted
http://leaflang.org/
_______________________________________________
Scons-users mailing list
https://pairlist4.pair.net/mailman/listinfo/scons-users
<https://pairlist4.pair.net/mailman/listinfo/scons-users>
_______________________________________________
Scons-users mailing list
https://pairlist4.pair.net/mailman/listinfo/scons-users
--
edA-qa mort-ora-y
http://mortoray.com/

Leaf - the language we always wanted
http://leaflang.org/
Bill Deegan
2018-01-27 21:59:05 UTC
Permalink
Post by edA-qa mort-ora-y
The library is built as part of an external build process (LLVM build
scripts). I specify the directory to it as part of my scons variables.
The reason to link it (or copy would be fine), is because I need the
linker to create a relative RPATH to the library (there are no flags to
configure this on Linux/OSX linkers other than just putting the library
beside the other libraries/EXEs).
I could possibly remove it from the Check step and do my own checking.
Originally I wasn't concerned about RPATH, thus it was setup differently.
I'm not sure why putting in it the check though prevents the other step
from updating it.
It's not preventing it from checking it, it's that the check will happen
first and thus not find it where the symlink will put it.

Not sure why you even need to check it.
User specifies location on command line:
scons MY_LIB=/home/balh/lib/libabc.so (or MY_LIB_PATH=/home/blah/lib )
You have your programs link against
variant_dir/libs
You have your symlink or whatever copy/link the file form MY_LIBPATH to
variant_dir/libs

Then it just works..
If the file is not there, the build will fail.

What are you trying to achieve by the check other than that the file is
present and linkable?
Post by edA-qa mort-ora-y
Configure contexts are usually evaluated first.
Why are you doing this?
If you're building the library, it's not clear why you need to have
Configure check if the library exists...
Is there some strange possibility that the library you build cannot be
linked against?
-Bill
Post by edA-qa mort-ora-y
I'm trying to get a library file linked in a variant_dir before the
configuration is complete (this is in order to get the rpath references
correct). It links the file once, but it does not copy it again if the
destination is deleted.
My SConstruct
baseEnv = Environment(
BUILD_DIR='build'
)
Export('baseEnv')
baseEnv.SConscript('src/SConscript',
variant_dir=baseEnv['BUILD_DIR'], duplicate=0)
Default(baseEnv['BUILD_DIR'])
My src/SConscript
import os
Import('baseEnv')
print( "SymLink" )
os.symlink(os.path.abspath(str(source[0])),
os.path.abspath(str(target[0])))
return 0
return Action(Impl, "linking file to $TARGET from $SOURCE" )
env = baseEnv.Clone()
env.Append( LIBPATH = './' )
lib_some = 'some'
lib_some_ref = 'libsome.so'
env.Command( lib_some_ref, '../lib/' + lib_some_ref, SymLink() )
conf = Configure(env)
conf.CheckLib( lib_some )
env = conf.Finish()
You can place any shared library into lib/libsome.so to test. I'm
testing on Linux at the moment.
I've tried env.Requires( '.', ... ) with the Command as well, but no luck.
It also doesn't appear to be an issue with the Symlink action since a
env.Command( lib_some_ref, '../lib/' + lib_some_ref,
Copy("$TARGET","$SOURCE")
--
edA-qa mort-ora-y
http://mortoray.com/
Leaf - the language we always wanted
http://leaflang.org/
_______________________________________________
Scons-users mailing list
https://pairlist4.pair.net/mailman/listinfo/scons-users
_______________________________________________
--
edA-qa mort-ora-y http://mortoray.com/
Leaf - the language we always wantedhttp://leaflang.org/
_______________________________________________
Scons-users mailing list
https://pairlist4.pair.net/mailman/listinfo/scons-users
edA-qa mort-ora-y
2018-01-28 08:35:38 UTC
Permalink
Yeah, the check was a remnant for when I wasn't copying the file.

I changed it as you suggested, copy the file, drop the conf, and just
depend on that library. It always copies the the file now.

Thanks.
Post by edA-qa mort-ora-y
The library is built as part of an external build process (LLVM
build scripts). I specify the directory to it as part of my scons
variables.
The reason to link it (or copy would be fine), is because I need
the linker to create a relative RPATH to the library (there are no
flags to configure this on Linux/OSX linkers other than just
putting the library beside the other libraries/EXEs).
I could possibly remove it from the Check step and do my own
checking.  Originally I wasn't concerned about RPATH, thus it was
setup differently.  I'm not sure why putting in it the check
though prevents the other step from updating it.
It's not preventing it from checking it, it's that the check will
happen first and thus not find it where the symlink will put it.
Not sure why you even need to check it.
scons MY_LIB=/home/balh/lib/libabc.so  (or MY_LIB_PATH=/home/blah/lib )
You have your programs link against
variant_dir/libs
You have your symlink or whatever copy/link the file form MY_LIBPATH
to variant_dir/libs
Then it just works..
If the file is not there, the build will fail.
What are you trying to achieve by the check other than that the file
is present and linkable?
 
Post by Bill Deegan
Configure contexts are usually evaluated first.
Why are you doing this?
If you're building the library, it's not clear why you need to
have Configure check if the library exists...
Is there some strange possibility that the library you build
cannot be linked against?
-Bill
On Sat, Jan 27, 2018 at 12:36 AM, edA-qa mort-ora-y
I'm trying to get a library file linked in a variant_dir before the
configuration is complete (this is in order to get the rpath references
correct). It links the file once, but it does not copy it again if the
destination is deleted.
My SConstruct
        baseEnv = Environment(
            BUILD_DIR='build'
            )
        Export('baseEnv')
        baseEnv.SConscript('src/SConscript',
variant_dir=baseEnv['BUILD_DIR'], duplicate=0)
        Default(baseEnv['BUILD_DIR'])
My src/SConscript
    import os
    Import('baseEnv')
            print( "SymLink" )
            os.symlink(os.path.abspath(str(source[0])),
os.path.abspath(str(target[0])))
            return 0
        return Action(Impl, "linking file to $TARGET from
$SOURCE" )
    env = baseEnv.Clone()
    env.Append( LIBPATH = './' )
    lib_some = 'some'
    lib_some_ref = 'libsome.so'
    env.Command( lib_some_ref, '../lib/' + lib_some_ref,
SymLink() )
    conf = Configure(env)
    conf.CheckLib( lib_some )
    env = conf.Finish()
You can place any shared library into lib/libsome.so to test. I'm
testing on Linux at the moment.
I've tried env.Requires( '.', ... ) with the Command as well,
but no luck.
It also doesn't appear to be an issue with the Symlink action since a
env.Command( lib_some_ref, '../lib/' + lib_some_ref,
Copy("$TARGET","$SOURCE")
--
edA-qa mort-ora-y
http://mortoray.com/
Leaf - the language we always wanted
http://leaflang.org/
_______________________________________________
Scons-users mailing list
https://pairlist4.pair.net/mailman/listinfo/scons-users
<https://pairlist4.pair.net/mailman/listinfo/scons-users>
_______________________________________________
Scons-users mailing list
https://pairlist4.pair.net/mailman/listinfo/scons-users
<https://pairlist4.pair.net/mailman/listinfo/scons-users>
--
edA-qa mort-ora-y
http://mortoray.com/
Leaf - the language we always wanted
http://leaflang.org/
_______________________________________________
Scons-users mailing list
https://pairlist4.pair.net/mailman/listinfo/scons-users
<https://pairlist4.pair.net/mailman/listinfo/scons-users>
_______________________________________________
Scons-users mailing list
https://pairlist4.pair.net/mailman/listinfo/scons-users
--
edA-qa mort-ora-y
http://mortoray.com/

Leaf - the language we always wanted
http://leaflang.org/
Loading...