xref: /DragonOS/docs/kernel/configuration/config.md (revision e4600f7f7d8f2295dbf970812ab1fcab81eb6eae)
1*e4600f7fSJomo# 内核编译配置说明
2*e4600f7fSJomo
3*e4600f7fSJomo## 原理
4*e4600f7fSJomo
5*e4600f7fSJomo  在内核目录下,用kernel.config来设置内核编译配置信息,以类似解析toml文件的方式去解析该文件,然后接着去解析各模块下的d.config以获取feature的启用情况
6*e4600f7fSJomo
7*e4600f7fSJomo## 示例
8*e4600f7fSJomo
9*e4600f7fSJomo**kernel.config**
10*e4600f7fSJomo
11*e4600f7fSJomo```toml
12*e4600f7fSJomo[[module.include]]
13*e4600f7fSJomoname = "init"
14*e4600f7fSJomopath = "src/init/"
15*e4600f7fSJomoenable = "y"
16*e4600f7fSJomodescription = ""
17*e4600f7fSJomo
18*e4600f7fSJomo[[module.include]]
19*e4600f7fSJomoname = "mm"
20*e4600f7fSJomopath = "src/mm/"
21*e4600f7fSJomoenable = "y"
22*e4600f7fSJomodescription = ""
23*e4600f7fSJomo```
24*e4600f7fSJomo
25*e4600f7fSJomo
26*e4600f7fSJomo- **[[module.include]]:** 将模块加入到include列表中
27*e4600f7fSJomo- **name:** 模块名
28*e4600f7fSJomo- **path:** 模块路径,存放着d.config
29*e4600f7fSJomo- **enable:**
30*e4600f7fSJomo  - **y:** 启用,解析模块下的d.config
31*e4600f7fSJomo  - **n:** 不启用,不解析
32*e4600f7fSJomo- **description:** 模块的描述信息
33*e4600f7fSJomo
34*e4600f7fSJomo
35*e4600f7fSJomo**src/mm/d.config**
36*e4600f7fSJomo
37*e4600f7fSJomo```toml
38*e4600f7fSJomo[module]
39*e4600f7fSJomoname = "mm"
40*e4600f7fSJomodescription = ""
41*e4600f7fSJomo
42*e4600f7fSJomo[[module.include]]
43*e4600f7fSJomoname = "allocator"
44*e4600f7fSJomopath = "src/mm/allocator/"
45*e4600f7fSJomoenable = "y"
46*e4600f7fSJomodescription = ""
47*e4600f7fSJomo
48*e4600f7fSJomo[[module.features]]
49*e4600f7fSJomoname = "mm_debug"
50*e4600f7fSJomoenable = "y"
51*e4600f7fSJomodescription = ""
52*e4600f7fSJomo```
53*e4600f7fSJomo
54*e4600f7fSJomo
55*e4600f7fSJomo- **\[module\]:** 当前模块
56*e4600f7fSJomo  - **name:** 当前模块名称
57*e4600f7fSJomo  - **description:** 模块的描述信息
58*e4600f7fSJomo- **[[module.include]]:** 当前模块下所包含的模块,与kernel.config下的相同
59*e4600f7fSJomo- **[[module.features]]:** 当前模块下的feature
60*e4600f7fSJomo  - **name:** feature名
61*e4600f7fSJomo  - **enable:** 是否开启
62*e4600f7fSJomo    - **y:** 开启
63*e4600f7fSJomo    - **n:** 不开启
64*e4600f7fSJomo  - **description:** feature的描述信息
65*e4600f7fSJomo
66*e4600f7fSJomo
67*e4600f7fSJomo*以下是其它模块下的d.config:*
68*e4600f7fSJomo
69*e4600f7fSJomo**src/mm/allocator/d.config**
70*e4600f7fSJomo
71*e4600f7fSJomo```toml
72*e4600f7fSJomo[module]
73*e4600f7fSJomoname = "allocator"
74*e4600f7fSJomodescription = ""
75*e4600f7fSJomo
76*e4600f7fSJomo[[module.features]]
77*e4600f7fSJomoname = "allocator_debug"
78*e4600f7fSJomoenable = "y"
79*e4600f7fSJomodescription = ""
80*e4600f7fSJomo```
81*e4600f7fSJomo
82*e4600f7fSJomo**src/init/d.config**
83*e4600f7fSJomo
84*e4600f7fSJomo```toml
85*e4600f7fSJomo[module]
86*e4600f7fSJomoname = "init"
87*e4600f7fSJomodescription = ""
88*e4600f7fSJomo
89*e4600f7fSJomo[[module.features]]
90*e4600f7fSJomoname = "init_debug"
91*e4600f7fSJomoenable = "y"
92*e4600f7fSJomodescription = ""
93*e4600f7fSJomo```
94*e4600f7fSJomo
95*e4600f7fSJomo
96*e4600f7fSJomo上面所有已开启模块的d.config中的feature,会最终生成到内核目录下的D.config文件,即D.config是最终内核编译的配置,如下:
97*e4600f7fSJomo
98*e4600f7fSJomo
99*e4600f7fSJomo**D.config**
100*e4600f7fSJomo
101*e4600f7fSJomo```
102*e4600f7fSJomoinit_debug = y
103*e4600f7fSJomoallocator_debug = y
104*e4600f7fSJomomm_debug = y
105*e4600f7fSJomo```