Skip to content

Commit 6bbb7a4

Browse files
committed
Update build script according to the latest framework structure
1 parent edb0d6e commit 6bbb7a4

File tree

1 file changed

+46
-29
lines changed

1 file changed

+46
-29
lines changed

mbed.py

Lines changed: 46 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -88,14 +88,42 @@ def get_dynamic_manifest(name, config, extra_inc_dirs=[]):
8888
for f in src_files:
8989
manifest['build']['srcFilter'].extend([" +<%s>" % f])
9090

91-
if name == "LWIP":
92-
manifest['dependencies'] = {"mbed-events": "*"}
91+
manifest['build']['libLDFMode'] = "deep+"
92+
93+
# Implicit dependencies:
94+
# OnboardNetworkStack::get_default_instance
95+
# mbed::mbed_event_queue
96+
if name == "netsocket":
97+
manifest['build']['flags'].extend(["-DMBED_CONF_EVENTS_PRESENT"])
98+
manifest['dependencies'] = {
99+
"mbed-LWIP": "*",
100+
"mbed-events": "*"
101+
}
93102

94-
manifest['build']['libLDFMode'] = "chain+"
103+
# arm_random_module_init
104+
if name == "mbed-client-randlib":
105+
manifest['dependencies'] = {"mbed-nanostack": "*"}
95106

96107
return manifest
97108

98109

110+
def process_global_lib(libname, mbed_config):
111+
if not libname or not mbed_config:
112+
return
113+
lib_config = mbed_config.get("libs").get(libname, {})
114+
if not lib_config:
115+
return
116+
lib_includes = [
117+
join(FRAMEWORK_DIR, lib_config.get("dir"), f)
118+
for f in lib_config.get("inc_dirs")
119+
]
120+
121+
env.Append(
122+
CPPPATH=lib_includes,
123+
LIB_DEPS=["mbed-%s" % libname]
124+
)
125+
126+
99127
variants_remap = util.load_json(
100128
join(FRAMEWORK_DIR, "platformio", "variants_remap.json"))
101129
board_type = env.subst("$BOARD")
@@ -137,19 +165,14 @@ def get_dynamic_manifest(name, config, extra_inc_dirs=[]):
137165
# apply user flags
138166
env.ProcessFlags(env.get("BUILD_FLAGS"))
139167

140-
MBED_RTOS = "PIO_FRAMEWORK_MBED_RTOS_PRESENT" in env.Flatten(
141-
env.get("CPPDEFINES", []))
142-
143-
if MBED_RTOS:
144-
env.Append(CPPDEFINES=["MBED_CONF_RTOS_PRESENT"])
145-
146168
#
147169
# Process libraries
148170
#
149171

150172
# There is no difference in processing between lib and feature
151173
libs = mbed_config.get("libs").copy()
152174
libs.update(mbed_config.get("features"))
175+
libs.update(mbed_config.get("frameworks"))
153176

154177
#
155178
# Process Core files from framework
@@ -170,10 +193,19 @@ def get_dynamic_manifest(name, config, extra_inc_dirs=[]):
170193
join(FRAMEWORK_DIR, "platformio", "variants", variant)
171194
])
172195

173-
# If RTOS is enabled then some of the files from Core depdend on it
196+
MBED_RTOS = "PIO_FRAMEWORK_MBED_RTOS_PRESENT" in env.Flatten(
197+
env.get("CPPDEFINES", []))
198+
174199
if MBED_RTOS:
175-
for d in mbed_config.get("libs").get("rtos").get("inc_dirs"):
176-
env.Append(CPPPATH=[join(FRAMEWORK_DIR, "rtos", d)])
200+
env.Append(CPPDEFINES=["MBED_CONF_RTOS_PRESENT"])
201+
process_global_lib("rtos", mbed_config)
202+
203+
MBED_EVENTS = "PIO_FRAMEWORK_MBED_EVENTS_PRESENT" in env.Flatten(
204+
env.get("CPPDEFINES", []))
205+
206+
if MBED_EVENTS:
207+
env.Append(CPPDEFINES=["MBED_CONF_EVENTS_PRESENT"])
208+
process_global_lib("events", mbed_config)
177209

178210
core_src_files = mbed_config.get("core").get("s_sources") + mbed_config.get(
179211
"core").get("c_sources") + mbed_config.get("core").get("cpp_sources")
@@ -219,25 +251,10 @@ def get_dynamic_manifest(name, config, extra_inc_dirs=[]):
219251

220252
for lib, lib_config in libs.items():
221253
extra_includes = []
222-
if lib == "events" and not MBED_RTOS:
223-
# Manually handle dependency on rtos lib
224-
extra_includes = [
225-
join(FRAMEWORK_DIR,
226-
mbed_config.get("libs").get("rtos").get("dir"), f)
227-
for f in mbed_config.get("libs").get("rtos").get("inc_dirs")
228-
]
229-
230254
env.Append(EXTRA_LIB_BUILDERS=[
231255
CustomLibBuilder(env, join(FRAMEWORK_DIR, lib_config.get("dir")),
232256
get_dynamic_manifest(lib, lib_config, extra_includes))
233257
])
234258

235-
# Add RTOS library only when a user requested it
236-
if MBED_RTOS:
237-
rtos_config = mbed_config.get("libs").get("rtos")
238-
env.Append(EXTRA_LIB_BUILDERS=[
239-
CustomLibBuilder(env, join(FRAMEWORK_DIR, rtos_config.get("dir")),
240-
get_dynamic_manifest("rtos", rtos_config))
241-
])
242-
243-
env.Append(LIB_DEPS=["mbed-rtos"])
259+
if lib == "mbedtls":
260+
env.Append(LIB_DEPS=["mbed-mbedtls"])

0 commit comments

Comments
 (0)