From af0fde8132d35d76ec5c304484788e9a1213c7d0 Mon Sep 17 00:00:00 2001 From: Bepis <36346617+bbepis@users.noreply.github.com> Date: Sun, 14 Nov 2021 01:00:09 +1100 Subject: [PATCH] Initial commit --- .config/dotnet-tools.json | 12 ++ .gitignore | 390 ++++++++++++++++++++++++++++++++++++++ README.md | 42 ++++ build-config.json | 6 + build.cake | 307 ++++++++++++++++++++++++++++++ build.ps1 | 13 ++ build.sh | 12 ++ 7 files changed, 782 insertions(+) create mode 100644 .config/dotnet-tools.json create mode 100644 .gitignore create mode 100644 README.md create mode 100644 build-config.json create mode 100644 build.cake create mode 100644 build.ps1 create mode 100644 build.sh diff --git a/.config/dotnet-tools.json b/.config/dotnet-tools.json new file mode 100644 index 0000000..3016fc7 --- /dev/null +++ b/.config/dotnet-tools.json @@ -0,0 +1,12 @@ +{ + "version": 1, + "isRoot": true, + "tools": { + "cake.tool": { + "version": "2.0.0-rc0001", + "commands": [ + "dotnet-cake" + ] + } + } +} \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..07c5a8e --- /dev/null +++ b/.gitignore @@ -0,0 +1,390 @@ +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. +## +## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore + +# User-specific files +*.rsuser +*.suo +*.user +*.userosscache +*.sln.docstates + +# User-specific files (MonoDevelop/Xamarin Studio) +*.userprefs + +# Mono auto generated files +mono_crash.* + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +x86/ +[Ww][Ii][Nn]32/ +[Aa][Rr][Mm]/ +[Aa][Rr][Mm]64/ +bld/ +[Bb]in/ +[Oo]bj/ +[Ll]og/ +[Ll]ogs/ + +# Visual Studio 2015/2017 cache/options directory +.vs/ +# Uncomment if you have tasks that create the project's static files in wwwroot +#wwwroot/ + +# Visual Studio 2017 auto generated files +Generated\ Files/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +# NUnit +*.VisualState.xml +TestResult.xml +nunit-*.xml + +# Build Results of an ATL Project +[Dd]ebugPS/ +[Rr]eleasePS/ +dlldata.c + +# Benchmark Results +BenchmarkDotNet.Artifacts/ + +# .NET Core +project.lock.json +project.fragment.lock.json +artifacts/ + +# ASP.NET Scaffolding +ScaffoldingReadMe.txt + +# StyleCop +StyleCopReport.xml + +# Files built by Visual Studio +*_i.c +*_p.c +*_h.h +*.ilk +*.meta +*.obj +*.iobj +*.pch +*.pdb +*.ipdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*_wpftmp.csproj +*.log +*.tlog +*.vspscc +*.vssscc +.builds +*.pidb +*.svclog +*.scc + +# Chutzpah Test files +_Chutzpah* + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opendb +*.opensdf +*.sdf +*.cachefile +*.VC.db +*.VC.VC.opendb + +# Visual Studio profiler +*.psess +*.vsp +*.vspx +*.sap + +# Visual Studio Trace Files +*.e2e + +# TFS 2012 Local Workspace +$tf/ + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# AxoCover is a Code Coverage Tool +.axoCover/* +!.axoCover/settings.json + +# Coverlet is a free, cross platform Code Coverage Tool +coverage*.json +coverage*.xml +coverage*.info + +# Visual Studio code coverage results +*.coverage +*.coveragexml + +# NCrunch +_NCrunch_* +.*crunch*.local.xml +nCrunchTemp_* + +# MightyMoose +*.mm.* +AutoTest.Net/ + +# Web workbench (sass) +.sass-cache/ + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.[Pp]ublish.xml +*.azurePubxml +# Note: Comment the next line if you want to checkin your web deploy settings, +# but database connection strings (with potential passwords) will be unencrypted +*.pubxml +*.publishproj + +# Microsoft Azure Web App publish settings. Comment the next line if you want to +# checkin your Azure Web App publish settings, but sensitive information contained +# in these scripts will be unencrypted +PublishScripts/ + +# NuGet Packages +*.nupkg +# NuGet Symbol Packages +*.snupkg +# The packages folder can be ignored because of Package Restore +**/[Pp]ackages/* +# except build/, which is used as an MSBuild target. +!**/[Pp]ackages/build/ +# Uncomment if necessary however generally it will be regenerated when needed +#!**/[Pp]ackages/repositories.config +# NuGet v3's project.json files produces more ignorable files +*.nuget.props +*.nuget.targets + +# Nuget personal access tokens and Credentials +# nuget.config + +# Microsoft Azure Build Output +csx/ +*.build.csdef + +# Microsoft Azure Emulator +ecf/ +rcf/ + +# Windows Store app package directories and files +AppPackages/ +BundleArtifacts/ +Package.StoreAssociation.xml +_pkginfo.txt +*.appx +*.appxbundle +*.appxupload + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!?*.[Cc]ache/ + +# Others +ClientBin/ +~$* +*~ +*.dbmdl +*.dbproj.schemaview +*.jfm +*.pfx +*.publishsettings +orleans.codegen.cs + +# Including strong name files can present a security risk +# (https://github.com/github/gitignore/pull/2483#issue-259490424) +#*.snk + +# Since there are multiple workflows, uncomment next line to ignore bower_components +# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) +#bower_components/ + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file +# to a newer Visual Studio version. Backup files are not needed, +# because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm +ServiceFabricBackup/ +*.rptproj.bak + +# SQL Server files +*.mdf +*.ldf +*.ndf + +# Business Intelligence projects +*.rdl.data +*.bim.layout +*.bim_*.settings +*.rptproj.rsuser +*- [Bb]ackup.rdl +*- [Bb]ackup ([0-9]).rdl +*- [Bb]ackup ([0-9][0-9]).rdl + +# Microsoft Fakes +FakesAssemblies/ + +# GhostDoc plugin setting file +*.GhostDoc.xml + +# Node.js Tools for Visual Studio +.ntvs_analysis.dat +node_modules/ + +# Visual Studio 6 build log +*.plg + +# Visual Studio 6 workspace options file +*.opt + +# Visual Studio 6 auto-generated workspace file (contains which files were open etc.) +*.vbw + +# Visual Studio LightSwitch build output +**/*.HTMLClient/GeneratedArtifacts +**/*.DesktopClient/GeneratedArtifacts +**/*.DesktopClient/ModelManifest.xml +**/*.Server/GeneratedArtifacts +**/*.Server/ModelManifest.xml +_Pvt_Extensions + +# Paket dependency manager +.paket/paket.exe +paket-files/ + +# FAKE - F# Make +.fake/ + +# CodeRush personal settings +.cr/personal + +# Python Tools for Visual Studio (PTVS) +__pycache__/ +*.pyc + +# Cake - Uncomment if you are using it +tools/** +!tools/packages.config + +# Tabs Studio +*.tss + +# Telerik's JustMock configuration file +*.jmconfig + +# BizTalk build output +*.btp.cs +*.btm.cs +*.odx.cs +*.xsd.cs + +# OpenCover UI analysis results +OpenCover/ + +# Azure Stream Analytics local run output +ASALocalRun/ + +# MSBuild Binary and Structured Log +*.binlog + +# NVidia Nsight GPU debugger configuration file +*.nvuser + +# MFractors (Xamarin productivity tool) working folder +.mfractor/ + +# Local History for Visual Studio +.localhistory/ + +# BeatPulse healthcheck temp database +healthchecksdb + +# Backup folder for Package Reference Convert tool in Visual Studio 2017 +MigrationBackup/ + +# Ionide (cross platform F# VS Code tools) working folder +.ionide/ + +# Fody - auto-generated XML schema +FodyWeavers.xsd + +# VS Code files for those working on multiple tools +.vscode/* +!.vscode/settings.json +!.vscode/tasks.json +!.vscode/launch.json +!.vscode/extensions.json +*.code-workspace + +# Local History for Visual Studio Code +.history/ + +# Windows Installer files from build outputs +*.cab +*.msi +*.msix +*.msm +*.msp + +# JetBrains Rider +.idea/ +*.sln.iml + +AkiRelease.zip \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..df08e79 --- /dev/null +++ b/README.md @@ -0,0 +1,42 @@ +# SPT-BuildTools + + +Contains tools to ease development of SPT-AKI. + +### Installation + +Cake requires some form of the .NET Core SDK to be installed, but that is already required by AKI development in the first place. + +### Instructions + +All build actions rely on you filling out `build-config.json` with the directory paths of your source code & (test) game folder. + +There are three sets of basic build commands: + +- `X:Clean` +- `X:Restore` +- `X:Build` + +Where `X` is replaced with either `Launcher`, `Modules` or `Server`. +Build invokes both the respective Clean and Restore step. + +---------- + +There are also "global" tasks that can be invoked as well: + +`Restore` performs all `X:Restore` tasks, which is useful for initiating development on a new machine. + +`Build` performs all `X:Build` tasks, which also invokes all respective prerequisite tasks too. + +`Package` runs the `Build` task and creates a `AkiRelease.zip` file in the current directory of the script invocation, containing the contents of an SPT-AKI release build. + +`CopyDev` runs the `Build` task and copies the built files into the development game folder listed in the build-config.json file. + + +------ + +To invoke: + +``` +[build.ps1 | build.sh] --Target="YourTaskHere" +``` \ No newline at end of file diff --git a/build-config.json b/build-config.json new file mode 100644 index 0000000..c9ff1de --- /dev/null +++ b/build-config.json @@ -0,0 +1,6 @@ +{ + "LauncherCodePath": "D:\\Sourcecode\\Gitea-SPT\\SPT-Launcher", + "ModulesCodePath": "D:\\Sourcecode\\Gitea-SPT\\SPT-Modules", + "ServerCodePath": "D:\\Sourcecode\\Gitea-SPT\\SPT-Server", + "DevGameFolder": "N:\\EFT-SP" +} \ No newline at end of file diff --git a/build.cake b/build.cake new file mode 100644 index 0000000..9940892 --- /dev/null +++ b/build.cake @@ -0,0 +1,307 @@ +#addin nuget:?package=Cake.Json&version=6.0.1 +#addin nuget:?package=Newtonsoft.Json&version=11.0.2 + +using Path = System.IO.Path; + +var target = Argument("target", "Build"); + +var skipClean = HasArgument("skip-clean"); +var skipBuild = !HasArgument("rebuild"); +var preserveDevFolder = HasArgument("preserve"); + +var configPath = Argument("config", "./build-config.json"); + +public class Config +{ + public string LauncherCodePath { get; set; } + public string ModulesCodePath { get; set; } + public string ServerCodePath { get; set; } + public string DevGameFolder { get; set; } +} + +var config = DeserializeJsonFromFile(configPath); + + + + + + + +// ------------------------------------------------------------------ +// Launcher +// ------------------------------------------------------------------ + +Task("Clean:Launcher") + .WithCriteria(!skipClean) + .Does(() => +{ + Information("Cleaning launcher build folder"); + CleanDirectory(Path.Combine(config.LauncherCodePath, "project", "Build")); + + Information("Cleaning launcher bin folders"); + DotNetCoreClean(Path.Combine(config.LauncherCodePath, "project", "Launcher.sln"), new DotNetCoreCleanSettings + { + Configuration = "Release", + DiagnosticOutput = false, + NoLogo = true, + Verbosity = DotNetCoreVerbosity.Minimal + }); +}); + +Task("Restore:Launcher") + .Does(() => +{ + DotNetCoreRestore(Path.Combine(config.LauncherCodePath, "project", "Launcher.sln"), new DotNetCoreRestoreSettings + { + Runtime = "win10-x64" + }); +}); + +Task("Build:Launcher") + .IsDependentOn("Clean:Launcher") + .IsDependentOn("Restore:Launcher") + .Does(() => +{ + var projectPath = Path.Combine(config.LauncherCodePath, "project"); + + var buildDirectory = Path.Combine(projectPath, "Build"); + + CreateDirectory(buildDirectory); + + var publishSettings = new DotNetCorePublishSettings + { + Configuration = "Release", + Runtime = "win10-x64", + NoRestore = true, + PublishSingleFile = true, + SelfContained = false, + OutputDirectory = buildDirectory + }; + + DotNetCorePublish(Path.Combine(projectPath, "Aki.Launcher", "Aki.Launcher.csproj"), publishSettings); + //DotNetCorePublish(Path.Combine(projectPath, "Aki.Launcher.CLI", "Aki.Launcher.CLI.csproj"), publishSettings); + + CopyDirectory(Path.Combine(projectPath, "Aki.Launcher", "Aki_Data"), Path.Combine(buildDirectory, "Aki_Data")); + + DeleteFiles(Path.Combine(buildDirectory, "*.pdb")); + + //CopyFileToDirectory(Path.Combine(projectPath, "Aki.Launcher", "bin", "Release", "net5.0-windows", "win10-x64", "Launcher.exe"), ); +}); + + + + + + + + + +// ------------------------------------------------------------------ +// Modules +// ------------------------------------------------------------------ + +Task("Clean:Modules") + .WithCriteria(!skipClean) + .Does(() => +{ + Information("Cleaning modules build folder"); + CleanDirectory(Path.Combine(config.ModulesCodePath, "project", "Build")); + + Information("Cleaning modules bin folders"); + DotNetCoreClean(Path.Combine(config.ModulesCodePath, "project", "Modules.sln"), new DotNetCoreCleanSettings + { + Configuration = "Release", + DiagnosticOutput = false, + NoLogo = true, + Verbosity = DotNetCoreVerbosity.Minimal + }); +}); + +Task("Restore:Modules") + .Does(() => +{ + // var buildSettings = new MSBuildSettings + // { + // Configuration = "Release", + // Restore = false + // }; + + // buildSettings.Targets.Add("build"); + + // MSBuild(Path.Combine(config.ModulesCodePath, "project", "Modules.sln")); +}); + +Task("Build:Modules") + .IsDependentOn("Clean:Modules") + .IsDependentOn("Restore:Modules") + .Does(() => +{ + Information("Building modules solution"); + + var projectPath = Path.Combine(config.ModulesCodePath, "project"); + + var buildDirectory = Path.Combine(projectPath, "Build"); + + CreateDirectory(buildDirectory); + + var buildSettings = new MSBuildSettings + { + Configuration = "Release", + Restore = true, + ArgumentCustomization = builder => builder.Append("-m") + }; + + buildSettings.Targets.Add("build"); + + MSBuild(Path.Combine(projectPath, "Modules.sln"), buildSettings); + + Information("Assembling output build directory"); + + var buildModulesDirectory = Path.Combine(buildDirectory, "Aki_Data", "Modules"); + + CreateDirectory(Path.Combine(buildModulesDirectory, "aki-core")); + CreateDirectory(Path.Combine(buildModulesDirectory, "aki-singleplayer")); + + CopyFile(Path.Combine(projectPath, "Aki.Core", "bin", "Release", "aki-core.dll"), + Path.Combine(buildModulesDirectory, "aki-core", "module.dll")); + + CopyFile(Path.Combine(projectPath, "Aki.SinglePlayer", "bin", "Release", "aki-singleplayer.dll"), + Path.Combine(buildModulesDirectory, "aki-singleplayer", "module.dll")); + + + + + var managedFolder = Path.Combine(buildDirectory, "EscapeFromTarkov_Data", "Managed"); + CreateDirectory(managedFolder); + + CopyFileToDirectory(Path.Combine(projectPath, "Aki.Core", "bin", "Release", "FilesChecker.dll"), managedFolder); + CopyFileToDirectory(Path.Combine(projectPath, "Aki.Common", "bin", "Release", "Aki.Common.dll"), managedFolder); + CopyFileToDirectory(Path.Combine(projectPath, "Aki.Reflection", "bin", "Release", "Aki.Reflection.dll"), managedFolder); + CopyFileToDirectory(Path.Combine(projectPath, "Aki.Loader", "bin", "Release", "NLog.Aki.Loader.dll"), managedFolder); + + CopyFiles(Path.Combine(projectPath, "Aki.Reflection", "bin", "Release", "*.dll"), managedFolder); +}); + + + + + + +// ------------------------------------------------------------------ +// Server +// ------------------------------------------------------------------ + +int RunNpm(string argument) +{ + var projectDirectory = Path.Combine(config.ServerCodePath, "project"); + + var npm = IsRunningOnWindows() ? Context.Tools.Resolve("npm.cmd") + : Context.Tools.Resolve("npm"); + + Information(npm); + + return StartProcess(npm, new ProcessSettings + { + Arguments = argument, + WorkingDirectory = projectDirectory + }); +} + +Task("Clean:Server") + .WithCriteria(!skipClean) + .Does(() => +{ + Information("Cleaning server build folder"); + CleanDirectory(Path.Combine(config.ServerCodePath, "project", "build")); +}); + +Task("Restore:Server") + .Does(() => +{ + Information("Installing server NPM packages"); + + RunNpm("install"); +}); + +Task("Build:Server") + .IsDependentOn("Clean:Server") + .IsDependentOn("Restore:Server") + .Does(() => +{ + Information("Building server"); + + RunNpm("run build:release"); +}); + + + + + +// ------------------------------------------------------------------ +// Packaging +// ------------------------------------------------------------------ + +Task("Build") + //.WithCriteria(!skipBuild) + .Does(() => +{ + RunTarget("Build:Launcher"); + RunTarget("Build:Modules"); + RunTarget("Build:Server"); +}); + +Task("Restore") + .IsDependentOn("Restore:Launcher") + .IsDependentOn("Restore:Modules") + .IsDependentOn("Restore:Server") + .Does(() => +{ + +}); + +Task("Package") + .IsDependentOn("Build") + .Does(() => +{ + var tempBuildFolder = Path.GetFullPath(Path.Combine(".", "TempBuild")); + + if (DirectoryExists(tempBuildFolder)) { + DeleteDirectory(tempBuildFolder, new DeleteDirectorySettings { + Recursive = true + }); + } + + CreateDirectory(tempBuildFolder); + + + CopyFiles(Path.Combine(config.LauncherCodePath, "project", "Build", "**/*"), tempBuildFolder, true); + CopyFiles(Path.Combine(config.ModulesCodePath, "project", "Build", "**/*"), tempBuildFolder, true); + CopyFiles(Path.Combine(config.ServerCodePath, "project", "build", "**/*"), tempBuildFolder, true); + + DeleteFile(Path.Combine(tempBuildFolder, "LauncherCLI.exe")); + + Zip(tempBuildFolder, "AkiRelease.zip"); + + DeleteDirectory(tempBuildFolder, new DeleteDirectorySettings { + Recursive = true + }); +}); + +Task("CopyDev") + .IsDependentOn("Build") + .Does(() => +{ + // if (!preserveDevFolder && DirectoryExists(config.DevGameFolder)) { + // DeleteDirectory(config.DevGameFolder, new DeleteDirectorySettings { + // Recursive = true + // }); + // } + + CopyFiles(Path.Combine(config.LauncherCodePath, "project", "Build", "**/*"), config.DevGameFolder, true); + CopyFiles(Path.Combine(config.ModulesCodePath, "project", "Build", "**/*"), config.DevGameFolder, true); + CopyFiles(Path.Combine(config.ServerCodePath, "project", "build", "**/*"), config.DevGameFolder, true); +}); + +Information("skipbuild: " + skipBuild); + +RunTarget(target); \ No newline at end of file diff --git a/build.ps1 b/build.ps1 new file mode 100644 index 0000000..21821d2 --- /dev/null +++ b/build.ps1 @@ -0,0 +1,13 @@ +$ErrorActionPreference = 'Stop' + +Set-Location -LiteralPath $PSScriptRoot + +$env:DOTNET_SKIP_FIRST_TIME_EXPERIENCE = '1' +$env:DOTNET_CLI_TELEMETRY_OPTOUT = '1' +$env:DOTNET_NOLOGO = '1' + +dotnet tool restore +if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE } + +dotnet cake @args +if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE } diff --git a/build.sh b/build.sh new file mode 100644 index 0000000..1d0e17c --- /dev/null +++ b/build.sh @@ -0,0 +1,12 @@ +#!/usr/bin/env bash +set -euox pipefail + +cd "$(dirname "${BASH_SOURCE[0]}")" + +export DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1 +export DOTNET_CLI_TELEMETRY_OPTOUT=1 +export DOTNET_NOLOGO=1 + +dotnet tool restore + +dotnet cake $@