Skip to content

Commit

Permalink
Remove creating symlinks to Mbed OS , Mbed OS posix socket from build…
Browse files Browse the repository at this point in the history
… script

Improve examples CMakeLists files - use env variable to Mbed OS , Mbed OS posix socket and ISM43362 Wi-Fi
  • Loading branch information
ATmobica committed Oct 6, 2021
1 parent 594a3c8 commit 1471366
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 41 deletions.
6 changes: 3 additions & 3 deletions examples/lighting-app/mbed/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,17 @@ configure_file(
@ONLY
)

set(MBED_PATH ${CMAKE_CURRENT_SOURCE_DIR}/mbed-os CACHE INTERNAL "")
set(MBED_PATH $ENV{MBED_OS_PATH} CACHE INTERNAL "")
set(MBED_CONFIG_PATH ${CMAKE_CURRENT_BINARY_DIR} CACHE INTERNAL "")
set(APP_TARGET chip-mbed-lighting-app-example)

include(${MBED_PATH}/tools/cmake/app.cmake)
add_subdirectory(${MBED_PATH} ./mbed_build)

add_subdirectory(mbed-os-posix-socket)
add_subdirectory($ENV{MBED_OS_POSIX_SOCKET_PATH} ./mbed_os_posix_socket_build)

if(MBED_TARGET STREQUAL "DISCO_L475VG_IOT01A")
add_subdirectory(wifi-ism43362)
add_subdirectory($ENV{WIFI_ISM43362_PATH} ./wifi_ism43362_build)
endif()

add_executable(${APP_TARGET})
Expand Down
8 changes: 4 additions & 4 deletions examples/lock-app/mbed/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,17 @@ configure_file(
@ONLY
)

set(MBED_PATH ${CMAKE_CURRENT_SOURCE_DIR}/mbed-os CACHE INTERNAL "")
set(MBED_CONFIG_PATH ${CMAKE_CURRENT_BINARY_DIR} CACHE INTERNAL "")
#set(MBED_PATH $ENV{MBED_OS_PATH} CACHE INTERNAL "")
#set(MBED_CONFIG_PATH ${CMAKE_CURRENT_BINARY_DIR} CACHE INTERNAL "")
set(APP_TARGET chip-mbed-lock-app-example)

include(${MBED_PATH}/tools/cmake/app.cmake)
add_subdirectory(${MBED_PATH} ./mbed_build)

add_subdirectory(mbed-os-posix-socket)
add_subdirectory($ENV{MBED_OS_POSIX_SOCKET_PATH} ./mbed_os_posix_socket_build)

if(MBED_TARGET STREQUAL "DISCO_L475VG_IOT01A")
add_subdirectory(wifi-ism43362)
add_subdirectory($ENV{WIFI_ISM43362_PATH} ./wifi_ism43362_build)
endif()

add_executable(${APP_TARGET})
Expand Down
64 changes: 30 additions & 34 deletions scripts/examples/mbed_example.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,29 +34,29 @@ PROFILE=release

for i in "$@"; do
case $i in
-a=* | --app=*)
APP="${i#*=}"
shift
;;
-b=* | --board=*)
TARGET_BOARD="${i#*=}"
shift
;;
-t=* | --toolchain=*)
TOOLCHAIN="${i#*=}"
shift
;;
-p=* | --profile=*)
PROFILE="${i#*=}"
shift
;;
-c=* | --command=*)
COMMAND="${i#*=}"
shift
;;
*)
# unknown option
;;
-a=* | --app=*)
APP="${i#*=}"
shift
;;
-b=* | --board=*)
TARGET_BOARD="${i#*=}"
shift
;;
-t=* | --toolchain=*)
TOOLCHAIN="${i#*=}"
shift
;;
-p=* | --profile=*)
PROFILE="${i#*=}"
shift
;;
-c=* | --command=*)
COMMAND="${i#*=}"
shift
;;
*)
# unknown option
;;
esac
done

Expand Down Expand Up @@ -100,26 +100,22 @@ if [[ "$COMMAND" == *"build"* ]]; then
# Config directory setup
MBED_CONFIG_PATH="$APP"/mbed/cmake_build/"$TARGET_BOARD"/develop/"$TOOLCHAIN"/

# Override Mbed OS path to development directory
MBED_OS_PATH="$CHIP_ROOT"/third_party/mbed-os/repo
# Set Mbed OS path
export MBED_OS_PATH="$CHIP_ROOT"/third_party/mbed-os/repo

# Create symlinks to mbed-os submodule
ln -sfTr "$MBED_OS_PATH" "$APP/mbed/mbed-os"

# Create symlinks to mbed-os-posix-socket submodule
MBED_OS_POSIX_SOCKET_PATH="$CHIP_ROOT"/third_party/mbed-os-posix-socket/repo
ln -sfTr "$MBED_OS_POSIX_SOCKET_PATH" "$APP/mbed/mbed-os-posix-socket"
# Set Mbed OS posix socket submodule path
export MBED_OS_POSIX_SOCKET_PATH="$CHIP_ROOT"/third_party/mbed-os-posix-socket/repo

if [ "$TARGET_BOARD" == "DISCO_L475VG_IOT01A" ]; then
# Add the Mbed OS driver for the ISM43362 Wi-Fi module
WIFI_ISM43362_PATH="$CHIP_ROOT"/third_party/wifi-ism43362/repo
# Set ISM43362 Wi-Fi submodule path
export WIFI_ISM43362_PATH="$CHIP_ROOT"/third_party/wifi-ism43362/repo

# Create symlinks to WIFI-ISM43362 submodule
ln -sfTr "$WIFI_ISM43362_PATH" "$APP/mbed/wifi-ism43362"
fi

# Generate config file for selected target, toolchain and hardware
mbed-tools configure -t "$TOOLCHAIN" -m "$TARGET_BOARD" -p "$APP"/mbed/
mbed-tools configure -t "$TOOLCHAIN" -m "$TARGET_BOARD" -p "$APP"/mbed/ --mbed-os-path "$MBED_OS_PATH"

# Remove old artifacts to force linking
rm -rf "$BUILD_DIRECTORY/chip-"*
Expand Down

0 comments on commit 1471366

Please sign in to comment.