Skip to content

Commit a7ddc46

Browse files
committed
restructure - Added single-nested inc_dir support to legacy build_lib
Added single-nested include directories to libraries built with the legacy build_lib function. Unfortunately, to get this working without a significant rewrite of the legacy build tools, library header files are just duplicated in the precompile stage.
1 parent 04a2af7 commit a7ddc46

File tree

4 files changed

+24
-18
lines changed

4 files changed

+24
-18
lines changed

mbed.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
#define MBED_LIBRARY_VERSION 123
2020

2121
#if MBED_CONF_RTOS_PRESENT
22-
#include "rtos.h"
22+
#include "rtos/rtos.h"
2323
#endif
2424

2525
#if MBED_CONF_NSAPI_PRESENT

tools/build_api.py

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@
2626
from tools.utils import mkdir, run_cmd, run_cmd_ext, NotSupportedException,\
2727
ToolException, InvalidReleaseTargetException
2828
from tools.paths import MBED_TARGETS_PATH, MBED_LIBRARIES, MBED_HEADER,\
29-
MBED_DRIVERS, MBED_PLATFORM, MBED_HAL, MBED_CONFIG_FILE
29+
MBED_DRIVERS, MBED_PLATFORM, MBED_HAL, MBED_CONFIG_FILE,\
30+
MBED_LIBRARIES_DRIVERS, MBED_LIBRARIES_PLATFORM, MBED_LIBRARIES_HAL,\
31+
BUILD_DIR
3032
from tools.targets import TARGET_NAMES, TARGET_MAP
3133
from tools.libraries import Library
3234
from tools.toolchains import TOOLCHAIN_CLASSES
@@ -772,6 +774,8 @@ def build_lib(lib_id, target, toolchain_name, verbose=False,
772774
for resource in resources:
773775
toolchain.copy_files(resource.headers, build_path,
774776
resources=resource)
777+
toolchain.copy_files(resource.headers, join(build_path, name),
778+
resources=resource)
775779

776780
dependencies_include_dir.extend(
777781
toolchain.scan_resources(build_path).inc_dirs)
@@ -905,12 +909,12 @@ def build_mbed_libs(target, toolchain_name, verbose=False,
905909

906910
# Common Headers
907911
toolchain.copy_files([MBED_HEADER], MBED_LIBRARIES)
908-
toolchain.copy_files(toolchain.scan_resources(MBED_DRIVERS).headers,
909-
MBED_LIBRARIES)
910-
toolchain.copy_files(toolchain.scan_resources(MBED_PLATFORM).headers,
911-
MBED_LIBRARIES)
912-
toolchain.copy_files(toolchain.scan_resources(MBED_HAL).headers,
913-
MBED_LIBRARIES)
912+
for dir, dest in [(MBED_DRIVERS, MBED_LIBRARIES_DRIVERS),
913+
(MBED_PLATFORM, MBED_LIBRARIES_PLATFORM),
914+
(MBED_HAL, MBED_LIBRARIES_HAL)]:
915+
resources = toolchain.scan_resources(dir)
916+
toolchain.copy_files(resources.headers, MBED_LIBRARIES)
917+
toolchain.copy_files(resources.headers, dest)
914918

915919
# Target specific sources
916920
hal_src = MBED_TARGETS_PATH
@@ -925,14 +929,14 @@ def build_mbed_libs(target, toolchain_name, verbose=False,
925929
[MBED_LIBRARIES] + incdirs)
926930

927931
# Common Sources
928-
mbed_resources = toolchain.scan_resources(MBED_DRIVERS)
929-
mbed_resources += toolchain.scan_resources(MBED_PLATFORM)
930-
mbed_resources += toolchain.scan_resources(MBED_HAL)
932+
mbed_resources = None
933+
for dir in [MBED_DRIVERS, MBED_PLATFORM, MBED_HAL]:
934+
mbed_resources += toolchain.scan_resources(dir)
935+
931936
objects += toolchain.compile_sources(mbed_resources, tmp_path,
932-
[MBED_LIBRARIES] + incdirs)
937+
[MBED_LIBRARIES] + incdirs)
933938

934939
# A number of compiled files need to be copied as objects as opposed to
935-
# being part of the mbed library, for reasons that have to do with the
936940
# way the linker search for symbols in archives. These are:
937941
# - retarget.o: to make sure that the C standard lib symbols get
938942
# overridden

tools/libraries.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
See the License for the specific language governing permissions and
1515
limitations under the License.
1616
"""
17-
from tools.paths import MBED_RTX, RTOS_LIBRARIES, MBED_LIBRARIES, MBED_RPC,\
18-
RTOS_ABSTRACTION, RPC_LIBRARY, USB, USB_LIBRARIES, USB_HOST,\
17+
from tools.paths import MBED_RTX, RTOS, RTOS_LIBRARIES, MBED_LIBRARIES,\
18+
MBED_RPC, RPC_LIBRARY, USB, USB_LIBRARIES, USB_HOST,\
1919
USB_HOST_LIBRARIES, FAT_FS, DSP_ABSTRACTION, DSP_CMSIS, DSP_LIBRARIES,\
2020
SD_FS, FS_LIBRARY, ETH_SOURCES, LWIP_SOURCES, ETH_LIBRARY, UBLOX_SOURCES,\
2121
UBLOX_LIBRARY, CELLULAR_SOURCES, CELLULAR_USB_SOURCES, CPPUTEST_SRC,\
@@ -36,7 +36,7 @@
3636
},
3737
{
3838
"id": "rtos",
39-
"source_dir": RTOS_ABSTRACTION,
39+
"source_dir": RTOS,
4040
"build_dir": RTOS_LIBRARIES,
4141
"dependencies": [MBED_LIBRARIES, MBED_RTX],
4242
},
@@ -62,7 +62,7 @@
6262
"id": "usb_host",
6363
"source_dir": USB_HOST,
6464
"build_dir": USB_HOST_LIBRARIES,
65-
"dependencies": [MBED_LIBRARIES, FAT_FS, MBED_RTX, RTOS_ABSTRACTION],
65+
"dependencies": [MBED_LIBRARIES, FAT_FS, MBED_RTX, RTOS_LIBRARIES],
6666
},
6767

6868
# DSP libraries

tools/paths.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@
3939
MBED_TARGETS_PATH = join(ROOT, "targets")
4040

4141
MBED_LIBRARIES = join(BUILD_DIR, "mbed")
42+
MBED_LIBRARIES_DRIVERS = join(MBED_LIBRARIES, "drivers")
43+
MBED_LIBRARIES_PLATFORM = join(MBED_LIBRARIES, "platform")
44+
MBED_LIBRARIES_HAL = join(MBED_LIBRARIES, "hal")
4245

4346
MBED_CONFIG_FILE = join(ROOT, "platform/mbed_lib.json")
4447

@@ -54,7 +57,6 @@
5457
# mbed RTOS
5558
RTOS = join(ROOT, "rtos")
5659
MBED_RTX = join(RTOS, "rtx")
57-
RTOS_ABSTRACTION = RTOS
5860

5961
RTOS_LIBRARIES = join(BUILD_DIR, "rtos")
6062

0 commit comments

Comments
 (0)