154568cb3Sopenharmony_ciset(BUILD_DIR "$ENV{BUILD_TMP_DIR}" ) #version id
254568cb3Sopenharmony_ciset(OBJCOPY_PATH "$ENV{OBJCOPY_PATH}" ) #OBJCOPY_PATH
354568cb3Sopenharmony_ci
454568cb3Sopenharmony_ci
554568cb3Sopenharmony_ci
654568cb3Sopenharmony_ci##最终的链接目标,会生成对应的.a库
754568cb3Sopenharmony_ci#################################################
854568cb3Sopenharmony_ci## arch代码
954568cb3Sopenharmony_ci#################################################
1054568cb3Sopenharmony_cilist(APPEND ARCH_SRCS
1154568cb3Sopenharmony_ci    $<TARGET_OBJECTS:prt_hw_boot>
1254568cb3Sopenharmony_ci    $<TARGET_OBJECTS:prt_port>
1354568cb3Sopenharmony_ci    $<TARGET_OBJECTS:prt_dispatch>
1454568cb3Sopenharmony_ci    $<TARGET_OBJECTS:prt_hwi>
1554568cb3Sopenharmony_ci    $<TARGET_OBJECTS:prt_exc>
1654568cb3Sopenharmony_ci    $<TARGET_OBJECTS:prt_hw_exc>
1754568cb3Sopenharmony_ci    $<TARGET_OBJECTS:prt_vector>
1854568cb3Sopenharmony_ci    $<TARGET_OBJECTS:prt_vi_dispatch>
1954568cb3Sopenharmony_ci    $<TARGET_OBJECTS:prt_hw_tick>
2054568cb3Sopenharmony_ci    $<TARGET_OBJECTS:prt_hw_tick_minor>
2154568cb3Sopenharmony_ci    $<TARGET_OBJECTS:prt_hw>
2254568cb3Sopenharmony_ci    $<TARGET_OBJECTS:prt_div64>
2354568cb3Sopenharmony_ci)
2454568cb3Sopenharmony_ci
2554568cb3Sopenharmony_ci#################################################
2654568cb3Sopenharmony_ci## kernel代码
2754568cb3Sopenharmony_ci#################################################
2854568cb3Sopenharmony_cilist(APPEND KERNEL_SRCS
2954568cb3Sopenharmony_ci    $<TARGET_OBJECTS:prt_sem>
3054568cb3Sopenharmony_ci    $<TARGET_OBJECTS:prt_sem_init>
3154568cb3Sopenharmony_ci    $<TARGET_OBJECTS:prt_sem_minor>
3254568cb3Sopenharmony_ci    $<TARGET_OBJECTS:prt_irq>
3354568cb3Sopenharmony_ci    $<TARGET_OBJECTS:prt_sys>
3454568cb3Sopenharmony_ci    $<TARGET_OBJECTS:prt_sys_init>
3554568cb3Sopenharmony_ci    $<TARGET_OBJECTS:prt_sys_time>
3654568cb3Sopenharmony_ci    $<TARGET_OBJECTS:prt_amp_task>
3754568cb3Sopenharmony_ci    $<TARGET_OBJECTS:prt_amp_task_del>
3854568cb3Sopenharmony_ci    $<TARGET_OBJECTS:prt_amp_task_init>
3954568cb3Sopenharmony_ci    $<TARGET_OBJECTS:prt_amp_task_minor>
4054568cb3Sopenharmony_ci    $<TARGET_OBJECTS:prt_task>
4154568cb3Sopenharmony_ci    $<TARGET_OBJECTS:prt_taskself_id>
4254568cb3Sopenharmony_ci    $<TARGET_OBJECTS:prt_task_attrib>
4354568cb3Sopenharmony_ci    $<TARGET_OBJECTS:prt_task_del>
4454568cb3Sopenharmony_ci    $<TARGET_OBJECTS:prt_task_global>
4554568cb3Sopenharmony_ci    $<TARGET_OBJECTS:prt_task_info>
4654568cb3Sopenharmony_ci    $<TARGET_OBJECTS:prt_task_init>
4754568cb3Sopenharmony_ci    $<TARGET_OBJECTS:prt_task_minor>
4854568cb3Sopenharmony_ci    $<TARGET_OBJECTS:prt_task_priority>
4954568cb3Sopenharmony_ci    $<TARGET_OBJECTS:prt_task_sem>
5054568cb3Sopenharmony_ci    $<TARGET_OBJECTS:prt_tick>
5154568cb3Sopenharmony_ci    $<TARGET_OBJECTS:prt_tick_init>
5254568cb3Sopenharmony_ci    $<TARGET_OBJECTS:prt_timer>
5354568cb3Sopenharmony_ci    $<TARGET_OBJECTS:prt_swtmr>
5454568cb3Sopenharmony_ci    $<TARGET_OBJECTS:prt_swtmr_init>
5554568cb3Sopenharmony_ci    $<TARGET_OBJECTS:prt_swtmr_minor>
5654568cb3Sopenharmony_ci    $<TARGET_OBJECTS:prt_kexc>
5754568cb3Sopenharmony_ci    $<TARGET_OBJECTS:prt_exc>
5854568cb3Sopenharmony_ci    $<TARGET_OBJECTS:prt_timer_minor>
5954568cb3Sopenharmony_ci)
6054568cb3Sopenharmony_cilist(APPEND IPC_SRCS
6154568cb3Sopenharmony_ci    $<TARGET_OBJECTS:prt_event>
6254568cb3Sopenharmony_ci    $<TARGET_OBJECTS:prt_queue>
6354568cb3Sopenharmony_ci    $<TARGET_OBJECTS:prt_queue_del>
6454568cb3Sopenharmony_ci    $<TARGET_OBJECTS:prt_queue_minor>
6554568cb3Sopenharmony_ci    $<TARGET_OBJECTS:prt_queue_init>
6654568cb3Sopenharmony_ci)
6754568cb3Sopenharmony_cilist(APPEND MEM_SRCS
6854568cb3Sopenharmony_ci    $<TARGET_OBJECTS:prt_fscmem>
6954568cb3Sopenharmony_ci    $<TARGET_OBJECTS:prt_mem>
7054568cb3Sopenharmony_ci)
7154568cb3Sopenharmony_cilist(APPEND OM_SRCS
7254568cb3Sopenharmony_ci    $<TARGET_OBJECTS:prt_cpup>
7354568cb3Sopenharmony_ci    $<TARGET_OBJECTS:prt_cpup_minor>
7454568cb3Sopenharmony_ci    $<TARGET_OBJECTS:prt_cpup_thread>
7554568cb3Sopenharmony_ci    $<TARGET_OBJECTS:prt_cpup_thread_64>
7654568cb3Sopenharmony_ci    $<TARGET_OBJECTS:prt_cpup_thread_init>
7754568cb3Sopenharmony_ci    $<TARGET_OBJECTS:prt_cpup_warn>
7854568cb3Sopenharmony_ci    $<TARGET_OBJECTS:prt_err>
7954568cb3Sopenharmony_ci    $<TARGET_OBJECTS:prt_err_init>
8054568cb3Sopenharmony_ci    $<TARGET_OBJECTS:prt_hook_init>
8154568cb3Sopenharmony_ci    $<TARGET_OBJECTS:prt_rnd_set>
8254568cb3Sopenharmony_ci)
8354568cb3Sopenharmony_cilist(APPEND BASE_LIB_SRCS
8454568cb3Sopenharmony_ci    $<TARGET_OBJECTS:prt_lib_math64>
8554568cb3Sopenharmony_ci    $<TARGET_OBJECTS:prt_lib_version>
8654568cb3Sopenharmony_ci)
8754568cb3Sopenharmony_ci
8854568cb3Sopenharmony_ci
8954568cb3Sopenharmony_ci
9054568cb3Sopenharmony_ci#编译结果
9154568cb3Sopenharmony_cistring(TOUPPER ${PLAM_TYPE} PLAM_TYPE_UP)
9254568cb3Sopenharmony_cistring(TOUPPER ${CPU_TYPE} CPU_TYPE_UP)
9354568cb3Sopenharmony_ci#编译通用的.a库
9454568cb3Sopenharmony_ciadd_library(CortexMXarch  STATIC "${ARCH_SRCS}")
9554568cb3Sopenharmony_ciadd_library(CortexMXkernel  STATIC "${KERNEL_SRCS}" "${BASE_LIB_SRCS}")
9654568cb3Sopenharmony_ciadd_library(CortexMXmem  STATIC "${MEM_SRCS}")
9754568cb3Sopenharmony_ciadd_library(CortexMXom  STATIC "${OM_SRCS}")
9854568cb3Sopenharmony_ciadd_library(CortexMXipc  STATIC "${IPC_SRCS}")
9954568cb3Sopenharmony_ci
10054568cb3Sopenharmony_ciset_target_properties(CortexMXarch PROPERTIES SUFFIX ".lib")
10154568cb3Sopenharmony_ciset_target_properties(CortexMXkernel PROPERTIES SUFFIX ".lib")
10254568cb3Sopenharmony_ciset_target_properties(CortexMXmem PROPERTIES SUFFIX ".lib")
10354568cb3Sopenharmony_ciset_target_properties(CortexMXom PROPERTIES SUFFIX ".lib")
10454568cb3Sopenharmony_ciset_target_properties(CortexMXipc PROPERTIES SUFFIX ".lib")
10554568cb3Sopenharmony_ci
10654568cb3Sopenharmony_ciadd_custom_target(cleanobj)
10754568cb3Sopenharmony_ciadd_custom_command(TARGET cleanobj POST_BUILD
10854568cb3Sopenharmony_ci                   COMMAND echo "Finish Building!"
10954568cb3Sopenharmony_ci                   )
11054568cb3Sopenharmony_ci
11154568cb3Sopenharmony_ciif (${COMPILE_MODE} STREQUAL "debug")
11254568cb3Sopenharmony_ci    message("=============== COMPILE_MODE is ${COMPILE_MODE} ===============")
11354568cb3Sopenharmony_cielse()
11454568cb3Sopenharmony_ci    add_custom_command(
11554568cb3Sopenharmony_ci        TARGET CortexMXarch
11654568cb3Sopenharmony_ci        POST_BUILD
11754568cb3Sopenharmony_ci        COMMAND sh ${PROJECT_SOURCE_DIR}/cmake/common/build_auxiliary_script/make_lib_rename_file_type.sh ${OBJCOPY_PATH} ${CMAKE_ARCHIVE_OUTPUT_DIRECTORY} "CortexMXarch.lib"
11854568cb3Sopenharmony_ci    )
11954568cb3Sopenharmony_ci
12054568cb3Sopenharmony_ci    add_custom_command(
12154568cb3Sopenharmony_ci        TARGET CortexMXkernel
12254568cb3Sopenharmony_ci        POST_BUILD
12354568cb3Sopenharmony_ci        COMMAND sh ${PROJECT_SOURCE_DIR}/cmake/common/build_auxiliary_script/make_lib_rename_file_type.sh ${OBJCOPY_PATH} ${CMAKE_ARCHIVE_OUTPUT_DIRECTORY} "CortexMXkernel.lib"
12454568cb3Sopenharmony_ci    )
12554568cb3Sopenharmony_ci
12654568cb3Sopenharmony_ci    add_custom_command(
12754568cb3Sopenharmony_ci        TARGET CortexMXmem
12854568cb3Sopenharmony_ci        POST_BUILD
12954568cb3Sopenharmony_ci        COMMAND sh ${PROJECT_SOURCE_DIR}/cmake/common/build_auxiliary_script/make_lib_rename_file_type.sh ${OBJCOPY_PATH} ${CMAKE_ARCHIVE_OUTPUT_DIRECTORY} "CortexMXmem.lib"
13054568cb3Sopenharmony_ci    )
13154568cb3Sopenharmony_ci
13254568cb3Sopenharmony_ci    add_custom_command(
13354568cb3Sopenharmony_ci        TARGET CortexMXom
13454568cb3Sopenharmony_ci        POST_BUILD
13554568cb3Sopenharmony_ci        COMMAND sh ${PROJECT_SOURCE_DIR}/cmake/common/build_auxiliary_script/make_lib_rename_file_type.sh ${OBJCOPY_PATH} ${CMAKE_ARCHIVE_OUTPUT_DIRECTORY} "CortexMXom.lib"
13654568cb3Sopenharmony_ci    )
13754568cb3Sopenharmony_ci
13854568cb3Sopenharmony_ci    add_custom_command(
13954568cb3Sopenharmony_ci        TARGET CortexMXipc
14054568cb3Sopenharmony_ci        POST_BUILD
14154568cb3Sopenharmony_ci        COMMAND sh ${PROJECT_SOURCE_DIR}/cmake/common/build_auxiliary_script/make_lib_rename_file_type.sh ${OBJCOPY_PATH} ${CMAKE_ARCHIVE_OUTPUT_DIRECTORY} "CortexMXipc.lib"
14254568cb3Sopenharmony_ci    )
14354568cb3Sopenharmony_ciendif()
14454568cb3Sopenharmony_ci####以下为m4 make install打包脚本#####
14554568cb3Sopenharmony_ciset(m4_cortex_export modules)
14654568cb3Sopenharmony_ci
14754568cb3Sopenharmony_ci# 下面的变量分别定义了安装根目录、头文件安装目录、动态库安装目录、静态库安装目录、OBJECT文件安装目录、可执行程序安装目录、配置文件安装目录。
14854568cb3Sopenharmony_ci# 注意:所有安装路径必须是相对CMAKE_INSTALL_PREFIX的相对路径,不可以使用绝对路径!!!
14954568cb3Sopenharmony_ci# 否则安装目录下的配置文件(foo-config.cmake, foo-tragets.cmake等)拷贝到其它目录时无法工作。
15054568cb3Sopenharmony_ciset(INSTALL_M4_CORTEX_BASE_DIR               .)
15154568cb3Sopenharmony_ciset(INSTALL_M4_CORTEX_INCLUDE_DIR            UniProton/include)
15254568cb3Sopenharmony_ciset(INSTALL_M4_CORTEX_INCLUDE_SEC_DIR        libboundscheck/include)
15354568cb3Sopenharmony_ciset(INSTALL_M4_CORTEX_ARCHIVE_DIR            UniProton/lib/cortex_m4)
15454568cb3Sopenharmony_ciset(INSTALL_M4_CORTEX_ARCHIVE_SEC_DIR        libboundscheck/lib/cortex_m4)
15554568cb3Sopenharmony_ciset(INSTALL_M4_CORTEX_ARCHIVE_CONFIG_DIR     UniProton/config)
15654568cb3Sopenharmony_ciset(INSTALL_M4_CORTEX_CONFIG_DIR             cmake/cortex_m4)
15754568cb3Sopenharmony_ci
15854568cb3Sopenharmony_ci
15954568cb3Sopenharmony_ci
16054568cb3Sopenharmony_ci
16154568cb3Sopenharmony_ciinclude(CMakePackageConfigHelpers)
16254568cb3Sopenharmony_ciconfigure_package_config_file(${PROJECT_SOURCE_DIR}/cmake/tool_chain/m4-cortex-config.cmake.in
16354568cb3Sopenharmony_ci    ${CMAKE_CURRENT_BINARY_DIR}/UniProton-m4-cortex-config.cmake
16454568cb3Sopenharmony_ci    INSTALL_DESTINATION ${INSTALL_M4_CORTEX_CONFIG_DIR}
16554568cb3Sopenharmony_ci    PATH_VARS
16654568cb3Sopenharmony_ci    INSTALL_M4_CORTEX_BASE_DIR
16754568cb3Sopenharmony_ci    INSTALL_M4_CORTEX_INCLUDE_DIR
16854568cb3Sopenharmony_ci    INSTALL_M4_CORTEX_INCLUDE_SEC_DIR
16954568cb3Sopenharmony_ci    INSTALL_M4_CORTEX_ARCHIVE_DIR
17054568cb3Sopenharmony_ci    INSTALL_M4_CORTEX_ARCHIVE_SEC_DIR
17154568cb3Sopenharmony_ci    INSTALL_M4_CORTEX_ARCHIVE_CONFIG_DIR
17254568cb3Sopenharmony_ci    INSTALL_M4_CORTEX_CONFIG_DIR
17354568cb3Sopenharmony_ci    INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX}
17454568cb3Sopenharmony_ci)
17554568cb3Sopenharmony_ciinstall(EXPORT ${m4_cortex_export}
17654568cb3Sopenharmony_ci        NAMESPACE UniProton::
17754568cb3Sopenharmony_ci        FILE UniProton-m4-cortex-targets.cmake
17854568cb3Sopenharmony_ci        DESTINATION ${INSTALL_M4_CORTEX_CONFIG_DIR}
17954568cb3Sopenharmony_ci)
18054568cb3Sopenharmony_ciinstall(FILES
18154568cb3Sopenharmony_ci    ${CMAKE_CURRENT_BINARY_DIR}/UniProton-m4-cortex-config.cmake
18254568cb3Sopenharmony_ci    DESTINATION ${INSTALL_M4_CORTEX_CONFIG_DIR}
18354568cb3Sopenharmony_ci)
18454568cb3Sopenharmony_ci
18554568cb3Sopenharmony_ciinstall(TARGETS
18654568cb3Sopenharmony_ci    CortexMXarch
18754568cb3Sopenharmony_ci    CortexMXkernel
18854568cb3Sopenharmony_ci    CortexMXmem
18954568cb3Sopenharmony_ci    CortexMXom
19054568cb3Sopenharmony_ci    CortexMXipc
19154568cb3Sopenharmony_ci    EXPORT ${m4_cortex_export}
19254568cb3Sopenharmony_ci    ARCHIVE DESTINATION ${INSTALL_M4_CORTEX_ARCHIVE_DIR}/
19354568cb3Sopenharmony_ci)
19454568cb3Sopenharmony_ciif (${COMPILE_OPTION} STREQUAL "coverity" OR ${COMPILE_OPTION} STREQUAL "fortify" OR ${COMPILE_OPTION} STREQUAL "UniProton")
19554568cb3Sopenharmony_ci    message("Don't Install Sec Lib In ${COMPILE_OPTION}")
19654568cb3Sopenharmony_cielse()
19754568cb3Sopenharmony_ci    install(TARGETS
19854568cb3Sopenharmony_ci        CortexMXsec_c
19954568cb3Sopenharmony_ci        EXPORT ${m4_cortex_export}
20054568cb3Sopenharmony_ci        ARCHIVE DESTINATION ${INSTALL_M4_CORTEX_ARCHIVE_SEC_DIR}
20154568cb3Sopenharmony_ci    )
20254568cb3Sopenharmony_ci
20354568cb3Sopenharmony_ci    if (NOT "${RPROTON_INSTALL_FILE_OPTION}" STREQUAL "SUPER_BUILD")
20454568cb3Sopenharmony_ci        ##{GLOB 所有文件 | GLOB_RECURSE 递归查找文件&文件夹}
20554568cb3Sopenharmony_ci        file(GLOB glob_sec_files  ${PROJECT_SOURCE_DIR}/platform/libboundscheck/include/*.h)
20654568cb3Sopenharmony_ci        install(FILES
20754568cb3Sopenharmony_ci            ${glob_sec_files}
20854568cb3Sopenharmony_ci            DESTINATION ${INSTALL_M4_CORTEX_INCLUDE_SEC_DIR}
20954568cb3Sopenharmony_ci        )
21054568cb3Sopenharmony_ci    endif()
21154568cb3Sopenharmony_ciendif()
21254568cb3Sopenharmony_ciinstall(FILES
21354568cb3Sopenharmony_ci    ${PROJECT_SOURCE_DIR}/build/uniproton_config/config_m4/prt_buildef.h
21454568cb3Sopenharmony_ci    DESTINATION ${INSTALL_M4_CORTEX_ARCHIVE_CONFIG_DIR}/cortex_m4/config_m4
21554568cb3Sopenharmony_ci)
21654568cb3Sopenharmony_ciif (NOT "${RPROTON_INSTALL_FILE_OPTION}" STREQUAL "SUPER_BUILD")
21754568cb3Sopenharmony_ci    ##{GLOB 所有文件 | GLOB_RECURSE 递归查找文件&文件夹}
21854568cb3Sopenharmony_ci
21954568cb3Sopenharmony_ci    install(FILES
22054568cb3Sopenharmony_ci        ${PROJECT_SOURCE_DIR}/src/config/prt_config.c
22154568cb3Sopenharmony_ci        ${PROJECT_SOURCE_DIR}/src/config/prt_config_internal.h
22254568cb3Sopenharmony_ci        ${PROJECT_SOURCE_DIR}/src/config/config/prt_config.h
22354568cb3Sopenharmony_ci        DESTINATION ${INSTALL_M4_CORTEX_ARCHIVE_CONFIG_DIR}
22454568cb3Sopenharmony_ci    )
22554568cb3Sopenharmony_ci
22654568cb3Sopenharmony_ci    ##{GLOB 所有文件 | GLOB_RECURSE 递归查找文件&文件夹}
22754568cb3Sopenharmony_ci    file(GLOB hw_drv_include_files  ${PROJECT_SOURCE_DIR}/src/include/uapi/hw/armv7-m/*)
22854568cb3Sopenharmony_ci    install(FILES
22954568cb3Sopenharmony_ci        ${hw_drv_include_files}
23054568cb3Sopenharmony_ci        DESTINATION ${INSTALL_M4_CORTEX_INCLUDE_DIR}/hw/armv7-m
23154568cb3Sopenharmony_ci    )
23254568cb3Sopenharmony_ci
23354568cb3Sopenharmony_ci
23454568cb3Sopenharmony_ci    install(FILES
23554568cb3Sopenharmony_ci
23654568cb3Sopenharmony_ci        ${PROJECT_SOURCE_DIR}/src/include/uapi/prt_clk.h
23754568cb3Sopenharmony_ci        ${PROJECT_SOURCE_DIR}/src/include/uapi/prt_cpup.h
23854568cb3Sopenharmony_ci        ${PROJECT_SOURCE_DIR}/src/include/uapi/prt_err.h
23954568cb3Sopenharmony_ci        ${PROJECT_SOURCE_DIR}/src/include/uapi/prt_errno.h
24054568cb3Sopenharmony_ci        ${PROJECT_SOURCE_DIR}/src/include/uapi/prt_event.h
24154568cb3Sopenharmony_ci        ${PROJECT_SOURCE_DIR}/src/include/uapi/prt_exc.h
24254568cb3Sopenharmony_ci        ${PROJECT_SOURCE_DIR}/src/include/uapi/prt_hook.h
24354568cb3Sopenharmony_ci        ${PROJECT_SOURCE_DIR}/src/include/uapi/prt_hwi.h
24454568cb3Sopenharmony_ci        ${PROJECT_SOURCE_DIR}/src/include/uapi/prt_idle.h
24554568cb3Sopenharmony_ci        ${PROJECT_SOURCE_DIR}/src/include/uapi/prt_mem.h
24654568cb3Sopenharmony_ci        ${PROJECT_SOURCE_DIR}/src/include/uapi/prt_module.h
24754568cb3Sopenharmony_ci        ${PROJECT_SOURCE_DIR}/src/include/uapi/prt_queue.h
24854568cb3Sopenharmony_ci        ${PROJECT_SOURCE_DIR}/src/include/uapi/prt_sem.h
24954568cb3Sopenharmony_ci        ${PROJECT_SOURCE_DIR}/src/include/uapi/prt_sys.h
25054568cb3Sopenharmony_ci        ${PROJECT_SOURCE_DIR}/src/include/uapi/prt_task.h
25154568cb3Sopenharmony_ci        ${PROJECT_SOURCE_DIR}/src/include/uapi/prt_tick.h
25254568cb3Sopenharmony_ci        ${PROJECT_SOURCE_DIR}/src/include/uapi/prt_timer.h
25354568cb3Sopenharmony_ci        ${PROJECT_SOURCE_DIR}/src/include/uapi/prt_typedef.h
25454568cb3Sopenharmony_ci        DESTINATION ${INSTALL_M4_CORTEX_INCLUDE_DIR}/
25554568cb3Sopenharmony_ci    )
25654568cb3Sopenharmony_ciendif()
257