Skip to content
This repository has been archived by the owner on Dec 8, 2022. It is now read-only.

Allow demos to be turned off in CMake #1161

Merged
merged 8 commits into from
Oct 19, 2019
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
9 changes: 9 additions & 0 deletions tools/cmake/afr.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,18 @@ if(NOT DEFINED CACHE{AFR_TOOLCHAIN})
set(AFR_TOOLCHAIN ${__toolchain} CACHE INTERNAL "Toolchain to build Amazon FreeRTOS.")
endif()

# Provide an option to enable demos. If we're not at top level, turn off demos build by default.
if("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}")
option(AFR_ENABLE_DEMOS "Build demos for Amazon FreeRTOS." ON)
else()
option(AFR_ENABLE_DEMOS "Build demos for Amazon FreeRTOS." OFF)
endif()

# Provide an option to enable tests. Also set an helper variable to use in generator expression.
option(AFR_ENABLE_TESTS "Build tests for Amazon FreeRTOS. Requires recompiling whole library." OFF)
if(AFR_ENABLE_TESTS)
# Turning off demo when tests are enabled.
set(AFR_ENABLE_DEMOS 0 CACHE BOOL "Build demos for Amazon FreeRTOS." FORCE)
add_compile_definitions(AMAZON_FREERTOS_ENABLE_UNIT_TESTS)
add_compile_definitions(IOT_BUILD_TESTS=1)
set(AFR_IS_TESTING 1 CACHE INTERNAL "")
Expand Down
5 changes: 4 additions & 1 deletion tools/cmake/afr_module.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,10 @@ function(afr_resolve_dependencies)
set(exe_target aws_demos)
set(exe_base demo_base)
endif()
__search_afr_dependencies(${exe_target} dependencies)
# If neither demos nor tests are enabled, then don't search the aws_demos/aws_tests targets.
if(AFR_ENABLE_DEMOS OR AFR_ENABLE_TESTS)
__search_afr_dependencies(${exe_target} dependencies)
endif()
afr_module_dependencies(${exe_base} INTERFACE ${dependencies})

# Make sure kernel can be enabled first.
Expand Down
44 changes: 21 additions & 23 deletions vendors/espressif/boards/esp32/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -192,33 +192,31 @@ afr_glob_src(config_files DIRECTORY "${board_dir}/config_files")

if(AFR_IS_TESTING)
set(exe_target aws_tests)
set(extra_exe_sources "${AFR_TESTS_DIR}/common/iot_tests_network.c")
else()
set(exe_target aws_demos)
set(
extra_exe_sources
"${AFR_DEMOS_DIR}/wifi_provisioning/aws_wifi_connect_task.c"
)
endif()

add_executable(
${exe_target}
"${board_dir}/application_code/main.c"
${extra_exe_sources}
)
target_include_directories(
${exe_target}
PUBLIC
$<TARGET_PROPERTY:AFR::kernel,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:AFR::ble_hal::mcu_port,INTERFACE_INCLUDE_DIRECTORIES>
)
target_link_libraries(
${exe_target}
PRIVATE
AFR::wifi
AFR::utils
AFR::ble
)
# Do not add demos or tests if they're turned off.
if(AFR_ENABLE_DEMOS OR AFR_ENABLE_TESTS)
add_executable(
${exe_target}
"${board_dir}/application_code/main.c"
${extra_exe_sources}
)
target_include_directories(
${exe_target}
PUBLIC
$<TARGET_PROPERTY:AFR::kernel,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:AFR::ble_hal::mcu_port,INTERFACE_INCLUDE_DIRECTORIES>
)
target_link_libraries(
${exe_target}
PRIVATE
AFR::wifi
AFR::utils
AFR::ble
)
endif()

if(AFR_METADATA_MODE)
return()
Expand Down
81 changes: 42 additions & 39 deletions vendors/infineon/boards/xmc4800_iotkit/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -254,43 +254,46 @@ afr_glob_src(board_src DIRECTORY "${xmc4800_aws_dir}/application_code/infineon_c
afr_glob_src(newlib DIRECTORY "${xmclib_dir}/Newlib")
afr_glob_src(config_src DIRECTORY "${xmc4800_aws_dir}/config_files")

add_executable(
${exe_target}
${board_src}
${config_src}
${newlib}
${esp_at_lib}
${linker_script}
"${xmc4800_aws_dir}/application_code/main.c"
)

target_link_libraries(
${exe_target}
PRIVATE
AFR::wifi
AFR::utils
)

if(AFR_METADATA_MODE)
return()
endif()

find_program(gcc_objectcopy arm-none-eabi-objcopy)
find_program(gcc_size arm-none-eabi-size)

if(NOT gcc_objectcopy )
message(FATAL_ERROR "Cannot find arm-none-eabi-objcopy.")
# Do not add demos or tests if they're turned off.
if(AFR_ENABLE_DEMOS OR AFR_ENABLE_TESTS)
add_executable(
${exe_target}
${board_src}
${config_src}
${newlib}
${esp_at_lib}
${linker_script}
"${xmc4800_aws_dir}/application_code/main.c"
)

target_link_libraries(
${exe_target}
PRIVATE
AFR::wifi
AFR::utils
)

if(AFR_METADATA_MODE)
return()
endif()

find_program(gcc_objectcopy arm-none-eabi-objcopy)
find_program(gcc_size arm-none-eabi-size)

if(NOT gcc_objectcopy )
message(FATAL_ERROR "Cannot find arm-none-eabi-objcopy.")
endif()

set(output_file "$<TARGET_FILE_DIR:${exe_target}>/${exe_target}.hex")

add_custom_command(
TARGET ${exe_target} POST_BUILD
COMMAND "${gcc_objectcopy}" -O ihex "$<TARGET_FILE:${exe_target}>" "${output_file}"
COMMAND "${gcc_size}" "$<TARGET_FILE:${exe_target}>"
)

add_custom_command(
TARGET ${exe_target} POST_BUILD
COMMAND "${CMAKE_COMMAND}" -E copy "${output_file}" "${CMAKE_BINARY_DIR}"
)
endif()

set(output_file "$<TARGET_FILE_DIR:${exe_target}>/${exe_target}.hex")

add_custom_command(
TARGET ${exe_target} POST_BUILD
COMMAND "${gcc_objectcopy}" -O ihex "$<TARGET_FILE:${exe_target}>" "${output_file}"
COMMAND "${gcc_size}" "$<TARGET_FILE:${exe_target}>"
)

add_custom_command(
TARGET ${exe_target} POST_BUILD
COMMAND "${CMAKE_COMMAND}" -E copy "${output_file}" "${CMAKE_BINARY_DIR}"
)
85 changes: 44 additions & 41 deletions vendors/marvell/boards/mw300_rd/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -257,45 +257,48 @@ set(default_modules AFR::wifi AFR::utils)
afr_glob_src(board_code_src RECURSE DIRECTORY "${board_dir}/application_code/marvell_code")
afr_glob_src(config_files DIRECTORY "${board_dir}/config_files")

add_executable(
${exe_target}
${board_code_src}
${config_files}
"${board_dir}/application_code/main.c"
)

target_include_directories(
${exe_target}
PUBLIC
"${AFR_MODULES_ABSTRACTIONS_DIR}/pkcs11/include"
"${AFR_3RDPARTY_DIR}/pkcs11"
"${AFR_MODULES_FREERTOS_PLUS_DIR}/standard/crypto/include"
)

target_link_libraries(
${exe_target}
PRIVATE
AFR::utils
${default_modules}
-T${global-linkerscript-y}
)

if(AFR_METADATA_MODE)
return()
endif()

# Convert afx file to bin file
if("${CMAKE_HOST_SYSTEM_NAME}" STREQUAL "Linux")
set(axf2fw "${mw320_dir}/sdk/tools/bin/Linux/axf2firmware")
execute_process(COMMAND chmod +x "${axf2fw}") # TODO, workaround for Amazon FreeRTOS console permission issue.
else()
message(FATAL_ERROR "Only Linux host is supported for marvell.")
# Do not add demos or tests if they're turned off.
if(AFR_ENABLE_DEMOS OR AFR_ENABLE_TESTS)
add_executable(
${exe_target}
${board_code_src}
${config_files}
"${board_dir}/application_code/main.c"
)

target_include_directories(
${exe_target}
PUBLIC
"${AFR_MODULES_ABSTRACTIONS_DIR}/pkcs11/include"
"${AFR_3RDPARTY_DIR}/pkcs11"
"${AFR_MODULES_FREERTOS_PLUS_DIR}/standard/crypto/include"
)

target_link_libraries(
${exe_target}
PRIVATE
AFR::utils
${default_modules}
-T${global-linkerscript-y}
)

if(AFR_METADATA_MODE)
return()
endif()

# Convert afx file to bin file
if("${CMAKE_HOST_SYSTEM_NAME}" STREQUAL "Linux")
set(axf2fw "${mw320_dir}/sdk/tools/bin/Linux/axf2firmware")
execute_process(COMMAND chmod +x "${axf2fw}") # TODO, workaround for Amazon FreeRTOS console permission issue.
else()
message(FATAL_ERROR "Only Linux host is supported for marvell.")
endif()

add_custom_command(
TARGET ${exe_target} POST_BUILD
COMMAND "${CMAKE_COMMAND}" -E remove "${exe_target}.bin"
COMMAND "${axf2fw}" "${exe_target}.axf" "${exe_target}.bin"
)

set_property(DIRECTORY APPEND PROPERTY ADDITIONAL_MAKE_CLEAN_FILES "${exe_target}.bin" "${exe_target}.map")
endif()

add_custom_command(
TARGET ${exe_target} POST_BUILD
COMMAND "${CMAKE_COMMAND}" -E remove "${exe_target}.bin"
COMMAND "${axf2fw}" "${exe_target}.axf" "${exe_target}.bin"
)

set_property(DIRECTORY APPEND PROPERTY ADDITIONAL_MAKE_CLEAN_FILES "${exe_target}.bin" "${exe_target}.map")
90 changes: 45 additions & 45 deletions vendors/mediatek/boards/mt7697hx-dev-kit/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -320,51 +320,51 @@ target_link_libraries(
# -------------------------------------------------------------------------------------------------
set(CMAKE_EXECUTABLE_SUFFIX ".axf")

# TODO, remove network manager src.
afr_glob_src(network_manager_src DIRECTORY "${AFR_DEMOS_DIR}/network_manager")
afr_glob_src(board_code_src DIRECTORY "${board_dir}/application_code/mediatek_code")
afr_glob_src(config_files DIRECTORY "${board_dir}/config_files")

add_executable(
${exe_target}
${board_code_src}
${config_files}
$<IF:${AFR_IS_TESTING}, ,${network_manager_src}>
"${board_dir}/startup_mt7687.s"
"${board_dir}/application_code/main.c"
"${board_dir}/application_code/mediatek_code/source/sys_init.c"
"${board_dir}/application_code/mediatek_code/source/system_mt7687.c"
"${board_dir}/application_code/mediatek_code/source/ept_gpio_var.c"
"${board_dir}/application_code/mediatek_code/source/ept_eint_var.c"

"${AFR_VENDORS_DIR}/mediatek/sdk/kernel/service/src/exception_handler.c"
"${AFR_VENDORS_DIR}/mediatek/sdk/kernel/service/src/toi.c"
"${AFR_VENDORS_DIR}/mediatek/sdk/kernel/service/src/os_trace_callback.c"
"${AFR_VENDORS_DIR}/mediatek/sdk/kernel/service/src/os_port_callback.c"
"${AFR_VENDORS_DIR}/mediatek/sdk/kernel/service/src/memory_regions.c"
)

target_link_libraries(
${exe_target}
PRIVATE
AFR::utils
"${AFR_VENDORS_DIR}/mediatek/sdk/prebuilt/keil/libwifi_CM4_Keil.lib"
"${AFR_VENDORS_DIR}/mediatek/sdk/prebuilt/keil/libhal_core_CM4_Keil.lib"
"${AFR_VENDORS_DIR}/mediatek/sdk/prebuilt/keil/libhal_protected_CM4_Keil.lib"
"${AFR_VENDORS_DIR}/mediatek/sdk/prebuilt/keil/libkservice_CM4_MT7687_Keil.lib"
"${AFR_VENDORS_DIR}/mediatek/sdk/prebuilt/keil/libminicli_CM4_Keil.lib"
"${AFR_VENDORS_DIR}/mediatek/sdk/prebuilt/keil/libminisupp_CM4_Keil.lib"
${link_extra_flags}
AFR::wifi
)

find_program(fromelf fromelf.exe PATHS "${AFR_COMPILER_DIR}")
set(output_bin_file "$<TARGET_FILE_DIR:${exe_target}>/${exe_target}.bin")
set(output_axf_file "$<TARGET_FILE_DIR:${exe_target}>/${exe_target}.axf")

add_custom_command(
TARGET ${exe_target} POST_BUILD
COMMAND "${CMAKE_COMMAND}" -E copy "$<TARGET_FILE:${exe_target}>" "${CMAKE_BINARY_DIR}"
COMMAND "echo" "Creating .bin file"
COMMAND "${fromelf}" --bin -o ${output_bin_file} ${output_axf_file}
)
# Do not add demos or tests if they're turned off.
if(AFR_ENABLE_DEMOS OR AFR_ENABLE_TESTS)
add_executable(
${exe_target}
${board_code_src}
${config_files}
"${board_dir}/startup_mt7687.s"
"${board_dir}/application_code/main.c"
"${board_dir}/application_code/mediatek_code/source/sys_init.c"
"${board_dir}/application_code/mediatek_code/source/system_mt7687.c"
"${board_dir}/application_code/mediatek_code/source/ept_gpio_var.c"
"${board_dir}/application_code/mediatek_code/source/ept_eint_var.c"

"${AFR_VENDORS_DIR}/mediatek/sdk/kernel/service/src/exception_handler.c"
"${AFR_VENDORS_DIR}/mediatek/sdk/kernel/service/src/toi.c"
"${AFR_VENDORS_DIR}/mediatek/sdk/kernel/service/src/os_trace_callback.c"
"${AFR_VENDORS_DIR}/mediatek/sdk/kernel/service/src/os_port_callback.c"
"${AFR_VENDORS_DIR}/mediatek/sdk/kernel/service/src/memory_regions.c"
)

target_link_libraries(
${exe_target}
PRIVATE
AFR::utils
"${AFR_VENDORS_DIR}/mediatek/sdk/prebuilt/keil/libwifi_CM4_Keil.lib"
"${AFR_VENDORS_DIR}/mediatek/sdk/prebuilt/keil/libhal_core_CM4_Keil.lib"
"${AFR_VENDORS_DIR}/mediatek/sdk/prebuilt/keil/libhal_protected_CM4_Keil.lib"
"${AFR_VENDORS_DIR}/mediatek/sdk/prebuilt/keil/libkservice_CM4_MT7687_Keil.lib"
"${AFR_VENDORS_DIR}/mediatek/sdk/prebuilt/keil/libminicli_CM4_Keil.lib"
"${AFR_VENDORS_DIR}/mediatek/sdk/prebuilt/keil/libminisupp_CM4_Keil.lib"
${link_extra_flags}
AFR::wifi
)

find_program(fromelf fromelf.exe PATHS "${AFR_COMPILER_DIR}")
set(output_bin_file "$<TARGET_FILE_DIR:${exe_target}>/${exe_target}.bin")
set(output_axf_file "$<TARGET_FILE_DIR:${exe_target}>/${exe_target}.axf")

add_custom_command(
TARGET ${exe_target} POST_BUILD
COMMAND "${CMAKE_COMMAND}" -E copy "$<TARGET_FILE:${exe_target}>" "${CMAKE_BINARY_DIR}"
COMMAND "echo" "Creating .bin file"
COMMAND "${fromelf}" --bin -o ${output_bin_file} ${output_axf_file}
)
endif()
Loading