Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SCons: prevent $TEXT expansion in construction variable

Tags:

scons

When I call a builder Program(Target, Source, CXXFLAGS=CompileFlags) the value of CompileFlags string contains -Wl,-rpath,lib:$ORIGIN/../lib causing $ORIGIN to be expanded to empty string, while it should be preserved as is.

I tried escaping the dollar sign, adding single quotes inside, nothing helps.

env['RPATH'] = Literal('lib:$ORIGIN/../lib')

also does not work: it produces

g++ -o main -Wl,-rpath=lib:/../lib

in command line even though the man page says "the paths added to RPATH are not transformed by scons in any way" so it supposed to work even without Literal(), I guess.

So how can I add a compiler flag containing $TEXT without SCons trying to expand it as a variable?

Thanks.

like image 240
jackhab Avatar asked Aug 23 '11 10:08

jackhab


2 Answers

You can use double dollars, like this:

env['RPATH'] = Literal('lib:$$ORIGIN/../lib')
like image 147
mcinek Avatar answered Oct 15 '22 17:10

mcinek


I found this can solve the expansion problem

    Env['ORIGIN'] = Literal('$ORIGIN')
    Env['RPATH'] = Literal('\'$ORIGIN/../lib:lib\'')

Please, let me know if you aware of more proper/elegant solution without.

like image 29
jackhab Avatar answered Oct 15 '22 17:10

jackhab