Brian Daniels / mbed-tools

Fork of mbed-tools by Morpheus

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers libraries.py Source File

libraries.py

00001 """
00002 mbed SDK
00003 Copyright (c) 2011-2013 ARM Limited
00004 
00005 Licensed under the Apache License, Version 2.0 (the "License");
00006 you may not use this file except in compliance with the License.
00007 You may obtain a copy of the License at
00008 
00009     http://www.apache.org/licenses/LICENSE-2.0
00010 
00011 Unless required by applicable law or agreed to in writing, software
00012 distributed under the License is distributed on an "AS IS" BASIS,
00013 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00014 See the License for the specific language governing permissions and
00015 limitations under the License.
00016 """
00017 from tools.paths import *
00018 from tools.data.support import *
00019 from tools.tests import TEST_MBED_LIB
00020 
00021 
00022 LIBRARIES = [
00023     # RTOS libraries
00024     {
00025         "id": "rtx",
00026         "source_dir": MBED_RTX,
00027         "build_dir": RTOS_LIBRARIES,
00028         "dependencies": [MBED_LIBRARIES],
00029     },
00030     {
00031         "id": "rtos",
00032         "source_dir": RTOS_ABSTRACTION,
00033         "build_dir": RTOS_LIBRARIES,
00034         "dependencies": [MBED_LIBRARIES, MBED_RTX],
00035     },
00036 
00037     # RPC
00038     {
00039         "id": "rpc",
00040         "source_dir": MBED_RPC,
00041         "build_dir": RPC_LIBRARY,
00042         "dependencies": [MBED_LIBRARIES],
00043     },
00044 
00045     # USB Device libraries
00046     {
00047         "id": "usb",
00048         "source_dir": USB,
00049         "build_dir": USB_LIBRARIES,
00050         "dependencies": [MBED_LIBRARIES],
00051     },
00052 
00053     # USB Host libraries
00054     {
00055         "id": "usb_host",
00056         "source_dir": USB_HOST,
00057         "build_dir": USB_HOST_LIBRARIES,
00058         "dependencies": [MBED_LIBRARIES, FAT_FS, MBED_RTX, RTOS_ABSTRACTION],
00059     },
00060 
00061     # DSP libraries
00062     {
00063         "id": "cmsis_dsp",
00064         "source_dir": DSP_CMSIS,
00065         "build_dir": DSP_LIBRARIES,
00066         "dependencies": [MBED_LIBRARIES],
00067     },
00068     {
00069         "id": "dsp",
00070         "source_dir": DSP_ABSTRACTION,
00071         "build_dir": DSP_LIBRARIES,
00072         "dependencies": [MBED_LIBRARIES, DSP_CMSIS],
00073     },
00074 
00075     # File system libraries
00076     {
00077         "id": "fat",
00078         "source_dir": [FAT_FS, SD_FS],
00079         "build_dir": FS_LIBRARY,
00080         "dependencies": [MBED_LIBRARIES]
00081     },
00082 
00083     # Network libraries
00084     {
00085         "id": "eth",
00086         "source_dir": [ETH_SOURCES, LWIP_SOURCES],
00087         "build_dir": ETH_LIBRARY,
00088         "dependencies": [MBED_LIBRARIES, RTOS_LIBRARIES]
00089     },
00090 
00091     {
00092         "id": "ublox",
00093         "source_dir": [UBLOX_SOURCES, CELLULAR_SOURCES, CELLULAR_USB_SOURCES, LWIP_SOURCES],
00094         "build_dir": UBLOX_LIBRARY,
00095         "dependencies": [MBED_LIBRARIES, RTOS_LIBRARIES, USB_HOST_LIBRARIES],
00096     },
00097 
00098     # Unit Testing library
00099     {
00100         "id": "cpputest",
00101         "source_dir": [CPPUTEST_SRC, CPPUTEST_PLATFORM_SRC, CPPUTEST_TESTRUNNER_SCR],
00102         "build_dir": CPPUTEST_LIBRARY,
00103         "dependencies": [MBED_LIBRARIES],
00104         'inc_dirs': [CPPUTEST_INC, CPPUTEST_PLATFORM_INC, CPPUTEST_TESTRUNNER_INC, TEST_MBED_LIB],
00105         'inc_dirs_ext': [CPPUTEST_INC_EXT],
00106         'macros': ["CPPUTEST_USE_MEM_LEAK_DETECTION=0", "CPPUTEST_USE_STD_CPP_LIB=0", "CPPUTEST=1"],
00107     },
00108 ]
00109 
00110 
00111 LIBRARY_MAP = dict([(library['id'], library) for library in LIBRARIES])
00112 
00113 
00114 class Library:
00115     DEFAULTS = {
00116         "supported": DEFAULT_SUPPORT,
00117         'dependencies': None,
00118         'inc_dirs': None,       # Include dirs required by library build
00119         'inc_dirs_ext': None,   # Include dirs required by others to use with this library
00120         'macros': None,         # Additional macros you want to define when building library
00121     }
00122     def __init__(self, lib_id):
00123         self.__dict__.update(Library.DEFAULTS)
00124         self.__dict__.update(LIBRARY_MAP[lib_id])
00125 
00126     def is_supported(self, target, toolchain):
00127         if not hasattr(self, 'supported'):
00128             return True
00129         return (target.name in self.supported) and (toolchain in self.supported[target.name])