Skip to content
Merged

2026 #18

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
91 changes: 81 additions & 10 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,13 @@ ext.prereqDestPath = file("${buildBasePath}/prerequisites")
// Source paths
ext.prereqSrcPath = file("${projectDir}/src")
ext.prereqSetupPath = file("${projectDir}/setup")
ext.vcRedistPath = file("${prereqSrcPath}/vcredist_2015_2022")

// VC Redistributable URLs
ext.vcRedistX86Url = 'https://aka.ms/vs/17/release/vc_redist.x86.exe'
ext.vcRedistX64Url = 'https://aka.ms/vs/17/release/vc_redist.x64.exe'
ext.vcRedistX86File = file("${vcRedistPath}/vc_redist.x86.exe")
ext.vcRedistX64File = file("${vcRedistPath}/vc_redist.x64.exe")

// Inno Setup path (from dev/bin/lib)
// Note: Tool paths are available via rootProject.ext.innosetupCompiler when used as a subproject
Expand Down Expand Up @@ -129,6 +136,77 @@ def calculateHash(File file, String algorithm) {
// TASKS
// ============================================================================

// Task: Download VC Redistributables
tasks.register('downloadVcRedist') {
group = 'build'
description = 'Download Visual C++ Redistributables from Microsoft'

doLast {
println ""
println "=".multiply(70)
println "Downloading Visual C++ Redistributables"
println "=".multiply(70)
println ""

// Create vcredist directory if it doesn't exist
if (!vcRedistPath.exists()) {
vcRedistPath.mkdirs()
println "Created directory: ${vcRedistPath}"
}

// Download x86 redistributable
println "Downloading x86 redistributable..."
println " URL: ${vcRedistX86Url}"
println " Destination: ${vcRedistX86File}"

try {
def x86Url = new URL(vcRedistX86Url)
x86Url.openConnection().with { conn ->
conn.instanceFollowRedirects = true
conn.setRequestProperty('User-Agent', 'Mozilla/5.0')
conn.connect()

if (conn.responseCode == 200 || conn.responseCode == 302 || conn.responseCode == 301) {
vcRedistX86File.bytes = conn.inputStream.bytes
println " [SUCCESS] Downloaded: ${vcRedistX86File.name} (${(vcRedistX86File.size() / 1024 / 1024).toInteger()} MB)"
} else {
throw new GradleException("Failed to download x86 redistributable. HTTP ${conn.responseCode}")
}
}
} catch (Exception e) {
throw new GradleException("Error downloading x86 redistributable: ${e.message}")
}

// Download x64 redistributable
println "Downloading x64 redistributable..."
println " URL: ${vcRedistX64Url}"
println " Destination: ${vcRedistX64File}"

try {
def x64Url = new URL(vcRedistX64Url)
x64Url.openConnection().with { conn ->
conn.instanceFollowRedirects = true
conn.setRequestProperty('User-Agent', 'Mozilla/5.0')
conn.connect()

if (conn.responseCode == 200 || conn.responseCode == 302 || conn.responseCode == 301) {
vcRedistX64File.bytes = conn.inputStream.bytes
println " [SUCCESS] Downloaded: ${vcRedistX64File.name} (${(vcRedistX64File.size() / 1024 / 1024).toInteger()} MB)"
} else {
throw new GradleException("Failed to download x64 redistributable. HTTP ${conn.responseCode}")
}
}
} catch (Exception e) {
throw new GradleException("Error downloading x64 redistributable: ${e.message}")
}

println ""
println "=".multiply(70)
println "[SUCCESS] Visual C++ Redistributables downloaded successfully"
println "=".multiply(70)
}
}

// Task: Display build information
tasks.register('info') {
group = 'help'
Expand Down Expand Up @@ -176,6 +254,7 @@ tasks.register('info') {
tasks.register('release') {
group = 'build'
description = 'Build prerequisites installer with Inno Setup'
dependsOn 'downloadVcRedist'

doLast {
println ""
Expand Down Expand Up @@ -325,11 +404,8 @@ tasks.register('verify') {
def fontFile = file("${prereqSrcPath}/fonts/CaskaydiaCoveNerdFont-Regular.ttf")
checks['CaskaydiaCove Nerd Font'] = fontFile.exists()

// Check for vcredist files
def vcredistX86 = file("${prereqSrcPath}/vcredist_2015_2022/VC_redist.x86.exe")
def vcredistX64 = file("${prereqSrcPath}/vcredist_2015_2022/VC_redist.x64.exe")
checks['VC++ Redist x86'] = vcredistX86.exists()
checks['VC++ Redist x64'] = vcredistX64.exists()
// Note: VC++ Redistributables are now downloaded dynamically from Microsoft
checks['VC++ Redist (Dynamic Download)'] = true

println "\nEnvironment Check Results:"
println "-".multiply(60)
Expand All @@ -355,11 +431,6 @@ tasks.register('verify') {
println "Download from: https://github.com/ryanoasis/nerd-fonts/releases/latest"
println "Place CaskaydiaCoveNerdFont-Regular.ttf in: ${prereqSrcPath}/fonts/"
}
if (!checks['VC++ Redist x86'] || !checks['VC++ Redist x64']) {
println "\nVisual C++ Redistributables not found."
println "Download from: https://learn.microsoft.com/en-us/cpp/windows/latest-supported-vc-redist"
println "Place in: ${prereqSrcPath}/vcredist_2015_2022/"
}

throw new GradleException("Build environment verification failed")
}
Expand Down
2 changes: 1 addition & 1 deletion build.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# ============================================================================

# Prerequisites Configuration
prerequisites.release = 2025.7.31
prerequisites.release = 2025.12.16
prerequisites.id = prerequisites
prerequisites.name = Bearsampp Prerequisites Package
prerequisites.setupname = Bearsampp-prerequisites-${prerequisites.release}
Expand Down