Skip to content

Commit daedf99

Browse files
authored
Merge pull request #63 from hugueskamba/hk_cmake_reduce_libs
CMake: Include only the libraries required
2 parents f10467b + 3b03bad commit daedf99

File tree

3 files changed

+47
-17
lines changed

3 files changed

+47
-17
lines changed

.travis.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,9 @@ matrix:
8888
- pip install "Jinja2>=2.10.1,<2.11"
8989
- pip install "intelhex>=1.3,<=2.2.1"
9090
script:
91-
- mbedtools checkout
92-
- echo mbedtools build -t GCC_ARM -m ${TARGET_NAME} -b ${PROFILE}
93-
- mbedtools build -t GCC_ARM -m ${TARGET_NAME} -b ${PROFILE}
91+
- mbedtools deploy
92+
- echo mbedtools compile -t GCC_ARM -m ${TARGET_NAME} -b ${PROFILE}
93+
- mbedtools compile -t GCC_ARM -m ${TARGET_NAME} -b ${PROFILE}
9494
- ccache -s
9595

9696
- &build-test

CMakeLists.txt

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,41 @@ target_sources(${APP_TARGET}
2424
main.cpp
2525
)
2626

27+
list(APPEND mbed_storage_libs)
28+
29+
if("DATAFLASH" IN_LIST MBED_TARGET_LABELS)
30+
list(APPEND mbed_storage_libs mbed-storage-dataflash)
31+
endif()
32+
33+
if("FLASHIAP" IN_LIST MBED_TARGET_LABELS)
34+
list(APPEND mbed_storage_libs mbed-storage-flashiap)
35+
endif()
36+
37+
if("I2CEE" IN_LIST MBED_TARGET_LABELS)
38+
list(APPEND mbed_storage_libs mbed-storage-i2cee)
39+
endif()
40+
41+
if("OSPIF" IN_LIST MBED_TARGET_LABELS)
42+
list(APPEND mbed_storage_libs mbed-storage-ospif)
43+
endif()
44+
45+
if("QSPIF" IN_LIST MBED_TARGET_LABELS)
46+
list(APPEND mbed_storage_libs mbed-storage-qspif)
47+
endif()
48+
49+
if("SD" IN_LIST MBED_TARGET_LABELS)
50+
list(APPEND mbed_storage_libs mbed-storage-sd)
51+
endif()
52+
53+
if("SPIF" IN_LIST MBED_TARGET_LABELS)
54+
list(APPEND mbed_storage_libs mbed-storage-spif)
55+
endif()
56+
2757
target_link_libraries(${APP_TARGET}
2858
PRIVATE
2959
mbed-os
30-
mbed-events
3160
mbed-storage
32-
mbed-storage-qspif
33-
mbed-storage-flashiap
61+
${mbed_storage_libs}
3462
)
3563

3664
mbed_set_post_build(${APP_TARGET})

main.cpp

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,30 +20,32 @@
2020
// Block devices
2121
#if COMPONENT_QSPIF
2222
#include "QSPIFBlockDevice.h"
23+
QSPIFBlockDevice bd;
24+
#endif
25+
26+
#if COMPONENT_OSPIF
27+
#include "OSPIFBlockDevice.h"
28+
OSPIFBlockDevice bd;
2329
#endif
2430

2531
#if COMPONENT_SPIF
2632
#include "SPIFBlockDevice.h"
33+
// Physical block device, can be any device that supports the BlockDevice API
34+
SPIFBlockDevice bd;
2735
#endif
2836

2937
#if COMPONENT_DATAFLASH
3038
#include "DataFlashBlockDevice.h"
31-
#endif
39+
DataFlashBlockDevice bd;
40+
#endif
3241

3342
#if COMPONENT_SD
3443
#include "SDBlockDevice.h"
35-
#endif
36-
37-
#include "HeapBlockDevice.h"
38-
39-
4044
// Physical block device, can be any device that supports the BlockDevice API
41-
SDBlockDevice bd(
42-
MBED_CONF_SD_SPI_MOSI,
43-
MBED_CONF_SD_SPI_MISO,
44-
MBED_CONF_SD_SPI_CLK,
45-
MBED_CONF_SD_SPI_CS);
45+
SDBlockDevice bd;
46+
#endif
4647

48+
#include "HeapBlockDevice.h"
4749

4850
// Entry point for the example
4951
int main() {

0 commit comments

Comments
 (0)