joey shelton / LED_Demo

Dependencies:   MAX44000 PWM_Tone_Library nexpaq_mdk

Fork of LED_Demo by Maxim nexpaq

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 MBED_RTX, RTOS_LIBRARIES, MBED_LIBRARIES, MBED_RPC,\
00018     RTOS_ABSTRACTION, RPC_LIBRARY, USB, USB_LIBRARIES, USB_HOST,\
00019     USB_HOST_LIBRARIES, FAT_FS, DSP_ABSTRACTION, DSP_CMSIS, DSP_LIBRARIES,\
00020     SD_FS, FS_LIBRARY, ETH_SOURCES, LWIP_SOURCES, ETH_LIBRARY, UBLOX_SOURCES,\
00021     UBLOX_LIBRARY, CELLULAR_SOURCES, CELLULAR_USB_SOURCES, CPPUTEST_SRC,\
00022     CPPUTEST_PLATFORM_SRC, CPPUTEST_TESTRUNNER_SCR, CPPUTEST_LIBRARY,\
00023     CPPUTEST_INC, CPPUTEST_PLATFORM_INC, CPPUTEST_TESTRUNNER_INC,\
00024     CPPUTEST_INC_EXT
00025 from tools.data.support import DEFAULT_SUPPORT
00026 from tools.tests import TEST_MBED_LIB
00027 
00028 
00029 LIBRARIES = [
00030     # RTOS libraries
00031     {
00032         "id": "rtx",
00033         "source_dir": MBED_RTX,
00034         "build_dir": RTOS_LIBRARIES,
00035         "dependencies": [MBED_LIBRARIES],
00036     },
00037     {
00038         "id": "rtos",
00039         "source_dir": RTOS_ABSTRACTION,
00040         "build_dir": RTOS_LIBRARIES,
00041         "dependencies": [MBED_LIBRARIES, MBED_RTX],
00042     },
00043 
00044     # RPC
00045     {
00046         "id": "rpc",
00047         "source_dir": MBED_RPC,
00048         "build_dir": RPC_LIBRARY,
00049         "dependencies": [MBED_LIBRARIES],
00050     },
00051 
00052     # USB Device libraries
00053     {
00054         "id": "usb",
00055         "source_dir": USB,
00056         "build_dir": USB_LIBRARIES,
00057         "dependencies": [MBED_LIBRARIES],
00058     },
00059 
00060     # USB Host libraries
00061     {
00062         "id": "usb_host",
00063         "source_dir": USB_HOST,
00064         "build_dir": USB_HOST_LIBRARIES,
00065         "dependencies": [MBED_LIBRARIES, FAT_FS, MBED_RTX, RTOS_ABSTRACTION],
00066     },
00067 
00068     # DSP libraries
00069     {
00070         "id": "dsp",
00071         "source_dir": [DSP_ABSTRACTION, DSP_CMSIS],
00072         "build_dir": DSP_LIBRARIES,
00073         "dependencies": [MBED_LIBRARIES]
00074     },
00075 
00076     # File system libraries
00077     {
00078         "id": "fat",
00079         "source_dir": [FAT_FS, SD_FS],
00080         "build_dir": FS_LIBRARY,
00081         "dependencies": [MBED_LIBRARIES]
00082     },
00083 
00084     # Network libraries
00085     {
00086         "id": "eth",
00087         "source_dir": [ETH_SOURCES, LWIP_SOURCES],
00088         "build_dir": ETH_LIBRARY,
00089         "dependencies": [MBED_LIBRARIES, RTOS_LIBRARIES]
00090     },
00091 
00092     {
00093         "id": "ublox",
00094         "source_dir": [UBLOX_SOURCES, CELLULAR_SOURCES, CELLULAR_USB_SOURCES,
00095                        LWIP_SOURCES],
00096         "build_dir": UBLOX_LIBRARY,
00097         "dependencies": [MBED_LIBRARIES, RTOS_LIBRARIES, USB_HOST_LIBRARIES],
00098     },
00099 
00100     # Unit Testing library
00101     {
00102         "id": "cpputest",
00103         "source_dir": [CPPUTEST_SRC, CPPUTEST_PLATFORM_SRC,
00104                        CPPUTEST_TESTRUNNER_SCR],
00105         "build_dir": CPPUTEST_LIBRARY,
00106         "dependencies": [MBED_LIBRARIES],
00107         'inc_dirs': [CPPUTEST_INC, CPPUTEST_PLATFORM_INC,
00108                      CPPUTEST_TESTRUNNER_INC, TEST_MBED_LIB],
00109         'inc_dirs_ext': [CPPUTEST_INC_EXT],
00110         'macros': ["CPPUTEST_USE_MEM_LEAK_DETECTION=0",
00111                    "CPPUTEST_USE_STD_CPP_LIB=0", "CPPUTEST=1"],
00112     },
00113 ]
00114 
00115 
00116 LIBRARY_MAP = dict([(library['id'], library) for library in LIBRARIES])
00117 
00118 
00119 class Library (object):
00120     """A library representation that allows for querying of support"""
00121     def __init__(self, lib_id):
00122         lib = LIBRARY_MAP[lib_id]
00123         self.supported  = lib.get("supported", DEFAULT_SUPPORT)
00124         self.dependencies  = lib.get("dependencies", None)
00125         # Include dirs required by library build
00126         self.inc_dirs  = lib.get("inc_dirs", None)
00127         # Include dirs required by others to use with this library
00128         self.inc_dirs_ext  = lib.get("inc_dirs_ext", None)
00129         # Additional macros you want to define when building library
00130         self.macros  = lib.get("macros", None)
00131 
00132         self.source_dir  = lib["source_dir"]
00133         self.build_dir  = lib["build_dir"]
00134 
00135     def is_supported (self, target, toolchain):
00136         """Check if a target toolchain combination is supported
00137 
00138         Positional arguments:
00139         target - the MCU or board
00140         toolchain - the compiler
00141         """
00142         if not hasattr(self, 'supported'):
00143             return True
00144         return (target.name in self.supported ) and \
00145             (toolchain in self.supported [target.name])