• 【Android】android编译之source build/envsetup.sh简单用法


    envsetup.sh内容:

    xxxx@rmxx07:/work/buildfarm/smxxxx_vnd$ head -50 build/envsetup.sh
    function hmm() {
    cat <<EOF
    
    Run "m help" for help with the build system itself.
    
    Invoke ". build/envsetup.sh" from your shell to add the following functions to your environment:
    - lunch:      lunch <product_name>-<build_variant>
                  Selects <product_name> as the product to build, and <build_variant> as the variant to
                  build, and stores those selections in the environment to be read by subsequent
                  invocations of 'm' etc.
    - tapas:      tapas [<App1> <App2> ...] [arm|x86|arm64|x86_64] [eng|userdebug|user]
                  Sets up the build environment for building unbundled apps (APKs).
    - banchan:    banchan <module1> [<module2> ...] [arm|x86|arm64|x86_64] [eng|userdebug|user]
                  Sets up the build environment for building unbundled modules (APEXes).
    - croot:      Changes directory to the top of the tree, or a subdirectory thereof.
    - m:          Makes from the top of the tree.
    - mm:         Builds and installs all of the modules in the current directory, and their
                  dependencies.
    - mmm:        Builds and installs all of the modules in the supplied directories, and their
                  dependencies.
                  To limit the modules being built use the syntax: mmm dir/:target1,target2.
    - mma:        Same as 'mm'
    - mmma:       Same as 'mmm'
    - provision:  Flash device with all required partitions. Options will be passed on to fastboot.
    - cgrep:      Greps on all local C/C++ files.
    - ggrep:      Greps on all local Gradle files.
    - gogrep:     Greps on all local Go files.
    - jgrep:      Greps on all local Java files.
    - ktgrep:     Greps on all local Kotlin files.
    - resgrep:    Greps on all local res/*.xml files.
    - mangrep:    Greps on all local AndroidManifest.xml files.
    - mgrep:      Greps on all local Makefiles and *.bp files.
    - owngrep:    Greps on all local OWNERS files.
    - rsgrep:     Greps on all local Rust files.
    - sepgrep:    Greps on all local sepolicy files.
    - sgrep:      Greps on all local source files.
    - godir:      Go to the directory containing a file.
    - allmod:     List all modules.
    - gomod:      Go to the directory containing a module.
    - pathmod:    Get the directory containing a module.
    - outmod:     Gets the location of a module's installed outputs with a certain extension.
    - dirmods:    Gets the modules defined in a given directory.
    - installmod: Adb installs a module's built APK.
    - refreshmod: Refresh list of modules for allmod/gomod/pathmod/outmod/installmod.
    - syswrite:   Remount partitions (e.g. system.img) as writable, rebooting if necessary.
    
    Environment options:
    - SANITIZE_HOST: Set to 'address' to use ASAN for all host modules.
    - ANDROID_QUIET_BUILD: set to 'true' to display only the essential messages.
    

    使用Demo:

    - croot:      Changes directory to the top of the tree, or a subdirectory thereof.
    - godir:      Go to the directory containing a file. #就是字面意思 
    
    xxx@rmxx07:/work/xxx/smxxx_vnd/frameworks/base/core/java/android/app$ croot
    xxx@rmxx07:/work/xxx/smxxx_vnd$ godir DownloadManager.java
       [1] ./external/exoplayer/tree_15dc86382f17a24a3e881e52e31a810c1ea44b49/library/core/src/main/java/com/google/android/exoplayer2/offline
       [2] ./external/exoplayer/tree_410ddf458c4daebcf3f997084891c82f2dbd6805/library/core/src/main/java/com/google/android/exoplayer2/offline
       [3] ./external/exoplayer/tree/library/core/src/main/java/com/google/android/exoplayer2/offline
       [4] ./external/libtextclassifier/java/src/com/android/textclassifier/downloader
       [5] ./external/robolectric-shadows/shadows/framework/src/main/java/org/robolectric/shadows
       [6] ./frameworks/base/core/java/android/app
       [7] ./frameworks/opt/telephony/src/java/com/android/internal/telephony
       [8] ./vendor/codeaurora/commonsys/packages/apps/Mms/src/com/android/mms/util
    
    Select one: 6
    buildfarm@rmbj07:/work/buildfarm/sm8550_vnd/frameworks/base/core/java/android/app$ ll DownloadManager.java
    -rw-rw-r-- 1 buildfarm buildfarm 77258 Jun  2 11:12 DownloadManager.java
    buildfarm@rmbj07:/work/buildfarm/sm8550_vnd/frameworks/base/core/java/android/app$
    

    godir方法函数实现:

    function godir () {
        if [[ -z "$1" ]]; then
            echo "Usage: godir <regex>"
            return
        fi
        local T=$(gettop)
        local FILELIST
        if [ ! "$OUT_DIR" = "" ]; then
            mkdir -p $OUT_DIR
            FILELIST=$OUT_DIR/filelist
        else
            FILELIST=$T/filelist
        fi
        if [[ ! -f $FILELIST ]]; then
            echo -n "Creating index..."
            (\cd $T; find . -wholename ./out -prune -o -wholename ./.repo -prune -o -type f > $FILELIST)
            echo " Done"
            echo ""
        fi
        local lines
        lines=($(\grep "$1" $FILELIST | sed -e 's/\/[^/]*$//' | sort | uniq))
        if [[ ${#lines[@]} = 0 ]]; then
            echo "Not found"
            return
        fi
        local pathname
        local choice
        if [[ ${#lines[@]} > 1 ]]; then
            while [[ -z "$pathname" ]]; do
                local index=1
                local line
                for line in ${lines[@]}; do
                    printf "%6s %s\n" "[$index]" $line
                    index=$(($index + 1))
                done
                echo
                echo -n "Select one: "
                unset choice
                read choice
                if [[ $choice -gt ${#lines[@]} || $choice -lt 1 ]]; then
                    echo "Invalid choice"
                    continue
                fi
                pathname=${lines[@]:$(($choice-1)):1}
            done
        else
            pathname=${lines[@]:0:1}
        fi
        \cd $T/$pathname
    }
    
  • 相关阅读:
    Python【第五篇】模块、包、常用模块
    Python【第四篇】函数、内置函数、递归、装饰器、生成器和迭代器
    TCP三次握手、四次挥手
    分别用postman和python做post请求接口功能测试
    Python【第三篇】文件操作、字符编码
    Python【第二篇】运算符及优先级、数据类型及常用操作、深浅拷贝
    Python【第一篇】python安装、pip基本用法、变量、输入输出、流程控制、循环
    oracle在windows(含客户端工具pl/sql安装)下安装
    Python【初识篇】简介
    Web jsp开发自学——ajax+servlet+echarts+json+gson 实现ajax传输servlert和echarts的数据,可视化结果
  • 原文地址:https://www.cnblogs.com/wucaiyun1/p/16357337.html
Copyright © 2020-2023  润新知