Repository navigation
Expose the Aegisub version to Lua as aegisub.version - #732
CoffeeFlux wants to merge 1 commit into
Conversation
|
I need to fix up the actual values returned here, but we definitely need a richer way to fetch the version than just the automation API counter, unless we want to start bumping that any time we change anything. The motivation here in particular is wanting to add an API for DepCtrl to use, but needing a way to gate on it. I'm inclined to start by exposing less and seeing what's useful, so maybe the build number is the right place to start, along with the semver version set in meson? |
|
While this does seem logical, is there a reason against scripts just checking for the specific features they expect to be present? e.g. EDIT: i somehow entirely glossed over this being mentioned in OP already, sorry. still, though: it's not clear to me what those cases are where you couldn't check for function existence (unless you're planning on significant backwards-compat breaks, i guess?) |
|
I guess one case I can think of is where an API function that used to take three arguments is extended to take an optional fourth argument in a newer version, or if Either way, exposing the version explicitly is just more idiomatic. As for the specific API, the conclusion is that it looks good to me, but for future reference here's why I discarded some alternatives:
Regarding the code:
|
Scripts have so far only been able to check lua_automation_version, which hasn't changed in years, so there's no way for them to check for changes that can't be detected by looking for a function, such as new optional arguments. aegisub.version is a table with: - string: the full version string, for display and logging - major, minor, patch: the version declared in meson.build, i.e. that of the latest release this was built from or of the release being prepared, so that a development build made after 3.5.0 reports 3.5.0 - build: the build number, which increases with every commit to master, or nil if unknown (when built from a shallow clone) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ce15dfe to
b25c41a
Compare
|
OK I've updated this to be a bit more useful. I'm not sure what the release flag would do so it has been dropped, and the version just threads the one set in Meson through. |
|
Needs a corresponding site update as well |
Scripts can currently only check
aegisub.lua_automation_version, which has been 4 for years, so they have no way to check for changes that can't be detected by looking for a function, such as new optional arguments or new dialog control fields. This addsaegisub.version, a table with:string"3.5.0"for a release or"9900-master-4e440a614"for a development build. For display and logging.major,minor,patchmeson.build(project(version: ...))buildnilif unknownVersion numbers
The numbers come from meson's project version rather than from parsing the version string. That version is bumped when a release is being prepared (e.g. to 3.5.0 alongside the 3.5.0 beta), so it's always the latest release a build contains, or the one being prepared. That means:
They're passed in as compile-time defines, so there's no string parsing.
Build number
This is the existing revision number from
tools/version.sh: commits since the last SVN commit. It's only increasing along master; other branches and forks number their builds differently. So it's useful for gating on features added since the latest release in official builds, but scripts should prefer the version numbers or feature detection. It'snilwhen the number is unknown, which happens when building from a shallow clone. CI clones the full history andmeson disttarballs carry the generated header, so official builds always have it.Docs and testing
automation/v4-docs/misc.txtdocuments the table. It recommends checking for the specific feature where possible, and notes that the version is for changes that can't be detected that way.Tested on macOS with an autoload script that dumps the table: a development build reports
string=9902-…-0e5bdd30c major=3 minor=5 patch=0 build=9902. Runningtools/version.shin a--depth 1clone gives build number 0, which is exposed asnil.🤖 Generated with Claude Code