首頁 > 軟體

VScode 隱藏大量無用的檔案比如在看Linux kernel或boot時候

2022-10-14 14:02:11

1. VScode 工程建立

先在 Ubuntu 下編譯一下 uboot,然後將編譯後的 uboot 資料夾複製到 windows 下,並建立VScode 工程。開啟 VScode,選擇:檔案->開啟資料夾…,選中 uboot 資料夾,如圖所示:

點選“檔案->將工作區另存為…”,開啟儲存工作區對話方塊,將工作區儲存到 uboot 原始碼根目錄下,設定檔名為“uboot”

2. 使用步驟

儲存成功以後就會在 uboot 原始碼根目錄下存在一個名為 uboot.code-workspace 的檔案。這樣一個完整的 VSCode 工程就建立起來了。但是這個 VSCode 工程包含了 uboot 的所有檔案, uboot中有些檔案是不需要的,比如 arch 目錄下是各種架構的資料夾,

在 arch 目錄下,我們只需要 arm 資料夾,所以需要將其它的目錄從 VSCode 中給遮蔽掉,比如將 arch/avr32 這個目錄給遮蔽掉。在 VSCode 上建名為“.vscode”的資料夾,

在.vscode 資料夾中新建一個名為“settings.json”的檔案,然後在 settings.json 中輸入如下內容:

{
"search.exclude": {
        "**/*.o":true,
        "**/*.su":true,
        "**/*.cmd":true,
        "arch/arc":true,
        "arch/avr32":true,
        "arch/blackfin":true,
        "arch/m68k":true,
        "arch/microblaze":true,
        "arch/mips":true,
        "arch/nds32":true,
        "arch/nios2":true,
        "arch/openrisc":true,
        "arch/powerpc":true,
        "arch/sandbox":true,
        "arch/sh":true,
        "arch/sparc":true,
        "arch/x86":true,
        "arch/arm/mach*":true,
        "arch/arm/cpu/arm11*":true,
        "arch/arm/cpu/arm720t":true,
        "arch/arm/cpu/arm9*":true,
        "arch/arm/cpu/armv7m":true,
        "arch/arm/cpu/armv8":true,
        "arch/arm/cpu/pxa":true,
        "arch/arm/cpu/sa1100":true,
        "board/[a-e]*":true,
        "board/[g-z]*":true,
        "board/[0-9]*":true,
        "board/[A-Z]*":true,
        "board/fir*":true,
        "board/freescale/b*":true,
        "board/freescale/l*":true,
        "board/freescale/m5*":true,
        "board/freescale/mp*":true,
        "board/freescale/c29*":true,
        "board/freescale/cor*":true,
        "board/freescale/mx7*":true,
        "board/freescale/mx2*":true,
        "board/freescale/mx3*":true,
        "board/freescale/mx5*":true,
        "board/freescale/p*":true,
        "board/freescale/q*":true,
        "board/freescale/t*":true,
        "board/freescale/v*":true,
        "configs/[a-l]*":true,
        "configs/[n-z]*":true,
        "configs/[A-Z]*":true,
        "configs/M[a-z]*":true,
        "configs/M[A-Z]*":true,
        "configs/M[0-9]*":true,
        "configs/m[a-w]*":true,
        "configs/m[0-9]*":true,
        "configs/[0-9]*":true,
        "include/configs/[a-l]*":true,
        "include/configs/[n-z]*":true,
        "include/configs/[A-Z]*":true,
        "include/configs/m[a-w]*":true,
    },
    "files.exclude": {
        "**/*.o":true,
        "**/*.su":true,
        "**/*.cmd":true,
        "arch/arc":true,
        "arch/avr32":true,
        "arch/blackfin":true,
        "arch/m68k":true,
        "arch/microblaze":true,
        "arch/mips":true,
        "arch/nds32":true,
        "arch/nios2":true,
        "arch/openrisc":true,
        "arch/powerpc":true,
        "arch/sandbox":true,
        "arch/sh":true,
        "arch/sparc":true,
        "arch/x86":true,
        "arch/arm/mach*":true,
        "arch/arm/cpu/arm11*":true,
        "arch/arm/cpu/arm720t":true,
        "arch/arm/cpu/arm9*":true,
        "arch/arm/cpu/armv7m":true,
        "arch/arm/cpu/armv8":true,
        "arch/arm/cpu/pxa":true,
        "arch/arm/cpu/sa1100":true,
        "board/[a-e]*":true,
        "board/[g-z]*":true,
        "board/[0-9]*":true,
        "board/[A-Z]*":true,
        "board/fir*":true,
        "board/freescale/b*":true,
        "board/freescale/l*":true,
        "board/freescale/m5*":true,
        "board/freescale/mp*":true,
        "board/freescale/c29*":true,
        "board/freescale/cor*":true,
        "board/freescale/mx7*":true,
        "board/freescale/mx2*":true,
        "board/freescale/mx3*":true,
        "board/freescale/mx5*":true,
        "board/freescale/p*":true,
        "board/freescale/q*":true,
        "board/freescale/t*":true,
        "board/freescale/v*":true,
        "configs/[a-l]*":true,
        "configs/[n-z]*":true,
        "configs/[A-Z]*":true,
        "configs/M[a-z]*":true,
        "configs/M[A-Z]*":true,
        "configs/M[0-9]*":true,
        "configs/m[a-w]*":true,
        "configs/m[0-9]*":true,
        "configs/[0-9]*":true,
        "include/configs/[a-l]*":true,
        "include/configs/[n-z]*":true,
        "include/configs/[A-Z]*":true,
        "include/configs/m[a-w]*":true,
    }   
}

其中"search.exclude"裡面是需要在搜尋結果中排除的檔案或者資料夾, "files.exclude"是左側工程目錄中需要排除的檔案或者資料夾。我們需要將 在arc資料夾中除了 arm 以及board資料夾中除了freescale 資料夾下的所有檔案從搜尋結果和左側的工程目錄中都排除掉,因此在 "search.exclude"和"files.exclude"中輸入如圖

上述程式碼用到了萬用字元“”,比如“**/.o”表示所有.o 結尾的檔案。“configs/[a-l]*”表示 configs 目錄下所有以‘a’ ~‘l’開頭的檔案或者資料夾。 上述設定只是排除了一部分資料夾,大家在實際的使用中可以根據自己的實際需求來選擇將哪些檔案或者資料夾排除掉。排除以後我們的工程就會清爽很多,搜尋的時候也不會跳出很多檔案了。

3. 在Linux kernel中,要忽略掉的內容

{
    "search.exclude": {
        "**/node_modules": true,
        "**/bower_components": true,
        "**/*.o":true,
        "**/*.su":true, 
        "**/*.cmd":true,
        "Documentation":true, 

        /* 遮蔽不用的架構相關的檔案 */
        "arch/alpha":true,
        "arch/arc":true,
        "arch/arm64":true,
        "arch/avr32":true,
        "arch/[b-z]*":true,
        "arch/arm/plat*":true,   
        "arch/arm/mach-[a-h]*":true,   
        "arch/arm/mach-[n-z]*":true,  
        "arch/arm/mach-i[n-z]*":true, 
        "arch/arm/mach-m[e-v]*":true, 
        "arch/arm/mach-k*":true, 
        "arch/arm/mach-l*":true, 

        /* 遮蔽排除不用的組態檔 */
        "arch/arm/configs/[a-h]*":true, 
        "arch/arm/configs/[j-z]*":true, 
        "arch/arm/configs/imo*":true, 
        "arch/arm/configs/in*":true, 
        "arch/arm/configs/io*":true, 
        "arch/arm/configs/ix*":true, 

        /* 遮蔽掉不用的DTB檔案 */
        "arch/arm/boot/dts/[a-h]*":true, 
        "arch/arm/boot/dts/[k-z]*":true, 
        "arch/arm/boot/dts/in*":true, 
        "arch/arm/boot/dts/imx1*":true, 
        "arch/arm/boot/dts/imx7*":true, 
        "arch/arm/boot/dts/imx2*":true, 
        "arch/arm/boot/dts/imx3*":true, 
        "arch/arm/boot/dts/imx5*":true, 
        "arch/arm/boot/dts/imx6d*":true, 
        "arch/arm/boot/dts/imx6q*":true, 
        "arch/arm/boot/dts/imx6s*":true, 
        "arch/arm/boot/dts/imx6ull-9x9*":true, 
        "arch/arm/boot/dts/imx6ull-14x14-ddr*":true, 
        "arch/arm/boot/dts/*.tmp":true,       
    },
    "files.exclude": {
        "**/.git": true,
        "**/.svn": true,
        "**/.hg": true,
        "**/CVS": true,
        "**/.DS_Store": true,  
        "**/*.o":true,
        "**/*.su":true, 
        "**/*.cmd":true,
        "Documentation":true, 

        /* 遮蔽不用的架構相關的檔案 */
        "arch/alpha":true,
        "arch/arc":true,
        "arch/arm64":true,
        "arch/avr32":true,
        "arch/[b-z]*":true,
        "arch/arm/plat*":true,   
        "arch/arm/mach-[a-h]*":true,   
        "arch/arm/mach-[n-z]*":true,  
        "arch/arm/mach-i[n-z]*":true, 
        "arch/arm/mach-m[e-v]*":true, 
        "arch/arm/mach-k*":true, 
        "arch/arm/mach-l*":true, 

        /* 遮蔽排除不用的組態檔 */
        "arch/arm/configs/[a-h]*":true, 
        "arch/arm/configs/[j-z]*":true, 
        "arch/arm/configs/imo*":true, 
        "arch/arm/configs/in*":true, 
        "arch/arm/configs/io*":true, 
        "arch/arm/configs/ix*":true, 

        /* 遮蔽掉不用的DTB檔案 */
        "arch/arm/boot/dts/[a-h]*":true, 
        "arch/arm/boot/dts/[k-z]*":true, 
        "arch/arm/boot/dts/in*":true, 
        "arch/arm/boot/dts/imx1*":true, 
        "arch/arm/boot/dts/imx7*":true, 
        "arch/arm/boot/dts/imx2*":true, 
        "arch/arm/boot/dts/imx3*":true, 
        "arch/arm/boot/dts/imx5*":true, 
        "arch/arm/boot/dts/imx6d*":true, 
        "arch/arm/boot/dts/imx6q*":true, 
        "arch/arm/boot/dts/imx6s*":true, 
        "arch/arm/boot/dts/imx6ull-9x9*":true, 
        "arch/arm/boot/dts/imx6ull-14x14-ddr*":true, 
        "arch/arm/boot/dts/*.tmp":true, 
    },
    "files.associations": {
        "kernel.h": "c",
        "fs.h": "c",
        "list.h": "c",
        "init.h": "c",
        "i2c.h": "c",
        "uaccess.h": "c",
        "i2c-dev.h": "c",
        "module.h": "c",
        "slab.h": "c"
    },
}

到此這篇關於VScode 隱藏大量無用的檔案比如在看Linux kernel或boot時候的文章就介紹到這了,更多相關VScode 隱藏無用檔案內容請搜尋it145.com以前的文章或繼續瀏覽下面的相關文章希望大家以後多多支援it145.com!


IT145.com E-mail:sddin#qq.com