* add nix flake nix profile install nix profile install github:diodeinc/pcb kicad isn't packaged here yet but can deal with that later used crane as there is a bug in nixpkgs rust https://discourse.nixos.org/t/rust-with-git-deps-symbolic-link-error-to-cargo-vendor-dep/28841 and naserk had some issue as well. crane isn't ideal because it doesn't cache properly but now it one click installs so whatever * allow external buildifier * fix linux compilation next up package kicad in a sane way * fmt * apply suggestions
pcb-buildifier
This crate provides a bundled buildifier binary for use by the PCB tooling ecosystem.
About Buildifier
Buildifier is a tool for formatting Bazel BUILD and .bzl files with a standard convention. It's part of the buildtools project by the Bazel Authors.
How It Works
This crate:
- Downloads the appropriate buildifier binary for the target platform during the build process
- Embeds the binary directly into the Rust binary at compile time
- On first use, extracts the binary to a cache directory (
~/.cache/pcb/buildifier/v<version>/on Linux/macOS,~/Library/Caches/pcb/buildifier/v<version>/on macOS,%LOCALAPPDATA%\pcb\buildifier\v<version>\on Windows) - Subsequent runs use the cached binary for optimal performance
This approach ensures that:
- No internet connection is required at runtime
- The buildifier version is consistent across all platforms
- No PATH configuration is needed
- The tool works out of the box
- Performance is optimal after the first run (typically 10-20x faster)
Supported Platforms
- macOS (x86_64, ARM64)
- Linux (x86_64, ARM64)
- Windows (x86_64)
Cache Management
The buildifier binary is cached to improve performance. If you need to clear the cache (e.g., if the binary becomes corrupted), you can delete the cache directory:
- macOS:
rm -rf ~/Library/Caches/pcb/buildifier/ - Linux:
rm -rf ~/.cache/pcb/buildifier/ - Windows:
rmdir /s %LOCALAPPDATA%\pcb\buildifier\
The binary will be re-extracted on the next run.
License
This crate is licensed under the MIT license (see the root LICENSE file).
The bundled buildifier binary is part of the buildtools project and is licensed under the Apache License, Version 2.0. See the LICENSE file in this directory for the full Apache 2.0 license text.
Usage
This crate is primarily intended to be used as a dependency by other PCB tools, particularly pcb fmt.
use pcb_buildifier::Buildifier;
let buildifier = Buildifier::new()?;
buildifier.format_file(&path)?;