nkjnm
Dependencies: MAX44000 nexpaq_mdk
Fork of LED_Demo by
mbd_os/tools/libraries.py@1:55a6170b404f, 2016-09-17 (annotated)
- Committer:
- nexpaq
- Date:
- Sat Sep 17 16:32:05 2016 +0000
- Revision:
- 1:55a6170b404f
checking in for sharing
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
nexpaq | 1:55a6170b404f | 1 | """ |
nexpaq | 1:55a6170b404f | 2 | mbed SDK |
nexpaq | 1:55a6170b404f | 3 | Copyright (c) 2011-2013 ARM Limited |
nexpaq | 1:55a6170b404f | 4 | |
nexpaq | 1:55a6170b404f | 5 | Licensed under the Apache License, Version 2.0 (the "License"); |
nexpaq | 1:55a6170b404f | 6 | you may not use this file except in compliance with the License. |
nexpaq | 1:55a6170b404f | 7 | You may obtain a copy of the License at |
nexpaq | 1:55a6170b404f | 8 | |
nexpaq | 1:55a6170b404f | 9 | http://www.apache.org/licenses/LICENSE-2.0 |
nexpaq | 1:55a6170b404f | 10 | |
nexpaq | 1:55a6170b404f | 11 | Unless required by applicable law or agreed to in writing, software |
nexpaq | 1:55a6170b404f | 12 | distributed under the License is distributed on an "AS IS" BASIS, |
nexpaq | 1:55a6170b404f | 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
nexpaq | 1:55a6170b404f | 14 | See the License for the specific language governing permissions and |
nexpaq | 1:55a6170b404f | 15 | limitations under the License. |
nexpaq | 1:55a6170b404f | 16 | """ |
nexpaq | 1:55a6170b404f | 17 | from tools.paths import MBED_RTX, RTOS_LIBRARIES, MBED_LIBRARIES, MBED_RPC,\ |
nexpaq | 1:55a6170b404f | 18 | RTOS_ABSTRACTION, RPC_LIBRARY, USB, USB_LIBRARIES, USB_HOST,\ |
nexpaq | 1:55a6170b404f | 19 | USB_HOST_LIBRARIES, FAT_FS, DSP_ABSTRACTION, DSP_CMSIS, DSP_LIBRARIES,\ |
nexpaq | 1:55a6170b404f | 20 | SD_FS, FS_LIBRARY, ETH_SOURCES, LWIP_SOURCES, ETH_LIBRARY, UBLOX_SOURCES,\ |
nexpaq | 1:55a6170b404f | 21 | UBLOX_LIBRARY, CELLULAR_SOURCES, CELLULAR_USB_SOURCES, CPPUTEST_SRC,\ |
nexpaq | 1:55a6170b404f | 22 | CPPUTEST_PLATFORM_SRC, CPPUTEST_TESTRUNNER_SCR, CPPUTEST_LIBRARY,\ |
nexpaq | 1:55a6170b404f | 23 | CPPUTEST_INC, CPPUTEST_PLATFORM_INC, CPPUTEST_TESTRUNNER_INC,\ |
nexpaq | 1:55a6170b404f | 24 | CPPUTEST_INC_EXT |
nexpaq | 1:55a6170b404f | 25 | from tools.data.support import DEFAULT_SUPPORT |
nexpaq | 1:55a6170b404f | 26 | from tools.tests import TEST_MBED_LIB |
nexpaq | 1:55a6170b404f | 27 | |
nexpaq | 1:55a6170b404f | 28 | |
nexpaq | 1:55a6170b404f | 29 | LIBRARIES = [ |
nexpaq | 1:55a6170b404f | 30 | # RTOS libraries |
nexpaq | 1:55a6170b404f | 31 | { |
nexpaq | 1:55a6170b404f | 32 | "id": "rtx", |
nexpaq | 1:55a6170b404f | 33 | "source_dir": MBED_RTX, |
nexpaq | 1:55a6170b404f | 34 | "build_dir": RTOS_LIBRARIES, |
nexpaq | 1:55a6170b404f | 35 | "dependencies": [MBED_LIBRARIES], |
nexpaq | 1:55a6170b404f | 36 | }, |
nexpaq | 1:55a6170b404f | 37 | { |
nexpaq | 1:55a6170b404f | 38 | "id": "rtos", |
nexpaq | 1:55a6170b404f | 39 | "source_dir": RTOS_ABSTRACTION, |
nexpaq | 1:55a6170b404f | 40 | "build_dir": RTOS_LIBRARIES, |
nexpaq | 1:55a6170b404f | 41 | "dependencies": [MBED_LIBRARIES, MBED_RTX], |
nexpaq | 1:55a6170b404f | 42 | }, |
nexpaq | 1:55a6170b404f | 43 | |
nexpaq | 1:55a6170b404f | 44 | # RPC |
nexpaq | 1:55a6170b404f | 45 | { |
nexpaq | 1:55a6170b404f | 46 | "id": "rpc", |
nexpaq | 1:55a6170b404f | 47 | "source_dir": MBED_RPC, |
nexpaq | 1:55a6170b404f | 48 | "build_dir": RPC_LIBRARY, |
nexpaq | 1:55a6170b404f | 49 | "dependencies": [MBED_LIBRARIES], |
nexpaq | 1:55a6170b404f | 50 | }, |
nexpaq | 1:55a6170b404f | 51 | |
nexpaq | 1:55a6170b404f | 52 | # USB Device libraries |
nexpaq | 1:55a6170b404f | 53 | { |
nexpaq | 1:55a6170b404f | 54 | "id": "usb", |
nexpaq | 1:55a6170b404f | 55 | "source_dir": USB, |
nexpaq | 1:55a6170b404f | 56 | "build_dir": USB_LIBRARIES, |
nexpaq | 1:55a6170b404f | 57 | "dependencies": [MBED_LIBRARIES], |
nexpaq | 1:55a6170b404f | 58 | }, |
nexpaq | 1:55a6170b404f | 59 | |
nexpaq | 1:55a6170b404f | 60 | # USB Host libraries |
nexpaq | 1:55a6170b404f | 61 | { |
nexpaq | 1:55a6170b404f | 62 | "id": "usb_host", |
nexpaq | 1:55a6170b404f | 63 | "source_dir": USB_HOST, |
nexpaq | 1:55a6170b404f | 64 | "build_dir": USB_HOST_LIBRARIES, |
nexpaq | 1:55a6170b404f | 65 | "dependencies": [MBED_LIBRARIES, FAT_FS, MBED_RTX, RTOS_ABSTRACTION], |
nexpaq | 1:55a6170b404f | 66 | }, |
nexpaq | 1:55a6170b404f | 67 | |
nexpaq | 1:55a6170b404f | 68 | # DSP libraries |
nexpaq | 1:55a6170b404f | 69 | { |
nexpaq | 1:55a6170b404f | 70 | "id": "dsp", |
nexpaq | 1:55a6170b404f | 71 | "source_dir": [DSP_ABSTRACTION, DSP_CMSIS], |
nexpaq | 1:55a6170b404f | 72 | "build_dir": DSP_LIBRARIES, |
nexpaq | 1:55a6170b404f | 73 | "dependencies": [MBED_LIBRARIES] |
nexpaq | 1:55a6170b404f | 74 | }, |
nexpaq | 1:55a6170b404f | 75 | |
nexpaq | 1:55a6170b404f | 76 | # File system libraries |
nexpaq | 1:55a6170b404f | 77 | { |
nexpaq | 1:55a6170b404f | 78 | "id": "fat", |
nexpaq | 1:55a6170b404f | 79 | "source_dir": [FAT_FS, SD_FS], |
nexpaq | 1:55a6170b404f | 80 | "build_dir": FS_LIBRARY, |
nexpaq | 1:55a6170b404f | 81 | "dependencies": [MBED_LIBRARIES] |
nexpaq | 1:55a6170b404f | 82 | }, |
nexpaq | 1:55a6170b404f | 83 | |
nexpaq | 1:55a6170b404f | 84 | # Network libraries |
nexpaq | 1:55a6170b404f | 85 | { |
nexpaq | 1:55a6170b404f | 86 | "id": "eth", |
nexpaq | 1:55a6170b404f | 87 | "source_dir": [ETH_SOURCES, LWIP_SOURCES], |
nexpaq | 1:55a6170b404f | 88 | "build_dir": ETH_LIBRARY, |
nexpaq | 1:55a6170b404f | 89 | "dependencies": [MBED_LIBRARIES, RTOS_LIBRARIES] |
nexpaq | 1:55a6170b404f | 90 | }, |
nexpaq | 1:55a6170b404f | 91 | |
nexpaq | 1:55a6170b404f | 92 | { |
nexpaq | 1:55a6170b404f | 93 | "id": "ublox", |
nexpaq | 1:55a6170b404f | 94 | "source_dir": [UBLOX_SOURCES, CELLULAR_SOURCES, CELLULAR_USB_SOURCES, |
nexpaq | 1:55a6170b404f | 95 | LWIP_SOURCES], |
nexpaq | 1:55a6170b404f | 96 | "build_dir": UBLOX_LIBRARY, |
nexpaq | 1:55a6170b404f | 97 | "dependencies": [MBED_LIBRARIES, RTOS_LIBRARIES, USB_HOST_LIBRARIES], |
nexpaq | 1:55a6170b404f | 98 | }, |
nexpaq | 1:55a6170b404f | 99 | |
nexpaq | 1:55a6170b404f | 100 | # Unit Testing library |
nexpaq | 1:55a6170b404f | 101 | { |
nexpaq | 1:55a6170b404f | 102 | "id": "cpputest", |
nexpaq | 1:55a6170b404f | 103 | "source_dir": [CPPUTEST_SRC, CPPUTEST_PLATFORM_SRC, |
nexpaq | 1:55a6170b404f | 104 | CPPUTEST_TESTRUNNER_SCR], |
nexpaq | 1:55a6170b404f | 105 | "build_dir": CPPUTEST_LIBRARY, |
nexpaq | 1:55a6170b404f | 106 | "dependencies": [MBED_LIBRARIES], |
nexpaq | 1:55a6170b404f | 107 | 'inc_dirs': [CPPUTEST_INC, CPPUTEST_PLATFORM_INC, |
nexpaq | 1:55a6170b404f | 108 | CPPUTEST_TESTRUNNER_INC, TEST_MBED_LIB], |
nexpaq | 1:55a6170b404f | 109 | 'inc_dirs_ext': [CPPUTEST_INC_EXT], |
nexpaq | 1:55a6170b404f | 110 | 'macros': ["CPPUTEST_USE_MEM_LEAK_DETECTION=0", |
nexpaq | 1:55a6170b404f | 111 | "CPPUTEST_USE_STD_CPP_LIB=0", "CPPUTEST=1"], |
nexpaq | 1:55a6170b404f | 112 | }, |
nexpaq | 1:55a6170b404f | 113 | ] |
nexpaq | 1:55a6170b404f | 114 | |
nexpaq | 1:55a6170b404f | 115 | |
nexpaq | 1:55a6170b404f | 116 | LIBRARY_MAP = dict([(library['id'], library) for library in LIBRARIES]) |
nexpaq | 1:55a6170b404f | 117 | |
nexpaq | 1:55a6170b404f | 118 | |
nexpaq | 1:55a6170b404f | 119 | class Library(object): |
nexpaq | 1:55a6170b404f | 120 | """A library representation that allows for querying of support""" |
nexpaq | 1:55a6170b404f | 121 | def __init__(self, lib_id): |
nexpaq | 1:55a6170b404f | 122 | lib = LIBRARY_MAP[lib_id] |
nexpaq | 1:55a6170b404f | 123 | self.supported = lib.get("supported", DEFAULT_SUPPORT) |
nexpaq | 1:55a6170b404f | 124 | self.dependencies = lib.get("dependencies", None) |
nexpaq | 1:55a6170b404f | 125 | # Include dirs required by library build |
nexpaq | 1:55a6170b404f | 126 | self.inc_dirs = lib.get("inc_dirs", None) |
nexpaq | 1:55a6170b404f | 127 | # Include dirs required by others to use with this library |
nexpaq | 1:55a6170b404f | 128 | self.inc_dirs_ext = lib.get("inc_dirs_ext", None) |
nexpaq | 1:55a6170b404f | 129 | # Additional macros you want to define when building library |
nexpaq | 1:55a6170b404f | 130 | self.macros = lib.get("macros", None) |
nexpaq | 1:55a6170b404f | 131 | |
nexpaq | 1:55a6170b404f | 132 | self.source_dir = lib["source_dir"] |
nexpaq | 1:55a6170b404f | 133 | self.build_dir = lib["build_dir"] |
nexpaq | 1:55a6170b404f | 134 | |
nexpaq | 1:55a6170b404f | 135 | def is_supported(self, target, toolchain): |
nexpaq | 1:55a6170b404f | 136 | """Check if a target toolchain combination is supported |
nexpaq | 1:55a6170b404f | 137 | |
nexpaq | 1:55a6170b404f | 138 | Positional arguments: |
nexpaq | 1:55a6170b404f | 139 | target - the MCU or board |
nexpaq | 1:55a6170b404f | 140 | toolchain - the compiler |
nexpaq | 1:55a6170b404f | 141 | """ |
nexpaq | 1:55a6170b404f | 142 | if not hasattr(self, 'supported'): |
nexpaq | 1:55a6170b404f | 143 | return True |
nexpaq | 1:55a6170b404f | 144 | return (target.name in self.supported) and \ |
nexpaq | 1:55a6170b404f | 145 | (toolchain in self.supported[target.name]) |