Daiki Kato / mbed-os-lychee

Dependents:   mbed-os-example-blinky-gr-lychee GR-Boads_Camera_sample GR-Boards_Audio_Recoder GR-Boads_Camera_DisplayApp ... more

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, RTOS_LIBRARIES, MBED_LIBRARIES,\
00018     MBED_RPC, RPC_LIBRARY, USB, USB_LIBRARIES, USB_HOST,\
00019     USB_HOST_LIBRARIES, DSP_ABSTRACTION, DSP_CMSIS, DSP_LIBRARIES,\
00020     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,
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, MBED_RTX, RTOS_LIBRARIES],
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     # Network libraries
00077     {
00078         "id": "eth",
00079         "source_dir": [ETH_SOURCES, LWIP_SOURCES],
00080         "build_dir": ETH_LIBRARY,
00081         "dependencies": [MBED_LIBRARIES, RTOS_LIBRARIES]
00082     },
00083 
00084     {
00085         "id": "ublox",
00086         "source_dir": [UBLOX_SOURCES, CELLULAR_SOURCES, CELLULAR_USB_SOURCES,
00087                        LWIP_SOURCES],
00088         "build_dir": UBLOX_LIBRARY,
00089         "dependencies": [MBED_LIBRARIES, RTOS_LIBRARIES, USB_HOST_LIBRARIES],
00090     },
00091 
00092     # Unit Testing library
00093     {
00094         "id": "cpputest",
00095         "source_dir": [CPPUTEST_SRC, CPPUTEST_PLATFORM_SRC,
00096                        CPPUTEST_TESTRUNNER_SCR],
00097         "build_dir": CPPUTEST_LIBRARY,
00098         "dependencies": [MBED_LIBRARIES],
00099         'inc_dirs': [CPPUTEST_INC, CPPUTEST_PLATFORM_INC,
00100                      CPPUTEST_TESTRUNNER_INC, TEST_MBED_LIB],
00101         'inc_dirs_ext': [CPPUTEST_INC_EXT],
00102         'macros': ["CPPUTEST_USE_MEM_LEAK_DETECTION=0",
00103                    "CPPUTEST_USE_STD_CPP_LIB=0", "CPPUTEST=1"],
00104     },
00105 ]
00106 
00107 
00108 LIBRARY_MAP = dict([(library['id'], library) for library in LIBRARIES])
00109 
00110 
00111 class Library (object):
00112     """A library representation that allows for querying of support"""
00113     def __init__(self, lib_id):
00114         lib = LIBRARY_MAP[lib_id]
00115         self.supported  = lib.get("supported", DEFAULT_SUPPORT)
00116         self.dependencies  = lib.get("dependencies", None)
00117         # Include dirs required by library build
00118         self.inc_dirs  = lib.get("inc_dirs", None)
00119         # Include dirs required by others to use with this library
00120         self.inc_dirs_ext  = lib.get("inc_dirs_ext", None)
00121         # Additional macros you want to define when building library
00122         self.macros  = lib.get("macros", None)
00123 
00124         self.source_dir  = lib["source_dir"]
00125         self.build_dir  = lib["build_dir"]
00126 
00127     def is_supported (self, target, toolchain):
00128         """Check if a target toolchain combination is supported
00129 
00130         Positional arguments:
00131         target - the MCU or board
00132         toolchain - the compiler
00133         """
00134         if not hasattr(self, 'supported'):
00135             return True
00136         return (target.name in self.supported ) and \
00137             (toolchain in self.supported [target.name])