Discussion:
[Scons-users] defining map files
Torsten Robitzki
2018-08-02 12:25:10 UTC
Permalink
Hello,

I try to build several Programs in the same environment. I would like to let the linker generate a map file and that map file name should depend on $TARGET (foo.elf -> foo.map).

All Programs share some common object files. According to "4.2.5. Variable substitution“ it should be possible to call functions during construction variable substitution:

env = Environment(FUNC = myfunc)
env.Command(target = ‚foo.out‘, source = 'foo.in', command = "${FUNC($<)}")

I’ve tried that:

def map_file_name_from_target(target):
return os.path.splitext(target)[ 0 ] + '.map'

hsm_env.Append(
FUNC = map_file_name_from_target,
EXEC_LDFLAGS = „-Wl,-Map=${FUNC($<)},—cref -Wl,-T,STM32F746NGHx_FLASH.ld „ )

but with no luck:

SyntaxError `invalid syntax (<string>, line 1)’ trying to evaluate `${FUNC($<)}'

I’m very new to Scons, but I think that deriving file names from other file name is such a common thing, when building software, so there must be a way to achieve what I want to do. Most likely there is a Sconish way that I’m not aware of.

Any hints, tipps?

Kind regards,

Torsten
Chris Redlats
2018-08-02 12:53:26 UTC
Permalink
Hi Thosten

I did it this way (for gcc on windows, SCons version : 2.5.1):
env.Append(LINKFLAGS = '--Map=${TARGET.base}.map')

Regards
Christoph
Post by Torsten Robitzki
Hello,
I try to build several Programs in the same environment. I would like to
let the linker generate a map file and that map file name should depend on
$TARGET (foo.elf -> foo.map).
All Programs share some common object files. According to "4.2.5. Variable
substitution“ it should be possible to call functions during construction
env = Environment(FUNC = myfunc)
env.Command(target = ‚foo.out‘, source = 'foo.in', command =
"${FUNC($<)}")
return os.path.splitext(target)[ 0 ] + '.map'
hsm_env.Append(
FUNC = map_file_name_from_target,
EXEC_LDFLAGS = „-Wl,-Map=${FUNC($<)},—cref
-Wl,-T,STM32F746NGHx_FLASH.ld „ )
SyntaxError `invalid syntax (<string>, line 1)’ trying to evaluate
`${FUNC($<)}'
I’m very new to Scons, but I think that deriving file names from other
file name is such a common thing, when building software, so there must be
a way to achieve what I want to do. Most likely there is a Sconish way that
I’m not aware of.
Any hints, tipps?
Kind regards,
Torsten
_______________________________________________
Scons-users mailing list
https://pairlist4.pair.net/mailman/listinfo/scons-users
Bill Deegan
2018-08-02 17:07:30 UTC
Permalink
+1 to Chris. Good solution!

A good way to find these options is to look at the Manpage, here's a link:
https://scons.org/doc/production/HTML/scons-man.html#variable_substitution
Post by Chris Redlats
Hi Thosten
env.Append(LINKFLAGS = '--Map=${TARGET.base}.map')
Regards
Christoph
Post by Torsten Robitzki
Hello,
I try to build several Programs in the same environment. I would like to
let the linker generate a map file and that map file name should depend on
$TARGET (foo.elf -> foo.map).
All Programs share some common object files. According to "4.2.5.
Variable substitution“ it should be possible to call functions during
env = Environment(FUNC = myfunc)
env.Command(target = ‚foo.out‘, source = 'foo.in', command =
"${FUNC($<)}")
return os.path.splitext(target)[ 0 ] + '.map'
hsm_env.Append(
FUNC = map_file_name_from_target,
EXEC_LDFLAGS = „-Wl,-Map=${FUNC($<)},—cref
-Wl,-T,STM32F746NGHx_FLASH.ld „ )
SyntaxError `invalid syntax (<string>, line 1)’ trying to evaluate
`${FUNC($<)}'
I’m very new to Scons, but I think that deriving file names from other
file name is such a common thing, when building software, so there must be
a way to achieve what I want to do. Most likely there is a Sconish way that
I’m not aware of.
Any hints, tipps?
Kind regards,
Torsten
_______________________________________________
Scons-users mailing list
https://pairlist4.pair.net/mailman/listinfo/scons-users
_______________________________________________
Scons-users mailing list
https://pairlist4.pair.net/mailman/listinfo/scons-users
Torsten Robitzki
2018-08-03 07:24:52 UTC
Permalink
Hi Christoph, Hi Bill,

thanks a lot for your help!

best regards,

Torsten

Loading...