获取源码
首先,我们拉一份最新的源代码(笔者是2024.6.6日拉取的):
fetch --nohistory chromium
源码预处理
如果运行build,会生成许多生成的代码,因此我们不运行build。
然后,把干扰后续分析的.git目录删除。这次拉取仅仅从源文件的物理结构对chromium进行分析。
rd /s /q .git
然后删除testsdata、test等相关的文件,减少理解源码功能的干扰。
@echo off
setlocal enabledelayedexpansion
REM Define the root directory to start searching from
set "ROOT_DIR=src"
REM Find all directories named "test" under the root directory and delete them
for /r "%ROOT_DIR%" %%d in (test) do (
if /i "%%~nxd"=="test" (
echo Deleting: "%%d"
rd /s /q "%%d"
)
)
echo Deletion complete.
endlocal
还手动删除了一些数据
获取数据
目录体积一览
用space sniffer 可视化观察源码目录体积的情况,有个大概的印象:
从src根目录:可见体积最大的是third-party,占据了接近80%
放大我们后面会重点关注的src/content部分:
以及重点关注的thirdparty/blink:
文件类型聚类
接着,我们写个脚本,按文件类型,统计个数和大小:(File Types Analysis)
Extension | File Count | Total Size (bytes) |
---|---|---|
.h | 92392 | 774105533 |
.cc | 78700 | 1011699744 |
[none] | 32369 | 528603110 |
.js | 22251 | 268799787 |
.sha1 | 21563 | 863072 |
.c | 18014 | 321187291 |
.py | 17853 | 193770487 |
.cpp | 15631 | 342358247 |
.html | 13107 | 77496984 |
.ts | 12298 | 87919096 |
.txt | 10025 | 163453438 |
.java | 9697 | 81780064 |
.pbtxt | 7673 | 14195049 |
.json | 7410 | 272957548 |
.md | 6227 | 31809118 |
.go | 5715 | 72429888 |
.gn | 5703 | 20890844 |
.png | 5611 | 102977493 |
.mm | 5519 | 44819979 |
.xtb | 5163 | 323351125 |
.frag | 4205 | 7609282 |
.pm | 3658 | 49830859 |
.xml | 3046 | 35833237 |
.map | 2953 | 48570301 |
.vert | 2761 | 4519297 |
.idl | 2714 | 6330826 |
.rs | 2337 | 50053349 |
.proto | 2132 | 9426761 |
.mojom | 1799 | 6385653 |
.sample | 1754 | 3230720 |
.yaml | 1707 | 3040011 |
.in | 1643 | 11598760 |
.sh | 1640 | 6088675 |
.pl | 1517 | 12907535 |
.icon | 1444 | 1821459 |
.css | 1376 | 8287662 |
.csv | 1351 | 65891710 |
.pod | 1326 | 23668650 |
.svg | 1285 | 12072576 |
.rst | 1196 | 7395627 |
.comp | 1164 | 2427107 |
.td | 1034 | 42924563 |
.S | 913 | 22159427 |
.gni | 848 | 5068002 |
.chromium | 826 | 634536 |
.cfg | 748 | 6186795 |
.inc | 744 | 292674669 |
.yml | 660 | 1235700 |
.cmake | 618 | 2809973 |
.asm | 606 | 16150717 |
.sksl | 601 | 638268 |
.ttf | 594 | 26986702 |
.bazel | 583 | 2224953 |
.pem | 569 | 7965101 |
.hpp | 566 | 33897254 |
.bzl | 551 | 4452617 |
.dll | 536 | 206950836 |
.s | 489 | 3164768 |
.test | 462 | 2524462 |
.a | 460 | 91781731 |
.tmpl | 459 | 1411432 |
427 | 161248367 | |
.utf8 | 424 | 11190941 |
.cjs | 399 | 3569046 |
.bin | 352 | 96919280 |
.patch | 351 | 2601932 |
.sql | 343 | 1388571 |
.def | 334 | 6722034 |
.m | 331 | 2704565 |
.hh | 327 | 3742006 |
.pyc | 310 | 3421089 |
.gif | 305 | 7698487 |
.rts | 294 | 202898 |
.wav | 284 | 10097254 |
.bat | 282 | 1842961 |
.BUILD | 277 | 472005 |
.vk | 271 | 161213 |
.key | 264 | 425547 |
.jpg | 256 | 12667896 |
.en | 246 | 5889240 |
.tq | 243 | 1415868 |
.template | 238 | 604356 |
.ucm | 222 | 20039087 |
.exe | 220 | 975639548 |
.tesc | 220 | 938125 |
.pb | 211 | 220387 |
.mk | 211 | 545744 |
.toml | 208 | 327721 |
.cs | 205 | 3693035 |
.webp | 203 | 4960153 |
.swift | 199 | 885223 |
.php | 195 | 1528709 |
.mjs | 186 | 3113129 |
.star | 178 | 2438276 |
.so | 178 | 13949612 |
.rb | 166 | 679869 |
.pyi | 144 | 304030 |
.grdp | 140 | 4163500 |
.grd | 136 | 5951416 |
.plist | 133 | 211718 |
.pdb | 130 | 76857344 |
.tese | 127 | 465412 |
.zip | 120 | 7022009 |
.euc-kr | 109 | 1966786 |
.ico | 106 | 2780310 |
.m4 | 102 | 2198456 |
.tpl | 102 | 793106 |
.man | 101 | 357309 |
.mdoc | 99 | 324131 |
.idx | 95 | 10188780 |
.pack | 91 | 1356462055 |
.rev | 91 | 1446336 |
.gz | 89 | 127234439 |
.rc | 87 | 168686 |
.conf | 85 | 242049 |
.pydeps | 82 | 137908 |
.dict | 82 | 356797 |
.al | 82 | 64043 |
.yapf | 81 | 6371 |
.dox | 80 | 549790 |
.orig | 79 | 130748 |
.current_version | 77 | 14439 |
.1 | 75 | 443936 |
.avif | 70 | 1305373 |
.expected | 68 | 863150 |
.json5 | 68 | 1213323 |
.jsx | 68 | 109086 |
.diff | 66 | 721048 |
.mock-http-headers | 63 | 4294 |
.ogg | 61 | 591480 |
.info | 61 | 172965 |
.ini | 58 | 34332 |
.woff2 | 58 | 1331069 |
.fbs | 57 | 335138 |
.tcl | 57 | 377715 |
.pxi | 57 | 257149 |
.bdic | 57 | 112934430 |
.vue | 57 | 110081 |
.build | 55 | 226201 |
.scss | 55 | 192410 |
.kt | 54 | 386835 |
.textpb | 53 | 69376 |
.dsc | 53 | 48662 |
.dart | 53 | 344885 |
.hyb | 52 | 1762492 |
.nc | 51 | 137573 |
.am | 51 | 642858 |
.f | 51 | 1364188 |
.cmd | 50 | 96767 |
.jst | 50 | 99630 |
.264 | 50 | 54395740 |
.geom | 50 | 44572 |
.include | 49 | 199229 |
.woff | 49 | 924084 |
.xhtml | 49 | 515027 |
.texi | 49 | 1956440 |
.aff | 49 | 13875810 |
.dic | 49 | 154174446 |
.textproto | 48 | 2488935 |
.lock | 48 | 3109574 |
.tlb | 45 | 525492 |
.settings | 44 | 10278 |
.tcc | 44 | 910592 |
.evt | 44 | 7131 |
.gradle | 43 | 70306 |
.aidl | 40 | 42663 |
.TXT | 40 | 272529 |
.pyd | 40 | 6201920 |
.properties | 40 | 19738 |
.eot | 40 | 1361708 |
.rchit | 40 | 7308 |
.storyboard | 37 | 231466 |
.mp4 | 37 | 1882958 |
.lds | 36 | 23048 |
.ipynb | 36 | 975712 |
.flags | 34 | 30045 |
.mod | 33 | 36815 |
.options | 33 | 1192 |
.pc | 33 | 25004 |
.compute | 33 | 30662 |
.jinja2 | 31 | 66533 |
.pyl | 31 | 699967 |
.typed | 31 | 488 |
.lua | 31 | 407540 |
.lib | 30 | 33084384 |
.pbxproj | 30 | 902205 |
.dot | 29 | 66483 |
.strings | 29 | 32513 |
.raw | 29 | 384009 |
.modulemap | 29 | 539586 |
.dic_delta | 29 | 442796 |
.hxx | 27 | 139938 |
.jpeg | 27 | 7161209 |
.jar | 26 | 23377841 |
.dat | 26 | 66069008 |
.j2 | 26 | 39960 |
.es | 26 | 980221 |
.enc | 26 | 280997 |
.unitjs | 26 | 418755 |
.ps1 | 25 | 84450 |
.rules | 23 | 820993 |
.errordata | 23 | 23597 |
.inl | 23 | 508913 |
.xsl | 23 | 335774 |
.podspec | 23 | 522317 |
.vcproj | 22 | 539682 |
.cxx | 22 | 1156567 |
.mac | 22 | 80583 |
.log | 21 | 186461 |
.de | 21 | 868870 |
.o | 21 | 41389 |
.cur | 21 | 56918 |
.wasm | 20 | 9476297 |
.hlsl | 20 | 96103 |
.fragment | 20 | 30580 |
.sln | 20 | 90004 |
.manifest | 19 | 14019 |
.ver | 19 | 9448 |
.bmp | 19 | 641343 |
.webm | 19 | 1367036 |
.markdown | 19 | 111988 |
.hjson | 19 | 34354 |
.mesh | 19 | 71472 |
.cipd_version | 18 | 2187 |
.var | 18 | 194614 |
.exp | 18 | 249790 |
.el | 18 | 83197 |
.rgen | 18 | 15726 |
.version | 17 | 15636 |
.entitlements | 17 | 7073 |
.sum | 17 | 124231 |
.tar | 17 | 247808 |
.vcxproj | 17 | 185018 |
.bazelrc | 17 | 44017 |
.hlo | 17 | 839360 |
.jinja | 16 | 15027 |
.cnf | 16 | 38464 |
.ac | 16 | 288424 |
.BSD | 16 | 20320 |
.bp | 16 | 1026851 |
.sb | 15 | 45622 |
.asset | 15 | 39079 |
.applescript | 14 | 9784 |
.dtd | 14 | 493656 |
.meson | 14 | 4077 |
.bash | 14 | 24521 |
.bnf | 14 | 8666 |
.cl | 14 | 73704 |
src 一级目录信息提取:写一段python脚本,自动提取第一层目录的特征和readme:
接下来移步:Chroium 源码目录结构分析(2)-CSDN博客