mirror of https://github.com/ARMmbed/mbed-os.git
Abstractify the mbedToolchain base class
The mbedToolchain class calls many members of it's subclasses, expecting them to implement a particular API. This change adds a requirement to each subclass that requires them to implement this expected API. The API consists of these methods: - parse_dependencies - parse_ouptut - get_config_option - compile_c - compile_cpp - link - archive - binarypull/2173/head
parent
d0d023ab58
commit
17833e8f58
|
@ -26,6 +26,7 @@ from os.path import join, splitext, exists, relpath, dirname, basename, split, a
|
|||
from inspect import getmro
|
||||
from copy import deepcopy
|
||||
from tools.config import Config
|
||||
from abc import ABCMeta, abstractmethod
|
||||
|
||||
from multiprocessing import Pool, cpu_count
|
||||
from tools.utils import run_cmd, mkdir, rel_path, ToolException, NotSupportedException, split_path
|
||||
|
@ -230,6 +231,8 @@ class mbedToolchain:
|
|||
|
||||
MBED_CONFIG_FILE_NAME="mbed_config.h"
|
||||
|
||||
__metaclass__ = ABCMeta
|
||||
|
||||
def __init__(self, target, options=None, notify=None, macros=None, silent=False, extra_verbose=False):
|
||||
self.target = target
|
||||
self.name = self.__class__.__name__
|
||||
|
@ -784,9 +787,22 @@ class mbedToolchain:
|
|||
|
||||
return None
|
||||
|
||||
@abstractmethod
|
||||
def parse_dependencies(self, dep_path):
|
||||
"""Take in a dependency file generated by the compiler and build a list of
|
||||
all files that the dep_path depends on.
|
||||
"""
|
||||
pass
|
||||
|
||||
def is_not_supported_error(self, output):
|
||||
return "#error directive: [NOT_SUPPORTED]" in output
|
||||
|
||||
@abstractmethod
|
||||
def parse_output(self, output):
|
||||
"""Take in compiler output and extract sinlge line warnings and errors from it
|
||||
"""
|
||||
pass
|
||||
|
||||
def compile_output(self, output=[]):
|
||||
_rc = output[0]
|
||||
_stderr = output[1]
|
||||
|
@ -958,6 +974,63 @@ class mbedToolchain:
|
|||
f.write(Config.config_to_header(self.config_data))
|
||||
return config_file
|
||||
|
||||
@abstractmethod
|
||||
def get_config_option(self, config_header):
|
||||
"""Generate the compiler option that forces the inclusion of the configuration
|
||||
header file.
|
||||
"""
|
||||
pass
|
||||
|
||||
@abstractmethod
|
||||
def assemble(self, source, object, includes):
|
||||
"""Generate the command line that:
|
||||
- Assembles the given assembly *source* file.
|
||||
- Puts the results into the file named *object*.
|
||||
- Has an include search path that includes everything in *includes*
|
||||
"""
|
||||
pass
|
||||
|
||||
@abstractmethod
|
||||
def compile_c(self, source, object, includes):
|
||||
"""Generate the command line that:
|
||||
- Compiles the given C *source* file.
|
||||
- Puts the results into the file named *object*.
|
||||
- Has an include search path that includes everything in *includes*
|
||||
"""
|
||||
pass
|
||||
|
||||
@abstractmethod
|
||||
def compile_cpp(self, source, object, includes):
|
||||
"""Generate the command line that:
|
||||
- Compiles the given C++ *source* file.
|
||||
- Puts the results into the file named *object*.
|
||||
- Has an include search path that includes everything in *includes*
|
||||
"""
|
||||
pass
|
||||
|
||||
@abstractmethod
|
||||
def link(self, output, objects, libraries, lib_dirs, mem_map):
|
||||
"""Run the link command that will:
|
||||
- Emit a file named *output*
|
||||
- Includes all *objects* and *libraries*
|
||||
- Searches for libraries in *lib_dirs*
|
||||
- Generates a memory map file in the file *mem_map*
|
||||
"""
|
||||
pass
|
||||
|
||||
@abstractmethod
|
||||
def archive(self, objects, lib_path):
|
||||
"""Run the command line that creates an archive containing *objects*, and named *lib_path*
|
||||
"""
|
||||
pass
|
||||
|
||||
@abstractmethod
|
||||
def binary(self, resources, elf, bin):
|
||||
"""Run the command line that will Extract a binary named *bin* from an
|
||||
elf file named *elf*.
|
||||
"""
|
||||
pass
|
||||
|
||||
# Return the list of macros geenrated by the build system
|
||||
def get_config_macros(self):
|
||||
return Config.config_to_macros(self.config_data) if self.config_data else []
|
||||
|
|
Loading…
Reference in New Issue