Merge branch 'bugfix/ldgen_fails_when_wifi_ram_opt_off' into 'master'

ldgen: do not generate rules when no condition is true

See merge request idf/esp-idf!4757
This commit is contained in:
Angus Gratton 2019-04-29 08:44:13 +08:00
commit 3694ed30eb
3 changed files with 23 additions and 5 deletions

View File

@ -276,12 +276,14 @@ class Mapping(Fragment):
MAPPING_ALL_OBJECTS = "*"
def __init__(self):
Fragment.__init__(self)
self.entries = set()
def set_key_value(self, key, parse_results):
if key == "archive":
self.archive = parse_results[0]["archive"]
elif key == "entries":
self.entries = set()
for result in parse_results:
obj = None
symbol = None
@ -321,7 +323,7 @@ class Mapping(Fragment):
grammars = {
"archive": KeyGrammar(Fragment.ENTITY.setResultsName("archive"), 1, 1, True),
"entries": KeyGrammar(entry, 1, None, True)
"entries": KeyGrammar(entry, 0, None, True)
}
return grammars

View File

@ -617,8 +617,10 @@ entries:
* (noflash) # if condition is false, then no 'entries' key value
""")
with self.assertRaises(ParseFatalException):
FragmentFile(test_fragment, self.sdkconfig)
expected = set()
fragment_file = FragmentFile(test_fragment, self.sdkconfig)
self.assertEqual(expected, fragment_file.fragments[0].entries)
test_fragment = self.create_fragment_file(u"""
[mapping:test]

View File

@ -1108,6 +1108,20 @@ entries:
self.compare_rules(expected, actual)
def test_rule_generation_empty_entries(self):
normal = u"""
[mapping:test]
archive: lib.a
entries:
if PERFORMANCE_LEVEL >= 1: # is false, generate no special rules
obj.a (noflash)
"""
self.add_fragments(normal)
actual = self.model.generate_rules(self.sections_info)
expected = self.generate_default_rules() # only default rules
self.compare_rules(expected, actual)
def test_conditional_sections_1(self):
generation_with_condition = u"""
[sections:cond_text_data]