mirror of
https://github.com/espressif/esp-idf.git
synced 2025-09-30 00:50:57 +02:00
ldgen: surround always pre and post
This commit is contained in:
@@ -276,42 +276,28 @@ class Mapping(Fragment):
|
||||
|
||||
class Surround(Flag):
|
||||
|
||||
def __init__(self, symbol, pre=True, post=True):
|
||||
def __init__(self, symbol):
|
||||
self.symbol = symbol
|
||||
self.pre = pre
|
||||
self.post = post
|
||||
self.pre = True
|
||||
self.post = True
|
||||
|
||||
@staticmethod
|
||||
def get_grammar():
|
||||
# surround(symbol [, pre, post])
|
||||
# surround(symbol)
|
||||
#
|
||||
# __symbol_start, __symbol_end is generated before and after
|
||||
# the corresponding input section description, respectively.
|
||||
grammar = (Keyword('surround').suppress() +
|
||||
Suppress('(') +
|
||||
Fragment.IDENTIFIER.setResultsName('symbol') +
|
||||
Mapping.Flag.PRE_POST +
|
||||
Suppress(')'))
|
||||
|
||||
def on_parse(tok):
|
||||
if tok.pre == '' and tok.post == '':
|
||||
res = Mapping.Surround(tok.symbol)
|
||||
elif tok.pre != '' and tok.post == '':
|
||||
res = Mapping.Surround(tok.symbol, tok.pre, False)
|
||||
elif tok.pre == '' and tok.post != '':
|
||||
res = Mapping.Surround(tok.symbol, False, tok.post)
|
||||
else:
|
||||
res = Mapping.Surround(tok.symbol, tok.pre, tok.post)
|
||||
return res
|
||||
|
||||
grammar.setParseAction(on_parse)
|
||||
grammar.setParseAction(lambda tok: Mapping.Surround(tok.symbol))
|
||||
return grammar
|
||||
|
||||
def __eq__(self, other):
|
||||
return (isinstance(other, Mapping.Surround) and
|
||||
self.symbol == other.symbol and
|
||||
self.pre == other.pre and
|
||||
self.post == other.post)
|
||||
self.symbol == other.symbol)
|
||||
|
||||
class Align(Flag):
|
||||
|
||||
|
@@ -906,28 +906,20 @@ entries:
|
||||
text->iram0_text sort(name) sort(alignment)
|
||||
""")
|
||||
|
||||
def test_emit_flag(self):
|
||||
def test_surround_flag(self):
|
||||
# Test parsing combinations and orders of flags
|
||||
test_fragment = self.create_fragment_file(u"""
|
||||
[mapping:map]
|
||||
archive: libmain.a
|
||||
entries:
|
||||
obj1 (default);
|
||||
text->flash_text surround(sym1),
|
||||
rodata->flash_rodata surround(sym2, pre),
|
||||
data->dram0_data surround(sym3, post),
|
||||
bss->dram0_bss surround(sym4, pre, post),
|
||||
common->dram0_bss surround(sym5, pre, post) surround(sym6)
|
||||
text->flash_text surround(sym1)
|
||||
""")
|
||||
|
||||
fragment_file = FragmentFile(test_fragment, self.sdkconfig)
|
||||
fragment = fragment_file.fragments[0]
|
||||
|
||||
expected = [('text', 'flash_text', [Mapping.Surround('sym1', True, True)]),
|
||||
('rodata', 'flash_rodata', [Mapping.Surround('sym2', True, False)]),
|
||||
('data', 'dram0_data', [Mapping.Surround('sym3', False, True)]),
|
||||
('bss', 'dram0_bss', [Mapping.Surround('sym4', True, True)]),
|
||||
('common', 'dram0_bss', [Mapping.Surround('sym5', True, True), Mapping.Surround('sym6', True, True)])]
|
||||
expected = [('text', 'flash_text', [Mapping.Surround('sym1')])]
|
||||
actual = fragment.flags[('obj1', None, 'default')]
|
||||
self.assertEqual(expected, actual)
|
||||
|
||||
@@ -946,13 +938,13 @@ entries:
|
||||
|
||||
expected = [('text', 'flash_text', [Mapping.Align(4, True, False),
|
||||
Mapping.Keep(),
|
||||
Mapping.Surround('sym1', True, True),
|
||||
Mapping.Surround('sym1'),
|
||||
Mapping.Align(8, True, False),
|
||||
Mapping.Sort('name')]),
|
||||
('rodata', 'flash_rodata', [Mapping.Keep(),
|
||||
Mapping.Align(4, True, False),
|
||||
Mapping.Keep(),
|
||||
Mapping.Surround('sym1', True, True),
|
||||
Mapping.Surround('sym1'),
|
||||
Mapping.Align(8, True, False),
|
||||
Mapping.Align(4, True, False),
|
||||
Mapping.Sort('name')])]
|
||||
@@ -976,11 +968,11 @@ entries:
|
||||
|
||||
expected = [('text', 'flash_text', [Mapping.Align(4, True, False),
|
||||
Mapping.Keep(),
|
||||
Mapping.Surround('sym1', True, True),
|
||||
Mapping.Surround('sym1'),
|
||||
Mapping.Sort('name')]),
|
||||
('text', 'flash_text', [Mapping.Align(4, True, False),
|
||||
Mapping.Keep(),
|
||||
Mapping.Surround('sym1', True, True),
|
||||
Mapping.Surround('sym1'),
|
||||
Mapping.Sort('name')])]
|
||||
actual = fragment.flags[('obj1', None, 'default')]
|
||||
self.assertEqual(expected, actual)
|
||||
@@ -1004,11 +996,11 @@ entries:
|
||||
|
||||
expected = [('text', 'flash_text', [Mapping.Align(4, True, False),
|
||||
Mapping.Keep(),
|
||||
Mapping.Surround('sym1', True, True),
|
||||
Mapping.Surround('sym1'),
|
||||
Mapping.Sort('name')]),
|
||||
('text', 'flash_text', [Mapping.Align(4, True, False),
|
||||
Mapping.Keep(),
|
||||
Mapping.Surround('sym1', True, True),
|
||||
Mapping.Surround('sym1'),
|
||||
Mapping.Sort('name')])]
|
||||
actual = fragment.flags[('obj1', None, 'default')]
|
||||
self.assertEqual(expected, actual)
|
||||
|
@@ -1428,11 +1428,11 @@ class FlagTest(GenerationTest):
|
||||
archive: libfreertos.a
|
||||
entries:
|
||||
croutine (noflash_text);
|
||||
text->iram0_text align(4, pre, post) surround(sym1, pre, post) #1
|
||||
text->iram0_text align(4, pre, post) surround(sym1) #1
|
||||
timers (default);
|
||||
text->flash_text keep sort(name) #2
|
||||
timers (default);
|
||||
rodata->flash_rodata surround(sym2, pre, post) align(4, pre, post) #3
|
||||
rodata->flash_rodata surround(sym2) align(4, pre, post) #3
|
||||
"""
|
||||
|
||||
self.add_fragments(mapping)
|
||||
|
Reference in New Issue
Block a user