Skip to content

Export: Impl Makefile-based response/command files #7583

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

Closed
wants to merge 3 commits into from
Closed
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
3 changes: 2 additions & 1 deletion tools/export/makefile/Makefile.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,9 @@ $(PROJECT).link_script{{link_script_ext}}: $(LINKER_SCRIPT)

{% block target_project_elf %}
$(PROJECT).elf: $(OBJECTS) $(SYS_OBJECTS) {% if pp_cmd -%} $(PROJECT).link_script{{link_script_ext}} {% else%} $(LINKER_SCRIPT) {% endif %}
$(file > $@.in, $(filter %.o, $^))
+@echo "link: $(notdir $@)"
@$(LD) $(LD_FLAGS) {{link_script_option}} $(filter-out %.o, $^) $(LIBRARY_PATHS) --output $@ $(filter %.o, $^) $(LIBRARIES) $(LD_SYS_LIBS)
@$(LD) $(LD_FLAGS) {{link_script_option}} $(filter-out %.o, $^) $(LIBRARY_PATHS) --output $@ {{response_option}}$@.in $(LIBRARIES) $(LD_SYS_LIBS)
{% endblock %}

$(PROJECT).bin: $(PROJECT).elf
Expand Down
4 changes: 4 additions & 0 deletions tools/export/makefile/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ def generate(self):
'link_script_option': self.LINK_SCRIPT_OPTION,
'user_library_flag': self.USER_LIBRARY_FLAG,
'needs_asm_preproc': self.PREPROCESS_ASM,
'response_option': self.RESPONSE_OPTION,
}

if hasattr(self.toolchain, "preproc"):
Expand Down Expand Up @@ -217,6 +218,7 @@ class GccArm(Makefile):
TOOLCHAIN = "GCC_ARM"
LINK_SCRIPT_OPTION = "-T"
USER_LIBRARY_FLAG = "-L"
RESPONSE_OPTION = "@"

@staticmethod
def prepare_lib(libname):
Expand All @@ -234,6 +236,7 @@ class Arm(Makefile):
LINK_SCRIPT_OPTION = "--scatter"
USER_LIBRARY_FLAG = "--userlibpath "
TEMPLATE = 'make-arm'
RESPONSE_OPTION = "--via "

@staticmethod
def prepare_lib(libname):
Expand Down Expand Up @@ -284,6 +287,7 @@ class IAR(Makefile):
TOOLCHAIN = "IAR"
LINK_SCRIPT_OPTION = "--config"
USER_LIBRARY_FLAG = "-L"
RESPONSE_OPTION = "-f "

@staticmethod
def prepare_lib(libname):
Expand Down
29 changes: 15 additions & 14 deletions tools/resources/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,8 @@ def __init__(self, notify, collect_ignores=False):
self._label_paths = []
self._labels = {"TARGET": [], "TOOLCHAIN": [], "FEATURE": []}

# Should we convert all paths to unix-style?
self._win_to_unix = False
# Path seperator style (defaults to OS-specific seperator)
self._sep = sep

# Ignore patterns from .mbedignore files and add_ignore_patters
self._ignore_patterns = []
Expand Down Expand Up @@ -181,11 +181,12 @@ def detect_duplicates(self):
return count

def win_to_unix(self):
self._win_to_unix = True
for file_type in self.ALL_FILE_TYPES:
v = [f._replace(name=f.name.replace('\\', '/')) for
f in self.get_file_refs(file_type)]
self._file_refs[file_type] = v
self._sep = "/"
if self._sep != sep:
for file_type in self.ALL_FILE_TYPES:
v = [f._replace(name=f.name.replace(sep, self._sep)) for
f in self.get_file_refs(file_type)]
self._file_refs[file_type] = v

def __str__(self):
s = []
Expand Down Expand Up @@ -262,8 +263,8 @@ def _not_current_label(self, dirname, label_type):
dirname[len(label_type) + 1:] not in self._labels[label_type])

def add_file_ref(self, file_type, file_name, file_path):
if self._win_to_unix:
ref = FileRef(file_name.replace("\\", "/"), file_path)
if sep != self._sep:
ref = FileRef(file_name.replace(sep, self._sep), file_path)
else:
ref = FileRef(file_name, file_path)
self._file_refs[file_type].add(ref)
Expand All @@ -272,12 +273,12 @@ def get_file_refs(self, file_type):
"""Return a list of FileRef for every file of the given type"""
return list(self._file_refs[file_type])

@staticmethod
def _all_parents(files):
def _all_parents(self, files):
for name in files:
components = name.split(sep)
for n in range(1, len(components)):
parent = join(*components[:n])
components = name.split(self._sep)
start_at = 2 if components[0] == '' else 1
for n in range(2, len(components)):
parent = self._sep.join(components[:n])
yield parent

def _get_from_refs(self, file_type, key):
Expand Down