*
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net9.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Dependencies\Actions.Library\Actions.Library.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@@ -0,0 +1,28 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.12.35707.178 d17.12
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Build", "Build.csproj", "{227CD697-3936-44E6-9804-5FD12EDF17E6}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Actions.Library", "..\Dependencies\Actions.Library\Actions.Library.csproj", "{15ECFF80-DEAF-4227-831B-D71FC0B65371}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{227CD697-3936-44E6-9804-5FD12EDF17E6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{227CD697-3936-44E6-9804-5FD12EDF17E6}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{227CD697-3936-44E6-9804-5FD12EDF17E6}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{227CD697-3936-44E6-9804-5FD12EDF17E6}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{15ECFF80-DEAF-4227-831B-D71FC0B65371}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{15ECFF80-DEAF-4227-831B-D71FC0B65371}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{15ECFF80-DEAF-4227-831B-D71FC0B65371}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{15ECFF80-DEAF-4227-831B-D71FC0B65371}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
@@ -0,0 +1,87 @@
|
||||
using Actions;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Build {
|
||||
public static class Dependencies {
|
||||
static readonly string APR_VERSION = "1.7.5";
|
||||
static readonly string APU_VERSION = "1.6.3";
|
||||
static readonly string PY3C_VERSION = "1.1";
|
||||
static readonly string SERF_VERSION = "1.3.10";
|
||||
static readonly string ZLIB_VERSION = "1.2.8";
|
||||
static readonly string SQLITE_VERSION = "3.39.4";
|
||||
static readonly int SQLITE_VERSION_REL_YEAR = 2022;
|
||||
static readonly string APACHE_MIRROR = "https://archive.apache.org/dist";
|
||||
|
||||
|
||||
public static async Task<string?> DownloadIfNotExist(string url, string outPath) {
|
||||
string? result = outPath;
|
||||
if (!File.Exists(outPath)) {
|
||||
Console.Write($"Downloading: {url}");
|
||||
result = await Download.FileFromUrl(url, outPath);
|
||||
Console.WriteLine($" Done");
|
||||
} else {
|
||||
Console.WriteLine($"Skip downloading: {url}");
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public static async Task<string> GetZLib(string dir) {
|
||||
var ZLIB = $"zlib-{ZLIB_VERSION}";
|
||||
var archiveFile = await DownloadIfNotExist($"https://github.com/madler/zlib/archive/refs/tags/v{ZLIB_VERSION}.tar.gz", Path.Combine(dir, $"{ZLIB}.tar.gz"));
|
||||
Archive.UnpackTarGz(archiveFile, dir);
|
||||
return Path.Combine(dir, ZLIB);
|
||||
}
|
||||
|
||||
public static async Task<string> GetSqlite(string dir) {
|
||||
var SQLITE_VERSION_LIST = SQLITE_VERSION.Split(".");
|
||||
var SQLITE = string.Format("sqlite-amalgamation-{0}{1}{2}00", SQLITE_VERSION_LIST[0], SQLITE_VERSION_LIST[1].PadLeft(2, '0'), SQLITE_VERSION_LIST[2].PadLeft(2, '0'));
|
||||
var archiveFile = await DownloadIfNotExist($"https://www.sqlite.org/{SQLITE_VERSION_REL_YEAR}/{SQLITE}.zip", Path.Combine(dir, $"{SQLITE}.zip"));
|
||||
Archive.UnpackZip(archiveFile, dir);
|
||||
return Path.Combine(dir, $"{SQLITE}");
|
||||
}
|
||||
|
||||
public static async Task<string> GetSerf(string dir) {
|
||||
var SERF = $"serf-{SERF_VERSION}";
|
||||
var archiveFile = await DownloadIfNotExist($"https://archive.apache.org/dist/serf/{SERF}.tar.bz2", Path.Combine(dir, $"{SERF}.tar.bz2"));
|
||||
Archive.UnpackTarBz2(archiveFile, dir);
|
||||
return Path.Combine(dir, $"{SERF}");
|
||||
}
|
||||
|
||||
public static async Task<string> GetExpat(string dir) {
|
||||
|
||||
var archiveFile = await DownloadIfNotExist($"https://github.com/libexpat/libexpat/releases/download/R_2_6_4/expat-win64bin-2.6.4.zip", Path.Combine(dir, $"expat-win64bin-2.6.4.zip"));
|
||||
var resultDir = Path.Combine(dir, "expat-win64bin-2.6.4");
|
||||
Directory.CreateDirectory(resultDir);
|
||||
Archive.UnpackZip(archiveFile, resultDir);
|
||||
return Path.Combine(dir, resultDir);
|
||||
}
|
||||
|
||||
public static async Task<string> GetOpenssl(string dir) {
|
||||
var archiveFile = await DownloadIfNotExist($"https://github.com/openssl/openssl/releases/download/openssl-3.2.3/openssl-3.2.3.tar.gz", Path.Combine(dir, $"openssl-3.2.3.tar.gz"));
|
||||
Archive.UnpackTarGz(archiveFile, dir);
|
||||
return Path.Combine(dir, $"openssl-3.2.3");
|
||||
}
|
||||
|
||||
public static async Task<string> GetApr(string dir) {
|
||||
var APR = $"apr-{APR_VERSION}";
|
||||
var archiveFile = await DownloadIfNotExist($"{APACHE_MIRROR}/apr/{APR}.tar.bz2", Path.Combine(dir, $"{APR}.tar.bz2"));
|
||||
Archive.UnpackTarBz2(archiveFile, dir);
|
||||
return Path.Combine(dir, $"{APR}");
|
||||
}
|
||||
|
||||
public static async Task<string> GetAprUtil(string dir) {
|
||||
var APR_UTIL = $"apr-util-{APU_VERSION}";
|
||||
var archiveFile = await DownloadIfNotExist($"{APACHE_MIRROR}/apr/{APR_UTIL}.tar.bz2", Path.Combine(dir, $"{APR_UTIL}.tar.bz2"));
|
||||
Archive.UnpackTarBz2(archiveFile, dir);
|
||||
return Path.Combine(dir, $"{APR_UTIL}");
|
||||
}
|
||||
|
||||
public static async Task<string> GetSubversion(string projectRootDir) {
|
||||
return Path.GetFullPath(Path.Combine(projectRootDir, "..", "subversion"));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,195 @@
|
||||
|
||||
|
||||
|
||||
using Actions;
|
||||
using Actions.Library;
|
||||
using Build;
|
||||
using System.Collections.Generic;
|
||||
using System.Data.SqlTypes;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Security.Cryptography;
|
||||
using static System.Runtime.InteropServices.JavaScript.JSType;
|
||||
|
||||
|
||||
class Application {
|
||||
|
||||
static string GetCurrentFileDir([CallerFilePath]string callerFilePath = null) {
|
||||
return Path.GetDirectoryName(callerFilePath);
|
||||
}
|
||||
|
||||
static string GetProjectRootDir() {
|
||||
return Path.GetDirectoryName(GetCurrentFileDir());
|
||||
}
|
||||
|
||||
|
||||
static void BuildZLib(string zlib, string installDir) {
|
||||
var buildDir = TempDirectory.New();
|
||||
var cmake = Find.Executable("cmake");
|
||||
var ninja = Find.Executable("ninja");
|
||||
var configResult = cmake.Run($"-G \"Ninja\" -DCMAKE_INSTALL_PREFIX={Path.Combine(installDir, "zlib")} -DCMAKE_BUILD_TYPE=RELEASE {zlib}", buildDir);
|
||||
var buildResult = ninja.Run("", buildDir);
|
||||
var installResult = ninja.Run("install", buildDir);
|
||||
}
|
||||
|
||||
static void BuildOpenssl(string source, string installDir) {
|
||||
var tmpDir = TempDirectory.New();
|
||||
|
||||
var perl = Find.Executable("perl");
|
||||
if (perl == null) {
|
||||
throw new Exception("Perl not found but required for OpenSSL build");
|
||||
}
|
||||
|
||||
var nasm = Find.Executable("nasm");
|
||||
if (nasm == null) {
|
||||
throw new Exception("Nasm not found but required for OpenSSL build");
|
||||
}
|
||||
|
||||
var installPrefix = Path.Combine(installDir, "openssl").Replace("\\", "/");
|
||||
var configFilePath = Path.Combine(source, "Configure").Replace("\\", "/");
|
||||
|
||||
var configureResult = perl.Run($"{configFilePath} VC-WIN64A enable-capieng --prefix={installPrefix} --openssldir={installPrefix}", tmpDir);
|
||||
|
||||
var nmake = Find.Executable("nmake");
|
||||
|
||||
var buildResult = nmake.Run("", tmpDir);
|
||||
var installResult = nmake.Run("install", tmpDir);
|
||||
}
|
||||
|
||||
|
||||
static void BuildApr(string source, string installDir) {
|
||||
var tmpDir = TempDirectory.New();
|
||||
|
||||
var cmake = Find.Executable("cmake");
|
||||
var ninja = Find.Executable("ninja");
|
||||
var installPrefix = Path.Combine(installDir, "apr").Replace("\\", "/");
|
||||
|
||||
var configResult = cmake.Run($"-DCMAKE_INSTALL_PREFIX={installPrefix} -G \"Ninja\" -DAPR_INSTALL_PRIVATE_H=ON -DCMAKE_BUILD_TYPE=RELEASE -DAPR_BUILD_STATIC=ON {source}", tmpDir);
|
||||
var buildResult = ninja.Run("", tmpDir);
|
||||
var installResult = ninja.Run("install", tmpDir);
|
||||
}
|
||||
|
||||
static void BuildAprUtil(string source, string expatLibDir, string installDir) {
|
||||
var tmpDir = TempDirectory.New();
|
||||
|
||||
var cmake = Find.Executable("cmake");
|
||||
var ninja = Find.Executable("ninja");
|
||||
var installPrefix = Path.Combine(installDir, "apr").Replace("\\", "/");
|
||||
|
||||
var expatLibPath = Path.Combine(expatLibDir, "Bin", "libexpat.lib").Replace("\\", "/");
|
||||
var expatIncPath = Path.Combine(expatLibDir, "Source", "lib").Replace("\\", "/");
|
||||
var opensslPath = Path.Combine(installDir, "openssl").Replace("\\", "/");
|
||||
|
||||
var configResult = cmake.Run($"-DCMAKE_INSTALL_PREFIX={installPrefix} -G \"Ninja\" -DAPR_INSTALL_PRIVATE_H=ON -DCMAKE_BUILD_TYPE=RELEASE -DEXPAT_LIBRARY={expatLibPath} -DEXPAT_INCLUDE_DIR={expatIncPath} -DAPU_HAVE_CRYPTO=ON -DOPENSSL_ROOT_DIR={opensslPath} {source}", tmpDir);
|
||||
var buildResult = ninja.Run("", tmpDir);
|
||||
var installResult = ninja.Run("install", tmpDir);
|
||||
}
|
||||
|
||||
static void BuildSerf(string source, string installDir) {
|
||||
var scons = Find.Executable("scons");
|
||||
var installPrefix = Path.Combine(installDir, "serf").Replace("\\", "/");
|
||||
var libinstallPrefix = Path.Combine(installPrefix, "lib").Replace("\\", "/");
|
||||
|
||||
var aprPath = Path.Combine(installDir, "apr").Replace("\\", "/");
|
||||
var aprUtilPath = Path.Combine(installDir, "apr").Replace("\\", "/");
|
||||
var zlibPath = Path.Combine(installDir, "zlib").Replace("\\", "/");
|
||||
var opensslPath = Path.Combine(installDir, "openssl").Replace("\\", "/");
|
||||
//
|
||||
scons.Run($"APR={aprPath} APU={aprUtilPath} ZLIB={zlibPath} OPENSSL={opensslPath} SOURCE_LAYOUT=0 TARGET_ARCH=X64 MSVC_VERSION=2022 PREFIX={installPrefix} LIBDIR={libinstallPrefix}", source);
|
||||
scons.Run("install", source);
|
||||
}
|
||||
|
||||
static void FixAprForSerf(string installDir) {
|
||||
var aprPath = Path.Combine(installDir, "apr");
|
||||
var incPath = Path.Combine(aprPath, "include");
|
||||
|
||||
var fixPath = Path.Combine(incPath, "apr-1");
|
||||
Directory.CreateDirectory(fixPath);
|
||||
|
||||
var files = Directory.GetFiles(incPath);
|
||||
|
||||
foreach (var file in files) {
|
||||
var name = Path.GetFileName(file);
|
||||
var destPath = Path.Combine(fixPath, name);
|
||||
File.Copy(file, destPath, true);
|
||||
}
|
||||
}
|
||||
|
||||
static void PatchSerf(string serfSource) {
|
||||
var sconstructPath = Path.Combine(serfSource, "SConstruct");
|
||||
|
||||
|
||||
string text = File.ReadAllText(sconstructPath);
|
||||
text = text.Replace("$OPENSSL/include/openssl", "$OPENSSL/include");
|
||||
File.WriteAllText(sconstructPath, text);
|
||||
}
|
||||
|
||||
static void BuildSubversion(string svnSource, string sqlSource, string installDir) {
|
||||
var aprPath = Path.Combine(installDir, "apr").Replace("\\", "/");
|
||||
var serfPath = Path.Combine(installDir, "serf").Replace("\\", "/");
|
||||
var zlibPath = Path.Combine(installDir, "zlib").Replace("\\", "/");
|
||||
var opensslPath = Path.Combine(installDir, "openssl").Replace("\\", "/");
|
||||
string libPaths = $"{aprPath};{serfPath};{zlibPath}";
|
||||
string expatBinDir = "e:/SvnDeps/expat/Bin";
|
||||
string expatIncDir = "e:/SvnDeps/expat/Source/lib";
|
||||
string installPrefix = Path.Combine(installDir, "subversion");
|
||||
|
||||
List<string> args = new List<string>();
|
||||
args.Add("-G \"Ninja\"");
|
||||
args.Add($"-DCMAKE_LIBRARY_PATH={libPaths}");
|
||||
args.Add($"-DCMAKE_PREFIX_PATH={libPaths}");
|
||||
args.Add($"-DPC_EXPAT_LIBRARY_DIRS={expatBinDir}");
|
||||
args.Add($"-DPC_EXPAT_INCLUDE_DIRS={expatIncDir}");
|
||||
args.Add($"-DSVN_SQLITE_USE_AMALGAMATION=ON");
|
||||
args.Add($"-DSQLITE_AMALGAMATION_DIR={sqlSource}");
|
||||
args.Add($"-DCMAKE_BUILD_TYPE=RELEASE");
|
||||
args.Add($"-DSVN_ENABLE_RA_SERF=ON");
|
||||
args.Add($"-DOPENSSL_ROOT_DIR={opensslPath}");
|
||||
args.Add($"-DSVN_ENABLE_SVNXX=ON");
|
||||
args.Add($"-DSVN_ENABLE_NLS=OFF");
|
||||
args.Add($"-DZLIB_USE_STATIC_LIBS=ON");
|
||||
args.Add($"-DCMAKE_INSTALL_PREFIX={installPrefix}");
|
||||
args.Add($"{svnSource}");
|
||||
|
||||
var argsString = string.Join(" ", args);
|
||||
|
||||
var cmake = Find.Executable("cmake");
|
||||
var ninja = Find.Executable("ninja");
|
||||
|
||||
var tmpDir = TempDirectory.New();
|
||||
var configResult = cmake.Run(argsString, tmpDir);
|
||||
|
||||
var buildResult = ninja.Run("", tmpDir);
|
||||
var installResult = ninja.Run("install", tmpDir);
|
||||
}
|
||||
|
||||
public static async Task<int> Main() {
|
||||
VisualStudio.SetupEnvironment(CpuArchitecture.x64);
|
||||
|
||||
var projectRootDir = GetProjectRootDir();
|
||||
var depsSourceDirectory = Path.Combine(projectRootDir, "DependenciesSource");
|
||||
Directory.CreateDirectory(depsSourceDirectory);
|
||||
var depsBuildDirectory = Path.Combine(projectRootDir, "DependenciesBuild");
|
||||
Directory.CreateDirectory(depsBuildDirectory);
|
||||
|
||||
var svn = await Dependencies.GetSubversion(projectRootDir);
|
||||
var zLib = await Dependencies.GetZLib(depsSourceDirectory);
|
||||
var sqLite = await Dependencies.GetSqlite(depsSourceDirectory);
|
||||
var apr = await Dependencies.GetApr(depsSourceDirectory);
|
||||
var aprUtil = await Dependencies.GetAprUtil(depsSourceDirectory);
|
||||
var serf = await Dependencies.GetSerf(depsSourceDirectory);
|
||||
var openssl = await Dependencies.GetOpenssl(depsSourceDirectory);
|
||||
var expat = await Dependencies.GetExpat(depsSourceDirectory);
|
||||
|
||||
BuildOpenssl(openssl, depsBuildDirectory);
|
||||
BuildZLib(zLib, depsBuildDirectory);
|
||||
BuildApr(apr, depsBuildDirectory);
|
||||
BuildAprUtil(aprUtil, expat, depsBuildDirectory);
|
||||
FixAprForSerf(depsBuildDirectory);
|
||||
PatchSerf(serf);
|
||||
BuildSerf(serf, depsBuildDirectory);
|
||||
BuildSubversion(svn, sqLite, depsBuildDirectory);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user