Skip to content

Commit

Permalink
Ship textures in separate compressed archive
Browse files Browse the repository at this point in the history
  • Loading branch information
ProbablyManuel committed Oct 23, 2022
1 parent 9d96991 commit 0ca89b6
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 3 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ components/**/obj
**/.vs/*
GeneratedResources
Requiem.bsa
Requiem - Textures.bsa
BsaFiles
BsaFilesTextures
Source/**
__pycache__/
31 changes: 29 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ val reqtificatorDir = file("Reqtificator")
val scriptsSourcesDir = file(sourceDir.resolve("Scripts"))
val reqtificatorSourcesDir = file(sourceDir.resolve("Reqtificator"))
val bsaFilesDir = file("BsaFiles")
val bsaFilesTexturesDir = file("BsaFilesTextures")
val bsaFile = file("Requiem.bsa")
val bsaFileTextures = file("Requiem - Textures.bsa")

val copyReqtificator by tasks.registering(Copy::class) {
dependsOn("components:mutagen-reqtificator:assemble")
Expand Down Expand Up @@ -99,23 +101,44 @@ val copyBsaFiles by tasks.registering(Copy::class) {
dependsOn("assemble")

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

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

from(".")
include("textures/**")
into(bsaFilesTexturesDir)
includeEmptyDirs = false
}

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
archiveFile = bsaFileTextures
logFile = file("distribution/bsaLog.txt")
archiveTool = bsArch
}

val createBsaTextures by tasks.registering(BsaPackingTask::class) {
description = "create a BSA archive for Requiem's textures"
group = "distribution"
dependsOn(copyBsaFilesTextures)

folder = bsaFilesTexturesDir
archiveFile = bsaFile
logFile = file("distribution/bsaTexturesLog.txt")
archiveTool = bsArch
compress = true
}

tasks.assemble {
dependsOn(copyReqtificator)
dependsOn(copyInterfaceFiles)
Expand All @@ -130,7 +153,9 @@ tasks.clean {
delete(interfaceDir)
delete(scriptsDir)
delete(bsaFilesDir)
delete(bsaFilesTexturesDir)
delete(bsaFile)
delete(bsaFileTextures)
}

val packRelease by tasks.registering(ReleaseArchiveTask::class) {
Expand All @@ -139,6 +164,7 @@ val packRelease by tasks.registering(ReleaseArchiveTask::class) {

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

Expand All @@ -154,6 +180,7 @@ val packRelease by tasks.registering(ReleaseArchiveTask::class) {
"Requiem.modgroups",
releaseDocsDir,
"Requiem.bsa",
"Requiem - Textures.bsa",
"Source",
"Reqtificator",
"BashTags"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,16 @@ open class BsaPackingTask : DefaultTask() {
lateinit var folder: File
@InputFile
lateinit var archiveTool: File
@Internal
var compress: Boolean = false

@TaskAction
fun buildBsaArchive() {
val myArgs = listOf(archiveTool.absolutePath, "pack", folder.absolutePath, archiveFile.absolutePath, "-sse")
val myArgs = if (compress) {
listOf(archiveTool.absolutePath, "pack", folder.absolutePath, archiveFile.absolutePath, "-sse", "-z")
} else {
listOf(archiveTool.absolutePath, "pack", folder.absolutePath, archiveFile.absolutePath, "-sse")
}
val archiveTask = ProcessBuilder(myArgs)
.redirectOutput(ProcessBuilder.Redirect.to(logFile))
.redirectErrorStream(true)
Expand Down

0 comments on commit 0ca89b6

Please sign in to comment.