kits

package
v0.1.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 20, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package kits 存放"某个工程用哪些Kit构建"的持久化状态: Kit列表, 叠在Kit上的构建变体(Debug/Release), 以及当前激活的那一组.

Store 绑定一个工程根目录, 只读写该目录下的一个文件 <root>/.silk-kits.json, 自己不探测机器 —— 需要填充新工程时由调用方跑 core.DetectKits 再 Set 进来.

Index

Constants

View Source
const (
	VariantDebug   = "Debug"
	VariantRelease = "Release"
)

默认构建变体名

View Source
const FileName = ".silk-kits.json"

FileName 是工程级Kit文件名, 放在工程根目录下

Variables

This section is empty.

Functions

This section is empty.

Types

type Store

type Store struct {
	// contains filtered or unexported fields
}

Store 是一个工程的Kit配置 New 之后是"默认状态"(无Kit, Debug/Release两个变体, 激活Debug), Load 把磁盘上的内容读进来, Save 写回去

func New

func New(dir string) *Store

New 返回绑定到工程根目录dir的Store, 内容是默认状态

func (*Store) ActiveKit

func (s *Store) ActiveKit() (core.Kit, bool)

ActiveKit 返回激活Kit(副本)

func (*Store) ActiveKitName

func (s *Store) ActiveKitName() string

ActiveKitName 返回激活Kit的名字, 没有则为 ""

func (*Store) ActiveVariant

func (s *Store) ActiveVariant() (Variant, bool)

ActiveVariant 返回激活变体

func (*Store) ActiveVariantName

func (s *Store) ActiveVariantName() string

ActiveVariantName 返回激活变体的名字

func (*Store) Dir

func (s *Store) Dir() string

Dir 返回Store绑定的工程根目录

func (*Store) Exists

func (s *Store) Exists() bool

Exists 报告Kit文件是否已经存在

func (*Store) Get

func (s *Store) Get(name string) (core.Kit, bool)

Get 按名字取Kit(副本)

func (*Store) List

func (s *Store) List() []core.Kit

List 返回所有Kit的副本, 顺序即写入顺序

func (*Store) Load

func (s *Store) Load() error

Load 读取Kit文件 文件不存在不算错误: 这是"工程还没配过Kit", Store保持默认状态并返回nil. 文件损坏时返回包装后的error, 同样保持默认状态, 绝不让脏文件把面板带崩

func (*Store) Path

func (s *Store) Path() string

Path 返回Kit文件的路径

func (*Store) Remove

func (s *Store) Remove(name string) bool

Remove 按名字删除Kit, 返回是否真的删掉了 删掉的正好是激活Kit时, 激活项顺延到剩下的第一个(没有则清空)

func (*Store) Resolved

func (s *Store) Resolved() (core.Kit, bool)

Resolved 返回"激活Kit叠上激活变体"的最终构建配置 没有激活Kit时返回false; 有Kit但变体缺失时返回未叠加的Kit

func (*Store) Save

func (s *Store) Save() error

Save 把当前状态写回Kit文件

func (*Store) Set

func (s *Store) Set(k core.Kit) error

Set 新增或按名字覆盖一个Kit 校验不过的Kit一律拒绝, 免得把跑不起来的配置写进工程文件. 第一个被加进来的Kit自动成为激活Kit

func (*Store) SetActiveKit

func (s *Store) SetActiveKit(name string) error

SetActiveKit 切换激活Kit, 名字不存在时报错且不改动状态

func (*Store) SetActiveVariant

func (s *Store) SetActiveVariant(name string) error

SetActiveVariant 切换激活变体, 名字不存在时报错且不改动状态 命中后写回变体自身的规范名字, 磁盘上不会留下 "release" 这类随手输入的大小写

func (*Store) SetVariant

func (s *Store) SetVariant(v Variant) error

SetVariant 新增或按名字覆盖一个变体

func (*Store) Variant

func (s *Store) Variant(name string) (Variant, bool)

Variant 按名字取变体, 名字大小写不敏感(用户手输 "release" 也能命中)

func (*Store) Variants

func (s *Store) Variants() []Variant

Variants 返回所有构建变体的副本

type Variant

type Variant struct {
	Name      string   `json:"name"`
	Tags      []string `json:"tags,omitempty"`       // 追加到Kit的tag后面
	Race      bool     `json:"race,omitempty"`       // 与Kit的Race取或
	Coverage  bool     `json:"coverage,omitempty"`   // 与Kit的Coverage取或
	OutputDir string   `json:"output_dir,omitempty"` // 非空则覆盖Kit的输出目录
}

Variant 是叠在Kit之上的具名构建变体, 对应 Qt Creator 的 Debug/Release 构建配置. 零值字段表示"沿用Kit本身的设置", 只有非零字段才覆盖

func DefaultVariants

func DefaultVariants() []Variant

DefaultVariants 是新工程的两个标准变体: Debug 开竞态检测, Release 不开, 产物分别落在 build/debug 与 build/release, 避免两种构建互相覆盖

func (Variant) Apply

func (v Variant) Apply(kit core.Kit) core.Kit

Apply 把变体叠到kit上, 返回合并后的新Kit(不改动入参)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL