refactor: move branding into tools/ and drive the checker from a table
Three changes that only make sense together. **tools/**. check-branding.sh, brand-plugin.sh and branding.conf were accumulating in the repo root, and a deploy.sh/bat/ps1 set would land there too. They now live in tools/ and resolve the repo root explicitly rather than assuming their own directory is it, so they behave the same however they are invoked. **One name drives the rest.** branding.conf now derives the package name, the Rust types and the display name from PLUGIN_NAME, each overridable. Derivation-by-default removes a class of drift; the override matters because the derivation is sometimes invalid — "206 Prototype" derives to "206_prototype", which cargo rejects outright — and because PLUGIN_NAME is cosmetic while the package name is structural. A display tweak should not silently rename the crate, its bundle lookup, the CI command and the lockfile. This template overrides three of them, which a real plugin normally will not: its names are the template's own rather than derived from a product name. An overridden PKG that no longer matches the derivation is reported at info level, never failed. The override is usually deliberate; a display rename that forgot the package looks identical from here, and is not. **The site table is data.** branding-sites.tsv lists every place a name must appear and in what form; check-branding.sh iterates it instead of carrying 29 check calls in shell. The scripts are now identical across every plugin built from this template, with only the table and conf differing — which matters because the template and codename-206 had already diverged by two checks, so every sync was a shell merge. brand-plugin.sh regenerates the rows it owns and preserves the rest, so a hand-added row for a file this template does not ship survives a rename. Custom rows are value-substituted like any other tracked file, so they track the rename rather than going stale — the first cut excluded the whole table from substitution and got that wrong. brand-plugin.sh also gained an interactive mode: run it with no arguments and it prompts for each value with the current one as the default, so Enter keeps it and a run that answers nothing changes nothing. It only engages when there is a terminal to ask at, so CI gets the usage message and exit 2 rather than a hang. Verified by applying a full rename to a sandboxed copy: 8 files rewritten, 29 owned rows regenerated, 1 custom row preserved and substituted, checker green at 48/0/7, and the result compiles as bari_206. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WHt4DykxXaQnyaJfyS8KCn
This commit is contained in:
@@ -0,0 +1,90 @@
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
# branding.conf - this plugin's canonical identity.
|
||||
#
|
||||
# Managed by tools/brand-plugin.sh, read by tools/check-branding.sh. Hand-editing
|
||||
# works and is sometimes the quickest thing, but the helper is what keeps this
|
||||
# file, the source tree and tools/branding-sites.tsv agreeing with each other.
|
||||
# Edit here and you are on the hook for running the checker afterwards.
|
||||
|
||||
# --- derivations ------------------------------------------------------------
|
||||
# Defined before the values so the defaults below can use them.
|
||||
# Package name: lowercased, every run of non-alphanumerics becomes one
|
||||
# underscore. Cargo accepts hyphens too and maps them to underscores for the
|
||||
# built artifact, which nih_plug_xtask already handles; underscores are used to
|
||||
# match the Rust convention.
|
||||
_derive_pkg() {
|
||||
printf '%s' "$1" | tr '[:upper:]' '[:lower:]' \
|
||||
| sed -e 's/[^a-z0-9]\{1,\}/_/g' -e 's/^_//' -e 's/_$//'
|
||||
}
|
||||
# Rust type name: CamelCase, non-alphanumerics dropped.
|
||||
_derive_struct() {
|
||||
printf '%s' "$1" | sed -e 's/[^A-Za-z0-9]\{1,\}/ /g' \
|
||||
| awk '{for(i=1;i<=NF;i++) printf "%s%s", toupper(substr($i,1,1)), substr($i,2); print ""}'
|
||||
}
|
||||
|
||||
# --- the names ---------------------------------------------------------------
|
||||
PLUGIN_NAME="Plugin Name" # the one name everything else derives from
|
||||
VENDOR="Your Name" # Plugin::VENDOR - the org, not the person
|
||||
EMAIL="your@email.com" # Plugin::EMAIL
|
||||
HOMEPAGE="https://github.com/YOUR-USERNAME/YOUR-PLUGIN-NAME" # -> Plugin::URL
|
||||
DESCRIPTION="A minimal NIH-plug audio plugin" # Cargo description
|
||||
|
||||
# What the plugin does *now*. No codename, no "prototype", no "v2 rewrite" -
|
||||
# hosts show this to users who never knew any of that. check-branding.sh
|
||||
# enforces the mechanical half by rejecting retired names and the repo codename.
|
||||
CLAP_DESCRIPTION="Your plugin description"
|
||||
|
||||
# --- frozen identity ---------------------------------------------------------
|
||||
# Hosts key saved projects and presets off these two. Change either and every
|
||||
# existing session silently loses the plugin: the track comes up empty, with no
|
||||
# error. Choose once before the first release, then never again.
|
||||
# brand-plugin.sh refuses to move them without --allow-identity-change.
|
||||
CLAP_ID="com.your-domain.plugin-name" # reverse-DNS, lowercase, no spaces
|
||||
VST3_CLASS_ID="Unique16CharId!!" # MUST be exactly 16 bytes
|
||||
|
||||
# --- fixed at repo creation --------------------------------------------------
|
||||
# The repository's own name. Deliberately NOT renamed when the plugin is: the
|
||||
# repo keeps its development codename while the plugin gets a product name.
|
||||
# Recorded only so it can be kept out of user-facing text.
|
||||
CODENAME="nih-plug-template"
|
||||
|
||||
# Where the two Rust types are defined. A plugin whose params outgrow lib.rs
|
||||
# points PARAMS_FILE at src/params.rs.
|
||||
LIB_FILE="src/lib.rs"
|
||||
PARAMS_FILE="src/lib.rs"
|
||||
|
||||
# --- derived unless overridden -----------------------------------------------
|
||||
# Set one only when the derivation is wrong or rejected - a name like
|
||||
# "206 Prototype" derives to "206_prototype", which cargo refuses because a
|
||||
# package name cannot start with a digit.
|
||||
#
|
||||
# This template overrides three of them, which a real plugin usually will not:
|
||||
# its package and type names are the template's own rather than derived from a
|
||||
# product name. Delete these three lines after renaming and the derivations
|
||||
# from PLUGIN_NAME take over.
|
||||
PKG="nih_plug_template"
|
||||
STRUCT="MyPlugin"
|
||||
PARAMS_STRUCT="PluginParams"
|
||||
# DISPLAY="Plugin Name" # defaults to PLUGIN_NAME
|
||||
: "${DISPLAY:=$PLUGIN_NAME}"
|
||||
: "${PKG:=$(_derive_pkg "$PLUGIN_NAME")}"
|
||||
: "${STRUCT:=$(_derive_struct "$PLUGIN_NAME")}"
|
||||
: "${PARAMS_STRUCT:=${STRUCT}Params}"
|
||||
|
||||
# --- retired spellings -------------------------------------------------------
|
||||
# Must no longer appear in tracked files. An entry is skipped while it is still
|
||||
# part of a canonical value above and arms the moment it stops being one, so a
|
||||
# rename is self-checking in both directions. brand-plugin.sh appends here.
|
||||
STALE="nih_plug_template
|
||||
MyPlugin
|
||||
PluginParams
|
||||
A minimal NIH-plug audio plugin
|
||||
Your plugin description
|
||||
Plugin Name
|
||||
Your Name
|
||||
your@email.com
|
||||
com.your-domain.plugin-name
|
||||
Unique16CharId!!
|
||||
YOUR-USERNAME
|
||||
YOUR-PLUGIN-NAME
|
||||
your-domain"
|
||||
Reference in New Issue
Block a user