|
14 | 14 | See the License for the specific language governing permissions and
|
15 | 15 | limitations under the License.
|
16 | 16 | """
|
17 |
| -from tools.paths import * |
18 |
| -from tools.data.support import * |
| 17 | +from tools.paths import MBED_RTX, RTOS_LIBRARIES, MBED_LIBRARIES, MBED_RPC,\ |
| 18 | + RTOS_ABSTRACTION, RPC_LIBRARY, USB, USB_LIBRARIES, USB_HOST,\ |
| 19 | + USB_HOST_LIBRARIES, FAT_FS, DSP_ABSTRACTION, DSP_CMSIS, DSP_LIBRARIES,\ |
| 20 | + SD_FS, FS_LIBRARY, ETH_SOURCES, LWIP_SOURCES, ETH_LIBRARY, UBLOX_SOURCES,\ |
| 21 | + UBLOX_LIBRARY, CELLULAR_SOURCES, CELLULAR_USB_SOURCES, CPPUTEST_SRC,\ |
| 22 | + CPPUTEST_PLATFORM_SRC, CPPUTEST_TESTRUNNER_SCR, CPPUTEST_LIBRARY,\ |
| 23 | + CPPUTEST_INC, CPPUTEST_PLATFORM_INC, CPPUTEST_TESTRUNNER_INC,\ |
| 24 | + CPPUTEST_INC_EXT |
| 25 | +from tools.data.support import DEFAULT_SUPPORT |
19 | 26 | from tools.tests import TEST_MBED_LIB
|
20 | 27 |
|
21 | 28 |
|
|
84 | 91 |
|
85 | 92 | {
|
86 | 93 | "id": "ublox",
|
87 |
| - "source_dir": [UBLOX_SOURCES, CELLULAR_SOURCES, CELLULAR_USB_SOURCES, LWIP_SOURCES], |
| 94 | + "source_dir": [UBLOX_SOURCES, CELLULAR_SOURCES, CELLULAR_USB_SOURCES, |
| 95 | + LWIP_SOURCES], |
88 | 96 | "build_dir": UBLOX_LIBRARY,
|
89 | 97 | "dependencies": [MBED_LIBRARIES, RTOS_LIBRARIES, USB_HOST_LIBRARIES],
|
90 | 98 | },
|
91 | 99 |
|
92 | 100 | # Unit Testing library
|
93 | 101 | {
|
94 | 102 | "id": "cpputest",
|
95 |
| - "source_dir": [CPPUTEST_SRC, CPPUTEST_PLATFORM_SRC, CPPUTEST_TESTRUNNER_SCR], |
| 103 | + "source_dir": [CPPUTEST_SRC, CPPUTEST_PLATFORM_SRC, |
| 104 | + CPPUTEST_TESTRUNNER_SCR], |
96 | 105 | "build_dir": CPPUTEST_LIBRARY,
|
97 | 106 | "dependencies": [MBED_LIBRARIES],
|
98 |
| - 'inc_dirs': [CPPUTEST_INC, CPPUTEST_PLATFORM_INC, CPPUTEST_TESTRUNNER_INC, TEST_MBED_LIB], |
| 107 | + 'inc_dirs': [CPPUTEST_INC, CPPUTEST_PLATFORM_INC, |
| 108 | + CPPUTEST_TESTRUNNER_INC, TEST_MBED_LIB], |
99 | 109 | 'inc_dirs_ext': [CPPUTEST_INC_EXT],
|
100 |
| - 'macros': ["CPPUTEST_USE_MEM_LEAK_DETECTION=0", "CPPUTEST_USE_STD_CPP_LIB=0", "CPPUTEST=1"], |
| 110 | + 'macros': ["CPPUTEST_USE_MEM_LEAK_DETECTION=0", |
| 111 | + "CPPUTEST_USE_STD_CPP_LIB=0", "CPPUTEST=1"], |
101 | 112 | },
|
102 | 113 | ]
|
103 | 114 |
|
104 | 115 |
|
105 | 116 | LIBRARY_MAP = dict([(library['id'], library) for library in LIBRARIES])
|
106 | 117 |
|
107 | 118 |
|
108 |
| -class Library: |
109 |
| - DEFAULTS = { |
110 |
| - "supported": DEFAULT_SUPPORT, |
111 |
| - 'dependencies': None, |
112 |
| - 'inc_dirs': None, # Include dirs required by library build |
113 |
| - 'inc_dirs_ext': None, # Include dirs required by others to use with this library |
114 |
| - 'macros': None, # Additional macros you want to define when building library |
115 |
| - } |
| 119 | +class Library(object): |
| 120 | + """A library representation that allows for querying of support""" |
116 | 121 | def __init__(self, lib_id):
|
117 |
| - self.__dict__.update(Library.DEFAULTS) |
118 |
| - self.__dict__.update(LIBRARY_MAP[lib_id]) |
| 122 | + lib = LIBRARY_MAP[lib_id] |
| 123 | + self.supported = lib.get("supported", DEFAULT_SUPPORT) |
| 124 | + self.dependencies = lib.get("dependencies", None) |
| 125 | + # Include dirs required by library build |
| 126 | + self.inc_dirs = lib.get("inc_dirs", None) |
| 127 | + # Include dirs required by others to use with this library |
| 128 | + self.inc_dirs_ext = lib.get("inc_dirs_ext", None) |
| 129 | + # Additional macros you want to define when building library |
| 130 | + self.macros = lib.get("macros", None) |
| 131 | + |
| 132 | + self.source_dir = lib["source_dir"] |
| 133 | + self.build_dir = lib["build_dir"] |
119 | 134 |
|
120 | 135 | def is_supported(self, target, toolchain):
|
| 136 | + """Check if a target toolchain combination is supported |
| 137 | +
|
| 138 | + Positional arguments: |
| 139 | + target - the MCU or board |
| 140 | + toolchain - the compiler |
| 141 | + """ |
121 | 142 | if not hasattr(self, 'supported'):
|
122 | 143 | return True
|
123 |
| - return (target.name in self.supported) and (toolchain in self.supported[target.name]) |
| 144 | + return (target.name in self.supported) and \ |
| 145 | + (toolchain in self.supported[target.name]) |
0 commit comments