Skip to content

sf-mod-build 0.4.0

Choose a tag to compare

@github-actions github-actions released this 23 Nov 23:05
· 58 commits to main since this release

What's new

  • Two more kinds of builder in sfmod.json. Give exactly one of builder.project (a .NET project, as before), builder.command or builder.prebuilt; validate reports none or two as a PROBLEM.
  • builder.command runs any program that writes the plugin: a list with the program first and its first arguments after it, such as ["python", "tools/build.py"] or ["dotnet", "run", "build.cs", "--"]. builder.args are added after it, and the builder placeholders work in both. A program with a / or \ is a path relative to sfmod.json; a bare name is found on PATH. It runs in the sfmod.json folder without a shell, and doesn't need .NET.
  • builder.prebuilt copies a ready plugin (made in the Creation Kit or by hand) into dist under the plugin name. It takes no args, and plugin needs neither the game nor .NET for it.
  • validate now prints a runs: line with the command a build would run. Read it before you build a mod someone else made: builder.command runs whatever program it names.
  • steps.afterPlugin and steps.afterPack in sfmod.json: lists of your own commands, each written like builder.command, run in order at the end of plugin and at the end of pack. Running a step on its own runs its commands too, so build and one step at a time give the same result. They take the builder placeholders plus {name} and {plugin}. A missing program stops the step before any work (exit 2); a command that exits non-zero stops it (exit 1) with a RESULT line naming the command. validate prints one runs: line per command.
  • A top-level archives list in sfmod.json: more archives that pack makes in dist, each named <plugin> - <suffix>.ba2. An entry either packs a source folder laid out like Data (with "compression": "none" for voice files, which play silent when stored compressed, and "format": "dds" for textures) or copies a ready archive from file as it is. These archives ship in the zip, pack deletes their old copies, and they never count as stray. The suffix may be Main or Textures only when pack doesn't make that archive itself. pack checks a source folder's files (a steps.afterPlugin command may fill it) and stops with exit 2 before Archive2 runs when it is missing, empty or holds a file that doesn't belong (a dot file or a file in a dot folder, Thumbs.db and desktop.ini included, since Archive2 packs the folder as it is). validate refuses a source that is, holds or is inside assets.source, assets.xboxTextures or another entry's source, so no file ships twice. validate prints an archive: line for each entry. In this version the list can't be used with "xbox": true.
  • parts in sfmod.json: the other plugins your builder writes into dist, each { "plugin": "MyMod-Extra.esm" } with optional scripts of its own (the same shape as the top-level scripts; source defaults to the top-level source folders). compile compiles a part's scripts into <stage>/parts/<part>/Scripts, pack packs them into <part> - Main.ba2, plugin stops (exit 1) when a part plugin isn't in dist, and zip ships every plugin and archive and stops (exit 2) when one is missing. validate prints a part: line for each and refuses a part named like the main plugin or another part, a name that breaks the plugin-name rules, a script in two places, and parts with builder.prebuilt. In this version a part with scripts can't be used with "xbox": true.
  • check and build take --masters-dir <folder>, which can be given more than once, and pass each folder to sf-mod-check's release. Use it for a mod whose master plugin isn't in the Data folder, such as another mod's folder in your mod manager. A folder that isn't there stops check, or build before it starts, with exit 2.
  • scripts.optimize in sfmod.json (default true): set it to false to compile without the compiler's -optimize option, for a mod whose scripts were tested in game that way. A part's scripts follow the top-level value unless they set their own. -release stays refused either way.
  • The release now has a <file>.sha256 beside each download, as well as SHA256SUMS, so a tool can check one download on its own.

Example

A made-up mod whose builder is a Python script, with "builder": { "command": ["python", "tools/build.py", "--out", "{dist}"], "args": ["{version}"] } (folder names are shortened):

> sf-mod-build validate
...
builder:  command python
          args {version}
runs:     python tools/build.py --out {dist} {version}
...
RESULT: OK

> sf-mod-build plugin
running the builder: python.exe (builder.command)
built    C:\Mods\MyMod\dist\MyMod.esm (20 bytes)
RESULT: OK, MyMod.esm built into C:\Mods\MyMod\dist

and a mod with "builder": { "prebuilt": "Original/MyOtherMod.esm" }:

> sf-mod-build plugin
copied   C:\Mods\MyOtherMod\Original\MyOtherMod.esm to C:\Mods\MyOtherMod\dist\MyOtherMod.esm (21 bytes)
RESULT: OK, MyOtherMod.esm copied into C:\Mods\MyOtherMod\dist

and a made-up mod with one step after pack that fails, "steps": { "afterPack": [["python", "tools/after.py", "{dist}/missing.txt", "fail"]] }:

> sf-mod-build pack
running  steps.afterPack[0]: python.exe tools/after.py C:\Mods\StepsMod\dist/missing.txt fail
FAILED   steps.afterPack[0] (python.exe) exited with code 3
         after.py: C:\Mods\StepsMod\dist/missing.txt is missing
RESULT: FAILED at steps.afterPack[0] (python.exe exited with code 3). Fix: fix the error shown above (the full output is in the log: --log <file>), or the command in C:\Mods\StepsMod\sfmod.json, and run again.

and a made-up mod with a voice folder and a ready archive, "archives": [ { "suffix": "Voices", "source": "Voices", "compression": "none" }, { "suffix": "Extra", "file": "Original/Other - Extra.ba2" } ]:

> sf-mod-build validate
...
archive:  "VoiceMod - Voices.ba2" packed from C:\Mods\VoiceMod\Voices, uncompressed
archive:  "VoiceMod - Extra.ba2" copied from C:\Mods\VoiceMod\Original\Other - Extra.ba2
...
          holds VoiceMod.esm, VoiceMod - Voices.ba2, VoiceMod - Extra.ba2
RESULT: OK

> sf-mod-build pack
packed   C:\Mods\VoiceMod\dist\VoiceMod - Voices.ba2 (127 bytes)
copied   C:\Mods\VoiceMod\dist\VoiceMod - Extra.ba2 from C:\Mods\VoiceMod\Original\Other - Extra.ba2 (23 bytes)
RESULT: OK, "VoiceMod - Voices.ba2" and "VoiceMod - Extra.ba2" made in C:\Mods\VoiceMod\dist

and a made-up mod whose Python builder writes three plugins, with "parts": [ { "plugin": "PartsMod-Extra.esm", "scripts": { "namespaces": ["PTMX"] } }, { "plugin": "PartsMod-Patch.esm" } ]:

> sf-mod-build build
== compile
compiled PTM\PTM_Main.psc into C:\Mods\PartsMod\.build\stage\Scripts
compiled PTMX\PTMX_Extra.psc into C:\Mods\PartsMod\.build\stage\parts\PartsMod-Extra\Scripts
...
== plugin
running the builder: python.exe (builder.command)
built    C:\Mods\PartsMod\dist\PartsMod.esm (16 bytes)
built    C:\Mods\PartsMod\dist\PartsMod-Extra.esm (16 bytes)
built    C:\Mods\PartsMod\dist\PartsMod-Patch.esm (16 bytes)
RESULT: OK, PartsMod.esm and 2 part plugin(s) built into C:\Mods\PartsMod\dist
== pack
packed   C:\Mods\PartsMod\dist\PartsMod - Main.ba2 (331 bytes)
packed   C:\Mods\PartsMod\dist\PartsMod-Extra - Main.ba2 (336 bytes)
RESULT: OK, "PartsMod - Main.ba2" and "PartsMod-Extra - Main.ba2" made in C:\Mods\PartsMod\dist
== zip
zipped   PartsMod - Main.ba2
zipped   PartsMod-Extra - Main.ba2
zipped   PartsMod-Extra.esm
zipped   PartsMod-Patch.esm
zipped   PartsMod.esm
...

and a made-up mod whose dist holds a folder of old copies:

> sf-mod-build plugin
RESULT: CANNOT BUILD THE PLUGIN (the dist folder C:\Mods\MyMod\dist holds "old" (a folder), which no earlier build listed as its own, and sf-mod-build deletes only the plugins and archives in dist and what earlier builds made there, so nothing was deleted. Fix: move it out of dist and run again (a build by sf-mod-build 0.3.0 or earlier left no list of what it made, so its builder's other files are named here once), or set "dist" in C:\Mods\MyMod\sfmod.json to a folder of its own).

Fixed

  • plugin no longer deletes the folders and other files you keep in dist (plugins and archives there are still deleted). Before, it emptied dist on every build, so a folder you kept there (old copies, notes) was deleted without a word. Now it deletes only what earlier builds made there (the names in dist's new .sf-mod-build-made list, plugins and .ba2 archives) and keeps zips and a zip.folder inside dist. When dist holds anything else, it deletes nothing and stops with exit 2, naming each one and the fix. The first build after an update from 0.3.0 or earlier may name your builder's own extra files this way once, because those versions kept no list; delete them and run again. A dist folder that is a link or junction is refused too. When a delete fails (a plugin open in the Creation Kit, say), the list stays for the next run. 0.3.0 and earlier have this problem.
  • A build no longer fails the second time when a loose file it copies is read-only: the copies pack makes in stage and creations-out (and, new in 0.4.0, the prebuilt plugin and ready archives plugin and pack copy into dist) are no longer read-only, so the next build can delete them. 0.3.0 and earlier have this problem for read-only loose files.
  • AGENTS.md no longer says that archives your builder writes aren't supported: they have shipped through zip.archives since 0.3.0.
  • When a zip.files entry isn't there, validate's fix now says that a file the builder or a step makes goes in dist instead, because zip.files takes only files that are there before the build.

Download

  • sf-mod-build-0.4.0-win-x64.zip: the Windows program (no .NET needed).
  • sf-mod-build-template-0.4.0.zip: the starter project.
  • sf-mod-build.0.4.0.nupkg: the .NET tool package.
  • Check each download against SHA256SUMS or its own .sha256 file.

See CHANGELOG.md for the full history.