Automatically pull and build mono once + .gitignore

This commit is contained in:
Simon Lübeß
2023-06-18 21:03:59 +02:00
parent 3becc1e25b
commit 04d69717a3
4 changed files with 119 additions and 2 deletions
+2
View File
@@ -0,0 +1,2 @@
vendor/mono/lib/
vendor/mono/repo/
+2 -2
View File
@@ -10,10 +10,10 @@ StartupObject = "GlitchyEngineHelper.Program"
BuildCommandsOnCompile = "IfFilesChanged"
BuildCommandsOnRun = "IfFilesChanged"
LibPaths = ["$(ProjectDir)/out/build/x64-debug/GlitchyEngineHelper.lib", "$(ProjectDir)/vendor/mono/lib/Windows/Debug/libmono-static-sgen.lib", "$(ProjectDir)/vendor/mono/lib/Windows/Debug/libmonoutils.lib", "$(ProjectDir)/vendor/mono/lib/Windows/Debug/libmonoruntime-sgen.lib", "ws2_32.lib", "Winmm.lib", "OleAut32.lib", "Bcrypt.lib"]
PreBuildCmds = ["$(ProjectDir)/../bin/vscmake.bat x64 $(ProjectDir) x64-debug"]
PreBuildCmds = ["$(ProjectDir)/../bin/vscmake.bat x64 $(ProjectDir) x64-debug", "powershell $(ProjectDir)/Build_Mono.ps1"]
[Configs.Release.Win64]
BuildCommandsOnCompile = "IfFilesChanged"
BuildCommandsOnRun = "IfFilesChanged"
LibPaths = ["$(ProjectDir)/out/build/x64-release/GlitchyEngineHelper.lib"]
PreBuildCmds = ["$(ProjectDir)/../bin/vscmake.bat x64 $(ProjectDir) x64-release"]
PreBuildCmds = ["$(ProjectDir)/../bin/vscmake.bat x64 $(ProjectDir) x64-release", "powershell $(ProjectDir)/Build_Mono.ps1"]
+99
View File
@@ -0,0 +1,99 @@
param(
[switch] $UpdateRepo,
[switch] $CleanBuild,
[switch] $Rebuild
)
$RepositoryPath = "./vendor/mono/repo"
# Directory which will contain the final build output
$TargetDirectory = Join-Path $PSScriptRoot "vendor/mono/lib/Windows"
if ((-Not $UpdateRepo) -and (-Not $CleanBuild) -and (-Not $Rebuild)) {
$DebugLibMono = Join-Path $TargetDirectory "Debug/libmono-static-sgen.lib";
$ReleaseLibMono = Join-Path $TargetDirectory "Release/libmono-static-sgen.lib";
# We assume, that everything exists, when libmono-static-sgen.lib exists and don't invoke devenv
# because devenv is slow as heck!
# Updates/Rebuilds and Cleans will issue a build
if ((Test-Path $DebugLibMono) -and (Test-Path $ReleaseLibMono)) {
Write-Output "Mono already build and ready."
exit
}
}
function Clone-GitRepoIfDestEmpty {
$RepoUrl = "https://github.com/mono/mono.git"
# Check if the destination directory is empty or does not exist
if ((-Not (Test-Path $RepositoryPath)) -or ((Get-ChildItem $RepositoryPath).Count -eq 0)) {
# If the directory does not exist or is empty, clone the repository
git clone $RepoUrl $RepositoryPath
} else {
Write-Output "Destination directory is not empty. Git repository will not be cloned."
}
}
function Update-GitRepo {
# Call Update-GitRepo function only if -Update switch is provided
if (-Not $UpdateRepo) {
Write-Output "Repository will not be updated. (Use -UpdateRepo if you want to update the repository)"
return
}
Write-Output "Pulling repository..."
git pull
}
function Patch-Mono {
# applies the patch that sets mono to statically link the clib
Write-Output "Patching..."
git apply ../patch.txt
}
function Build-Mono {
if ($CleanBuild) {
Write-Output "Cleaning Debug..."
devenv msvc/mono.sln /Clean "Debug|x64"
Write-Output "Cleaning Release..."
devenv msvc/mono.sln /Clean "Release|x64"
}
$BuildOption = if ($Rebuild) { "/Rebuild" } else { "/Build" }
Write-Output "Building Debug..."
devenv msvc/mono.sln $BuildOption "Debug|x64" /Project "libmono-static"
#Write-Output "Building Release..."
#devenv msvc/mono.sln $BuildOption "Release|x64" /Project "libmono-static"
}
function Copy-BuildResults {
$SourceDirectory = "msvc/build/sgen/x64/lib"
# Create the target directory if it does not exist
if (-Not (Test-Path $TargetDirectory)) {
New-Item -ItemType Directory -Force -Path $TargetDirectory
}
# Copy all files from source to target directory
Copy-Item -Path "$SourceDirectory\*" -Destination $TargetDirectory -Force -Recurse
}
# Switch working directory to directory containing the script (allows calling the script from anywhere)
Push-Location $PSScriptRoot
# Clone the git-repository, if necessary.
Clone-GitRepoIfDestEmpty
# Change into repository
Set-Location $RepositoryPath
Update-GitRepo
Patch-Mono
Build-Mono
Copy-BuildResults
# Return to the original directory
Pop-Location
+16
View File
@@ -0,0 +1,16 @@
diff --git a/msvc/mono.props b/msvc/mono.props
index 4aa149a7ab5..f9824d3020c 100644
--- a/msvc/mono.props
+++ b/msvc/mono.props
@@ -12,9 +12,9 @@
<!-- When true, build will get a separate build folder based on various configuration parameters. Makes it possible separate builds into different output folders under the same build prefix. -->
<MONO_USE_SEPARATE_BUILD_DIR>true</MONO_USE_SEPARATE_BUILD_DIR>
<!-- When true, all binaries and libraries will link using static c-runtime. When false, all binaries and libraries will link using dynamic c-runtime. -->
- <MONO_USE_STATIC_C_RUNTIME>false</MONO_USE_STATIC_C_RUNTIME>
+ <MONO_USE_STATIC_C_RUNTIME>true</MONO_USE_STATIC_C_RUNTIME>
<!-- When true, mono binaries will link using static libmono. When false, mono binaries will link using dynamic libmono. -->
- <MONO_USE_STATIC_LIBMONO>false</MONO_USE_STATIC_LIBMONO>
+ <MONO_USE_STATIC_LIBMONO>true</MONO_USE_STATIC_LIBMONO>
<!-- When true, mono binaries will link and include llvm. When false, mono binaries will not link and include llvm. -->
<MONO_ENABLE_LLVM>false</MONO_ENABLE_LLVM>
<!-- When true, enable LLVM asserts for internal LLVM build. When false, disable LLVM asserts for internal LLVM build. -->