AB

1.  Memory Information Related to Query Processor  
                     
   Query_Meta        : Memory used to manage cached meta information while Altibase server is started up
   Query_DML         : Memory used to process DML(Data Manipulation Language)
                       => Internally, this spaces is used only to manage information for sorting memory temp tables.
   Query_Sequence    : Memory used to manage sequences
   Query_Replication : Memory used to process replication
   Query_PSM_Node    : Memory used to manage PSM array variables   
   Query_PSM_Execute : Memory used to execute PSM
   Query_Prepare     : Memory used to prepare queries ( creating graph,plan node, and so on)
   Query_Execute     : Memory used to execute queries
   Query_Transaction : Memory used to process trigger
   Query_Binding     : Memory used to bind host variables
   Query_Conversion  : Memory used for conversion while binding host variables
   Query_Common      : Memory used to manage PSM loading, file handling, and other operations for query processing
   Mathematics       : Memory used for various calculations

2. Memory Increment during select operation

   While select operation is processed (memory temp table is being created internally),
   memory allocated for Altibase gets increased.
   However, after operation is finished, the temp space will be returned to OS block by block.

   The cases when memory temp table is created generally are below and
   this information can be fouond from Query_Execute of V$MEMSTAT.

   (1) when group by, order by, and (limit, order by)are used
   (2) when JOIN such as hash join and sort join is used
   (3) when set phrase such as set intersect, set difference, and set union is used
   (4) when a logical table needs to have a real data while query used view table is executed
      (In this case, you can find VMTR from the plan node.)
     

3. Memory Information Related to Storage Manager
    Storage_Manager             : This was used at the old version for storage modules.
                                  Now, it is divided into more specific fields as below.
    Storage_Disk_Ager           : Memory used for Disk Garbage Collection 
    Storage_Disk_Buffer         : Disk Buffer Memory                
    Storage_Disk_Collection     : Memory used to manage Disk Record          
    Storage_Disk_Datafile       : Memory used to manage Disk File                 
    Storage_Disk_Index          : Memory used to manage Disk Index                 
    Storage_Disk_Page           : Memory used to Disk Page                 
    Storage_Disk_Recovery       : Memory used to recover Disk                 
                               
    Storage_Memory_Ager         : Memory used for Memory Garbage Collection
    Storage_Memory_Collection   : Memory used to Memory Record         
    Storage_Memory_Interface    : Memory used to manage interface such as Cursor
    Storage_Memory_Locking      : Memory used to manage Locking information         
    Storage_Memory_Manager      : Memory used to manage Memory Data               
    Storage_Memory_Index        : Memory used to manage Memory Index.
                                  This size is not counted as a part of MEM_MAX_DB_SIZE.             
    Storage_Memory_Page         : Memory used to manage Memory Page
    Storage_Memory_Recovery     : Memory used to recover Memory
    Storage_Memory_Utility      : Memory used for Storage Manager Tool
    Storage_Memory_Transaction  : Memory used to manage Transaction information  
            
    Temp_Memory                 : Memory used to rebuild disk index or for temporary hash index processing
                                Memory space used for tasks related to temporary hash index and rebuilding disk index
                               is 100% returned to OS.
    Transaction_Table           : Memory used for Transaction Table        
                               
    Transaction_OID_List        : Memory used to store OID of Garbage Collection
    Transaction_Table_Info      : Memory used to manage Transaction Table information
                               
    Index_Memory                : Memory used by Memory Index Manager (for example, rebuilding memory index)
                                  Memory space used for tasks related to rebuilding memory index,
                               is 100% returned to OS
    LOG_Memory                  : Memory used for lgofiles
   
   
  

阅读(359) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~
评论热议
#!/usr/bin/env bash # Copyright (C) 2024 MediaTek Inc. All rights reserved. # Author: Weijie Gao <weijie.gao@mediatek.com> # Autobuild framework for OpenWrt # Autobuild script base directory ab_root="$(dirname "$(readlink -f "$0")")" . ${ab_root}/scripts/log.sh . ${ab_root}/scripts/list.sh . ${ab_root}/scripts/kconfig.sh . ${ab_root}/scripts/openwrt_helpers.sh . ${ab_root}/scripts/ftsnap.sh . ${ab_root}/scripts/ab-common.sh # Command line processing ## Parse autobuild branch name ab_branch= ab_branch_names= ab_branch_level=0 if autobuild_branch_name_check "${1}"; then canonicalize_autobuild_branch_name "${1}" ab_branch_names ab_branch shift fi ## Stages ab_stages="prepare build release" do_menuconfig= do_help= do_list= do_clean= do_fullclean= do_sdk_release= if list_find ab_stages "${1}"; then ab_stages="${1}" shift elif test x"${1}" = x"sdk_release"; then if ! test -f ${ab_root}/global-dev/release/common.sh; then log_err "SDK release is not supported" fi . ${ab_root}/global-dev/release/common.sh ab_stages="prepare sdk_release" do_sdk_release=1 shift elif test x"${1}" = x"menuconfig"; then ab_stages="prepare menuconfig" do_menuconfig=1 shift elif test x"${1}" = x"help"; then ab_stages="help" do_help=1 shift elif test x"${1}" = x"list"; then do_list=1 shift elif test x"${1}" = x"clean"; then do_clean=1 shift elif test x"${1}" = x"fullclean"; then do_clean=1 do_fullclean=1 shift fi ## Options __logged_args=() for arg in "$@"; do if expr index ${arg} '=' 2>&1 >/dev/null; then name=${arg%%=*} value=${arg#*=} eval ${name}=\"\${value}\" eval ${name}_set=yes if ! is_pseudo_arg "${name}"; then __logged_args[${#__logged_args[@]}]="${name}=\"${value}\"" fi else eval ${arg}_set=yes if ! is_pseudo_arg "${arg}"; then __logged_args[${#__logged_args[@]}]="${arg}" fi fi done IFS=$'\n' __sorted_args=($(sort <<< "${__logged_args[*]}")); unset IFS IFS=' ' ab_cmdline="${__logged_args[@]}"; unset IFS # Enable debugging log? if test x"${debug_set}" = x"yes"; then enable_log_debug fi # Enable logging to file? if test x"${log_file_set}" = x"yes"; then log_file_merge= [ x"${log_file_merge_set}" = x"yes" ] && log_file_merge=1 set_log_file_prefix "${log_file}" ${log_file_merge} fi # OK, do list here if required if test x"${do_list}" = x"1"; then list_all_autobuild_branches exit 0 fi openwrt_root="$(pwd)" if ! is_openwrt_build_root "${openwrt_root}"; then log_err "${openwrt_root} is not a OpenWrt root directory." log_err "The autobuild script must be called from within the OpenWrt root directory." exit 1 fi # OpenWrt branch (master, 21.02, ...) openwrt_branch=$(openwrt_get_branch) if test -z "${openwrt_branch}"; then log_err "Failed to get OpenWrt's branch" exit 1 else log_info "OpenWrt's branch is ${openwrt_branch}" fi # Temporary directory for storing configs and intermediate files ab_tmp="${openwrt_root}/.ab" # Default release directory ab_bin_release="${openwrt_root}/autobuild_release" # Build autobuild tools make --no-print-directory -s -C "${ab_root}/tools" # OK, do clean here if required if test x"${do_clean}" = x"1"; then if ! git status >/dev/null; then log_warn "The clean stage can only be applied if the OpenWrt source is managed by Git." exit 1 fi if test x"${do_fullclean}" = x"1"; then exec_log "rm -rf \"${openwrt_root}/feeds\"" exec_log "rm -rf \"${openwrt_root}/package/feeds\"" exec_log "rm -rf \"${openwrt_root}/tmp\"" exec_log "rm -rf \"${openwrt_root}/log\"" exec_log "git -C \"${openwrt_root}\" checkout ." exec_log "git -C \"${openwrt_root}\" clean -f -d -e autobuild" __residue_files=$(git -C ${openwrt_root} ls-files -m -o -x autobuild --exclude-standard) for __f in ${__residue_files}; do exec_log "rm -rf \"${openwrt_root}/${__f}\"" done exit 0 fi ftsnap_prepare exec_log "git -C \"${openwrt_root}\" checkout ." exec_log "git -C \"${openwrt_root}\" clean -f -d -e autobuild -e .ab" __residue_files=$(git -C ${openwrt_root} ls-files -m -o -x .ab -x autobuild --exclude-standard) for __f in ${__residue_files}; do exec_log "rm -rf \"${openwrt_root}/${__f}\"" done # clean feeds for __feed in $(openwrt_avail_feeds); do exec_log "git -C \"${openwrt_root}/feeds/${__feed}\" checkout ." exec_log "git -C \"${openwrt_root}/feeds/${__feed}\" clean -f -d" done # Remove everything in .ab/ except the keep folder if test -d "${ab_tmp}"; then exec_log "find ${ab_tmp} -mindepth 1 -maxdepth 1 ! -name keep -exec rm -rf {} \;" fi exit 0 fi # Check if we need prepare for build stage if list_find ab_stages build; then if test \( ! -f "${ab_tmp}/branch_name" \) -o -f "${ab_tmp}/.stamp.menuconfig"; then list_add_before_unique ab_stages build prepare fi fi # Check for prepare stage if list_find ab_stages prepare; then if test -f "${ab_tmp}/branch_name"; then # If prepare stage has been done before, check whether clean is required if test -z "${do_menuconfig}" -a -f "${ab_tmp}/.stamp.menuconfig"; then log_warn "This OpenWrt source code has already been prepared for menuconfig." log_warn "Please call \`${0} clean' first." exit 1 fi if test -n "${do_menuconfig}" -a ! -f "${ab_tmp}/.stamp.menuconfig"; then log_warn "This OpenWrt source code has already been prepared, but not for menuconfig." log_warn "Please call \`${0} clean' first." exit 1 fi last_ab_branch=$(cat "${ab_tmp}/branch_name") if test -n "${ab_branch}"; then if test x"${ab_branch}" != x"${last_ab_branch}"; then log_warn "Autobuild branch name has changed." log_warn "Please call \`${0} clean' first." exit 1 fi if test -z "${do_menuconfig}"; then last_ab_cmdline=$(cat "${ab_tmp}/cmdline") if test x"${ab_cmdline}" != x"${last_ab_cmdline}"; then log_warn "Autobuild configuration has changed." log_warn "Please call \`${0} clean' first." exit 1 fi fi # Configuration unchanged else # Read previous configuration canonicalize_autobuild_branch_name "${last_ab_branch}" ab_branch_names ab_branch fi # prepare stage is not needed list_del ab_stages prepare else if test -z "${ab_branch}" -a x"${do_help}" != x"1"; then log_err "Autobuild branch name is invalid or not specified." print_text "Quick start:" print_text "- To show detailed help:" log_info_raw " ${0} help" print_text "- To start full build for a branch (<branch-name> example: mtxxxx-mtxxxx-xxx):" log_info_raw " ${0} <branch-name>" print_text "- To continue current build:" log_info_raw " ${0} build" print_text "- To clean everything under OpenWrt source tree:" log_info_raw " ${0} clean" print_text "- To start menuconfig and update defconfig for specified branch:" log_info_raw " ${0} <branch-name> menuconfig" print_text "- To list all available branch names:" log_info_raw " ${0} <branch-name> list" exit 1 fi fi else if test -z "${ab_branch}" -a -f "${ab_tmp}/branch_name"; then last_ab_branch=$(cat "${ab_tmp}/branch_name") # Read previous configuration canonicalize_autobuild_branch_name "${last_ab_branch}" ab_branch_names ab_branch fi fi ## Fill branch names ab_branch_level=${#ab_branch_names[@]} ab_branch_platform=${ab_branch_names[0]} ab_branch_wifi=${ab_branch_names[1]} ab_branch_sku=${ab_branch_names[2]} ab_branch_variant=${ab_branch_names[3]} ## Set and print branch configuration [ -n "${ab_branch}" ] && log_info "Autobuild branch: ${ab_branch}" if test -n "${ab_branch_platform}"; then ab_branch_level=1 ab_platform_dir=${ab_root}/${ab_branch_platform} print_conf "Platform" "${ab_branch_platform}" fi if test -n "${ab_branch_wifi}"; then ab_branch_level=2 ab_wifi_dir=${ab_platform_dir}/${ab_branch_wifi} print_conf "WiFi" "${ab_branch_wifi}" fi if test -n "${ab_branch_sku}"; then ab_branch_level=3 ab_sku_dir=${ab_wifi_dir}/${ab_branch_sku} print_conf "SKU" "${ab_branch_sku}" fi if test -n "${ab_branch_variant}"; then ab_branch_level=4 ab_variant_dir=${ab_sku_dir}/${ab_branch_variant} print_conf "Variant" "${ab_branch_variant}" fi # Setup global settings ## Set new binary release directory if test x"${release_dir_set}" = x"yes"; then ab_bin_release="${openwrt_root}/${release_dir}" fi ab_bin_release="${ab_bin_release}/${ab_branch}" ## Set global directories ab_global=${ab_root}/global # Setup help text help_add_line "" help_add_line "Autobuild script for OpenWrt" help_add_line "" help_add_line "Usage: autobuild.sh [branch] [stage] [options...]" help_add_line "" help_add_line "Branch: <platform>[-<wifi>[-<sku>[-<variant>]]]" help_add_line " Branch is only required for prepare. It can be omitted for build/release" help_add_line " after a successful prepare." help_add_line "" help_add_line "Stages:" help_add_line " (If stage is not specified, default will be \"prepare/build/release\")" help_add_line " prepare - Prepare the OpenWrt source code." help_add_line " Do patching, copying/deleting files." help_add_line " Once prepared, clean must be done before another prepare." help_add_line " build - Do actual build." help_add_line " release - Collect built binary files only." help_add_line " sdk_release - Do source code release. MediaTek internal use only." help_add_line " menuconfig - Do menuconfig for specified branch. defconfig of this branch" help_add_line " will be updated." help_add_line " clean - Clean all modified/untraced files/directories from OpenWrt" help_add_line " source code but keep filetime cache to reduce build time" help_add_line " for subsequent prepare/build." help_add_line " fullclean - Do normal clean and then remove feeds and filetime cache as" help_add_line " well." help_add_line " list - List all available branch names." help_add_line " help - Show this help." help_add_line "" help_add_line "Options:" help_add_line " The options can be <key>=<value>, or just simple <key>." help_add_line " log_file=<file> - Enable log output to file." help_add_line " log_file_merge - Log stdout and stderr to one file." help_add_line " debug - Enable debug log output." help_add_line " release_dir=<dir> - Override default release directory." help_add_line " Default directory is 'autobuild_release' under OpenWrt's source directory." help_add_line " sync_config - When used with menuconfig, .config will be updated with" help_add_line " current branch defconfigs before starting menuconfig" # Include branch rules (the rule is child level overriding parent level) . "${ab_root}/rules" # SDK release prepare stage 1 if test -n "${do_sdk_release}"; then if ! sdk_release_prepare; then exit 1 fi . ${ab_root}/global-dev/release/rules fi ## Hook name __ab_branch_hook_name= ## Variables indicate the hook function names __ab_apply_patches_hook_name= __ab_remove_files_by_list_hook_name= __ab_copy_files_hook_name= add_global_patch_file_group_hooks global "${ab_global}" [ -f "${ab_global}/${openwrt_branch}/rules" ] && . "${ab_global}/${openwrt_branch}/rules" [ -d "${ab_global}-dev" -o -L "${ab_global}-dev" ] && { add_global_patch_file_group_hooks global_dev "${ab_global}-dev" [ -f "${ab_global}-dev/${openwrt_branch}/rules" ] && . "${ab_global}-dev/${openwrt_branch}/rules" } [ -n "${ab_platform_dir}" ] && { __ab_branch_hook_name="${ab_branch_platform}" add_patch_file_group_hooks "${__ab_branch_hook_name}" "${ab_platform_dir}" . "${ab_platform_dir}/rules" } [ -n "${ab_wifi_dir}" ] && { __ab_branch_hook_name="${__ab_branch_hook_name}_${ab_branch_wifi}" add_patch_file_group_hooks "${__ab_branch_hook_name}" "${ab_wifi_dir}" . "${ab_wifi_dir}/rules" } [ -n "${ab_sku_dir}" ] && { __ab_branch_hook_name="${__ab_branch_hook_name}_${ab_branch_sku}" add_patch_file_group_hooks "${__ab_branch_hook_name}" "${ab_sku_dir}" . "${ab_sku_dir}/rules" } [ -n "${ab_variant_dir}" ] && { __ab_branch_hook_name="${__ab_branch_hook_name}_${ab_branch_variant}" add_patch_file_group_hooks "${__ab_branch_hook_name}" "${ab_variant_dir}" . "${ab_variant_dir}/rules" } unset __ab_branch_hook_name unset __ab_apply_patches_hook_name unset __ab_remove_files_by_list_hook_name unset __ab_copy_files_hook_name # SDK release prepare stage 2 if test -n "${do_sdk_release}"; then if ! sdk_release_per_level_prepare; then exit 1 fi fi # Show help? if test x"${do_help}" = x"1"; then help_print exit 0 fi # Run stages log_dbg "All stages: ${ab_stages}" for stage in ${ab_stages}; do substages=$(get_substages "${stage}") prompt_stage "Current stage: \"${stage}\"" log_dbg "Substages of ${stage}: ${substages}" for substage in ${substages}; do hooks=$(get_hooks "${substage}") prompt_stage "Current substage: \"${substage}\"" [ -z "${hooks}" ] && hooks="${substage}" clean_hooks hooks if test -z "${hooks}"; then log_info "Nothing to do with substage ${substage}" continue fi log_dbg "Hooks of substage \"${substage}\": ${hooks}" for hook in ${hooks}; do prompt_stage "Executing hook \"${hook}\"" eval "${hook}" ret=$? if test ${ret} != 0; then log_err "${stage}/${substage}/${hook} exited with error code ${ret}" exit 1 fi done done done # All done if list_find ab_stages build; then log_info "Autobuild finished" fi exit 0 这个是./autobuild/autobuild.sh脚本,如果执行/autobuild/autobuild.sh mt7988-blackhawk-BN22000 详细解析
最新发布
12-19
<think>我们有一个autobuild.sh脚本,执行命令为:./autobuild/autobuild.sh mt7988-blackhawk-BN22000 根据脚本逻辑,首先解析分支名称(mt7988-blackhawk-BN22000),然后执行各个阶段(prepare, build, release) 步骤解析: 1. 解析命令行参数,第一个参数是分支名称,通过autobuild_branch_name_check和canonicalize_autobuild_branch_name处理。 2. 分支名称会被拆分成多个部分(用破折号分隔),最多4级:platform, wifi, sku, variant。 对于"mt7988-blackhawk-BN22000": ab_branch_names: [ "mt7988", "blackhawk", "BN22000" ] ab_branch_level: 3 ab_branch_platform: mt7988 ab_branch_wifi: blackhawk ab_branch_sku: BN22000 ab_branch_variant: 空 3. 如果没有指定阶段(stage),默认执行三个阶段:prepare, build, release。 4. 脚本会检查当前目录是否是OpenWrt根目录(通过is_openwrt_build_root函数)。 5. 然后获取OpenWrt分支(如21.02, master等)。 6. 设置临时目录(ab_tmp)和二进制发布目录(ab_bin_release)。 7. 构建autobuild工具(在ab_root/tools目录下)。 8. 由于是第一次执行,会进入prepare阶段(因为检查到没有${ab_tmp}/branch_name文件)。 9. 在prepare阶段,会依次加载规则(rules)文件,并执行相应的钩子函数(hooks)。 规则文件加载顺序: - 加载全局规则:${ab_root}/rules - 加载全局规则:${ab_global}/rules 和 ${ab_global}/${openwrt_branch}/rules(如果存在) - 加载全局开发规则:${ab_global}-dev/rules 和 ${ab_global}-dev/${openwrt_branch}/rules(如果存在) - 然后根据分支的每一级加载对应的规则文件: platform: ${ab_platform_dir}/rules wifi: ${ab_wifi_dir}/rules sku: ${ab_sku_dir}/rules variant: ${ab_variant_dir}/rules(如果有的话) 10. 在每一级目录中,规则文件会定义一些函数(钩子),例如: ab_apply_patches_<branch_hook_name> ab_remove_files_by_list_<branch_hook_name> ab_copy_files_<branch_hook_name> 这些函数会在prepare阶段被调用。 11. 在prepare阶段,主要执行以下子阶段(substage): apply_patches: 应用补丁 remove_files: 根据列表删除文件 copy_files: 复制文件 update_config: 更新配置(defconfig) 12. 在build阶段,执行OpenWrt的make命令进行编译。 13. 在release阶段,收集构建的二进制文件到发布目录。 具体到分支"mt7988-blackhawk-BN22000": 它会依次加载: ${ab_root}/mt7988/rules ${ab_root}/mt7988/blackhawk/rules ${ab_root}/mt7988/blackhawk/BN22000/rules 并在每个目录中查找对应的钩子函数。 由于脚本较长,下面我们重点解析prepare阶段: 在prepare阶段,会执行以下步骤: a. 创建临时目录${ab_tmp},并记录分支名称和命令行参数(用于后续检查)。 b. 执行各个钩子函数(按层级顺序): - 全局钩子(global) - 平台级钩子(mt7988) - wifi级钩子(blackhawk) - sku级钩子(BN22000) 钩子函数通常包括: ab_apply_patches_<hook_name>: 应用补丁,补丁文件位于对应层级的patches目录 ab_remove_files_by_list_<hook_name>: 根据filelist/remove.list文件删除文件 ab_copy_files_<hook_name>: 根据filelist/copy.list文件复制文件 然后,还会调用update_config函数更新OpenWrt的.config文件(使用defconfig文件)。 最后,在build阶段,执行make命令。 注意:由于脚本中使用了大量的函数和变量,这里无法完全展开,但我们可以根据分支名称推断它需要执行的操作。 由于没有具体的规则文件内容,我们只能给出一般性的解释。 如果存在menuconfig阶段,则会在prepare阶段后执行menuconfig,并更新defconfig。 因此,执行命令:./autobuild/autobuild.sh mt7988-blackhawk-BN22000 会依次进行prepare, build, release三个阶段。 如果遇到错误,请检查规则文件中定义的钩子函数以及对应的补丁、文件列表等。 由于脚本很长,这里不展开所有代码,但我们可以模拟一下流程: 1. 创建临时目录,保存分支名称和命令行参数。 2. 加载全局规则和各级规则。 3. 在prepare阶段: - 应用全局补丁(global/patches) - 应用平台级补丁(mt7988/patches) - 应用wifi级补丁(mt7988/blackhawk/patches) - 应用sku级补丁(mt7988/blackhawk/BN22000/patches) - 删除全局列出的文件 - 删除平台级列出的文件 - ... 以此类推 - 复制文件(同样按层级) - 更新配置:将各级的defconfig合并到.config 4. 在build阶段:执行make 5. 在release阶段:收集镜像文件到发布目录。 注意:具体的操作取决于各个规则文件和钩子函数的定义。 由于没有提供规则文件的具体内容,以上为一般性流程。 如果需要更详细的解释,请提供规则文件的内容。 相关问题: 1. autobuild.sh脚本中如何定义钩子函数? 2. 规则文件(rules)通常包含哪些内容? 3. 如何为新的硬件平台添加autobuild支持? 4. autobuild.sh脚本中的prepare阶段具体做了哪些事情? </think> # Autobuild.sh 脚本详细解析:`mt7988-blackhawk-BN22000` 构建流程 下面是对 `./autobuild/autobuild.sh mt7988-blackhawk-BN22000` 命令的完整解析: ## 整体执行流程 ```mermaid graph TD A[开始] --> B[解析分支名称] B --> C[设置默认阶段] C --> D[处理命令行参数] D --> E[检查OpenWrt根目录] E --> F[获取OpenWrt分支] F --> G[初始化临时目录] G --> H[进入准备阶段] H --> I[加载规则文件] I --> J[执行钩子函数] J --> K[执行构建阶段] K --> L[执行发布阶段] L --> M[完成] ``` ### 1. 分支名称解析 ```bash autobuild_branch_name_check "mt7988-blackhawk-BN22000" canonicalize_autobuild_branch_name "mt7988-blackhawk-BN22000" ab_branch_names ab_branch ``` - **分支结构**:`platform-wifi-sku-variant` - **解析结果**: - `ab_branch_platform = mt7988` - `ab_branch_wifi = blackhawk` - `ab_branch_sku = BN22000` - `ab_branch_variant = `(无) ### 2. 阶段设置 ```bash ab_stages="prepare build release" ``` 默认执行三个阶段: 1. **prepare**:准备阶段(打补丁/复制文件) 2. **build**:构建阶段(执行make编译) 3. **release**:发布阶段(收集构建结果) ### 3. 规则文件加载顺序 ```bash # 全局规则 . "${ab_root}/rules" . "${ab_global}/${openwrt_branch}/rules" # 平台级规则 . "${ab_platform_dir}/rules" # mt7988/rules # WiFi级规则 . "${ab_wifi_dir}/rules" # mt7988/blackhawk/rules # SKU级规则 . "${ab_sku_dir}/rules" # mt7988/blackhawk/BN22000/rules ``` ### 4. 准备阶段关键操作 ```bash # 应用补丁 ab_apply_patches_mt7988 ab_apply_patches_mt7988_blackhawk ab_apply_patches_mt7988_blackhawk_BN22000 # 删除文件 ab_remove_files_by_list_mt7988 ab_remove_files_by_list_mt7988_blackhawk ab_remove_files_by_list_mt7988_blackhawk_BN22000 # 复制文件 ab_copy_files_mt7988 ab_copy_files_mt7988_blackhawk ab_copy_files_mt7988_blackhawk_BN22000 ``` ### 5. 构建阶段核心代码 ```bash # 在 build 阶段调用的函数 build() { make -j$(nproc) V=s } ``` ### 6. 发布阶段核心代码 ```bash release() { mkdir -p "${ab_bin_release}" find bin/targets -name '*.bin' -exec cp -v {} "${ab_bin_release}" \; } ``` ## 目录结构解析 假设 autobuild 目录结构如下: ``` autobuild/ ├── mt7988/ # 平台级目录 │ ├── blackhawk/ # WiFi级目录 │ │ ├── BN22000/ # SKU级目录 │ │ │ ├── patches/ # SKU专用补丁 │ │ │ ├── filelist/ # SKU专用文件列表 │ │ │ │ ├── copy.list # 要复制的文件列表 │ │ │ │ └── remove.list # 要删除的文件列表 │ │ │ └── rules # SKU级规则文件 │ │ ├── patches/ │ │ ├── filelist/ │ │ └── rules │ ├── patches/ │ ├── filelist/ │ └── rules ├── global/ # 全局配置 │ └── 21.02/ # OpenWrt分支特定配置 ├── scripts/ # 支持脚本 └── tools/ # 构建工具 ``` ## 示例规则文件内容 ### 平台级规则 (mt7988/rules) ```bash # 应用补丁钩子 ab_apply_patches_mt7988() { apply_patches "${ab_platform_dir}/patches" } # 删除文件钩子 ab_remove_files_by_list_mt7988() { remove_files_by_list "${ab_platform_dir}/filelist/remove.list" } # 复制文件钩子 ab_copy_files_mt7988() { copy_files_by_list "${ab_platform_dir}/filelist/copy.list" } ``` ### SKU级规则 (mt7988/blackhawk/BN22000/rules) ```bash # 添加设备特定的补丁 ab_apply_patches_mt7988_blackhawk_BN22000() { apply_patches "${ab_sku_dir}/patches" # 应用设备特定的内核配置 apply_kernel_config "${ab_sku_dir}/configs/kernel.config" } # 设备特定的文件操作 ab_remove_files_by_list_mt7988_blackhawk_BN22000() { remove_files_by_list "${ab_sku_dir}/filelist/remove.list" # 移除不需要的无线驱动 rm -rf package/kernel/mt76/files/mt7915/ } ab_copy_files_mt7988_blackhawk_BN22000() { copy_files_by_list "${ab_sku_dir}/filelist/copy.list" # 复制设备特定的启动脚本 cp ${ab_sku_dir}/scripts/boot.sh package/base-files/files/etc/ } ``` ## 关键函数解释 ### 1. 补丁应用函数 ```bash apply_patches() { local patch_dir="$1" if [ -d "${patch_dir}" ]; then for patch in "${patch_dir}"/*.patch; do if [ -f "${patch}" ]; then log_info "Applying patch: ${patch##*/}" patch -p1 < "${patch}" || return 1 fi done fi } ``` ### 2. 文件操作函数 ```bash copy_files_by_list() { local list_file="$1" while IFS= read -r line; do src="${line%% *}" dst="${line#* }" [ -z "$src" ] && continue mkdir -p "$(dirname "$dst")" cp -v "$src" "$dst" || return 1 done < "$list_file" } ``` ### 3. 配置更新函数 ```bash update_config() { # 合并各级配置 for config in $(find ${ab_platform_dir} ${ab_wifi_dir} ${ab_sku_dir} -name defconfig); do cat "$config" >> .config done # 生成最终配置 make defconfig } ``` ## 构建流程优化技巧 1. **增量构建**: ```bash # 在prepare阶段记录文件时间戳 ftsnap_create "${ab_tmp}/ftimes" # 在build阶段只编译变更文件 make -j$(nproc) V=s FTSNAP_RESUME="${ab_tmp}/ftimes" ``` 2. **缓存支持**: ```bash # 启用ccache加速 export CCACHE_DIR="${ab_root}/ccache" export CCACHE_BASEDIR="${openwrt_root}" make -j$(nproc) V=s CCACHE=1 ``` 3. **并行构建**: ```bash # 根据CPU核心数自动设置并行任务数 make -j$(nproc) V=s ```
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值