[Scons-users] Cannot write variable names with the SubstFile builder

Werner Reisberger wr at pure.ch
Tue Jan 25 11:48:24 EST 2022


The SubstFile builder always expands variable names an ignores any 
escapes.

My SConstruct is:

   env = Environment(tools=['default'])
   env['prefix'] = '/usr/bin'
   script_dict = {'@prefix@': '/bin', '@exec_prefix@': '$prefix and 
"${RPM_BUILD_ROOT}"'}
   env.Substfile('script.in', SUBST_DICT=script_dict, 
SUBSTFILESUFFIX='.spec')

The expected content in script.spec should be:

   prefix:      /bin
   exec-prefix: /usr/bin and "${RPM_BUILD_ROOT}"

However I am getting:

   prefix:      /bin
   exec-prefix: /usr/bin and ""

Whatever I try with backslashes doesn't give me the expected result. The 
closest I am coming is

   '@exec_prefix@': '$prefix and "$\{RPM_BUILD_ROOT}" ==> exec-prefix: 
/usr/bin and "$\{RPM_BUILD_ROOT}"

Seems to be a bug for me. Luckily I could replace ${RPM_BUILD_ROOT} with 
%{buildroot} which has the same value in a RPM spec file.

--Werner



More information about the Scons-users mailing list