Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"name": "framework-mbed-ce",
"version": "6.99.0",
"title": "Mbed OS Community Edition",
"description": "Mbed CE is a platform operating system designed for the internet of things",
"keywords": [
"framework",
"os",
"arm",
"hal"
],
"homepage": "http://mbed-ce.dev",
"repository": {
"type": "git",
"url": "https://github.com/mbed-ce/mbed-os"
}
}
2 changes: 1 addition & 1 deletion tools/cmake/mbed_create_distro.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ function(mbed_extract_flags NAME) # ARGN: modules...
foreach(SUBMODULE ${SUBMODULES})
if(NOT "${SUBMODULE}" MATCHES "::@") # remove CMake internal CMAKE_DIRECTORY_ID_SEP markers
# Remove LINK_ONLY genexes from target_link_libraries(... PRIVATE). We can ignore things wrapped in these
# because they will already have been handled by the target_link_libraries earlier on.
# because they are for private dependencies.
if(NOT "${SUBMODULE}" MATCHES "\\$<LINK_ONLY:.*>")
if(NOT ${SUBMODULE} IN_LIST COMPLETED_MODULES)
list(APPEND REMAINING_MODULES ${SUBMODULE})
Expand Down
54 changes: 48 additions & 6 deletions tools/cmake/mbed_generate_configuration.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,30 @@

set(MBED_NEED_TO_RECONFIGURE FALSE)

# Check that path variables (MBED_APP_JSON_PATH, CUSTOM_TARGETS_JSON_PATH) are valid and set
# vars (HAS_CUSTOM_TARGETS_JSON, HAS_MBED_APP_JSON) based on whether they exist.
# Also, convert all relative paths to absolute paths, rooted at CMAKE_SOURCE_DIR.
# This makes sure that they are interpreted the same way everywhere.
foreach(json_var_name MBED_APP_JSON CUSTOM_TARGETS_JSON)

if("${${json_var_name}_PATH}" STREQUAL "")
set(HAS_${json_var_name} FALSE)
else()
get_filename_component(${json_var_name}_PATH "${${json_var_name}_PATH}" ABSOLUTE BASE_DIR ${CMAKE_SOURCE_DIR})
if(NOT EXISTS ${${json_var_name}_PATH} OR IS_DIRECTORY ${${json_var_name}_PATH})
message(FATAL_ERROR "${json_var_name}_PATH value of ${${json_var_name}_PATH} is not a valid file!")
endif()
set(HAS_${json_var_name} TRUE)
endif()
endforeach()

if("${CUSTOM_TARGETS_JSON_PATH}" STREQUAL "")
set(HAS_CUSTOM_TARGETS_JSON FALSE)
else()
set(HAS_CUSTOM_TARGETS_JSON TRUE)
get_filename_component(CUSTOM_TARGETS_JSON_PATH "${CUSTOM_TARGETS_JSON_PATH}" ABSOLUTE BASE_DIR ${CMAKE_SOURCE_DIR})
endif()

# First, verify that MBED_TARGET has not changed
if(DEFINED MBED_INTERNAL_LAST_MBED_TARGET)
if(NOT "${MBED_INTERNAL_LAST_MBED_TARGET}" STREQUAL "${MBED_TARGET}")
Expand Down Expand Up @@ -42,9 +66,19 @@ endif()
if(NOT MBED_NEED_TO_RECONFIGURE)
file(TIMESTAMP ${CMAKE_CURRENT_BINARY_DIR}/mbed_config.cmake MBED_CONFIG_CMAKE_TIMESTAMP "%s" UTC)

set(MBED_APP_JSON_FOUND FALSE)
set(CUSTOM_TARGETS_JSON_FOUND FALSE)

foreach(CONFIG_JSON ${MBED_CONFIG_JSON_SOURCE_FILES})
get_filename_component(CONFIG_JSON_ABSPATH ${CONFIG_JSON} ABSOLUTE)

if(CONFIG_JSON_ABSPATH STREQUAL MBED_APP_JSON_PATH)
set(MBED_APP_JSON_FOUND TRUE)
endif()
if(CONFIG_JSON_ABSPATH STREQUAL CUSTOM_TARGETS_JSON_PATH)
set(CUSTOM_TARGETS_JSON_FOUND TRUE)
endif()

if(NOT EXISTS ${CONFIG_JSON_ABSPATH})
message(STATUS "Mbed: ${CONFIG_JSON} deleted or renamed, regenerating configs...")
set(MBED_NEED_TO_RECONFIGURE TRUE)
Expand All @@ -60,20 +94,28 @@ if(NOT MBED_NEED_TO_RECONFIGURE)
endforeach()
endif()

# Convert all relative paths to absolute paths, rooted at CMAKE_SOURCE_DIR.
# This makes sure that they are interpreted the same way everywhere.
get_filename_component(MBED_APP_JSON_PATH "${MBED_APP_JSON_PATH}" ABSOLUTE BASE_DIR ${CMAKE_SOURCE_DIR})
get_filename_component(CUSTOM_TARGETS_JSON_PATH "${CUSTOM_TARGETS_JSON_PATH}" ABSOLUTE BASE_DIR ${CMAKE_SOURCE_DIR})
if(NOT MBED_NEED_TO_RECONFIGURE)
# Corner case: if we previously had not set an mbed_app.json and now we do, we need to detect that
# and reconfigure.
if(HAS_MBED_APP_JSON AND NOT MBED_APP_JSON_FOUND)
message(STATUS "Mbed: mbed_app.json added/moved, regenerating configs...")
set(MBED_NEED_TO_RECONFIGURE TRUE)
endif()
if(HAS_CUSTOM_TARGETS_JSON AND NOT CUSTOM_TARGETS_JSON_FOUND)
message(STATUS "Mbed: custom_targets.json added/moved, regenerating configs...")
set(MBED_NEED_TO_RECONFIGURE TRUE)
endif()
endif()

if(MBED_NEED_TO_RECONFIGURE)
# Generate mbed_config.cmake for this target
if(EXISTS "${MBED_APP_JSON_PATH}" AND (NOT IS_DIRECTORY "${MBED_APP_JSON_PATH}"))
if(HAS_MBED_APP_JSON)
set(APP_CONFIG_ARGUMENT --app-config "${MBED_APP_JSON_PATH}")
else()
set(APP_CONFIG_ARGUMENT "")
endif()

if(EXISTS "${CUSTOM_TARGETS_JSON_PATH}" AND (NOT IS_DIRECTORY "${CUSTOM_TARGETS_JSON_PATH}"))
if(HAS_CUSTOM_TARGETS_JSON)
set(CUSTOM_TARGET_ARGUMENT --custom-targets-json "${CUSTOM_TARGETS_JSON_PATH}")
else()
set(CUSTOM_TARGET_ARGUMENT "")
Expand Down
7 changes: 7 additions & 0 deletions tools/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,13 @@ unit-tests = [
"lxml"
]

# Install this optional dependency group to get IDE completion for packages used by the mbed_platformio package.
# Note that this package is actually run in platformio's venv, not the Mbed venv, so there is no other need to install these.
platformio = [
"SCons",
"platformio"
]

[tool.hatch.build.targets.wheel]
packages = [
"python/mbed_host_tests",
Expand Down
22 changes: 22 additions & 0 deletions tools/python/mbed_platformio/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#
# This file is used as the CMakeLists.txt when building a PlatformIO project.
#

cmake_minimum_required(VERSION 3.19)
cmake_policy(VERSION 3.19...3.22)

set(MBED_APP_JSON_PATH ${PLATFORMIO_PROJECT_PATH}/mbed_app.json5)

include(${PLATFORMIO_MBED_OS_PATH}/tools/cmake/mbed_toolchain_setup.cmake)
project(PlatformIOMbedProject
LANGUAGES C CXX ASM)
include(mbed_project_setup)

add_subdirectory(${PLATFORMIO_MBED_OS_PATH} mbed-os)

# Dummy executable. Not built, but needed to get the compile and linker flags via the CMake file API
add_executable(PIODummyExecutable
dummy_source_file.c
dummy_source_file.cpp
dummy_source_file.S)
target_link_libraries(PIODummyExecutable mbed-os)
4 changes: 4 additions & 0 deletions tools/python/mbed_platformio/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
"""
Copyright (c) 2025 Jamie Smith
SPDX-License-Identifier: Apache-2.0
"""
Loading
Loading