SoC common : build :refactor the build system. [1/1]
PD#SWPL-174904
Problem:
Remove the duplicate code of package search and soc path set.
Solution:
Remove the duplicate code of package search and soc path set.
Verify:
N/A
Change-Id: I5e77417ce36c7a67e4b8d8ae7ddecd6634658770
Signed-off-by: xiaohu.huang <xiaohu.huang@amlogic.com>
diff --git a/cmake/extensions.cmake b/cmake/extensions.cmake
index 013b7ab..42b60d4 100755
--- a/cmake/extensions.cmake
+++ b/cmake/extensions.cmake
@@ -815,17 +815,11 @@
endfunction()
function(generate_module_info_output TARGET)
- find_package(Python 3 REQUIRED)
- if(Python_FOUND)
set(map_file_path ${PROJECT_SOURCE_DIR}/output/$ENV{ARCH}-$ENV{BOARD}-$ENV{PRODUCT}/$ENV{KERNEL}/${TARGET_NAME}.map)
- message(STATUS "Python found: ${Python_EXECUTABLE}")
if($ENV{COMPILER} STREQUAL "clang+llvm")
- add_custom_command(TARGET ${TARGET} POST_BUILD COMMAND COMPILER=$ENV{COMPILER} ARCH=$ENV{ARCH} ${Python_EXECUTABLE} ${PROJECT_SOURCE_DIR}/scripts/map_analyzer_clang_llvm.py --combine ${map_file_path} > $<TARGET_FILE_DIR:${TARGET}>/$ENV{KERNEL}_module_info.txt)
+ add_custom_command(TARGET ${TARGET} POST_BUILD COMMAND COMPILER=$ENV{COMPILER} ARCH=$ENV{ARCH} ${PYTHON_EXECUTABLE} ${PROJECT_SOURCE_DIR}/scripts/map_analyzer_clang_llvm.py --combine ${map_file_path} > $<TARGET_FILE_DIR:${TARGET}>/$ENV{KERNEL}_module_info.txt)
else()
- add_custom_command(TARGET ${TARGET} POST_BUILD COMMAND COMPILER=$ENV{COMPILER} ARCH=$ENV{ARCH} ${Python_EXECUTABLE} ${PROJECT_SOURCE_DIR}/scripts/map_analyzer_gcc_xcc.py --combine ${map_file_path} > $<TARGET_FILE_DIR:${TARGET}>/$ENV{KERNEL}_module_info.txt)
+ add_custom_command(TARGET ${TARGET} POST_BUILD COMMAND COMPILER=$ENV{COMPILER} ARCH=$ENV{ARCH} ${PYTHON_EXECUTABLE} ${PROJECT_SOURCE_DIR}/scripts/map_analyzer_gcc_xcc.py --combine ${map_file_path} > $<TARGET_FILE_DIR:${TARGET}>/$ENV{KERNEL}_module_info.txt)
endif()
- else()
- message(FATAL_ERROR "Python not found. Please install Python.")
- endif()
endfunction()
diff --git a/cmake/python.cmake b/cmake/python.cmake
index 949a223..91c7bfe 100755
--- a/cmake/python.cmake
+++ b/cmake/python.cmake
@@ -9,7 +9,7 @@
# are invoked by CMake code and, on Windows, standard I/O encoding defaults
# to the current code page if not connected to a terminal, which is often
# not what we want.
-if (WIN32)
+if(WIN32)
set(ENV{PYTHONIOENCODING} "utf-8")
endif()
@@ -46,4 +46,8 @@
endforeach()
find_package(Python3 ${PYTHON_MINIMUM_REQUIRED} REQUIRED ${PYTHON_EXACT})
-set(PYTHON_EXECUTABLE ${Python3_EXECUTABLE})
+if(Python3_FOUND)
+ set(PYTHON_EXECUTABLE ${Python3_EXECUTABLE})
+else()
+ message(FATAL_ERROR "Python not found. Please install Python.")
+endif()
diff --git a/cmake/toolchains/find_compiler.cmake b/cmake/toolchains/find_compiler.cmake
index c572bdf..4d62009 100755
--- a/cmake/toolchains/find_compiler.cmake
+++ b/cmake/toolchains/find_compiler.cmake
@@ -2,19 +2,6 @@
# SPDX-License-Identifier: MIT
-# Attempting to retrieve the toolchain path parameter defined in the SoC.
-if("$ENV{SPLIT_ARCH_DIR}" STREQUAL "")
- set(SOC_DIR $ENV{SDK_BASE}/soc/$ENV{ARCH}/$ENV{SOC})
-else()
- set(SOC_DIR $ENV{SDK_BASE}/soc/$ENV{ARCH}/$ENV{SPLIT_ARCH_DIR}/$ENV{SOC})
-endif()
-
-message(STATUS "Compiler parameter storage path: ${SOC_DIR}")
-
-if(EXISTS ${SOC_DIR}/compiler_options.cmake)
- include(${SOC_DIR}/compiler_options.cmake)
-endif()
-
# Toolchain file is processed multiple times, however, it cannot access CMake cache on some runs.
# We store the search path in an environment variable so that we can always access it.
if("$ENV{TOOLCHAIN_PATH}" STREQUAL "")