builder-updater 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- builder_updater-0.1.0/LICENSE +21 -0
- builder_updater-0.1.0/MANIFEST.in +1 -0
- builder_updater-0.1.0/PKG-INFO +470 -0
- builder_updater-0.1.0/README.md +458 -0
- builder_updater-0.1.0/builder_updater/__init__.py +5 -0
- builder_updater-0.1.0/builder_updater/__main__.py +4 -0
- builder_updater-0.1.0/builder_updater/assets/example/example.code-workspace +7 -0
- builder_updater-0.1.0/builder_updater/assets/example/project_configs/build_configs/bc_first.mk +30 -0
- builder_updater-0.1.0/builder_updater/assets/example/project_configs/build_configs/bc_second.mk +31 -0
- builder_updater-0.1.0/builder_updater/assets/example/project_configs/common.mk +60 -0
- builder_updater-0.1.0/builder_updater/assets/example/project_configs/gitlab-ci-project.yml +2 -0
- builder_updater-0.1.0/builder_updater/assets/example/src/main.c +228 -0
- builder_updater-0.1.0/builder_updater/assets/template/.gitignore +20 -0
- builder_updater-0.1.0/builder_updater/assets/template/.gitlab-ci.yml +3 -0
- builder_updater-0.1.0/builder_updater/assets/template/.vscode/c_cpp_properties.json +9 -0
- builder_updater-0.1.0/builder_updater/assets/template/.vscode/launch.json +123 -0
- builder_updater-0.1.0/builder_updater/assets/template/.vscode/settings.json +9 -0
- builder_updater-0.1.0/builder_updater/assets/template/.vscode/tasks.json +39 -0
- builder_updater-0.1.0/builder_updater/assets/template/build_scripts/bin_header/bin_header.c +170 -0
- builder_updater-0.1.0/builder_updater/assets/template/build_scripts/bin_header/bin_header.h +189 -0
- builder_updater-0.1.0/builder_updater/assets/template/build_scripts/builder.mk +175 -0
- builder_updater-0.1.0/builder_updater/assets/template/build_scripts/crc_soft/crc_soft.c +230 -0
- builder_updater-0.1.0/builder_updater/assets/template/build_scripts/crc_soft/crc_soft.h +204 -0
- builder_updater-0.1.0/builder_updater/assets/template/build_scripts/env_default.mk +16 -0
- builder_updater-0.1.0/builder_updater/assets/template/build_scripts/gitlab-ci-builder.yml +24 -0
- builder_updater-0.1.0/builder_updater/assets/template/build_scripts/global.mk +25 -0
- builder_updater-0.1.0/builder_updater/assets/template/build_scripts/post_build/gcc_map_parser.py +201 -0
- builder_updater-0.1.0/builder_updater/assets/template/build_scripts/post_build/modify_header.py +249 -0
- builder_updater-0.1.0/builder_updater/assets/template/makefile +22 -0
- builder_updater-0.1.0/builder_updater/assets/template/project_configs/build_configs/bc_release.mk +29 -0
- builder_updater-0.1.0/builder_updater/assets/template/project_configs/common.mk +44 -0
- builder_updater-0.1.0/builder_updater/assets/template/project_configs/gitlab-ci-project.yml +2 -0
- builder_updater-0.1.0/builder_updater/builder_info.py +73 -0
- builder_updater-0.1.0/builder_updater/builder_updater.py +268 -0
- builder_updater-0.1.0/builder_updater/cli.py +69 -0
- builder_updater-0.1.0/builder_updater.egg-info/PKG-INFO +470 -0
- builder_updater-0.1.0/builder_updater.egg-info/SOURCES.txt +41 -0
- builder_updater-0.1.0/builder_updater.egg-info/dependency_links.txt +1 -0
- builder_updater-0.1.0/builder_updater.egg-info/entry_points.txt +2 -0
- builder_updater-0.1.0/builder_updater.egg-info/top_level.txt +1 -0
- builder_updater-0.1.0/pyproject.toml +24 -0
- builder_updater-0.1.0/setup.cfg +4 -0
- builder_updater-0.1.0/tests/test_builder_updater.py +70 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 KARMA-Electronics
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
recursive-include builder_updater/assets *
|
|
@@ -0,0 +1,470 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: builder-updater
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: C/C++ project builder updater
|
|
5
|
+
License-Expression: MIT
|
|
6
|
+
Project-URL: Homepage, https://gitlab.com/karma_electronics/desktop/builder_updater
|
|
7
|
+
Project-URL: Repository, https://gitlab.com/karma_electronics/desktop/builder_updater.git
|
|
8
|
+
Requires-Python: >=3.6
|
|
9
|
+
Description-Content-Type: text/markdown
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
Dynamic: license-file
|
|
12
|
+
|
|
13
|
+
# C/C++ project builder updater
|
|
14
|
+
|
|
15
|
+
> **Примечание:** ниже приведено описание на русском
|
|
16
|
+
|
|
17
|
+
Command-line tool for setting up and maintaining C/C++ project build systems. Based on Makefile, provides VSCode support, and designed for CI/CD workflows.
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
## Key Features
|
|
21
|
+
|
|
22
|
+
- **Makefile-based** - built on Makefile with minimal external dependencies
|
|
23
|
+
- **Embedded focused** - for embedded development while also supporting desktop environments
|
|
24
|
+
- **IDE independent** - build process does not require any specific IDE
|
|
25
|
+
- **Multi-platform support** - supports building on both Windows and Linux
|
|
26
|
+
- **VSCode support** - VSCode is the primary supported editor
|
|
27
|
+
- **CI/CD support** - includes ready-to-use configs for CI/CD pipelines
|
|
28
|
+
- **Header generation** - utilities for generating and using header with project metadata (including data extracted from the Git repository)
|
|
29
|
+
- **Separation of concerns** - strict separation of all scripts and configurations into three segments: `builder`, `project`, and `workspace`
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
## Installation
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
pip install builder-updater
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
## Running
|
|
40
|
+
|
|
41
|
+
Once installed, you can run the tool from the command line.
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
builder_updater
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
## Command‑Line Options
|
|
49
|
+
|
|
50
|
+
- **`-p`, `--path` *`<project_path>`*** Specifies the path to the target project directory (defaults to the current directory).
|
|
51
|
+
- **`-f`, `--force`** Forces the update of the project, overriding existing configuration files.
|
|
52
|
+
- **`-c`, `--clean`** Cleans old files in the project directory before performing the update.
|
|
53
|
+
- **`-e`, `--example`** Copies example source files into the project directory.
|
|
54
|
+
- **`-i`, `--info`** Recursive scan and displays information about projects (`--path` is root of scan).
|
|
55
|
+
- **`-h`, `--help`** Shows the help message with a summary of all available options and exits.
|
|
56
|
+
- **`--version`** Prints the current version of the `builder-updater` package and exits.
|
|
57
|
+
- **`--builder-version`** Prints the version of the `builder` and exits.
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
## Builder structure
|
|
61
|
+
|
|
62
|
+
1. `builder` - fixed core segment of builder files (tracked by Git)
|
|
63
|
+
|
|
64
|
+
* `build_scripts/bin_header/bin_header.c`
|
|
65
|
+
* `build_scripts/bin_header/bin_header.h`
|
|
66
|
+
* `build_scripts/crc_soft/crc_soft.с`
|
|
67
|
+
* `build_scripts/crc_soft/crc_soft.h`
|
|
68
|
+
* `build_scripts/post_build/gcc_map_parser.py`
|
|
69
|
+
* `build_scripts/post_build/modify_header.py`
|
|
70
|
+
* `build_scripts/builder.mk`
|
|
71
|
+
* `build_scripts/env_default.mk`
|
|
72
|
+
* `build_scripts/gitlab-ci-builder.yml`
|
|
73
|
+
* `build_scripts/global.mk`
|
|
74
|
+
* `.gitignore`
|
|
75
|
+
* `gitlab-ci.yml`
|
|
76
|
+
* `makefile`
|
|
77
|
+
|
|
78
|
+
1. `project` - project-specific configuration files (tracked by Git)
|
|
79
|
+
|
|
80
|
+
* `.vscode/c_cpp_properties.json`
|
|
81
|
+
* `.vscode/launch.json`
|
|
82
|
+
* `.vscode/settings.json`
|
|
83
|
+
* `.vscode/tasks.json`
|
|
84
|
+
* `project_configs/build_configs/<bc_name>.mk`
|
|
85
|
+
* `project_configs/common.mk`
|
|
86
|
+
* `project_configs/gitlab-ci-project.yml`
|
|
87
|
+
|
|
88
|
+
1. `workspace` - local workspace configuration files (**NOT** tracked by Git)
|
|
89
|
+
|
|
90
|
+
* `env.mk`
|
|
91
|
+
* `<name>.code-workspace`
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
## Component Description
|
|
95
|
+
|
|
96
|
+
1. Core of the makefile-based build system:
|
|
97
|
+
|
|
98
|
+
1. `makefile` - the top-level entry point of the build system. It assembles a list of build configurations based on filenames located in `project_configs/build_configs`. For each discovered configuration, it invokes the build script `build_scripts/builder.mk`. The targets defined in this script also allow building each configuration individually. See the file contents and inline comments for detailed information.
|
|
99
|
+
|
|
100
|
+
1. `build_scripts/builder.mk` - the main build script. Contains all required targets and mechanisms that implement recursive discovery and compilation of source files. The list of search directories is configured in `project_configs/common.mk` (shared for all build configurations) and `project_configs/build_configs/<bc_name>.mk` (specific to each configuration). Refer to the file contents and comments for details.
|
|
101
|
+
|
|
102
|
+
1. `build_scripts/global.mk` - provides global variables, including platform-specific ones for different operating systems.
|
|
103
|
+
|
|
104
|
+
1. `build_scripts/env_default.mk` - default environment settings. To configure a local environment, create a file `env.mk` (see below).
|
|
105
|
+
|
|
106
|
+
1. Build configuration:
|
|
107
|
+
|
|
108
|
+
1. `project_configs/common.mk` - a set of common project settings and parameters. Includes toolchain selection, additional build flags, source directories, static library paths, and more.
|
|
109
|
+
|
|
110
|
+
1. `project_configs/build_configs/<bc_name>.mk` - settings and parameters for the corresponding build configuration. The filename is automatically detected by the top-level `makefile` and used as the configuration name. At least one build configuration file must exist.
|
|
111
|
+
|
|
112
|
+
1. `CI/CD` configuration:
|
|
113
|
+
|
|
114
|
+
1. `build_scripts/gitlab-ci-builder.yml` - defines the primary GitLab CI stages required to build the project.
|
|
115
|
+
|
|
116
|
+
1. `project_configs/gitlab-ci-project.yml` - project-specific environment variables and CI/CD stages used during pipeline execution.
|
|
117
|
+
|
|
118
|
+
1. `gitlab-ci.yml` - combines `build_scripts/gitlab-ci-builder.yml` and `project_configs/gitlab-ci-project.yml` into a unified project configuration.
|
|
119
|
+
|
|
120
|
+
1. Executable file header:
|
|
121
|
+
|
|
122
|
+
1. `build_scripts/bin_header/bin_header.h` - header structure definition for use within the project’s source code.
|
|
123
|
+
|
|
124
|
+
1. `build_scripts/bin_header/bin_header.c` - contains the header instance. To embed it into the executable, include this file in the project’s `.c` source list.
|
|
125
|
+
|
|
126
|
+
1. `build_scripts/post_build/modify_header.py` - a script that injects project information into the header (including Git repository state) and computes CRC.
|
|
127
|
+
|
|
128
|
+
1. `build_scripts/crc_soft/crc_soft.h` - header file of the CRC calculation module used to verify header and firmware integrity; also includes table generators.
|
|
129
|
+
|
|
130
|
+
1. `build_scripts/crc_soft/crc_soft.c` - implementation of the CRC module, including constant tables for IEEE 802.3 CRC-32 and CCITT CRC-16.
|
|
131
|
+
|
|
132
|
+
1. `VSCode` editor configuration:
|
|
133
|
+
|
|
134
|
+
1. `.vscode/c_cpp_properties.json` - configuration for the VSCode C/C++ extension, including the path to `compile_commands.json`.
|
|
135
|
+
|
|
136
|
+
1. `.vscode/launch.json` - debugger launch configuration for VSCode (`F5`).
|
|
137
|
+
|
|
138
|
+
1. `.vscode/settings.json` - general VSCode editor settings.
|
|
139
|
+
|
|
140
|
+
1. `.vscode/tasks.json` - build task configuration for VSCode (`Ctrl + Shift + B`).
|
|
141
|
+
|
|
142
|
+
1. Environment files (created by the user):
|
|
143
|
+
|
|
144
|
+
1. `env.mk` - environment configuration for `makefile`, specific to the user’s workspace (compiler paths, OpenOCD path, etc.). Version control tracking is **disabled** for this file to avoid conflicts between different user environments.
|
|
145
|
+
|
|
146
|
+
1. `<name>.code-workspace` - VSCode workspace configuration. Version control tracking is **disabled** for this file for the same reason.
|
|
147
|
+
|
|
148
|
+
1. Miscellaneous:
|
|
149
|
+
|
|
150
|
+
1. `.gitignore` - list of file patterns ignored by `git`.
|
|
151
|
+
|
|
152
|
+
1. `output/compile_commands.json` - generated during the build (not stored in git). Used by the editor to provide correct syntax and preprocessing insights, including parameters defined in `.mk` files.
|
|
153
|
+
|
|
154
|
+
1. `build_scripts/post_build/gcc_map_parser.py` - parser for `.map` files, used to analyze the largest modules, memory usage, etc. (in development).
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
## Adding the Build System to a New or Existing Project
|
|
159
|
+
|
|
160
|
+
1. The target project must be prepared for updating the build system in advance - all changes must be saved, or (for projects without version control) copied to another directory.
|
|
161
|
+
|
|
162
|
+
1. Run the build-system installation script (when launched from the project directory, the `--path` argument is optional):
|
|
163
|
+
```bash
|
|
164
|
+
builder_updater --path <project_path> --force
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
1. Configure the files `project_configs/common.mk` and `project_configs/build_configs/<bc_name>.mk` (see comments for variable descriptions).
|
|
168
|
+
|
|
169
|
+
1. Create and configure the file `env.mk` based on the template in `build_scripts/env_default.mk`.
|
|
170
|
+
|
|
171
|
+
1. Create and configure the `<name>.code-workspace` file based on the following template:
|
|
172
|
+
```json
|
|
173
|
+
{
|
|
174
|
+
"folders": [
|
|
175
|
+
{
|
|
176
|
+
"path": "."
|
|
177
|
+
}
|
|
178
|
+
],
|
|
179
|
+
"settings": {
|
|
180
|
+
"prjCfg.svdPath": "${workspaceFolder}\\STM32F103.svd", // path to the MCU peripheral description file
|
|
181
|
+
"prjCfg.gdbPath": "arm-none-eabi-gdb", // path to the gdb debugger (or command if added to the `PATH` environment variable)
|
|
182
|
+
"prjCfg.ocdPath": "openocd", // path to openocd (or command if added to the `PATH` environment variable)
|
|
183
|
+
"prjCfg.ocdPort": "3333", // port for gdb to connect to openocd
|
|
184
|
+
"prjCfg.ocdAddr": "localhost", // IP address or hostname of the openocd server for remote debugging
|
|
185
|
+
"prjCfg.ocdInterface": "interface/stlink.cfg", // path to the interface `.cfg` file (debug probe)
|
|
186
|
+
"prjCfg.ocdTarget": "target/stm32f1x.cfg", // path to the target `.cfg` file (micro-controller)
|
|
187
|
+
"prjCfg.ocdUserCmd": "", // custom openocd startup command
|
|
188
|
+
"prjCfg.pythonPath": "python3" // path to the Python interpreter
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
1. `.vscode/settings.json` - configure the compiler version and select the target architecture.
|
|
194
|
+
|
|
195
|
+
1. `.vscode/tasks.json` - list all project configuration names inside `inputs.options`.
|
|
196
|
+
|
|
197
|
+
1. `.vscode/launch.json` - list relative paths to executable files (relative to the `output` directory) inside `inputs.options`.
|
|
198
|
+
|
|
199
|
+
1. `project_configs/gitlab-ci-project.yml` - specify the container image used by the project in the variable `GITLAB_DOCKER_IMAGE`.
|
|
200
|
+
|
|
201
|
+
1. To enable automatic header generation, add the following template to the project's linker script (and adjust if necessary):
|
|
202
|
+
```ld
|
|
203
|
+
.header (READONLY):
|
|
204
|
+
{
|
|
205
|
+
. = ALIGN(4);
|
|
206
|
+
KEEP(*(.header))
|
|
207
|
+
. = ALIGN(4);
|
|
208
|
+
} > FLASH
|
|
209
|
+
|
|
210
|
+
PROVIDE(header_load_addr = ORIGIN(FLASH));
|
|
211
|
+
PROVIDE(header_boot_addr = Reset_Handler);
|
|
212
|
+
PROVIDE(header_firmware_size = LOADADDR(.data) + SIZEOF(.data) - header_load_addr);
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
|
|
216
|
+
## Updating Non-Breaking Changes of the Build System
|
|
217
|
+
|
|
218
|
+
1. Run the build system update script:
|
|
219
|
+
```bash
|
|
220
|
+
builder_updater -p <project_path>
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
|
|
224
|
+
## Updating BREAKING Changes of the Build System
|
|
225
|
+
|
|
226
|
+
1. Run the build system update script:
|
|
227
|
+
```bash
|
|
228
|
+
builder_updater -p <project_path> -f -c
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
1. Since `--force` mode overwrites all configuration files, you must manually restore your project-specific settings while taking into account changes introduced in the build system (automation is under development). Files requiring manual adjustments:
|
|
232
|
+
|
|
233
|
+
* `project_configs/common.mk`
|
|
234
|
+
* `project_configs/build_configs/<bc_name>.mk`
|
|
235
|
+
* `project_configs/gitlab-ci-project.yml`
|
|
236
|
+
|
|
237
|
+
<br>
|
|
238
|
+
<br>
|
|
239
|
+
|
|
240
|
+
---
|
|
241
|
+
---
|
|
242
|
+
---
|
|
243
|
+
|
|
244
|
+
<br>
|
|
245
|
+
<br>
|
|
246
|
+
|
|
247
|
+
# C/C++ project builder updater
|
|
248
|
+
|
|
249
|
+
Инструмент для настройки и обновления системы сборки C/C++ проектов. Построен на базе Makefile, включает поддержку VSCode и ориентирован на использование в CI/CD.
|
|
250
|
+
|
|
251
|
+
|
|
252
|
+
## Ключевые особенности
|
|
253
|
+
|
|
254
|
+
- **Makefile-based** - построен на Makefile с минимизацией дополнительных зависимостей
|
|
255
|
+
- **Embedded focused** - ориентировано на сборку embedded проектов, но поддерживает и desktop
|
|
256
|
+
- **IDE independent** - сборка не требует обязательного использования IDE
|
|
257
|
+
- **Multi-platform support** - поддержка сборки в Windows и Linux
|
|
258
|
+
- **VSCode support** - основной поддерживаемый редактор VSCode
|
|
259
|
+
- **CI/CD support** - готовый инструментарий для CI/CD
|
|
260
|
+
- **Header generation** - инструменты формирования секции заголовка с информацией о проекте (в том числе из git репозитория)
|
|
261
|
+
- **Separation of concerns** - строгое разделение всех скриптов и конфигураций на 3 сегмента: `builder`, `project`, and `workspace`
|
|
262
|
+
|
|
263
|
+
|
|
264
|
+
## Установка
|
|
265
|
+
|
|
266
|
+
```bash
|
|
267
|
+
pip install builder-updater
|
|
268
|
+
```
|
|
269
|
+
|
|
270
|
+
|
|
271
|
+
## Запуск
|
|
272
|
+
|
|
273
|
+
```bash
|
|
274
|
+
builder_updater
|
|
275
|
+
```
|
|
276
|
+
|
|
277
|
+
|
|
278
|
+
## Параметры запуска
|
|
279
|
+
|
|
280
|
+
- **`-p`, `--path` *`<project_path>`*** Путь к целевой директории проекта (по умолчанию — текущая директория).
|
|
281
|
+
- **`-f`, `--force`** Выполняет принудительное обновление проекта, перезаписывая существующие конфигурационные файлы.
|
|
282
|
+
- **`-c`, `--clean`** Очищает старые файлы в директории проекта перед обновлением.
|
|
283
|
+
- **`-e`, `--example`** Копирует пример исходных файлов в директорию проекта.
|
|
284
|
+
- **`-i`, `--info`** Рекурсивно сканирует и выводит информацию о проектах (`--path` используется как корень сканирования).
|
|
285
|
+
- **`-h`, `--help`** Показывает справку со сводкой всех доступных опций и завершает работу.
|
|
286
|
+
- **`--version`** Выводит текущую версию пакета `builder-updater` и завершает работу.
|
|
287
|
+
- **`--builder-version`** Выводит версию `builder` и завершает работу.
|
|
288
|
+
|
|
289
|
+
|
|
290
|
+
## Структура системы сборки
|
|
291
|
+
|
|
292
|
+
1. `builder` - не изменяемый сегмент файлов системы сборки (отслеживается Git)
|
|
293
|
+
|
|
294
|
+
* `build_scripts/bin_header/bin_header.c`
|
|
295
|
+
* `build_scripts/bin_header/bin_header.h`
|
|
296
|
+
* `build_scripts/crc_soft/crc_soft.с`
|
|
297
|
+
* `build_scripts/crc_soft/crc_soft.h`
|
|
298
|
+
* `build_scripts/post_build/gcc_map_parser.py`
|
|
299
|
+
* `build_scripts/post_build/modify_header.py`
|
|
300
|
+
* `build_scripts/builder.mk`
|
|
301
|
+
* `build_scripts/env_default.mk`
|
|
302
|
+
* `build_scripts/gitlab-ci-builder.yml`
|
|
303
|
+
* `build_scripts/global.mk`
|
|
304
|
+
* `.gitignore`
|
|
305
|
+
* `gitlab-ci.yml`
|
|
306
|
+
* `makefile`
|
|
307
|
+
|
|
308
|
+
1. `project` - проект-специфичные конфигурационные файлы (отслеживается Git)
|
|
309
|
+
|
|
310
|
+
* `.vscode/c_cpp_properties.json`
|
|
311
|
+
* `.vscode/launch.json`
|
|
312
|
+
* `.vscode/settings.json`
|
|
313
|
+
* `.vscode/tasks.json`
|
|
314
|
+
* `project_configs/build_configs/<bc_name>.mk`
|
|
315
|
+
* `project_configs/common.mk`
|
|
316
|
+
* `project_configs/gitlab-ci-project.yml`
|
|
317
|
+
|
|
318
|
+
1. `workspace` - файлы конфигурации окружения (**NOT** tracked by Git)
|
|
319
|
+
|
|
320
|
+
* `env.mk`
|
|
321
|
+
* `<name>.code-workspace`
|
|
322
|
+
|
|
323
|
+
|
|
324
|
+
## Описание компонентов
|
|
325
|
+
|
|
326
|
+
1. Ядро makefile-based сборки:
|
|
327
|
+
|
|
328
|
+
1. `makefile` - верхний уровень системы сборки. Формирует список конфигураций по названиям файлов, расположенных в папке `project_configs/build_configs`. По сформированному списку запускает сборку `build_scripts/builder.mk` для каждой конфигурации. Также по сформированным в этом скрипте целям можно запустить сборку каждой конфигурации по отдельности. Подробнее смотри содержимое файла и приведенные в нем комментарии.
|
|
329
|
+
|
|
330
|
+
1. `build_scripts/builder.mk` - основной скрипт сборки. Содержит все необходимые описания целей и механизмов, реализующих рекурсивный поиск и компиляцию исходных файлов. Список директорий для поиска настраивается в файлах `project_configs/common.mk` (общие для всех конфигураций сборки) и `project_configs/build_configs/<bc_name>.mk` (для соответствующей конфигурации). Подробнее смотри содержимое файлов и приведенные в нем комментарии.
|
|
331
|
+
|
|
332
|
+
1. `build_scripts/global.mk` - содержит общие глобальные переменные, в том числе различающиеся в разных операционных системах.
|
|
333
|
+
|
|
334
|
+
1. `build_scripts/env_default.mk` - настройки окружения по умолчанию. Для настройки локального окружения необходимо создать файл `env.mk` (см. подробнее ниже).
|
|
335
|
+
|
|
336
|
+
1. Конфигурация сборки:
|
|
337
|
+
|
|
338
|
+
1. `project_configs/common.mk` - набор общих настроек и параметров проекта. Включает в себя наименование тулчейна, дополнительные флаги сборки, расположение исходников, статических библиотек и пр.
|
|
339
|
+
|
|
340
|
+
1. `project_configs/build_configs/<bc_name>.mk` - настройки и параметры соответствующих конфигураций. Наименование файла автоматически подхватывается скриптом `makefile` и далее используется как название конфигурации. Должен существовать минимум один файл конфигурации сборки.
|
|
341
|
+
|
|
342
|
+
1. Описание `CI/CD`:
|
|
343
|
+
|
|
344
|
+
1. `build_scripts/gitlab-ci-builder.yml` - основные `stages`, необходимые для сборки проекта.
|
|
345
|
+
|
|
346
|
+
1. `project_configs/gitlab-ci-project.yml` - специфичные для проекта переменные окружения и `stages`, используемые при сборке через `CI/CD`.
|
|
347
|
+
|
|
348
|
+
1. `gitlab-ci.yml` - комбинирует конфигурации `build_scripts/gitlab-ci-builder.yml` и `project_configs/gitlab-ci-project.yml` в общую для проекта.
|
|
349
|
+
|
|
350
|
+
1. Заголовок исполняемого файла
|
|
351
|
+
|
|
352
|
+
1. `build_scripts/bin_header/bin_header.h` - описание структуры заголовка для использования в исходном коде проекта.
|
|
353
|
+
|
|
354
|
+
1. `build_scripts/bin_header/bin_header.c` - содержит инстанс заголовка. Для его инъекции в исполняемый файл необходимо добавить этот файл в список `.c` исходников проекта.
|
|
355
|
+
|
|
356
|
+
1. `build_scripts/post_build/modify_header.py` - скрипт для добавления в заголовок информации о состоянии `git` репозитория проекта и расчета CRC.
|
|
357
|
+
|
|
358
|
+
1. `build_scripts/crc_soft/crc_soft.h` - заголовочный файл модуля вычисления CRC для контроля целостности заголовка и ВПО, также содержит генераторы таблиц.
|
|
359
|
+
|
|
360
|
+
1. `build_scripts/crc_soft/crc_soft.с` - исходный код модуля вычисления CRC, дополнительно содержит const таблицы для IEEE 802.3 CRC-32 и CCITT CRC-16
|
|
361
|
+
|
|
362
|
+
1. Конфигурация редактора `VSCode`
|
|
363
|
+
|
|
364
|
+
1. `.vscode/c_cpp_properties.json` - настройки плагина С/C++ для VSCode, в том числе путь к файлу `compile_commands.json`.
|
|
365
|
+
|
|
366
|
+
1. `.vscode/launch.json` - настройки запуска отладчика в VSCode `F5`.
|
|
367
|
+
|
|
368
|
+
1. `.vscode/settings.json` - общие настройки редактора VSCode.
|
|
369
|
+
|
|
370
|
+
1. `.vscode/tasks.json` - настройки запуска сборки в VSCode `Ctrl + Shift + B`.
|
|
371
|
+
|
|
372
|
+
1. Файлы окружения (создаются пользователем)
|
|
373
|
+
|
|
374
|
+
1. `env.mk` - содержит конфигурацию окружения для `makefile`, специфичную для конкретного рабочего пространства (путь к компилятору, openocd и т.п.). Для файла **отключено отслеживание** системой контроля версий `git` для избежания конфликтов настроек разных окружений.
|
|
375
|
+
|
|
376
|
+
1. `<name>.code-workspace` - содержит конфигурацию workspace `VSCode`. Для файла **отключено отслеживание** системой контроля версий `git` для избежания конфликтов настроек разных окружений.
|
|
377
|
+
|
|
378
|
+
1. Остальное:
|
|
379
|
+
|
|
380
|
+
1. `.gitignore` - список шаблонов файлов, игнорируемых `git`.
|
|
381
|
+
|
|
382
|
+
1. `output/compile_commands.json` - создается в процессе сборки (не сохраняется в git). Позволяет корректно формировать подсветку синтаксиса и препроцессора в том числе для параметров, задаваемых в файлах `.mk`.
|
|
383
|
+
|
|
384
|
+
1. `build_scripts/post_build/gcc_map_parser.py` - парсер `.map` файла для анализа самых объемных модулей, использования памяти и пр. (в разработке).
|
|
385
|
+
|
|
386
|
+
|
|
387
|
+
## Добавление системы сборки в новый или существующий проект
|
|
388
|
+
|
|
389
|
+
1. Целевой проект должен быть предварительно подготовлен к обновлению системы сборки - все изменения сохранены или (для проектов без контроля версии) скопированы в другую папку.
|
|
390
|
+
|
|
391
|
+
1. Запустить скрипт добавления системы сборки (при запуске из директории проекта аргумент `--path` указывать не обязательно):
|
|
392
|
+
```bash
|
|
393
|
+
builder_updater --path <project_path> --force
|
|
394
|
+
```
|
|
395
|
+
|
|
396
|
+
1. Заполнить файлы `project_configs/common.mk` и `project_configs/build_configs/<bc_name>.mk` (см. комментарии к переменным).
|
|
397
|
+
|
|
398
|
+
1. Создать и заполнить файл `env.mk` по шаблону из `build_scripts/env_default.mk`.
|
|
399
|
+
|
|
400
|
+
1. Создать и заполнить файл `<name>.code-workspace` по шаблону:
|
|
401
|
+
```json
|
|
402
|
+
{
|
|
403
|
+
"folders": [
|
|
404
|
+
{
|
|
405
|
+
"path": "."
|
|
406
|
+
}
|
|
407
|
+
],
|
|
408
|
+
"settings": {
|
|
409
|
+
"prjCfg.svdPath": "${workspaceFolder}\\STM32F103.svd", // путь к файлу с описанием периферии контроллера
|
|
410
|
+
"prjCfg.gdbPath": "arm-none-eabi-gdb", // путь к отладчику gdb (или команда вызова, если путь указан в переменной окружения `PATH`)
|
|
411
|
+
"prjCfg.ocdPath": "openocd", // путь к openocd (или команда вызова, если путь указан в переменной окружения `PATH`)
|
|
412
|
+
"prjCfg.ocdPort": "3333", // порт для подключения gdb к openocd
|
|
413
|
+
"prjCfg.ocdAddr": "localhost", // ip адрес или hostname сервера openocd для удаленного подключения
|
|
414
|
+
"prjCfg.ocdInterface": "interface/stlink.cfg", // путь к `.cfg` файлу интерфейса (программатора)
|
|
415
|
+
"prjCfg.ocdTarget": "target/stm32f1x.cfg", // путь к `.cfg` файлу таргета (микроконтроллера)
|
|
416
|
+
"prjCfg.ocdUserCmd": "", // пользовательская команда запуска openocd
|
|
417
|
+
"prjCfg.pythonPath": "python3", // путь к интерпретатору python
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
```
|
|
421
|
+
|
|
422
|
+
1. В файле `.vscode/settings.json` настроить версию компилятора и выбрать архитектуру.
|
|
423
|
+
|
|
424
|
+
1. В файле `.vscode/tasks.json` в списке `inputs.options` перечислить названия конфигураций проекта
|
|
425
|
+
|
|
426
|
+
1. В файле `.vscode/launch.json` в списке `inputs.options` перечислить относительные пути к исполняемым файлам (относительно папки `output`).
|
|
427
|
+
|
|
428
|
+
1. В файле `project_configs/gitlab-ci-project.yml` указать используемый образ контейнера в переменной `GITLAB_DOCKER_IMAGE`.
|
|
429
|
+
|
|
430
|
+
1. Для использования механизма генерации заголовка необходимо добавить в линкер-скрипт проекта шаблон (при необходимости отредактировав):
|
|
431
|
+
```ld
|
|
432
|
+
.header (READONLY):
|
|
433
|
+
{
|
|
434
|
+
. = ALIGN(4);
|
|
435
|
+
KEEP(*(.header))
|
|
436
|
+
. = ALIGN(4);
|
|
437
|
+
} > FLASH
|
|
438
|
+
|
|
439
|
+
PROVIDE(header_load_addr = ORIGIN(FLASH));
|
|
440
|
+
PROVIDE(header_boot_addr = Reset_Handler);
|
|
441
|
+
PROVIDE(header_firmware_size = LOADADDR(.data) + SIZEOF(.data) - header_load_addr);
|
|
442
|
+
```
|
|
443
|
+
|
|
444
|
+
|
|
445
|
+
## Обновление не ломающих изменений системы сборки
|
|
446
|
+
|
|
447
|
+
1. Запустить скрипт обновления системы сборки:
|
|
448
|
+
```bash
|
|
449
|
+
builder_updater -p <project_path>
|
|
450
|
+
```
|
|
451
|
+
|
|
452
|
+
|
|
453
|
+
## Обновление ЛОМАЮЩИХ изменений системы сборки
|
|
454
|
+
|
|
455
|
+
1. Запустить скрипт обновления системы сборки:
|
|
456
|
+
```bash
|
|
457
|
+
builder_updater -p <project_path> -f -с
|
|
458
|
+
```
|
|
459
|
+
|
|
460
|
+
1. Так как в режиме `--force` скрипт перезаписывает все конфигурационные файлы, необходимо вручную восстановить настройки с учетом изменений системы сборки (автоматизация будет дорабатываться). Список файлов требующих ручного исправления:
|
|
461
|
+
|
|
462
|
+
* `project_configs/common.mk`
|
|
463
|
+
* `project_configs/build_configs/<bc_name>.mk`
|
|
464
|
+
* `project_configs/gitlab-ci-project.yml`
|
|
465
|
+
|
|
466
|
+
|
|
467
|
+
## Задачи в части доработок следующей версии
|
|
468
|
+
|
|
469
|
+
* Расширить файл `env.mk` и добавить генерацию `<name>.code-workspace` на его основе
|
|
470
|
+
* Возможно добавить алгоритм авто-заполнения inputs в `tasks.json` и `launch.json`
|