154568cb3Sopenharmony_ci# Copyright (c) 2022-2022 Huawei Technologies Co., Ltd. All rights reserved. 254568cb3Sopenharmony_ci# 354568cb3Sopenharmony_ci# UniProton is licensed under Mulan PSL v2. 454568cb3Sopenharmony_ci# You can use this software according to the terms and conditions of the Mulan PSL v2. 554568cb3Sopenharmony_ci# You may obtain a copy of Mulan PSL v2 at: 654568cb3Sopenharmony_ci# http://license.coscl.org.cn/MulanPSL2 754568cb3Sopenharmony_ci# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, 854568cb3Sopenharmony_ci# EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, 954568cb3Sopenharmony_ci# MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. 1054568cb3Sopenharmony_ci# See the Mulan PSL v2 for more details. 1154568cb3Sopenharmony_ci# Create: 2022-09-21 1254568cb3Sopenharmony_ci# Description: UniProton内核配置开关编译脚本。 1354568cb3Sopenharmony_ciimport("//build/lite/config/component/lite_component.gni") 1454568cb3Sopenharmony_ci 1554568cb3Sopenharmony_ciproduct_config_file = "${ohos_build_type}.config" 1654568cb3Sopenharmony_ciproduct_config_file = 1754568cb3Sopenharmony_ci rebase_path(product_config_file, "", "$product_path/kernel_configs") 1854568cb3Sopenharmony_ciprint("product_config_file:", product_config_file) 1954568cb3Sopenharmony_ci 2054568cb3Sopenharmony_ciMENUCONFIG_H = rebase_path("$root_out_dir/config.h") 2154568cb3Sopenharmony_ciexec_script( 2254568cb3Sopenharmony_ci "//build/lite/run_shell_cmd.py", 2354568cb3Sopenharmony_ci [ "env" + " CONFIG_=" + " KCONFIG_CONFIG_HEADER='y=true'" + 2454568cb3Sopenharmony_ci " KCONFIG_CONFIG=$product_config_file" + 2554568cb3Sopenharmony_ci " BOARD_COMPANY=$device_company" + " DEVICE_PATH=$device_path" + 2654568cb3Sopenharmony_ci " srctree=" + rebase_path("./src") + " genconfig" + 2754568cb3Sopenharmony_ci " --header-path $MENUCONFIG_H" + " --file-list kconfig_files.txt" + 2854568cb3Sopenharmony_ci " --env-list kconfig_env.txt" + " --config-out config.gni" ], 2954568cb3Sopenharmony_ci "", 3054568cb3Sopenharmony_ci [ product_config_file ]) 3154568cb3Sopenharmony_ci 3254568cb3Sopenharmony_ciimport("$root_out_dir/config.gni") 3354568cb3Sopenharmony_ci 3454568cb3Sopenharmony_ciOSTOPDIR = "//kernel/uniproton/src" 3554568cb3Sopenharmony_ciOSTHIRDPARTY = "//third_party" 3654568cb3Sopenharmony_ci 3754568cb3Sopenharmony_ciHDFTOPDIR = "//drivers/hdf_core/adapter/khdf/uniproton" 3854568cb3Sopenharmony_ci 3954568cb3Sopenharmony_citemplate("kernel_module") { 4054568cb3Sopenharmony_ci build_gn = rebase_path("BUILD.gn") 4154568cb3Sopenharmony_ci print("build_gn is $build_gn") 4254568cb3Sopenharmony_ci cmd = "grep -c '^\s*\(kernel_module\|hdf_driver\)\s*(\s*\S*\s*)\s*{\s*\$' $build_gn" 4354568cb3Sopenharmony_ci modules_count = exec_script("//build/lite/run_shell_cmd.py", [ cmd ], "value") 4454568cb3Sopenharmony_ci if (modules_count == 1) { 4554568cb3Sopenharmony_ci auto_config = true 4654568cb3Sopenharmony_ci } 4754568cb3Sopenharmony_ci 4854568cb3Sopenharmony_ci cmd = "if grep -q '^\s*\(config\s*(\s*\"public\"\s*)\|module_group\s*(\s*\"\S*\"\s*)\)\s*{\s*\$' $build_gn; then echo true; else echo false; fi" 4954568cb3Sopenharmony_ci has_public_config = 5054568cb3Sopenharmony_ci exec_script("//build/lite/run_shell_cmd.py", [ cmd ], "value") 5154568cb3Sopenharmony_ci if (!has_public_config && defined(auto_config)) { 5254568cb3Sopenharmony_ci config("public") { 5354568cb3Sopenharmony_ci configs = [] 5454568cb3Sopenharmony_ci } 5554568cb3Sopenharmony_ci } 5654568cb3Sopenharmony_ci 5754568cb3Sopenharmony_ci current_dir_name = get_path_info(rebase_path("."), "file") 5854568cb3Sopenharmony_ci if (target_name != current_dir_name) { 5954568cb3Sopenharmony_ci cmd = "if grep -q '^\s*\(module_group\|group\)\s*(\s*\"$current_dir_name\"\s*)\s*{\s*\$' $build_gn; then echo true; else echo false; fi" 6054568cb3Sopenharmony_ci has_current_dir_group = 6154568cb3Sopenharmony_ci exec_script("//build/lite/run_shell_cmd.py", [ cmd ], "value") 6254568cb3Sopenharmony_ci if (!has_current_dir_group && defined(auto_config)) { 6354568cb3Sopenharmony_ci module_name = target_name 6454568cb3Sopenharmony_ci group(current_dir_name) { 6554568cb3Sopenharmony_ci public_deps = [ ":$module_name" ] 6654568cb3Sopenharmony_ci } 6754568cb3Sopenharmony_ci } 6854568cb3Sopenharmony_ci } 6954568cb3Sopenharmony_ci 7054568cb3Sopenharmony_ci if (defined(invoker.module_switch) && !invoker.module_switch) { 7154568cb3Sopenharmony_ci group(target_name) { 7254568cb3Sopenharmony_ci not_needed(invoker, "*") 7354568cb3Sopenharmony_ci } 7454568cb3Sopenharmony_ci } else { 7554568cb3Sopenharmony_ci source_set(target_name) { 7654568cb3Sopenharmony_ci public_configs = [] 7754568cb3Sopenharmony_ci forward_variables_from(invoker, "*", [ "configs" ]) 7854568cb3Sopenharmony_ci configs += invoker.configs 7954568cb3Sopenharmony_ci if (has_public_config) { 8054568cb3Sopenharmony_ci included_public_config = false 8154568cb3Sopenharmony_ci foreach(cfg, public_configs) { 8254568cb3Sopenharmony_ci what = "label_no_toolchain" 8354568cb3Sopenharmony_ci if (get_label_info(cfg, what) == get_label_info(":public", what)) { 8454568cb3Sopenharmony_ci included_public_config = true 8554568cb3Sopenharmony_ci included_public_config = false 8654568cb3Sopenharmony_ci } 8754568cb3Sopenharmony_ci } 8854568cb3Sopenharmony_ci if (!included_public_config) { 8954568cb3Sopenharmony_ci public_configs += [ ":public" ] 9054568cb3Sopenharmony_ci } 9154568cb3Sopenharmony_ci } 9254568cb3Sopenharmony_ci } 9354568cb3Sopenharmony_ci } 9454568cb3Sopenharmony_ci not_needed([ "auto_config" ]) 9554568cb3Sopenharmony_ci} 9654568cb3Sopenharmony_ci 9754568cb3Sopenharmony_citemplate("config") { 9854568cb3Sopenharmony_ci config(target_name) { 9954568cb3Sopenharmony_ci if (defined(invoker.module_switch) && !invoker.module_switch && 10054568cb3Sopenharmony_ci target_name == "public") { 10154568cb3Sopenharmony_ci not_needed(invoker, "*") 10254568cb3Sopenharmony_ci forward_variables_from(invoker, [ "configs" ]) 10354568cb3Sopenharmony_ci } else { 10454568cb3Sopenharmony_ci forward_variables_from(invoker, "*") 10554568cb3Sopenharmony_ci } 10654568cb3Sopenharmony_ci } 10754568cb3Sopenharmony_ci} 10854568cb3Sopenharmony_ci 10954568cb3Sopenharmony_citemplate("module_group") { 11054568cb3Sopenharmony_ci assert(defined(invoker.modules), "modules are must") 11154568cb3Sopenharmony_ci group(target_name) { 11254568cb3Sopenharmony_ci deps = [] 11354568cb3Sopenharmony_ci foreach(m, invoker.modules) { 11454568cb3Sopenharmony_ci deps += [ m ] 11554568cb3Sopenharmony_ci } 11654568cb3Sopenharmony_ci if (defined(invoker.deps)) { 11754568cb3Sopenharmony_ci deps += invoker.deps 11854568cb3Sopenharmony_ci } 11954568cb3Sopenharmony_ci } 12054568cb3Sopenharmony_ci config("public") { 12154568cb3Sopenharmony_ci configs = [] 12254568cb3Sopenharmony_ci foreach(m, invoker.modules) { 12354568cb3Sopenharmony_ci configs += [ "$m:public" ] 12454568cb3Sopenharmony_ci } 12554568cb3Sopenharmony_ci if (defined(invoker.configs)) { 12654568cb3Sopenharmony_ci configs += invoker.configs 12754568cb3Sopenharmony_ci } 12854568cb3Sopenharmony_ci } 12954568cb3Sopenharmony_ci} 13054568cb3Sopenharmony_ci 13154568cb3Sopenharmony_ciKERNEL_BASE_INCLUDE_DIRS = [ 13254568cb3Sopenharmony_ci "$OSTOPDIR/arch/include", 13354568cb3Sopenharmony_ci "$OSTOPDIR/config", 13454568cb3Sopenharmony_ci "$OSTOPDIR/core/ipc/include", 13554568cb3Sopenharmony_ci "$OSTOPDIR/core/kernel/include", 13654568cb3Sopenharmony_ci "$OSTOPDIR/mem/include", 13754568cb3Sopenharmony_ci "$OSTOPDIR/om/include", 13854568cb3Sopenharmony_ci "$OSTOPDIR/utility/lib/include", 13954568cb3Sopenharmony_ci] 14054568cb3Sopenharmony_ci 14154568cb3Sopenharmony_ciKERNEL_BASE_SOURCES = [ 14254568cb3Sopenharmony_ci "$OSTOPDIR/config/prt_config.c", 14354568cb3Sopenharmony_ci "$OSTOPDIR/core/kernel/irq/prt_irq.c", 14454568cb3Sopenharmony_ci "$OSTOPDIR/core/kernel/kexc/prt_kexc.c", 14554568cb3Sopenharmony_ci "$OSTOPDIR/core/kernel/sys/prt_sys.c", 14654568cb3Sopenharmony_ci "$OSTOPDIR/core/kernel/sys/prt_sys_init.c", 14754568cb3Sopenharmony_ci "$OSTOPDIR/core/kernel/sys/prt_sys_time.c", 14854568cb3Sopenharmony_ci "$OSTOPDIR/core/kernel/task/prt_amp_task.c", 14954568cb3Sopenharmony_ci "$OSTOPDIR/core/kernel/task/prt_amp_task_del.c", 15054568cb3Sopenharmony_ci "$OSTOPDIR/core/kernel/task/prt_amp_task_init.c", 15154568cb3Sopenharmony_ci "$OSTOPDIR/core/kernel/task/prt_amp_task_minor.c", 15254568cb3Sopenharmony_ci "$OSTOPDIR/core/kernel/task/prt_task.c", 15354568cb3Sopenharmony_ci "$OSTOPDIR/core/kernel/task/prt_task_attrib.c", 15454568cb3Sopenharmony_ci "$OSTOPDIR/core/kernel/task/prt_task_del.c", 15554568cb3Sopenharmony_ci "$OSTOPDIR/core/kernel/task/prt_task_global.c", 15654568cb3Sopenharmony_ci "$OSTOPDIR/core/kernel/task/prt_task_info.c", 15754568cb3Sopenharmony_ci "$OSTOPDIR/core/kernel/task/prt_task_init.c", 15854568cb3Sopenharmony_ci "$OSTOPDIR/core/kernel/task/prt_task_minor.c", 15954568cb3Sopenharmony_ci "$OSTOPDIR/core/kernel/task/prt_task_priority.c", 16054568cb3Sopenharmony_ci "$OSTOPDIR/core/kernel/task/prt_task_sem.c", 16154568cb3Sopenharmony_ci "$OSTOPDIR/core/kernel/task/prt_taskself_id.c", 16254568cb3Sopenharmony_ci "$OSTOPDIR/core/kernel/tick/prt_tick.c", 16354568cb3Sopenharmony_ci "$OSTOPDIR/core/kernel/tick/prt_tick_init.c", 16454568cb3Sopenharmony_ci "$OSTOPDIR/core/kernel/timer/prt_timer.c", 16554568cb3Sopenharmony_ci "$OSTOPDIR/core/kernel/timer/prt_timer_minor.c", 16654568cb3Sopenharmony_ci] 16754568cb3Sopenharmony_ci 16854568cb3Sopenharmony_ciKERNEL_SWTMR_SOURCES = [ 16954568cb3Sopenharmony_ci "$OSTOPDIR/core/kernel/timer/swtmr/prt_swtmr.c", 17054568cb3Sopenharmony_ci "$OSTOPDIR/core/kernel/timer/swtmr/prt_swtmr_init.c", 17154568cb3Sopenharmony_ci "$OSTOPDIR/core/kernel/timer/swtmr/prt_swtmr_minor.c", 17254568cb3Sopenharmony_ci] 17354568cb3Sopenharmony_ci 17454568cb3Sopenharmony_ciKERNEL_IPC_EVENT_SOURCES = [ "$OSTOPDIR/core/ipc/event/prt_event.c" ] 17554568cb3Sopenharmony_ci 17654568cb3Sopenharmony_ciKERNEL_IPC_QUEUE_SOURCES = [ 17754568cb3Sopenharmony_ci "$OSTOPDIR/core/ipc/queue/prt_queue.c", 17854568cb3Sopenharmony_ci "$OSTOPDIR/core/ipc/queue/prt_queue_del.c", 17954568cb3Sopenharmony_ci "$OSTOPDIR/core/ipc/queue/prt_queue_init.c", 18054568cb3Sopenharmony_ci "$OSTOPDIR/core/ipc/queue/prt_queue_minor.c", 18154568cb3Sopenharmony_ci] 18254568cb3Sopenharmony_ci 18354568cb3Sopenharmony_ciKERNEL_IPC_SEM_SOURCES = [ 18454568cb3Sopenharmony_ci "$OSTOPDIR/core/ipc/sem/prt_sem.c", 18554568cb3Sopenharmony_ci "$OSTOPDIR/core/ipc/sem/prt_sem_init.c", 18654568cb3Sopenharmony_ci "$OSTOPDIR/core/ipc/sem/prt_sem_minor.c", 18754568cb3Sopenharmony_ci] 18854568cb3Sopenharmony_ci 18954568cb3Sopenharmony_ciKERNEL_MEM_SOURCES = [ 19054568cb3Sopenharmony_ci "$OSTOPDIR/mem/prt_mem.c", 19154568cb3Sopenharmony_ci "$OSTOPDIR/mem/fsc/prt_fscmem.c", 19254568cb3Sopenharmony_ci] 19354568cb3Sopenharmony_ci 19454568cb3Sopenharmony_ciKERNEL_OM_SOURCES = [ 19554568cb3Sopenharmony_ci "$OSTOPDIR/om/err/prt_err.c", 19654568cb3Sopenharmony_ci "$OSTOPDIR/om/err/prt_err_init.c", 19754568cb3Sopenharmony_ci "$OSTOPDIR/om/hook/prt_hook_init.c", 19854568cb3Sopenharmony_ci] 19954568cb3Sopenharmony_ci 20054568cb3Sopenharmony_ciKERNEL_OM_CPUP_SOURCES = [ 20154568cb3Sopenharmony_ci "$OSTOPDIR/om/cpup/prt_cpup.c", 20254568cb3Sopenharmony_ci "$OSTOPDIR/om/cpup/prt_cpup_minor.c", 20354568cb3Sopenharmony_ci "$OSTOPDIR/om/cpup/prt_cpup_thread.c", 20454568cb3Sopenharmony_ci "$OSTOPDIR/om/cpup/prt_cpup_thread_64.c", 20554568cb3Sopenharmony_ci "$OSTOPDIR/om/cpup/prt_cpup_thread_init.c", 20654568cb3Sopenharmony_ci "$OSTOPDIR/om/cpup/prt_cpup_warn.c", 20754568cb3Sopenharmony_ci] 20854568cb3Sopenharmony_ci 20954568cb3Sopenharmony_ciKERNEL_SECURITY_SOURCES = [ "$OSTOPDIR/security/rnd/prt_rnd_set.c" ] 21054568cb3Sopenharmony_ci 21154568cb3Sopenharmony_ciKERNEL_UTILITY_SOURCES = [ 21254568cb3Sopenharmony_ci "$OSTOPDIR/utility/lib/prt_lib_math64.c", 21354568cb3Sopenharmony_ci "$OSTOPDIR/utility/lib/prt_lib_version.c", 21454568cb3Sopenharmony_ci] 21554568cb3Sopenharmony_ci 21654568cb3Sopenharmony_ciKERNEL_FS_INCLUDE_DIRS = [ 21754568cb3Sopenharmony_ci "$OSTOPDIR/fs/porting", 21854568cb3Sopenharmony_ci "$OSTOPDIR/fs/vfs", 21954568cb3Sopenharmony_ci "$OSTOPDIR/fs/littlefs", 22054568cb3Sopenharmony_ci] 22154568cb3Sopenharmony_ci 22254568cb3Sopenharmony_ciKERNEL_FS_SOURCES = [ 22354568cb3Sopenharmony_ci "$OSTOPDIR/fs/fs.c", 22454568cb3Sopenharmony_ci "$OSTOPDIR/fs/vfs/vfs_files.c", 22554568cb3Sopenharmony_ci "$OSTOPDIR/fs/vfs/vfs_fs.c", 22654568cb3Sopenharmony_ci "$OSTOPDIR/fs/vfs/vfs_init.c", 22754568cb3Sopenharmony_ci "$OSTOPDIR/fs/vfs/vfs_maps.c", 22854568cb3Sopenharmony_ci "$OSTOPDIR/fs/vfs/vfs_mount.c", 22954568cb3Sopenharmony_ci "$OSTOPDIR/fs/vfs/vfs_partition.c", 23054568cb3Sopenharmony_ci "$OSTOPDIR/fs/littlefs/lfs_adapter.c", 23154568cb3Sopenharmony_ci] 23254568cb3Sopenharmony_ci 23354568cb3Sopenharmony_ciKERNEL_LWIP_INCLUDE_DIRS = [ "$OSTOPDIR/net/lwip-2.1/include" ] 23454568cb3Sopenharmony_ci 23554568cb3Sopenharmony_ciKERNEL_LWIP_SOURCES = [ 23654568cb3Sopenharmony_ci "$OSTOPDIR/net/lwip-2.1/src/driverif.c", 23754568cb3Sopenharmony_ci "$OSTOPDIR/net/lwip-2.1/src/netdb.c", 23854568cb3Sopenharmony_ci "$OSTOPDIR/net/lwip-2.1/src/sockets.c", 23954568cb3Sopenharmony_ci "$OSTOPDIR/net/lwip-2.1/src/sys_arch.c", 24054568cb3Sopenharmony_ci "$OSTOPDIR/net/lwip-2.1/enhancement/src/fixme.c", 24154568cb3Sopenharmony_ci "$OSTOPDIR/net/lwip-2.1/enhancement/src/lwip_ifaddrs.c", 24254568cb3Sopenharmony_ci] 24354568cb3Sopenharmony_ci 24454568cb3Sopenharmony_ciARCH_ARMVM7_M_SOURCES = [ 24554568cb3Sopenharmony_ci "$OSTOPDIR/arch/cpu/armv7-m/common/boot/prt_hw_boot.c", 24654568cb3Sopenharmony_ci "$OSTOPDIR/arch/cpu/armv7-m/common/exc/prt_exc.c", 24754568cb3Sopenharmony_ci "$OSTOPDIR/arch/cpu/armv7-m/common/hwi/prt_hwi.c", 24854568cb3Sopenharmony_ci "$OSTOPDIR/arch/cpu/armv7-m/common/hwi/prt_vi_dispatch.c", 24954568cb3Sopenharmony_ci "$OSTOPDIR/arch/cpu/armv7-m/common/tick/prt_hw_tick.c", 25054568cb3Sopenharmony_ci "$OSTOPDIR/arch/cpu/armv7-m/common/tick/prt_hw_tick_minor.c", 25154568cb3Sopenharmony_ci "$OSTOPDIR/arch/cpu/armv7-m/common/prt_port.c", 25254568cb3Sopenharmony_ci] 25354568cb3Sopenharmony_ci 25454568cb3Sopenharmony_ciARCH_ARMVM7_M_INCLUDE_DIRS = [ "$OSTOPDIR/arch/cpu/armv7-m/common" ] 25554568cb3Sopenharmony_ci 25654568cb3Sopenharmony_ciARCH_CORTEX_M4_SOURCES = [ 25754568cb3Sopenharmony_ci "$OSTOPDIR/arch/cpu/armv7-m/cortex-m4/prt_dispatch.S", 25854568cb3Sopenharmony_ci "$OSTOPDIR/arch/cpu/armv7-m/cortex-m4/prt_div64.c", 25954568cb3Sopenharmony_ci "$OSTOPDIR/arch/cpu/armv7-m/cortex-m4/prt_hw.S", 26054568cb3Sopenharmony_ci "$OSTOPDIR/arch/cpu/armv7-m/cortex-m4/prt_hw_exc.S", 26154568cb3Sopenharmony_ci "$OSTOPDIR/arch/cpu/armv7-m/cortex-m4/prt_vector.S", 26254568cb3Sopenharmony_ci] 26354568cb3Sopenharmony_ci 26454568cb3Sopenharmony_ciARCH_CORTEX_M4_INCLUDE_DIRS = [ "$OSTOPDIR/arch/cpu/armv7-m/cortex-m4" ] 26554568cb3Sopenharmony_ci 26654568cb3Sopenharmony_ciset_defaults("kernel_module") { 26754568cb3Sopenharmony_ci configs = [ 26854568cb3Sopenharmony_ci "//kernel/uniproton:os_config", 26954568cb3Sopenharmony_ci "//kernel/uniproton:kernel_config", 27054568cb3Sopenharmony_ci "//kernel/uniproton:public", 27154568cb3Sopenharmony_ci ] 27254568cb3Sopenharmony_ci visibility = [ 27354568cb3Sopenharmony_ci ":*", 27454568cb3Sopenharmony_ci "..:*", 27554568cb3Sopenharmony_ci "../..:*", 27654568cb3Sopenharmony_ci "//kernel/uniproton:*", 27754568cb3Sopenharmony_ci ] 27854568cb3Sopenharmony_ci} 279