Skip to content

Commit a607d87

Browse files
authored
Merge pull request #1670 from espressif/docs/translate_cmakelists_editor_resubmit
Provide CN translation for cmakelists-editor.rst (resubmit)
2 parents 0646ac7 + d907a6c commit a607d87

File tree

2 files changed

+109
-36
lines changed

2 files changed

+109
-36
lines changed
Lines changed: 39 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,66 +1,70 @@
11
CMakeLists.txt Editor
2-
==============================
2+
=====================
3+
4+
:link_to_translation:`zh_CN:[中文]`
35

46
.. warning::
5-
* This will override any existing code in the file with the one generated in the editor. If you have any code not included in the schema (or single line comments) use a regular text editor instead.
67

7-
When you right click on any CMakeLists.txt file this extension provides a custom CMakeLists.txt Editor to fill an ESP-IDF Project and Component Registration as specified in:
8+
This will override any existing code in the file with the one generated in the editor. If you have any code not included in the schema (or single line comments), use a regular text editor instead.
9+
10+
When you right-click any ``CMakeLists.txt`` file, this extension provides a custom ``CMakeLists.txt`` editor to fill an ESP-IDF project and component registration as specified in:
811

9-
- `ESP-IDF Project CMakeLists.txt <https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-guides/build-system.html#project-cmakelists-file>`_
10-
- `ESP-IDF Component CMakeLists.txt Files <https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-guides/build-system.html#component-cmakelists-files>`_
12+
- `Project CMakeLists File <https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-guides/build-system.html#project-cmakelists-file>`_
13+
- `Component CMakeLists Files <https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-guides/build-system.html#component-cmakelists-files>`_
1114

12-
You need to choose which kind of CMakeLists.txt file (project or component) to edit. There is 2 types of input, one is a simple string and another is an array of strings, such as Component Sources (SRCS).
15+
You need to choose which kind of ``CMakeLists.txt`` file (project or component) to edit. There are two types of input: a simple string and an array of strings, such as Component Sources (SRCS).
1316

1417
.. note::
15-
* All inputs are described in the `CMakeLists.txt schema <https://github.com/espressif/vscode-esp-idf-extension/blob/master/cmakeListsSchema.json>`_
16-
* This editor doesn't support all CMake functions and syntaxes. This editor should only be used for simple CMakeLists.txt options such as component registration (using idf_component_register) and basic project elements. If you need more customization or advanced CMakeLists.txt, consider reviewing `ESP-IDF Build System <https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-guides/build-system.html>`_. Also review **CMakeLists.txt editor schema** for a list of supported code.
1718

19+
* All inputs are described in the `CMakeLists.txt schema <https://github.com/espressif/vscode-esp-idf-extension/blob/master/cmakeListsSchema.json>`_.
20+
* This editor doesn't support all CMake functions and syntax. Use it only for simple ``CMakeLists.txt`` options, such as component registration (using ``idf_component_register``) and basic project elements. For more customization or advanced ``CMakeLists.txt``, review `ESP-IDF Build System <https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-guides/build-system.html>`_. You may also refer to **CMakeLists.txt editor schema** for a list of supported code.
1821

19-
For this tutorial we will use the get-started's blink example.
22+
For this tutorial we will use the blink example.
2023

21-
1. Right click the ``<project_path>/blink/CMakeLists.txt``, click on **ESP-IDF: CMakeLists.txt Editor** and select ``Project CMakeLists.txt``.
24+
1. Right-click the ``<project_path>/blink/CMakeLists.txt``, click ``ESP-IDF: CMakeLists.txt Editor`` and select ``Project CMakeLists.txt``.
2225

23-
.. image:: ../../../media/tutorials/cmakelists_editor/cmakelists_editor.png
26+
.. image:: ../../../media/tutorials/cmakelists_editor/cmakelists_editor.png
2427

25-
2. We can add new elements by selecting them from the ``New Element`` dropdown and clicking the ``Add`` button. For simplicity we will just change the project name and save changes with the ``Save`` button.
28+
2. Add new elements by selecting them from the ``New Element`` dropdown and clicking the ``Add`` button. For simplicity, change the project name and save changes with the ``Save`` button.
2629

27-
We can observe when we re-open the file in a regular text-editor changes are reflected.
30+
When re-opening the file in a regular text editor, changes are reflected.
2831

29-
3. Now let's create a new ESP-IDF component in this project to modify its ``CMakeLists.txt``. Click menu **View** > **Command Palette** and type **ESP-IDF: Create New ESP-IDF Component** and enter the new component name.
32+
3. Create a new ESP-IDF component in this project to modify its ``CMakeLists.txt``. Go to menu ``View`` > ``Command Palette``, type ``ESP-IDF: Create New ESP-IDF Component``, and enter the new component name.
3033

31-
4. A new component will be created in ``<project_path>/blink/components/<component_name>``. Opening in the regular text editor, you will see an ``idf_component_register`` method with:
34+
4. A new component will be created in ``<project_path>/blink/components/<component_name>``. Open ``CMakeLists.txt`` in the regular text editor, you will see an ``idf_component_register`` method with:
3235

33-
.. code-block:: C
36+
.. code-block:: C
3437
35-
idf_component_register(SRCS "my_component.c"
36-
INCLUDE_DIRS "include")
38+
idf_component_register(SRCS "my_component.c"
39+
INCLUDE_DIRS "include")
3740
38-
Right click on ``<project_path>/blink/components/<component_name>/CMakeLists.txt``, click on **ESP-IDF: CMakeLists.txt Editor** and select ``Component CMakeLists.txt``.
41+
Right-click ``<project_path>/blink/components/<component_name>/CMakeLists.txt``, click ``ESP-IDF: CMakeLists.txt Editor`` and select ``Component CMakeLists.txt``.
3942

40-
.. image:: ../../../media/tutorials/cmakelists_editor/components_editor.png
43+
.. image:: ../../../media/tutorials/cmakelists_editor/components_editor.png
4144

42-
5. Observe that some fields are of array types such as **Component Sources (SRCS)** since we can add several paths while other are just string input fields (as described in cmakeListsSchema.json).
45+
5. Observe that some fields are of array types such as **Component Sources (SRCS)** since you can add several paths, while others are just string input fields (as described in ``cmakeListsSchema.json``).
4346

44-
.. note::
45-
While using this extension, source files are added and deleted automatically from the same directory where CMakeLists.txt is located without user intervention.
47+
.. note::
48+
49+
While using this extension, source files are added and deleted automatically from the same directory where ``CMakeLists.txt`` is located without user intervention.
4650

47-
6. Add a new element ``Public Component Requirements for the Component (REQUIRES)`` and click the ``Add`` button. A new array field will appear.
51+
6. Add a new element ``Public Component Requirements for the Component (REQUIRES)`` and click the ``Add`` button. A new array field will appear.
4852

49-
7. As described in `ESP-IDF Component CMakeLists.txt Files <https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-guides/build-system.html#component-cmakelists-files>`_, ``REQUIRES`` is used to list the component dependencies. Type ``mbedtls`` and click the ``+`` button (can also press enter on typing).
53+
7. As described in `Component CMakeLists Files <https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-guides/build-system.html#component-cmakelists-files>`_, ``REQUIRES`` is used to list the component dependencies. Type ``mbedtls`` and click the ``+`` button (you can also press enter after typing).
5054

51-
8. Click on ``Save`` button and close the CMakeLists.txt editor. If you open ``<project_path>/blink/components/<component_name>/CMakeLists.txt`` on a regular text editor, you will see:
55+
8. Click the ``Save`` button and close the ``CMakeLists.txt`` editor. If you open ``<project_path>/blink/components/<component_name>/CMakeLists.txt`` in a regular text editor, you will see:
5256

53-
.. code-block:: C
57+
.. code-block:: C
5458
55-
idf_component_register(SRCS "my_component.c"
56-
INCLUDE_DIRS "include"
57-
REQUIRES "mbedtls")
59+
idf_component_register(SRCS "my_component.c"
60+
INCLUDE_DIRS "include"
61+
REQUIRES "mbedtls")
5862
59-
Reference links
60-
-----------------------
63+
Reference Links
64+
---------------
6165

62-
To review all fields used in the CMakeLists.txt editor go to:
66+
To review all fields used in the ``CMakeLists.txt`` editor, go to:
6367

64-
1. `ESP-IDF Project CMakeLists.txt <https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-guides/build-system.html#project-cmakelists-file>`_
68+
- `ESP-IDF Project CMakeLists Files <https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-guides/build-system.html#project-cmakelists-file>`_
6569

66-
2. `ESP-IDF Component CMakeLists.txt Files <https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-guides/build-system.html#component-cmakelists-files>`_
70+
- `ESP-IDF Component CMakeLists Files <https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-guides/build-system.html#component-cmakelists-files>`_
Lines changed: 70 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,70 @@
1-
.. include:: ../../en/additionalfeatures/cmakelists-editor.rst
1+
CMakeLists.txt 编辑器
2+
=====================
3+
4+
:link_to_translation:`en:[English]`
5+
6+
.. warning::
7+
8+
该操作会用编辑器生成的内容覆盖文件中现有的代码。如果文件中有未包含在 schema 中的代码(或单行注释),请使用常规文本编辑器。
9+
10+
右键点击任意 ``CMakeLists.txt`` 文件时,该扩展会提供一个自定义的 ``CMakeLists.txt`` 编辑器,用于填写 ESP-IDF 项目和组件注册,具体参考:
11+
12+
- `项目 CMakeLists 文件 <https://docs.espressif.com/projects/esp-idf/zh_CN/latest/esp32/api-guides/build-system.html#cmakelists>`_
13+
- `组件 CMakeLists 文件 <https://docs.espressif.com/projects/esp-idf/zh_CN/latest/esp32/api-guides/build-system.html#component-directories>`_
14+
15+
需要选择要编辑哪种类型的 ``CMakeLists.txt`` 文件(项目或组件),共有两种类型:简单字符串和字符串数组,例如 Component Sources (SRCS)。
16+
17+
.. note::
18+
19+
* 所有输入项都在 `CMakeLists.txt schema <https://github.com/espressif/vscode-esp-idf-extension/blob/master/cmakeListsSchema.json>`_ 中有描述。
20+
* 该编辑器并不支持所有 CMake 函数和语法,仅用于简单的 ``CMakeLists.txt`` 配置,例如组件注册(使用 ``idf_component_register``)和基础项目元素。如需自定义或进行高级的 ``CMakeLists.txt`` 配置,请参考 `ESP-IDF 构建系统 <https://docs.espressif.com/projects/esp-idf/zh_CN/latest/esp32/api-guides/build-system.html>`_。此外,可查看 **CMakeLists.txt 编辑器 schema** 以获取支持的代码列表。
21+
22+
本教程将使用 blink 示例项目。
23+
24+
1. 右键点击 ``<project_path>/blink/CMakeLists.txt``,选择 ``ESP-IDF:CMakeLists.txt 编辑器``,然后选择 ``Project CMakeLists.txt``。
25+
26+
.. image:: ../../../media/tutorials/cmakelists_editor/cmakelists_editor.png
27+
28+
2. 从 ``New Element`` 下拉菜单中选择新元素,然后点击 ``Add`` 按钮添加。为简单起见,可以修改项目名称,然后点击 ``Save`` 保存更改。
29+
30+
在常规文本编辑器中重新打开文件,可以看到修改后的内容。
31+
32+
3. 在该项目中创建一个新的 ESP-IDF 组件,以便修改其 ``CMakeLists.txt``。前往菜单栏 ``查看`` > ``命令面板``,输入 ``ESP-IDF:创建新 ESP-IDF 组件``,并输入新组件名称。
33+
34+
4. 新组件将创建在 ``<project_path>/blink/components/<component_name>`` 目录下。在常规文本编辑器中打开 ``CMakeLists.txt``,可以看到一个 ``idf_component_register`` 方法,如下:
35+
36+
.. code-block:: C
37+
38+
idf_component_register(SRCS "my_component.c"
39+
INCLUDE_DIRS "include")
40+
41+
右键点击 ``<project_path>/blink/components/<component_name>/CMakeLists.txt``,选择 ``ESP-IDF:CMakeLists.txt 编辑器``,然后选择 ``Component CMakeLists.txt``。
42+
43+
.. image:: ../../../media/tutorials/cmakelists_editor/components_editor.png
44+
45+
5. 注意,某些字段是数组类型,例如 **Component Sources (SRCS)**,你可以添加多个路径,而其他字段仅是字符串输入(如 ``cmakeListsSchema.json`` 所述)。
46+
47+
.. note::
48+
49+
使用该扩展时,源文件会在 ``CMakeLists.txt`` 所在目录自动添加或删除,无需用户手动操作。
50+
51+
6. 添加新元素 ``Public Component Requirements for the Component (REQUIRES)``,点击 ``Add`` 按钮。将出现新的数组字段。
52+
53+
7. 如 `组件 CMakeLists 文件 <https://docs.espressif.com/projects/esp-idf/zh_CN/latest/esp32/api-guides/build-system.html#component-directories>`_ 中所述,``REQUIRES`` 用于列出组件依赖项。输入 ``mbedtls`` 并点击 ``+`` 按钮(也可在输入后按 Enter 键)。
54+
55+
8. 点击 ``Save`` 按钮并关闭 ``CMakeLists.txt`` 编辑器。在常规文本编辑器中打开 ``<project_path>/blink/components/<component_name>/CMakeLists.txt``,你将看到如下内容:
56+
57+
.. code-block:: C
58+
59+
idf_component_register(SRCS "my_component.c"
60+
INCLUDE_DIRS "include"
61+
REQUIRES "mbedtls")
62+
63+
参考链接
64+
--------
65+
66+
要查看 ``CMakeLists.txt`` 编辑器中使用的所有字段,请访问:
67+
68+
- `ESP-IDF 项目 CMakeLists 文件 <https://docs.espressif.com/projects/esp-idf/zh_CN/latest/esp32/api-guides/build-system.html#cmakelists>`_
69+
70+
- `ESP-IDF 组件 CMakeLists 文件 <https://docs.espressif.com/projects/esp-idf/zh_CN/latest/esp32/api-guides/build-system.html#component-directories>`_

0 commit comments

Comments
 (0)