pankore | 544da73c | 2021-10-19 02:51:16 +0800 | [diff] [blame] | 1 | cmake_minimum_required(VERSION 3.6) |
| 2 | |
| 3 | project(chip-gn) |
| 4 | |
| 5 | set(chip_dir "${ameba_matter_root}") |
| 6 | set(chip_dir_output "${matter_output_path}/chip") |
| 7 | set(chip_c_flags "") |
| 8 | set(chip_cpp_flags "") |
| 9 | set(chip-gn chip-gn) |
| 10 | |
pankore | b8c0b6d | 2022-04-01 12:13:55 +0800 | [diff] [blame] | 11 | set(matter_enable_rotating_id 1) |
| 12 | |
pankore | 544da73c | 2021-10-19 02:51:16 +0800 | [diff] [blame] | 13 | get_filename_component(CHIP_ROOT ${chip_dir} REALPATH) |
| 14 | get_filename_component(CHIP_OUTPUT ${chip_dir_output} REALPATH) |
| 15 | get_filename_component(LIB_ROOT ${prj_root}/GCC-RELEASE/project_hp/asdk/lib/application REALPATH) |
| 16 | |
| 17 | include(ExternalProject) |
| 18 | |
| 19 | # FOR CHIP |
| 20 | string(APPEND CHIP_GN_ARGS) |
| 21 | |
| 22 | list( |
| 23 | APPEND CHIP_CFLAGS |
| 24 | |
| 25 | -DCHIP_PROJECT=1 |
| 26 | -DCONFIG_PLATFORM_8721D |
| 27 | -DCONFIG_USE_MBEDTLS_ROM_ALG |
| 28 | -DCONFIG_FUNCION_O0_OPTIMIZE |
pankore | faf8511 | 2023-01-07 05:53:54 +0800 | [diff] [blame] | 29 | -DCONFIG_ENABLE_AMEBA_FACTORY_DATA=0 |
pankore | 544da73c | 2021-10-19 02:51:16 +0800 | [diff] [blame] | 30 | -DDM_ODM_SUPPORT_TYPE=32 |
| 31 | -DCHIP_DEVICE_LAYER_TARGET=Ameba |
pankore | bab75e6 | 2021-10-28 21:48:46 +0800 | [diff] [blame] | 32 | -DMBEDTLS_CONFIG_FILE=<mbedtls_config.h> |
| 33 | -D_POSIX_REALTIME_SIGNALS |
pankore | 33b9046 | 2022-11-23 22:52:29 +0800 | [diff] [blame] | 34 | -DCHIP_SHELL_MAX_TOKENS=11 |
pankore | 544da73c | 2021-10-19 02:51:16 +0800 | [diff] [blame] | 35 | ) |
| 36 | |
| 37 | list( |
| 38 | APPEND CHIP_CXXFLAGS |
| 39 | |
| 40 | -DFD_SETSIZE=10 |
| 41 | -Wno-sign-compare |
| 42 | -Wno-unused-function |
| 43 | -Wno-unused-but-set-variable |
| 44 | -Wno-unused-variable |
| 45 | -Wno-deprecated-declarations |
| 46 | -Wno-unused-parameter |
pankore | faf8511 | 2023-01-07 05:53:54 +0800 | [diff] [blame] | 47 | -Wno-unused-label |
pankore | 544da73c | 2021-10-19 02:51:16 +0800 | [diff] [blame] | 48 | -Wno-format |
pankore | 6e035c8 | 2021-12-22 14:17:38 +0800 | [diff] [blame] | 49 | -Wno-stringop-truncation |
Justin Wood | 0e14979 | 2022-01-06 21:52:51 +0100 | [diff] [blame] | 50 | -Wno-format-nonliteral |
| 51 | -Wno-format-security |
pankore | 6e035c8 | 2021-12-22 14:17:38 +0800 | [diff] [blame] | 52 | -std=c++17 |
pankore | 544da73c | 2021-10-19 02:51:16 +0800 | [diff] [blame] | 53 | ) |
| 54 | |
| 55 | list( |
| 56 | APPEND CHIP_INC |
| 57 | |
| 58 | ${CHIP_ROOT}/config/ameba |
| 59 | ${CHIP_ROOT}/src/include |
| 60 | ${CHIP_ROOT}/src/lib |
| 61 | ${CHIP_ROOT}/src |
| 62 | ${CHIP_ROOT}/src/system |
| 63 | ${CHIP_ROOT}/src/app |
| 64 | ${CHIP_ROOT}/third_party/nlassert/repo/include |
| 65 | ${CHIP_ROOT}/third_party/nlio/repo/include |
pankore | 544da73c | 2021-10-19 02:51:16 +0800 | [diff] [blame] | 66 | ) |
| 67 | |
| 68 | execute_process( |
| 69 | COMMAND echo "mkdir CHIP output folder ..." |
| 70 | COMMAND mkdir -p ${CHIP_OUTPUT} |
| 71 | ) |
| 72 | |
| 73 | foreach(tmp IN LISTS CHIP_CFLAGS) |
| 74 | string(CONCAT appended "\"" ${tmp} "\", ") |
| 75 | string(APPEND chip_c_flags "${appended}") |
| 76 | endforeach() |
| 77 | foreach(tmp IN LISTS GLOBAL_C_FLAGS) |
| 78 | string(CONCAT appended "\"" ${tmp} "\", ") |
| 79 | string(APPEND chip_c_flags "${appended}") |
| 80 | endforeach() |
| 81 | foreach(tmp IN LISTS inc_path) |
| 82 | string(CONCAT appended "\"-I" ${tmp} "\", ") |
| 83 | string(APPEND chip_c_flags "${appended}") |
| 84 | endforeach() |
| 85 | foreach(tmp IN LISTS CHIP_INC) |
| 86 | string(CONCAT appended "\"-I" ${tmp} "\", ") |
| 87 | string(APPEND chip_c_flags "${appended}") |
| 88 | endforeach() |
| 89 | foreach(tmp IN LISTS CHIP_CXXFLAGS) |
| 90 | string(CONCAT appended "\"" ${tmp} "\", ") |
| 91 | string(APPEND chip_cpp_flags "${appended}") |
| 92 | endforeach() |
| 93 | foreach(tmp IN LISTS GLOBAL_CPP_FLAGS) |
| 94 | string(CONCAT appended "\"" ${tmp} "\", ") |
| 95 | string(APPEND chip_cpp_flags "${appended}") |
| 96 | endforeach() |
| 97 | string(APPEND chip_cpp_flags "${chip_c_flags}") |
| 98 | |
| 99 | set(import_str "import(\"//args.gni\")\n" ) |
| 100 | |
| 101 | string(APPEND CHIP_GN_ARGS "${import_str}") |
| 102 | string(APPEND CHIP_GN_ARGS "target_cflags_c = [${chip_c_flags}]\n") |
| 103 | string(APPEND CHIP_GN_ARGS "target_cflags_cc = [${chip_cpp_flags}]\n") |
| 104 | string(APPEND CHIP_GN_ARGS "ameba_ar = \"arm-none-eabi-ar\"\n") |
| 105 | string(APPEND CHIP_GN_ARGS "ameba_cc = \"arm-none-eabi-gcc\"\n") |
| 106 | string(APPEND CHIP_GN_ARGS "ameba_cxx = \"arm-none-eabi-c++\"\n") |
| 107 | string(APPEND CHIP_GN_ARGS "ameba_cpu = \"ameba\"\n") |
pankore | b8c0b6d | 2022-04-01 12:13:55 +0800 | [diff] [blame] | 108 | string(APPEND CHIP_GN_ARGS "chip_inet_config_enable_ipv4 = false\n") |
pankore | daa30ec | 2023-04-12 21:05:23 +0800 | [diff] [blame] | 109 | string(APPEND CHIP_GN_ARGS "chip_use_transitional_commissionable_data_provider = true\n") |
pankore | 544da73c | 2021-10-19 02:51:16 +0800 | [diff] [blame] | 110 | |
pankore | cd42353 | 2022-07-15 20:45:41 -0700 | [diff] [blame] | 111 | # Enable persistent storage audit |
| 112 | if (matter_enable_persistentstorage_audit) |
| 113 | string(APPEND CHIP_GN_ARGS "chip_support_enable_storage_api_audit = true\n") |
| 114 | endif (matter_enable_persistentstorage_audit) |
| 115 | #endif |
| 116 | |
pankore | 6e035c8 | 2021-12-22 14:17:38 +0800 | [diff] [blame] | 117 | # Build RPC |
pankore | b79b781 | 2022-01-24 21:03:12 +0800 | [diff] [blame] | 118 | if (matter_enable_rpc) |
pankore | 6e035c8 | 2021-12-22 14:17:38 +0800 | [diff] [blame] | 119 | #string(APPEND CHIP_GN_ARGS "remove_default_configs = [\"//third_party/connectedhomeip/third_party/pigweed/repo/pw_build:cpp17\"]\n") |
| 120 | string(APPEND CHIP_GN_ARGS "chip_build_pw_rpc_lib = true\n") |
| 121 | string(APPEND CHIP_GN_ARGS "pw_log_BACKEND = \"//third_party/connectedhomeip/third_party/pigweed/repo/pw_log_basic\"\n") |
rgoliver | dcec35a | 2022-06-15 10:50:26 -0400 | [diff] [blame] | 122 | string(APPEND CHIP_GN_ARGS "pw_assert_BACKEND = \"//third_party/connectedhomeip/third_party/pigweed/repo/pw_assert_log:check_backend\"\n") |
pankore | 6e035c8 | 2021-12-22 14:17:38 +0800 | [diff] [blame] | 123 | string(APPEND CHIP_GN_ARGS "pw_sys_io_BACKEND = \"//third_party/connectedhomeip/examples/platform/ameba/pw_sys_io:pw_sys_io_ameba\"\n") |
| 124 | string(APPEND CHIP_GN_ARGS "dir_pw_third_party_nanopb = \"//third_party/connectedhomeip/third_party/nanopb/repo\"\n") |
| 125 | string(APPEND CHIP_GN_ARGS "pw_build_LINK_DEPS = [\"//third_party/connectedhomeip/third_party/pigweed/repo/pw_assert:impl\", \"//third_party/connectedhomeip/third_party/pigweed/repo/pw_log:impl\"]\n") |
rgoliver | eb3ac83 | 2022-05-31 16:02:41 -0400 | [diff] [blame] | 126 | string(APPEND CHIP_GN_ARGS "pw_rpc_CONFIG = \"//third_party/connectedhomeip/third_party/pigweed/repo/pw_rpc:disable_global_mutex\"") |
pankore | b79b781 | 2022-01-24 21:03:12 +0800 | [diff] [blame] | 127 | endif (matter_enable_rpc) |
| 128 | |
pankore | 6a3c36c | 2022-07-28 00:56:06 +0800 | [diff] [blame] | 129 | # Build Matter Shell |
| 130 | if (matter_enable_shell) |
| 131 | string(APPEND CHIP_GN_ARGS "chip_build_libshell = true\n") |
| 132 | endif (matter_enable_shell) |
| 133 | |
pankore | b79b781 | 2022-01-24 21:03:12 +0800 | [diff] [blame] | 134 | # Build ota-requestor |
| 135 | if (matter_enable_ota_requestor) |
| 136 | string(APPEND CHIP_GN_ARGS "chip_enable_ota_requestor = true\n") |
| 137 | endif (matter_enable_ota_requestor) |
pankore | 6e035c8 | 2021-12-22 14:17:38 +0800 | [diff] [blame] | 138 | |
pankore | 6a3c36c | 2022-07-28 00:56:06 +0800 | [diff] [blame] | 139 | # Rotating ID |
pankore | b8c0b6d | 2022-04-01 12:13:55 +0800 | [diff] [blame] | 140 | if (matter_enable_rotating_id) |
| 141 | string(APPEND CHIP_GN_ARGS "chip_enable_additional_data_advertising = true\n") |
| 142 | string(APPEND CHIP_GN_ARGS "chip_enable_rotating_device_id = true\n") |
pankore | 6a3c36c | 2022-07-28 00:56:06 +0800 | [diff] [blame] | 143 | else (matter_enable_rotating_id) |
pankore | b8c0b6d | 2022-04-01 12:13:55 +0800 | [diff] [blame] | 144 | string(APPEND CHIP_GN_ARGS "chip_enable_additional_data_advertising = false\n") |
| 145 | string(APPEND CHIP_GN_ARGS "chip_enable_rotating_device_id = false\n") |
pankore | 6a3c36c | 2022-07-28 00:56:06 +0800 | [diff] [blame] | 146 | endif (matter_enable_rotating_id) |
pankore | 9ac8ef4 | 2022-02-07 23:22:52 +0800 | [diff] [blame] | 147 | |
pankore | 544da73c | 2021-10-19 02:51:16 +0800 | [diff] [blame] | 148 | file(GENERATE OUTPUT ${CHIP_OUTPUT}/args.gn CONTENT ${CHIP_GN_ARGS}) |
| 149 | |
| 150 | ExternalProject_Add( |
| 151 | chip-gn |
| 152 | PREFIX ${CMAKE_CURRENT_BINARY_DIR} |
| 153 | SOURCE_DIR ${CHIP_ROOT} |
| 154 | BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR} |
| 155 | CONFIGURE_COMMAND gn --root=${CHIP_ROOT}/config/ameba gen --check --fail-on-unused-args ${CHIP_OUTPUT} |
pankore | 6e035c8 | 2021-12-22 14:17:38 +0800 | [diff] [blame] | 156 | BUILD_COMMAND ninja -C ${CHIP_OUTPUT} :ameba |
pankore | 544da73c | 2021-10-19 02:51:16 +0800 | [diff] [blame] | 157 | INSTALL_COMMAND "" |
pankore | 6e035c8 | 2021-12-22 14:17:38 +0800 | [diff] [blame] | 158 | BUILD_BYPRODUCTS -lCHIP -lPwRpc |
pankore | 544da73c | 2021-10-19 02:51:16 +0800 | [diff] [blame] | 159 | CONFIGURE_ALWAYS TRUE |
| 160 | BUILD_ALWAYS TRUE |
| 161 | USES_TERMINAL_CONFIGURE TRUE |
| 162 | USES_TERMINAL_BUILD TRUE |
| 163 | ) |