Add global-install support and document installation in README
- scripts/generate_global_tables.py generates sym-lib-table.global /
fp-lib-table.global using a custom env var (default MIKILAB) instead
of ${KIPRJMOD}, for use across every KiCad project
- README §1 now has concrete, tested install steps for this machine's
KiCad 10.0 setup (per-project vs. global), including a merge script
and a note about stale kicad-personal-library entries already
present in the user's global sym-lib-table
This commit is contained in:
@@ -33,7 +33,8 @@ ROOT = lc.LIBRARY_ROOT
|
||||
|
||||
EXPECTED_TOP_LEVEL = {
|
||||
"symbols", "footprints", "3dmodels", "docs", "legacy", "scripts",
|
||||
"sym-lib-table", "fp-lib-table", "MANIFEST.csv", "MANIFEST.md",
|
||||
"sym-lib-table", "fp-lib-table", "sym-lib-table.global", "fp-lib-table.global",
|
||||
"MANIFEST.csv", "MANIFEST.md",
|
||||
"README.md", ".git", ".claude", ".gitignore", ".DS_Store",
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
generate_global_tables.py
|
||||
==========================
|
||||
|
||||
sym-lib-table / fp-lib-table at the library root use ${KIPRJMOD}, which
|
||||
KiCad only resolves when this directory *is* (or is symlinked as) the
|
||||
currently open project's directory. To use this library globally, across
|
||||
every KiCad project, you instead need a custom environment variable (this
|
||||
script defaults to MIKILAB) defined once in KiCad's Configure Paths, plus
|
||||
a copy of the two tables that reference that variable instead of
|
||||
${KIPRJMOD}.
|
||||
|
||||
This script writes:
|
||||
sym-lib-table.global
|
||||
fp-lib-table.global
|
||||
|
||||
at the library root, identical in content to sym-lib-table/fp-lib-table
|
||||
except for the environment variable used in each URI. See README.md
|
||||
section 1 for the full install steps.
|
||||
|
||||
Usage:
|
||||
python3 scripts/generate_global_tables.py [--env-var MIKILAB]
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import argparse
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
sys.path.insert(0, str(Path(__file__).resolve().parent))
|
||||
|
||||
import lib_common as lc
|
||||
|
||||
ROOT = lc.LIBRARY_ROOT
|
||||
|
||||
|
||||
def main() -> int:
|
||||
parser = argparse.ArgumentParser(description=__doc__)
|
||||
parser.add_argument("--env-var", default="MIKILAB", help="KiCad environment variable name to use (default: MIKILAB)")
|
||||
args = parser.parse_args()
|
||||
|
||||
sym_entries = lc.build_sym_table_entries(ROOT, env_var=args.env_var)
|
||||
fp_entries = lc.build_fp_table_entries(ROOT, env_var=args.env_var)
|
||||
|
||||
(ROOT / "sym-lib-table.global").write_text(
|
||||
lc.render_lib_table("sym_lib_table", sym_entries), encoding="utf-8"
|
||||
)
|
||||
(ROOT / "fp-lib-table.global").write_text(
|
||||
lc.render_lib_table("fp_lib_table", fp_entries), encoding="utf-8"
|
||||
)
|
||||
|
||||
print(f"Wrote sym-lib-table.global ({len(sym_entries)} libraries, using \\${{{args.env_var}}})")
|
||||
print(f"Wrote fp-lib-table.global ({len(fp_entries)} libraries, using \\${{{args.env_var}}})")
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
@@ -155,27 +155,27 @@ class LibEntry:
|
||||
options: str = ""
|
||||
|
||||
|
||||
def build_sym_table_entries(root: Path) -> list[LibEntry]:
|
||||
def build_sym_table_entries(root: Path, env_var: str = "KIPRJMOD") -> list[LibEntry]:
|
||||
used: set[str] = set()
|
||||
entries = []
|
||||
|
||||
for path in discover_symbol_libraries(root):
|
||||
relative = path.relative_to(root)
|
||||
nickname = unique_nickname(sym_nickname(path), used)
|
||||
uri = "${KIPRJMOD}/" + str(relative)
|
||||
uri = "${" + env_var + "}/" + str(relative)
|
||||
entries.append(LibEntry(nickname=nickname, uri=uri, descr=path.stem))
|
||||
|
||||
return entries
|
||||
|
||||
|
||||
def build_fp_table_entries(root: Path) -> list[LibEntry]:
|
||||
def build_fp_table_entries(root: Path, env_var: str = "KIPRJMOD") -> list[LibEntry]:
|
||||
used: set[str] = set()
|
||||
entries = []
|
||||
|
||||
for path in discover_footprint_libraries(root):
|
||||
relative = path.relative_to(root)
|
||||
nickname = unique_nickname(fp_nickname(path), used)
|
||||
uri = "${KIPRJMOD}/" + str(relative)
|
||||
uri = "${" + env_var + "}/" + str(relative)
|
||||
entries.append(LibEntry(nickname=nickname, uri=uri, descr=path.name))
|
||||
|
||||
return entries
|
||||
|
||||
Reference in New Issue
Block a user