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