diff --git a/en/clice/design/command-resolve.md b/en/clice/design/command-resolve.md index 6ccbc876c..7b4ab6131 100644 --- a/en/clice/design/command-resolve.md +++ b/en/clice/design/command-resolve.md @@ -214,4 +214,4 @@ After the four tiers are concatenated, deduplication begins from the Angled tier - **MSVC-style option parsing.** On non-Windows systems, MSVC-style option prefixes (`/U`, `/D`, `/I`) must be handled specially to prevent Unix absolute paths (such as `/Users/...`) from being misparsed as MSVC options. This is currently resolved by dynamically adjusting option visibility based on the driver name, but edge cases may still exist. -- **Compiler launchers are not recognized.** CDB commands wrapped in a launcher (`ccache g++ ...`, `sccache clang++ ...`) are parsed as if the launcher were the compiler, so family identification and toolchain probing target the wrong binary. Strip the launcher from the compilation database, or override the flags with configuration rules. +- **Only the common compiler launchers are recognized.** ccache, sccache, distcc and icecc are taken off a command with their own options and environment assignments, and the compiler after them is the one clice asks. Any other launcher is taken for the compiler, so family identification and toolchain probing target the wrong binary; strip it from the compilation database. diff --git a/en/clice/guide/configuration.md b/en/clice/guide/configuration.md index 2394b6af1..6f2b8064f 100644 --- a/en/clice/guide/configuration.md +++ b/en/clice/guide/configuration.md @@ -746,7 +746,7 @@ Compilation databases, in priority order: a compile_commands.json or a directory | ----------------- | ----------------------------- | ------- | | `default_command` | `string` or `array of string` | `""` | -The compile command for matching files without a database entry, without the source file: a string tokenized like a shell command line, or an argv array. It runs from the directory of the configuration file it was read from (the workspace root for a rule passed through initializationOptions), and the matching source files on disk join the background index (unless the rule turns `index` off) — enumerated at startup and again on every workspace poll, so a file created later compiles when opened and joins the index within a poll period. Omitted means none. +The compile command for matching files without a database entry, without the source file: a string tokenized like a shell command line, or an argv array. It runs from the directory of the configuration file it was read from (the workspace root for a rule passed through initializationOptions), and the matching source files on disk join the background index (unless the rule turns `index` off) — enumerated at startup and again on every workspace poll, so a file created later compiles when opened and joins the index within a poll period. A file clang has no language for (an Arduino `.ino`, an extensionless tool) is a source only when the command forces a language (`-x c++`) and a pattern names its suffix (`*.ino`) or the file itself. Omitted means none. @@ -766,7 +766,7 @@ Compilation flags appended for matching files, e.g. `["-std=c++20", "-DNDEBUG"]` | -------- | ----------------- | ------- | | `remove` | `array of string` | `[]` | -Compilation flags removed for matching files, e.g. `["-Wall"]`. +Compilation flags removed for matching files, e.g. `["-Wall"]`. A flag with a value removes that value (`-DDEBUG`), the next element being a separate value as on a command line; one with `*` for its value (`-I*`, `["-include", "*"]`), or without one at the end of the list (`["-include"]`), removes every value; a `*` right after a flag's name removes every flag of its kind spelled with that prefix (`-W*` takes `-Wall` and `-Wextra` too). diff --git a/public/clice-config.schema.json b/public/clice-config.schema.json index 5f5a24778..5348a1dfb 100644 --- a/public/clice-config.schema.json +++ b/public/clice-config.schema.json @@ -569,7 +569,7 @@ } } ], - "description": "The compile command for matching files without a database entry, without the source file: a string tokenized like a shell command line, or an argv array. It runs from the directory of the configuration file it was read from (the workspace root for a rule passed through initializationOptions), and the matching source files on disk join the background index (unless the rule turns `index` off) — enumerated at startup and again on every workspace poll, so a file created later compiles when opened and joins the index within a poll period. Omitted means none.", + "description": "The compile command for matching files without a database entry, without the source file: a string tokenized like a shell command line, or an argv array. It runs from the directory of the configuration file it was read from (the workspace root for a rule passed through initializationOptions), and the matching source files on disk join the background index (unless the rule turns `index` off) — enumerated at startup and again on every workspace poll, so a file created later compiles when opened and joins the index within a poll period. A file clang has no language for (an Arduino `.ino`, an extensionless tool) is a source only when the command forces a language (`-x c++`) and a pattern names its suffix (`*.ino`) or the file itself. Omitted means none.", "default": "" }, "append": { @@ -585,7 +585,7 @@ "items": { "type": "string" }, - "description": "Compilation flags removed for matching files, e.g. `[\"-Wall\"]`.", + "description": "Compilation flags removed for matching files, e.g. `[\"-Wall\"]`. A flag with a value removes that value (`-DDEBUG`), the next element being a separate value as on a command line; one with `*` for its value (`-I*`, `[\"-include\", \"*\"]`), or without one at the end of the list (`[\"-include\"]`), removes every value; a `*` right after a flag's name removes every flag of its kind spelled with that prefix (`-W*` takes `-Wall` and `-Wextra` too).", "default": [] }, "query_toolchain": { diff --git a/zh/clice/design/command-resolve.md b/zh/clice/design/command-resolve.md index 450bfe113..1a7206abf 100644 --- a/zh/clice/design/command-resolve.md +++ b/zh/clice/design/command-resolve.md @@ -214,4 +214,4 @@ CDB 加载使用 simdjson 进行流式 JSON 解析,逐条处理记录: - **MSVC 风格选项解析。** 在非 Windows 系统上,必须特别处理 MSVC 风格选项前缀(`/U`、`/D`、`/I`),避免 Unix 绝对路径(如 `/Users/...`)被误解析为 MSVC 选项。目前通过根据驱动名称动态调整选项可见性来解决,但边界情况仍可能存在。 -- **编译器启动器不被识别。** 被启动器包装的 CDB 命令(`ccache g++ ...`、`sccache clang++ ...`)在解析时会将启动器视为编译器,导致家族识别和工具链探测以错误的二进制文件为目标。请从编译数据库的命令中去掉启动器,或用配置规则覆盖相关选项。 +- **只识别常见的编译器启动器。** ccache、sccache、distcc 和 icecc 会连同它们自己的选项和环境变量赋值一起从命令中去掉,clice 询问的是它们后面的编译器。其他启动器会被当成编译器,导致家族识别和工具链探测以错误的二进制文件为目标;请从编译数据库的命令中去掉它。 diff --git a/zh/clice/guide/configuration.md b/zh/clice/guide/configuration.md index 21aaf858d..13c16b96f 100644 --- a/zh/clice/guide/configuration.md +++ b/zh/clice/guide/configuration.md @@ -746,7 +746,7 @@ clice 会在后台查看磁盘上的文件,以发现编辑器之外发生的 | ----------------- | ----------------------------- | ------ | | `default_command` | `string` 或 `array of string` | `""` | -匹配到但没有数据库条目的文件所用的编译命令,其中不含源文件本身:可以是一个按 shell 命令行方式分词的字符串,也可以是 argv 数组。它以读取到该命令的配置文件所在目录为工作目录运行(通过 initializationOptions 传入的规则则以工作区根目录为准),磁盘上匹配到的源文件会加入后台索引(除非规则关闭了 `index`)——这些文件在启动时枚举,之后每次工作区轮询时再枚举一遍,因此新建的文件打开时即可编译,并在一个轮询周期内加入索引。省略则不提供命令。 +匹配到但没有数据库条目的文件所用的编译命令,其中不含源文件本身:可以是一个按 shell 命令行方式分词的字符串,也可以是 argv 数组。它以读取到该命令的配置文件所在目录为工作目录运行(通过 initializationOptions 传入的规则则以工作区根目录为准),磁盘上匹配到的源文件会加入后台索引(除非规则关闭了 `index`)——这些文件在启动时枚举,之后每次工作区轮询时再枚举一遍,因此新建的文件打开时即可编译,并在一个轮询周期内加入索引。clang 不认得语言的文件(Arduino 的 `.ino`、没有扩展名的工具源文件)只有在命令强制了语言(`-x c++`)、且有模式写出了它的后缀(`*.ino`)或它本身时,才算源文件。省略则不提供命令。 @@ -766,7 +766,7 @@ clice 会在后台查看磁盘上的文件,以发现编辑器之外发生的 | -------- | ----------------- | ------ | | `remove` | `array of string` | `[]` | -为匹配的文件移除编译标志,例如 `["-Wall"]`。 +为匹配的文件移除编译标志,例如 `["-Wall"]`。带值的标志只移除这个值(`-DDEBUG`),和命令行一样,下一个元素是它的分离值;值写成 `*`(`-I*`、`["-include", "*"]`),或在列表末尾不写值(`["-include"]`)时,移除它的所有值;紧跟在标志名后的 `*` 移除同类标志中所有以这个前缀拼写的(`-W*` 连 `-Wall` 和 `-Wextra` 也一并移除)。