mirror of
https://github.com/sipeed/MaixCDK.git
synced 2026-09-10 21:59:54 -05:00
optimize compile, add build2 command
This commit is contained in:
@@ -77,17 +77,23 @@ Follow the prompts to select the device platform. A menu appears to configure pa
|
||||
```shell
|
||||
maixcdk build
|
||||
```
|
||||
On first run, this step downloads the necessary toolchain. If downloads are slow, manually download to the specified directory, then run the build again.
|
||||
> Downloaded resources are mainly from GitHub. Set up a proxy for faster downloads. Users in China can download from the [main page QQ group](../) file section.
|
||||
> To set a proxy: `export http_proxy=http://127.0.0.1:8123 https_proxy=http://127.0.0.1:8123`, where `http://127.0.0.1:8123` is your proxy address.
|
||||
The first time you run this step, the device will download the compilation toolchain. If the download is slow, you can manually download it to the specified directory as prompted, and then proceed with the compilation.
|
||||
|
||||
After compilation, the binary files can be found in the `build` directory, with dependencies in `build/dl_lib`.
|
||||
>! The resources are mostly downloaded from GitHub, and download speeds in China may be slow or even fail (the list of files to download is in `dl/pkgs_info.json`). There are several common solutions:
|
||||
> 1. Set a proxy in the terminal (recommended), for example: `export http_proxy=http://127.0.0.1:8123 https_proxy=http://127.0.0.1:8123`. Here, `http://127.0.0.1:8123` is the address of your HTTP proxy.
|
||||
> 2. Manually download to the `dl/pkgs` folder: During the download, the download URL and local path will be printed. You can manually download the files and place them in the corresponding directory. When you run the build command again, it will use the locally prepared files (Note: the file’s sha256 checksum must match, i.e., it must be the same file).
|
||||
> 3. Users in China can go to the [QQ Group](../) on the homepage, find the `MaixCDK` folder, and download the files to the `MaixCDK/dl` directory.
|
||||
|
||||
After code changes, rerun `maixcdk build` to recompile.
|
||||
>! For common errors and solutions, refer to the [FAQ](./faq.md).
|
||||
|
||||
The `maixcdk build` command scans all file changes before building.
|
||||
If **no source files are added or removed, use `maixcdk build --no-gen` for faster compilation**.
|
||||
> Since it uses `cmake`, the `build` command always executes `cmake` first. Adding `--no-gen` skips `cmake` and runs `make` directly, saving time if files haven’t changed.
|
||||
After the compilation, you will find the binary program files in the `build` directory, and the dependent `.so` files in `build/dl_lib`.
|
||||
|
||||
After modifying the code, you can run `maixcdk build` again to compile.
|
||||
|
||||
The `maixcdk build` command will scan all files for changes and rebuild them by default.
|
||||
If you **haven’t added or removed source files**, you can run `maixcdk build2` or `maixcdk build --no-gen` for faster compilation (it will only compile the modified files).
|
||||
> This is because the `build` command starts the entire build process from scratch, scanning files and recompiling. In contrast, the `build2` command will not scan for file additions or deletions and will only compile the edited files.
|
||||
> Note: The `build2` command will not detect file additions or deletions, so if you **add or remove files**, you must run the `build` command again.
|
||||
|
||||
Run `maixcdk distclean` to clear all temporary build files and start fresh (this increases build time and is typically used to troubleshoot issues).
|
||||
|
||||
|
||||
@@ -6,6 +6,16 @@ You can also find FAQ from:
|
||||
* [MaixCAM FAQ](https://wiki.sipeed.com/hardware/zh/maixcam/faq.html)
|
||||
* [MaixPy souce code FAQ](https://wiki.sipeed.com/maixpy/doc/zh/source_code/faq.html)
|
||||
|
||||
|
||||
## Common Compilation Errors and General Solutions
|
||||
|
||||
* **Errors such as extraction failures**: Try deleting the corresponding files in the `dl/pkgs` and `dl/extracted` directories, then recompile and download again.
|
||||
|
||||
* **Compilation errors**:
|
||||
* Run `maixcdk build --verbose` to see where the error occurs. **Carefully check the error log** and investigate the issue step by step.
|
||||
* Run `maixcdk distclean` to clean temporary files, then try recompiling.
|
||||
* Visit the [GitHub commit history](https://github.com/sipeed/MaixCDK/commits/main/) to check whether the automated tests for each commit passed (a green checkmark ✅ means it passed, a red cross ❌ means it failed). You can switch your local code to a commit that passed the tests ✅ and recompile. Use the command `git checkout <commit-hash>`, for example: `git checkout 3aba2fe3fa9de9f638bb9cb34eca0c2e0f5f3813`. If switching fails, you may need to search for Git usage instructions or start over, but make sure to back up any changes you made to your code.
|
||||
|
||||
## Downloading ippicv_2021.8_lnx_intel64_20230330_general.tgz takes a long time or fail
|
||||
|
||||
Manually download according to the log's url, and put it into:
|
||||
|
||||
@@ -83,16 +83,22 @@ maixcdk menuconfig
|
||||
maixcdk build
|
||||
```
|
||||
第一次执行这一步会根据设备下载编译工具链,下载如果太慢,可以根据提示手动下载到提示的目录,然后再执行编译。
|
||||
> 下载的资源基本都是 github 上的,建议终端执行设置代理下载,如果没有代理,速度可能会比较慢,中国国内用户可以到 [首页 QQ 群](../) 群文件下载。
|
||||
> 终端设置代理方法:`export http_proxy=http://127.0.0.1:8123 https_proxy=http://127.0.0.1:8123`,这里`http://127.0.0.1:8123`就是你的`http`代理的地址。
|
||||
>! 下载的资源基本都是 github 上的,中国国内下载速度可能会比较慢甚至失败(要下载的文件列表在`dl/pkgs_info.json`),有几种常见解决方法:
|
||||
> 1. 终端设置代理(推荐), 比如:`export http_proxy=http://127.0.0.1:8123 https_proxy=http://127.0.0.1:8123`,这里`http://127.0.0.1:8123`就是你的`http`代理的地址。
|
||||
> 2. 手动下载到`dl/pkgs`下:下载时,会打印下载连接和下载到本地的路径,手动下载文件方到对应路径,再次执行编译就会直接使用本地准备好的(注意文件 sha256 校验值必须相同即同一个文件)。
|
||||
> 3. 中国国内用户可以到 [首页 QQ 群](../) 群文件`MaixCDK`文件夹下载放到`MaixCDK/dl`目录下。
|
||||
|
||||
|
||||
>! 常见错误和解决方法看[FAQ](./faq.md)
|
||||
|
||||
编译完后在`build`目录下可以看到二进制程序文件,以及`build/dl_lib`下有依赖的`so`文件。
|
||||
|
||||
修改了代码后,再次执行`maixcdk build`即可编译。
|
||||
|
||||
`maixcdk build` 命令默认会扫描所有文件更改再构建,
|
||||
如果你**没有增删源码文件可以执行`maixcdk build --no-gen`编译会更快**。
|
||||
> 因为用了 `cmake`, `build`命令会每次都执行`cmake`命令,加了`--no-gen`参数后只会执行`make`命令所以更快,但是由于增删文件后需要执行`cmake`来扫描文件更改,为了防止开发者忘记执行所以默认行为就是每次都扫描再构建。
|
||||
如果你**没有增删源码文件可以执行`maixcdk build2` 或者 `maixcdk build --no-gen` 编译会更快**(只编译修改了的文件)。
|
||||
> 因为`build`命令会从头开始构建,扫描文件再编译,`build2`命令则不会扫描文件增删,直接编译编辑过的文件。
|
||||
> 注意`build2`命令不会检测到文件增加或者删除,如果**增删了文件必须再执行一遍`build`命令**。
|
||||
|
||||
也可以执行`maixcdk distclean` 清除所有编译产生的临时文件以从一个干净的环境开始编译(但是这样构建时间会很长,一般编译出现奇怪的问题可以先尝试这样解决)。
|
||||
|
||||
|
||||
@@ -6,6 +6,14 @@ You can also find FAQ from:
|
||||
* [MaixCAM FAQ](https://wiki.sipeed.com/hardware/zh/maixcam/faq.html)
|
||||
* [MaixPy 源码 FAQ](https://wiki.sipeed.com/maixpy/doc/zh/source_code/faq.html)
|
||||
|
||||
## 常见编译错误的通用解决方法
|
||||
|
||||
* **提示解压失败等错误**: 可以尝试删除掉`dl/pkgs`和`dl/extracted`目录下的对应文件让重新编译下载即可。
|
||||
* **编译报错**:
|
||||
* 执行`maixcdk build --verbose` 查看哪里报错,**仔细看报错日志**一步一步探寻问题。
|
||||
* 执行 `maixcdk distclean` 清理临时文件后重新编译。
|
||||
* 到[github 提交记录](https://github.com/sipeed/MaixCDK/commits/main/)处看到每个提交的自动测试是否通过(绿色的勾勾✅就是通过,红色叉叉❌就是失败),可以将本地代码切换到测试通过的提交✅再编译(本地执行`git checkout 提交号`比如`git checkout 3aba2fe3fa9de9f638bb9cb34eca0c2e0f5f3813`, 如果切换失败请自行搜索 git 用法或者直接从头来过,注意备份自己修改的代码)。
|
||||
|
||||
## Downloading ippicv_2021.8_lnx_intel64_20230330_general.tgz takes a long time or fail
|
||||
|
||||
Manually download according to the log's url, and put it into:
|
||||
|
||||
@@ -201,22 +201,26 @@ def parse_args(sdk_path, project_path, extra_tools):
|
||||
subparsers.add_parser(sub_parser.prog, parents=[sub_parser], help=sub_parser.description)
|
||||
|
||||
# cmd build
|
||||
parser_build = subparsers.add_parser("build", help="start compile project, temp files in `build` dir, dist files in `dist` dir, by default always execute cmake to regenerate, to disable cmake execute, use --no-gen option")
|
||||
parser_build.add_argument('--config-file',
|
||||
help='config file path, e.g. config_defaults.mk',
|
||||
metavar='PATH',
|
||||
default="{}/config_defaults.mk".format(project_path))
|
||||
parser_build.add_argument('--verbose',
|
||||
help='for build command, execute `cmake -build . --verbose` to compile',
|
||||
action="store_true",
|
||||
default=False)
|
||||
parser_build.add_argument('-G', '--generator', default="", help="project type to generate, supported type on your platform see `cmake --help`")
|
||||
parser_build.add_argument('--release', action="store_true", default=False, help="release mode, default is release mode")
|
||||
parser_build.add_argument('--debug', action="store_true", default=False, help="debug mode, default is release mode")
|
||||
parser_build.add_argument('--build-type', default=None, help="build type, [Debug, Release, MinRelSize, RelWithDebInfo], you can also set build type by CMAKE_BUILD_TYPE environment variable")
|
||||
parser_build.add_argument('-p', "--platform", default="", help="device name, e.g. linux, maixcam, m2dock", choices=get_platforms(sdk_path))
|
||||
parser_build.add_argument("--no-gen", action="store_true", default=False, help="by default the build command do the same action as rebuild to avoid user can't understand rebuild, but if you don't want to re-execute cmake command, and only compile, use this option")
|
||||
parser_build.add_argument('--toolchain-id', default="", help="toolchain id, if platform has multiple toolchains, use this option to select one")
|
||||
parser_build = subparsers.add_parser("build", help="start compile project, temp files in `build` dir, dist files in `dist` dir, build command by default always execute cmake to regenerate, to disable file change scan (cmake execute), use build2 command or add --no-gen option to only compile changed files, warning build2 will not detect file additions and deletions")
|
||||
parser_build2 = subparsers.add_parser("build2", help="same as `maixcdk build --no-gen`, compile project, not scan files additions and deletions, only compile changed files, so build faster but be attention you should use build again if you add new file or delete files")
|
||||
parser_build.add_argument("--no-gen", action="store_true", default=False, help="same as command build2, by default the build command do the same action as rebuild to avoid user can't understand rebuild, but if you don't want to re-execute cmake command, and only compile, use this option")
|
||||
def add_build_args(parser_):
|
||||
parser_.add_argument('--config-file',
|
||||
help='config file path, e.g. config_defaults.mk',
|
||||
metavar='PATH',
|
||||
default="{}/config_defaults.mk".format(project_path))
|
||||
parser_.add_argument('--verbose',
|
||||
help='for build command, execute `cmake -build . --verbose` to compile',
|
||||
action="store_true",
|
||||
default=False)
|
||||
parser_.add_argument('-G', '--generator', default="", help="project type to generate, supported type on your platform see `cmake --help`")
|
||||
parser_.add_argument('--release', action="store_true", default=False, help="release mode, default is release mode")
|
||||
parser_.add_argument('--debug', action="store_true", default=False, help="debug mode, default is release mode")
|
||||
parser_.add_argument('--build-type', default=None, help="build type, [Debug, Release, MinRelSize, RelWithDebInfo], you can also set build type by CMAKE_BUILD_TYPE environment variable")
|
||||
parser_.add_argument('-p', "--platform", default="", help="device name, e.g. linux, maixcam, m2dock", choices=get_platforms(sdk_path))
|
||||
parser_.add_argument('--toolchain-id', default="", help="toolchain id, if platform has multiple toolchains, use this option to select one")
|
||||
add_build_args(parser_build)
|
||||
add_build_args(parser_build2)
|
||||
|
||||
# cmd menuconfig
|
||||
parser_menuconfig = subparsers.add_parser("menuconfig", help="open menuconfig panel, a visual config panel")
|
||||
@@ -322,7 +326,7 @@ def main(sdk_path, project_path):
|
||||
distclean(project_path, build_path, dist_path)
|
||||
print("-- Distclean done")
|
||||
sys.exit(0)
|
||||
elif cmd in ["build"]:
|
||||
elif cmd in ["build", "build2"]:
|
||||
check_project_valid()
|
||||
platform = configs["PLATFORM"]
|
||||
print("-- Project ID: {}".format(project_id))
|
||||
@@ -364,7 +368,7 @@ def main(sdk_path, project_path):
|
||||
|
||||
print("-- Build now")
|
||||
t = time.time()
|
||||
if args.no_gen:
|
||||
if cmd == "build2" or args.no_gen:
|
||||
build(build_path, configs, info, args.verbose)
|
||||
else:
|
||||
rebuild(build_path, configs, info, args.verbose)
|
||||
|
||||
Reference in New Issue
Block a user