Skip to main content

xt sdk command line tool

Project description

xt-cli

xt-cli 是 xt-sdk 的命令行工具,用于简化 xt-sdk 的配置、编译、清理和运行流程。

安装

pip install xt-cli

快速开始

xt config --sdk <sdk-path>
cd <project-dir>
xt build --target <target>

命令

xt-cli 基础命令格式如下:

xt [GLOBAL OPTIONS] TASK [TASK OPTIONS] ...
命令 说明
xt build 编译工程,支持 xt clean build 多 task 组合
xt clean 清理构建产物(xmake clean)
xt fullclean 删除 .xmake / .build 目录
xt config 管理配置,支持 set / get / reset / show
xt deps 管理版本依赖,--update-deps-require 更新 require
xt --version 输出版本号

全局参数

以下参数可用于命令行任意位置:

参数 说明 示例
--target / -t 目标平台路径或名称 windows/simulatorlm620/r4f4
--sdk SDK 根目录路径 D:/xt-sdk
--toolchain-path 工具链路径 C:/tools/mingw64/bin
--project / -p 工程目录路径 examples/get_started/hello_world
--board 板级名称 e837n_v01simulator
--dirty 允许脏仓库编译
--no-track 跳过本次 xt_vers 更新
--strict 严格模式:强制所有约束,dirty 中止
--sync-deps 编译前 checkout 各仓库到 xt_deps.jsonc 要求版本

配置系统

配置文件 xt_conf.jsonc(JSONC 格式),支持工程级(local)和用户级(~/.xt/ global)二级作用域。优先级:CLI 参数 > 工程配置 > 全局配置 > 默认值。

xt config --sdk D:/xt-sdk                   # 设置 SDK 路径
xt config --target windows/simulator        # 设置默认 target
xt config --platform windows --toolchain-path C:/mingw64/bin
xt config --get sdk                         # 查询
xt config --reset target                    # 重置
xt config                                   # 展示全部配置

Hook 扩展

在工程目录或平台目录下创建 xt_hook.py,定义 handle_<task> 函数即可扩展命令。xt-cli 自动发现并注册,import xt_cli 提供稳定 API:

import xt_cli

def handle_flash(context: xt_cli.BuildContext, global_args, shared_args, self_args, unknown_args):
    """--help: Flash firmware to the device."""
    print(f"flashing {context.target} via {self_args.port}")
    return 0

def add_args_flash(parser):
    parser.add_argument("--port", default="COM1")
xt flash --port COM3           # 自动分发到 handle_flash
xt build                       # 自动触发 before_build / after_build 生命周期
  • 调度优先级:工程 hook > 平台 hook
  • 支持 before_build / after_build / before_clean / after_clean 等生命周期 hook
  • context.run_task("build") 支持 hook 内组合调用内置命令

版本追踪

每次 xt build 自动记录依赖仓库的 git commit 到 xt_vers.jsonc。通过 xt_deps.jsonc 声明版本约束,不匹配时自动警告或中止:

// xt_deps.jsonc
{
  "xt-sdk": { "require": ">= c9e1234" },
  "platforms": {
    "windows": { "require": "b8d82d2", "targets": ["simulator"] }
  }
}
xt build                        # 自动检查约束,通过后编译并记录版本
xt build --strict               # 约束不匹配 → 中止
xt build --dirty                # 允许脏仓库编译
xt build --no-track             # 本次跳过版本记录
xt build --sync-deps            # 编译前 checkout 各仓库到 require 版本
xt deps --update-deps-require   # 将当前版本写回 xt_deps.jsonc

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

xt_cli-0.2.2.tar.gz (36.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

xt_cli-0.2.2-py3-none-any.whl (42.3 kB view details)

Uploaded Python 3

File details

Details for the file xt_cli-0.2.2.tar.gz.

File metadata

  • Download URL: xt_cli-0.2.2.tar.gz
  • Upload date:
  • Size: 36.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.6

File hashes

Hashes for xt_cli-0.2.2.tar.gz
Algorithm Hash digest
SHA256 b94a7b5780836aa8dd3154913b348547c2bdec8317f30785e09efe93d40d610b
MD5 6eea927f6fa05e3b35d4a04087747a62
BLAKE2b-256 e20d3833401b7090174dea8efbe45deebff918d1ec847ce3eb686c2de3106ea3

See more details on using hashes here.

File details

Details for the file xt_cli-0.2.2-py3-none-any.whl.

File metadata

  • Download URL: xt_cli-0.2.2-py3-none-any.whl
  • Upload date:
  • Size: 42.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.6

File hashes

Hashes for xt_cli-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 224b2e8c51d2a5980c2ca6eb43efaf7fdcdd0efbda4720b5b6f7c4fff80dc227
MD5 4047ee5e25c2164e45065e1b51debae7
BLAKE2b-256 f5e2256bf96b6ad49b2e72f2ea90f326d62abe36ee7a6f00c7e35310458fe225

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page