|
26 | 26 | from inspect import getmro
|
27 | 27 | from copy import deepcopy
|
28 | 28 | from tools.config import Config
|
| 29 | +from abc import ABCMeta, abstractmethod |
29 | 30 |
|
30 | 31 | from multiprocessing import Pool, cpu_count
|
31 | 32 | from tools.utils import run_cmd, mkdir, rel_path, ToolException, NotSupportedException, split_path
|
@@ -230,6 +231,8 @@ class mbedToolchain:
|
230 | 231 |
|
231 | 232 | MBED_CONFIG_FILE_NAME="mbed_config.h"
|
232 | 233 |
|
| 234 | + __metaclass__ = ABCMeta |
| 235 | + |
233 | 236 | def __init__(self, target, options=None, notify=None, macros=None, silent=False, extra_verbose=False):
|
234 | 237 | self.target = target
|
235 | 238 | self.name = self.__class__.__name__
|
@@ -784,9 +787,22 @@ def compile_command(self, source, object, includes):
|
784 | 787 |
|
785 | 788 | return None
|
786 | 789 |
|
| 790 | + @abstractmethod |
| 791 | + def parse_dependencies(self, dep_path): |
| 792 | + """Take in a dependency file generated by the compiler and build a list of |
| 793 | + all files that the dep_path depends on. |
| 794 | + """ |
| 795 | + pass |
| 796 | + |
787 | 797 | def is_not_supported_error(self, output):
|
788 | 798 | return "#error directive: [NOT_SUPPORTED]" in output
|
789 | 799 |
|
| 800 | + @abstractmethod |
| 801 | + def parse_output(self, output): |
| 802 | + """Take in compiler output and extract sinlge line warnings and errors from it |
| 803 | + """ |
| 804 | + pass |
| 805 | + |
790 | 806 | def compile_output(self, output=[]):
|
791 | 807 | _rc = output[0]
|
792 | 808 | _stderr = output[1]
|
@@ -958,6 +974,63 @@ def get_config_header(self):
|
958 | 974 | f.write(Config.config_to_header(self.config_data))
|
959 | 975 | return config_file
|
960 | 976 |
|
| 977 | + @abstractmethod |
| 978 | + def get_config_option(self, config_header): |
| 979 | + """Generate the compiler option that forces the inclusion of the configuration |
| 980 | + header file. |
| 981 | + """ |
| 982 | + pass |
| 983 | + |
| 984 | + @abstractmethod |
| 985 | + def assemble(self, source, object, includes): |
| 986 | + """Generate the command line that: |
| 987 | + - Assembles the given assembly *source* file. |
| 988 | + - Puts the results into the file named *object*. |
| 989 | + - Has an include search path that includes everything in *includes* |
| 990 | + """ |
| 991 | + pass |
| 992 | + |
| 993 | + @abstractmethod |
| 994 | + def compile_c(self, source, object, includes): |
| 995 | + """Generate the command line that: |
| 996 | + - Compiles the given C *source* file. |
| 997 | + - Puts the results into the file named *object*. |
| 998 | + - Has an include search path that includes everything in *includes* |
| 999 | + """ |
| 1000 | + pass |
| 1001 | + |
| 1002 | + @abstractmethod |
| 1003 | + def compile_cpp(self, source, object, includes): |
| 1004 | + """Generate the command line that: |
| 1005 | + - Compiles the given C++ *source* file. |
| 1006 | + - Puts the results into the file named *object*. |
| 1007 | + - Has an include search path that includes everything in *includes* |
| 1008 | + """ |
| 1009 | + pass |
| 1010 | + |
| 1011 | + @abstractmethod |
| 1012 | + def link(self, output, objects, libraries, lib_dirs, mem_map): |
| 1013 | + """Run the link command that will: |
| 1014 | + - Emit a file named *output* |
| 1015 | + - Includes all *objects* and *libraries* |
| 1016 | + - Searches for libraries in *lib_dirs* |
| 1017 | + - Generates a memory map file in the file *mem_map* |
| 1018 | + """ |
| 1019 | + pass |
| 1020 | + |
| 1021 | + @abstractmethod |
| 1022 | + def archive(self, objects, lib_path): |
| 1023 | + """Run the command line that creates an archive containing *objects*, and named *lib_path* |
| 1024 | + """ |
| 1025 | + pass |
| 1026 | + |
| 1027 | + @abstractmethod |
| 1028 | + def binary(self, resources, elf, bin): |
| 1029 | + """Run the command line that will Extract a binary named *bin* from an |
| 1030 | + elf file named *elf*. |
| 1031 | + """ |
| 1032 | + pass |
| 1033 | + |
961 | 1034 | # Return the list of macros geenrated by the build system
|
962 | 1035 | def get_config_macros(self):
|
963 | 1036 | return Config.config_to_macros(self.config_data) if self.config_data else []
|
|
0 commit comments