Skip to content

Migrate old memap file handling into toolchains #8779

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 30, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 2 additions & 8 deletions tools/memap.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@

from abc import abstractmethod, ABCMeta
from sys import stdout, exit, argv, path
from os import sep, rename, remove
from os import sep
from os.path import (basename, dirname, join, relpath, abspath, commonprefix,
splitext, exists)
splitext)

# Be sure that the tools directory is in the search path
ROOT = abspath(join(dirname(__file__), ".."))
Expand All @@ -25,7 +25,6 @@

from tools.utils import (argparse_filestring_type, argparse_lowercase_hyphen_type,
argparse_uppercase_type)
from tools.settings import COMPARE_FIXED


class _Parser(object):
Expand Down Expand Up @@ -831,11 +830,6 @@ def parse(self, mapfile, toolchain):
self.old_modules = parser().parse_mapfile(old_input)
except IOError:
self.old_modules = None
if not COMPARE_FIXED:
old_mapfile = "%s.old" % mapfile
if exists(old_mapfile):
remove(old_mapfile)
rename(mapfile, old_mapfile)
return True

except IOError as error:
Expand Down
12 changes: 9 additions & 3 deletions tools/toolchains/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import re
import sys
import json
from os import stat, walk, getcwd, sep, remove, getenv
from os import stat, walk, getcwd, sep, remove, getenv, rename, remove
from copy import copy
from time import time, sleep
from shutil import copyfile
Expand All @@ -41,6 +41,7 @@
from ..resources import FileType
from ..memap import MemapParser
from ..config import (ConfigException, RAM_ALL_MEMORIES, ROM_ALL_MEMORIES)
from ..settings import COMPARE_FIXED


#Disables multiprocessing if set to higher number than the host machine CPUs
Expand Down Expand Up @@ -617,7 +618,7 @@ def link_program(self, r, tmp_path, name):
full_path = join(tmp_path, filename)
elf = join(tmp_path, name + '.elf')
bin = None if ext == 'elf' else full_path
map = join(tmp_path, name + '.map')
mapfile = join(tmp_path, name + '.map')

objects = sorted(set(r.get_file_paths(FileType.OBJECT)))
config_file = ([self.config.app_config_location]
Expand All @@ -634,6 +635,11 @@ def link_program(self, r, tmp_path, name):
dependencies = objects + libraries + [linker_script] + config_file + hex_files
dependencies.append(join(self.build_dir, self.PROFILE_FILE_NAME + "-ld"))
if self.need_update(elf, dependencies):
if not COMPARE_FIXED and exists(mapfile):
old_mapfile = "%s.old" % mapfile
if exists(old_mapfile):
remove(old_mapfile)
rename(mapfile, old_mapfile)
needed_update = True
self.progress("link", name)
self.link(elf, objects, libraries, lib_dirs, linker_script)
Expand All @@ -644,7 +650,7 @@ def link_program(self, r, tmp_path, name):
self.binary(r, elf, bin)

# Initialize memap and process map file. This doesn't generate output.
self.mem_stats(map)
self.mem_stats(mapfile)

self.notify.var("compile_succeded", True)
self.notify.var("binary", filename)
Expand Down