From c9ed195790cdd1f38672278cc73831edb56564a8 Mon Sep 17 00:00:00 2001 From: Dane Walton Date: Tue, 23 Mar 2021 11:41:20 -0700 Subject: [PATCH] generate map files for iot samples (#1656) --- cmake-modules/create_map_file.cmake | 14 +++++------ .../templates/jobs/archetype-sdk-client.yml | 25 ++++++++----------- sdk/samples/iot/CMakeLists.txt | 18 +++++++++++++ sdk/tests/core/CMakeLists.txt | 4 +-- sdk/tests/iot/common/CMakeLists.txt | 4 +-- sdk/tests/iot/hub/CMakeLists.txt | 4 +-- sdk/tests/iot/provisioning/CMakeLists.txt | 4 +-- 7 files changed, 44 insertions(+), 29 deletions(-) diff --git a/cmake-modules/create_map_file.cmake b/cmake-modules/create_map_file.cmake index b20093cc7..5791428d0 100644 --- a/cmake-modules/create_map_file.cmake +++ b/cmake-modules/create_map_file.cmake @@ -4,18 +4,18 @@ # Instructs linker to generate map files and optimize build for minimal size # Requires CMake version >= 3.13 to use add_link_options -function(create_map_file MAP_FILE_NAME) +function(create_map_file TARGET_NAME MAP_FILE_NAME) if (${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.13") if(MSVC) - add_link_options(/MAP) + target_link_options(${TARGET_NAME} PRIVATE /MAP) elseif(CMAKE_C_COMPILER_ID MATCHES "Clang") - add_link_options(-Wl,-map,${MAP_FILE_NAME}) - add_link_options(-Os) + target_link_options(${TARGET_NAME} PRIVATE -Wl,-map,${MAP_FILE_NAME}) + target_link_options(${TARGET_NAME} PRIVATE -Os) else() - add_link_options(-Xlinker -Map=${MAP_FILE_NAME}) - add_link_options(-Os) + target_link_options(${TARGET_NAME} PRIVATE -Xlinker -Map=${MAP_FILE_NAME}) + target_link_options(${TARGET_NAME} PRIVATE -Os) endif() else() - message("Skipping map file generation because CMake version does not support add_link_options") + message("Skipping map file generation because CMake version does not support target_link_options") endif() endfunction() diff --git a/eng/pipelines/templates/jobs/archetype-sdk-client.yml b/eng/pipelines/templates/jobs/archetype-sdk-client.yml index 41c5ce1d5..ac524dfd1 100644 --- a/eng/pipelines/templates/jobs/archetype-sdk-client.yml +++ b/eng/pipelines/templates/jobs/archetype-sdk-client.yml @@ -6,7 +6,7 @@ # +----+------------------+---------+---------------+-----------+---------+------------+-------+---------+---------------+--------+ # | 1 | Linux ARM | + | | | + | N/A | | N/A | | | # | 2 | Linux ARM | | | | | N/A | | N/A | | | -# | 3 | Linux (x64) | + | | + | + | + | + | | | | +# | 3 | Linux (x64) | + | | + | + | + | + | + | | | # | 4 | Linux (x64) | | | | + | + | + | + | | | # | 5 | Windows x86 | + | | + | | + | | | | | # | 6 | MacOS (x64) | + | | + | + | + | | + | | | @@ -22,7 +22,7 @@ # | 16 | MacOS (x64) | | + | | + | + | | | | | # | 17 | Linux (x64) GCC5 | + | + | | | + | | + | | | # | 18 | Linux (x64) GCC5 | | + | | | + | | | | | -# | 19 | Windows x64 | + | | + | | | | | | | +# | 19 | Windows x64 | + | | + | | | | + | | | # | 20 | G E N E R A T E A R T I F A C T S | # +----+------------------+---------+---------------+-----------+---------+------------+-------+---------+---------------+--------+ # @@ -62,15 +62,14 @@ jobs: PublishMapFiles: 'false' BuildType: Debug - Linux_Release_MapFiles_Logging_UnitTests_Mocks: + Linux_Release_MapFiles_Logging_UnitTests_Mocks_Samples: Pool: azsdk-pool-mms-ubuntu-1804-general OSVmImage: MMSUbuntu18.04 - vcpkg.deps: 'cmocka' + vcpkg.deps: 'cmocka paho-mqtt' VCPKG_DEFAULT_TRIPLET: 'x64-linux' - build.args: '-DPRECONDITIONS=OFF -DUNIT_TESTING=ON -DUNIT_TESTING_MOCKS=ON' - AZ_SDK_C_NO_SAMPLES: 'true' + build.args: '-DPRECONDITIONS=OFF -DUNIT_TESTING=ON -DUNIT_TESTING_MOCKS=ON -DTRANSPORT_PAHO=ON' PublishMapFiles: 'true' - MapFileArtifactSuffix: 'lnx-x64-rel-noprc-log' + MapFileArtifactSuffix: 'lnx-x64-rel-noprc-log-samples' BuildType: Release Linux_Logging_UnitTests_Mocks_Samples: @@ -101,8 +100,7 @@ jobs: vcpkg.deps: 'curl[ssl] paho-mqtt cmocka' VCPKG_DEFAULT_TRIPLET: 'x64-osx' build.args: '-DTRANSPORT_CURL=ON -DTRANSPORT_PAHO=ON -DAZ_PLATFORM_IMPL=POSIX -DPRECONDITIONS=OFF -DUNIT_TESTING=ON' - PublishMapFiles: 'true' - MapFileArtifactSuffix: 'mac-rel-noprc-log' + MapFileArtifactSuffix: 'mac-rel-noprc-log-samples' BuildType: Release MacOS_Logging_UnitTests_Samples: @@ -230,17 +228,16 @@ jobs: CC: '/usr/bin/gcc-5' BuildType: Debug - Windows_Release_MapFiles: + Windows_Release_Samples_MapFiles: Pool: azsdk-pool-mms-win-2019-general OSVmImage: MMS2019 - vcpkg.deps: '' + vcpkg.deps: 'paho-mqtt' VCPKG_DEFAULT_TRIPLET: 'x64-windows-static' - build.args: '-DPRECONDITIONS=OFF -DLOGGING=OFF' + build.args: '-DPRECONDITIONS=OFF -DLOGGING=OFF -DTRANSPORT_PAHO=ON' CMAKE_GENERATOR: 'Visual Studio 16 2019' CMAKE_GENERATOR_PLATFORM: x64 - AZ_SDK_C_NO_SAMPLES: 'true' PublishMapFiles: 'true' - MapFileArtifactSuffix: 'win-x64-rel-noprc-nolog' + MapFileArtifactSuffix: 'win-x64-rel-noprc-nolog-samples' BuildType: Release pool: name: $(Pool) diff --git a/sdk/samples/iot/CMakeLists.txt b/sdk/samples/iot/CMakeLists.txt index 275ad32f0..77e061bf9 100644 --- a/sdk/samples/iot/CMakeLists.txt +++ b/sdk/samples/iot/CMakeLists.txt @@ -53,6 +53,8 @@ target_link_libraries(paho_iot_hub_c2d_sample az::iot::sample::common ) +create_map_file(paho_iot_hub_c2d_sample paho_iot_hub_c2d_sample.map) + # Methods Sample add_executable (paho_iot_hub_methods_sample ${CMAKE_CURRENT_LIST_DIR}/paho_iot_hub_methods_sample.c @@ -63,6 +65,8 @@ target_link_libraries(paho_iot_hub_methods_sample az::iot::sample::common ) +create_map_file(paho_iot_hub_methods_sample paho_iot_hub_methods_sample.map) + # PnP Sample add_executable (paho_iot_hub_pnp_sample ${CMAKE_CURRENT_LIST_DIR}/paho_iot_hub_pnp_sample.c @@ -73,6 +77,8 @@ target_link_libraries(paho_iot_hub_pnp_sample az::iot::sample::common ) +create_map_file(paho_iot_hub_pnp_sample paho_iot_hub_pnp_sample.map) + # PnP Component Sample add_executable (paho_iot_hub_pnp_component_sample ${CMAKE_CURRENT_LIST_DIR}/pnp/pnp_mqtt_message.c @@ -93,6 +99,8 @@ target_include_directories(paho_iot_hub_pnp_component_sample ${CMAKE_CURRENT_LIST_DIR} ) +create_map_file(paho_iot_hub_pnp_component_sample paho_iot_hub_pnp_component_sample.map) + # Telemetry (Certificates) Sample add_executable (paho_iot_hub_telemetry_sample ${CMAKE_CURRENT_LIST_DIR}/paho_iot_hub_telemetry_sample.c @@ -103,6 +111,8 @@ target_link_libraries(paho_iot_hub_telemetry_sample az::iot::sample::common ) +create_map_file(paho_iot_hub_telemetry_sample paho_iot_hub_telemetry_sample.map) + # Telemetry (SAS) Sample add_executable (paho_iot_hub_sas_telemetry_sample ${CMAKE_CURRENT_LIST_DIR}/paho_iot_hub_sas_telemetry_sample.c @@ -113,6 +123,8 @@ target_link_libraries(paho_iot_hub_sas_telemetry_sample az::iot::sample::common ) +create_map_file(paho_iot_hub_sas_telemetry_sample paho_iot_hub_sas_telemetry_sample.map) + # Twin Sample add_executable (paho_iot_hub_twin_sample ${CMAKE_CURRENT_LIST_DIR}/paho_iot_hub_twin_sample.c @@ -123,6 +135,8 @@ target_link_libraries(paho_iot_hub_twin_sample az::iot::sample::common ) +create_map_file(paho_iot_hub_twin_sample paho_iot_hub_twin_sample.map) + # Provisioning (Certificates) Sample add_executable (paho_iot_provisioning_sample ${CMAKE_CURRENT_LIST_DIR}/paho_iot_provisioning_sample.c @@ -133,6 +147,8 @@ target_link_libraries(paho_iot_provisioning_sample az::iot::sample::common ) +create_map_file(paho_iot_provisioning_sample paho_iot_provisioning_sample.map) + # Provisioning (SAS) Sample add_executable (paho_iot_provisioning_sas_sample ${CMAKE_CURRENT_LIST_DIR}/paho_iot_provisioning_sas_sample.c @@ -143,4 +159,6 @@ target_link_libraries(paho_iot_provisioning_sas_sample az::iot::sample::common ) +create_map_file(paho_iot_provisioning_sas_sample paho_iot_provisioning_sas_sample.map) + endif() # TRANSPORT_PAHO diff --git a/sdk/tests/core/CMakeLists.txt b/sdk/tests/core/CMakeLists.txt index 547a57a94..75f181771 100644 --- a/sdk/tests/core/CMakeLists.txt +++ b/sdk/tests/core/CMakeLists.txt @@ -16,8 +16,6 @@ else() set(WRAP_FUNCTIONS "") endif() -create_map_file(az_core_test.map) - set(MATH_LIB_UNIX "") if (UNIX) set(MATH_LIB_UNIX "m") @@ -40,4 +38,6 @@ add_cmocka_test(az_core_test SOURCES INCLUDE_DIRECTORIES ${CMOCKA_INCLUDE_DIR} ${CMAKE_SOURCE_DIR}/sdk/src/azure/core/ ) +create_map_file(az_core_test az_core_test.map) + add_cmocka_test_environment(az_core_test) diff --git a/sdk/tests/iot/common/CMakeLists.txt b/sdk/tests/iot/common/CMakeLists.txt index 8cc874ec2..9b17fd4c9 100644 --- a/sdk/tests/iot/common/CMakeLists.txt +++ b/sdk/tests/iot/common/CMakeLists.txt @@ -9,8 +9,6 @@ set(CMAKE_C_STANDARD 99) include(AddCMockaTest) -create_map_file(az_iot_common_test.map) - add_cmocka_test(az_iot_common_test SOURCES main.c test_az_iot_common.c @@ -21,4 +19,6 @@ add_cmocka_test(az_iot_common_test SOURCES INCLUDE_DIRECTORIES ${CMOCKA_INCLUDE_DIR} ) +create_map_file(az_iot_common_test az_iot_common_test.map) + add_cmocka_test_environment(az_iot_common_test) diff --git a/sdk/tests/iot/hub/CMakeLists.txt b/sdk/tests/iot/hub/CMakeLists.txt index df869d071..fcf427c17 100644 --- a/sdk/tests/iot/hub/CMakeLists.txt +++ b/sdk/tests/iot/hub/CMakeLists.txt @@ -9,8 +9,6 @@ set(CMAKE_C_STANDARD 99) include(AddCMockaTest) -create_map_file(az_iot_hub_test.map) - add_cmocka_test(az_iot_hub_test SOURCES main.c test_az_iot_hub_client_sas.c @@ -27,4 +25,6 @@ add_cmocka_test(az_iot_hub_test SOURCES INCLUDE_DIRECTORIES ${CMOCKA_INCLUDE_DIR} ) +create_map_file(az_iot_hub_test az_iot_hub_test.map) + add_cmocka_test_environment(az_iot_hub_test) diff --git a/sdk/tests/iot/provisioning/CMakeLists.txt b/sdk/tests/iot/provisioning/CMakeLists.txt index dbf74002a..ad2f49f35 100644 --- a/sdk/tests/iot/provisioning/CMakeLists.txt +++ b/sdk/tests/iot/provisioning/CMakeLists.txt @@ -9,8 +9,6 @@ set(CMAKE_C_STANDARD 99) include(AddCMockaTest) -create_map_file(az_iot_provisioning_test.map) - add_cmocka_test(az_iot_provisioning_test SOURCES main.c test_az_iot_provisioning_client.c @@ -24,4 +22,6 @@ add_cmocka_test(az_iot_provisioning_test SOURCES INCLUDE_DIRECTORIES ${CMOCKA_INCLUDE_DIR} ) +create_map_file(az_iot_provisioning_test az_iot_provisioning_test.map) + add_cmocka_test_environment(az_iot_provisioning_test)