Skip to content

Commit

Permalink
RRO-875 - back Requiem files as BSA
Browse files Browse the repository at this point in the history
  • Loading branch information
Ogerboss committed Oct 17, 2021
1 parent 2678c92 commit c295792
Show file tree
Hide file tree
Showing 9 changed files with 64 additions and 9 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,5 @@ components/**/bin
components/**/obj
*.sln.DotSettings.user
**/.vs/*
Requiem.bsa
BsaFiles
5 changes: 4 additions & 1 deletion ReadMe.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ This mod is published on NexusMods:
* Skyrim Special Edition
* Creation Kit (you're not required to use it for modding, but you need its Papyrus Script Compiler)
* [SSE CreationKit Fixes](https://www.nexusmods.com/skyrimspecialedition/mods/20061) (you're not required to use it for modding, but without it you cannot save a plugin that has a regular plugin as master file)
* [BSArch](https://www.nexusmods.com/newvegas/mods/64745)
* Mod Organizer 2.x

## Setup
Expand All @@ -38,6 +39,7 @@ This mod is published on NexusMods:
papyrusFailFast = false
csharpWarningsAsErrors = true
reqtificatorBuildDir = file("S:\\MO-Skyrim\\mods\\SkyProcBuild")
bsArch = file("S:\\bsarch.exe")
}

* `papyrusCompiler` - path to your Papyrus compiler
Expand All @@ -64,7 +66,8 @@ This mod is published on NexusMods:
present.
* `reqtificatorBuildDir` - external directory for the intermediate build files of the Reqtificator
* This build directory must not be linked by Mod Organizer into your Skyrim installation.
Some build intermediate files can have very long file names that can cause Skyrim to crash when starting.
Some build intermediate files can have very long file names that can cause Skyrim to crash when starting
* `bsArch` - the full path to the executable from BSArch

4. Open a (power)shell, go to the repository's directory and execute `gradlew.bat installDevVersion`. This may take
some time when you execute it the first time because the wrapper needs to download the Gradle distribution and other
Expand Down
37 changes: 30 additions & 7 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import skyrim.requiem.build.ReleaseArchiveTask
import skyrim.requiem.build.BsaPackingTask
import skyrim.requiem.build.RequiemVersion
import java.io.BufferedReader
import java.io.InputStreamReader
Expand Down Expand Up @@ -35,11 +36,15 @@ fun runCommand(command: List<String>): String = try {
val gitRevision by extra { runCommand(listOf("git", "rev-parse", "HEAD")) }
val gitBranch by extra { runCommand(listOf("git", "symbolic-ref", "--short", "-q", "HEAD")) }

val bsArch: File by extra

val skyProcDir = file("SkyProc Patchers")
val reqtificatorDir = file("$skyProcDir/Requiem")
val mutagenDir = file("Reqtificator")
val interfaceDir = file("Interface")
val scriptsDir = file("Scripts")
val bsaFilesDir = file("BsaFiles")
val bsaFile = file("Requiem.bsa")

val copyReqtificator by tasks.registering(Copy::class) {
dependsOn("components:reqtificator:assemble")
Expand Down Expand Up @@ -69,6 +74,26 @@ val copyInterfaceFiles by tasks.registering(Copy::class) {
into(interfaceDir)
}

val copyBsaFiles by tasks.registering(Copy::class) {
dependsOn("assemble")

from(".")
include("Interface/**", "meshes/**", "Sound/**", "textures/**", "Scripts/**")
into(bsaFilesDir)
exclude("**/REQ_Debug*.pex", "**/REQ_Debug*.psc")
}

val createBsa by tasks.registering(BsaPackingTask::class) {
description = "create a BSA archive for Requiem's core assets"
group = "distribution"
dependsOn(copyBsaFiles)

folder = bsaFilesDir
archiveFile = bsaFile
logFile = file("distribution/bsaLog.txt")
archiveTool = bsArch
}

tasks.assemble {
dependsOn(copyReqtificator)
dependsOn(copyMutagenReqtificator)
Expand All @@ -82,13 +107,16 @@ tasks.clean {
delete(mutagenDir)
delete(scriptsDir)
delete(skyProcDir)
delete(bsaFilesDir)
delete(bsaFile)
}

val packRelease by tasks.registering(ReleaseArchiveTask::class) {
description = "Pack Requiem as a ready to ship 7z archive"
group = "distribution"

dependsOn(tasks.assemble)
dependsOn(createBsa)
dependsOn("components:fomod-installer:assemble")
dependsOn("components:documentation:assemble")

Expand All @@ -103,13 +131,8 @@ val packRelease by tasks.registering(ReleaseArchiveTask::class) {
"Reqtificator.bat",
"Requiem.modgroups",
releaseDocsDir,
"Scripts",
"interface",
"meshes",
"SkyProc Patchers",
"sound",
"textures",
"Requiem.bsa",
"BashTags"
)
excludePatterns = listOf("REQ_Debug.+\\.pex")
excludePatterns = listOf()
}
26 changes: 26 additions & 0 deletions buildSrc/src/main/kotlin/skyrim/requiem/build/BsaPackingTask.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package skyrim.requiem.build

import org.gradle.api.DefaultTask
import org.gradle.api.GradleException
import org.gradle.api.tasks.*
import java.io.File

open class BsaPackingTask : DefaultTask() {
@OutputFile
lateinit var logFile: File
@OutputFile
lateinit var archiveFile: File
@InputDirectory
lateinit var folder: File
@InputFile
lateinit var archiveTool: File

@TaskAction
fun buildBsaArchive() {
val myArgs = listOf(archiveTool.absolutePath, "pack", folder.absolutePath, archiveFile.absolutePath, "-sse")
val archiveTask = ProcessBuilder(myArgs)
.redirectOutput(ProcessBuilder.Redirect.to(logFile))
.redirectErrorStream(true)
if (archiveTask.start().waitFor() != 0) throw GradleException("BSA archive creation failed!")
}
}
3 changes: 2 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
org.gradle.warning.mode=all
org.gradle.warning.mode=all
org.gradle.jvmargs=-Xmx2048m

0 comments on commit c295792

Please sign in to comment.