Skip to content
This repository has been archived by the owner on Feb 7, 2022. It is now read-only.

Commit

Permalink
Rebrand
Browse files Browse the repository at this point in the history
  • Loading branch information
js6pak committed Jan 2, 2021
1 parent 7b67bf8 commit 19b8ca4
Show file tree
Hide file tree
Showing 10 changed files with 133 additions and 22 deletions.
12 changes: 12 additions & 0 deletions .config/dotnet-tools.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"version": 1,
"isRoot": true,
"tools": {
"cake.tool": {
"version": "0.38.5",
"commands": [
"dotnet-cake"
]
}
}
}
29 changes: 29 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Cake

on:
push:
branches: [ reactor ]
pull_request:
branches: [ reactor ]

jobs:
build:
runs-on: ubuntu-20.04

steps:
- uses: actions/checkout@v2
with:
submodules: true

- name: Setup .NET
uses: actions/setup-dotnet@v1
with:
dotnet-version: 5.0.101

- name: Cake Action
uses: cake-build/[email protected]

- uses: actions/upload-artifact@v2
with:
name: BepInEx-reactor
path: bin/dist/BepInEx_UnityIL2CPP_x86*.zip
81 changes: 72 additions & 9 deletions BepInEx.Core/Contract/Attributes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.Reflection;
using BepInEx.Bootstrap;
using Mono.Cecil;
using MonoMod.Utils;

namespace BepInEx
{
Expand Down Expand Up @@ -33,14 +34,14 @@ public class BepInPlugin : Attribute
/// </summary>
public SemVer.Version Version { get; protected set; }

/// <param name="GUID">The unique identifier of the plugin. Should not change between plugin versions.</param>
/// <param name="Name">The user friendly name of the plugin. Is able to be changed between versions.</param>
/// <param name="Version">The specific version of the plugin.</param>
public BepInPlugin(string GUID, string Name, string Version)
/// <param name="guid">The unique identifier of the plugin. Should not change between plugin versions.</param>
/// <param name="name">The user friendly name of the plugin. Is able to be changed between versions.</param>
/// <param name="version">The specific version of the plugin.</param>
public BepInPlugin(string guid, string name = null, string version = null)
{
this.GUID = GUID;
this.Name = Name;
this.Version = TryParseLongVersion(Version);
this.GUID = guid;
this.Name = name;
this.Version = TryParseLongVersion(version);
}

private static SemVer.Version TryParseLongVersion(string version)
Expand All @@ -67,7 +68,66 @@ internal static BepInPlugin FromCecilType(TypeDefinition td)
if (attr == null)
return null;

return new BepInPlugin((string)attr.ConstructorArguments[0].Value, (string)attr.ConstructorArguments[1].Value, (string)attr.ConstructorArguments[2].Value);
var guid = (string)attr.ConstructorArguments[0].Value;
var name = (string)attr.ConstructorArguments[1].Value;
var version = (string)attr.ConstructorArguments[2].Value;

var assembly = td.Module.Assembly;

if (name == null)
{
name = assembly.Name.Name;

var nameAttribute = assembly.GetCustomAttribute(typeof(AssemblyTitleAttribute).FullName);
if (nameAttribute != null && nameAttribute.ConstructorArguments.Count == 1)
{
name = (string)nameAttribute.ConstructorArguments.Single().Value;
}
}

if (version == null)
{
version = assembly.Name.Version.ToString();

var versionAttribute = assembly.GetCustomAttribute(typeof(AssemblyInformationalVersionAttribute).FullName);
if (versionAttribute != null && versionAttribute.ConstructorArguments.Count == 1)
{
version = (string)versionAttribute.ConstructorArguments.Single().Value;
}
}

return new BepInPlugin(guid, name, version);
}

internal void Update(Type pluginType)
{
var assembly = pluginType.Assembly;

if (Name == null)
{
Name = assembly.GetName().Name;

var nameAttribute = MetadataHelper.GetAttributes<AssemblyTitleAttribute>(assembly).Single();
if (nameAttribute != null)
{
Name = nameAttribute.Title;
}
}

if (Version == null)
{
var version = assembly.GetName().Version;
Version = new SemVer.Version(version.Major, version.Minor, version.Build != -1 ? version.Build : 0);

var versionAttribute = MetadataHelper.GetAttributes<AssemblyInformationalVersionAttribute>(assembly).Single();
if (versionAttribute != null)
{
if (SemVer.Version.TryParse(versionAttribute.InformationalVersion, out var v))
{
Version = v;
}
}
}
}
}

Expand Down Expand Up @@ -264,7 +324,10 @@ public static BepInPlugin GetMetadata(Type pluginType)
if (attributes.Length == 0)
return null;

return (BepInPlugin)attributes[0];
var attribute = (BepInPlugin)attributes[0];
attribute.Update(pluginType);

return attribute;
}

/// <summary>
Expand Down
8 changes: 3 additions & 5 deletions BepInEx.IL2CPP/BepInEx.IL2CPP.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,6 @@
<HintPath>..\lib\Il2Cppmscorlib.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="UnhollowerBaseLib">
<HintPath>..\lib\UnhollowerBaseLib.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="UnityEngine-IL2CPP">
<HintPath>..\lib\UnityEngine-IL2CPP.dll</HintPath>
<Private>False</Private>
Expand All @@ -41,6 +37,8 @@
<Private>False</Private>
<Aliases>il2cpp</Aliases>
</Reference>
<PackageReference Include="js6pak.Il2CppDumper" Version="6.4.20" />
<PackageReference Include="NuclearPowered.AssemblyUnhollower" Version="0.4.12" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\BepInEx.Core\BepInEx.Core.csproj" />
Expand All @@ -49,7 +47,7 @@
<ItemGroup>
<PackageReference Include="BepInEx.Il2Cpp.TlsAdapter" Version="1.0.1" />
<PackageReference Include="HarmonyX" Version="2.3.1" />
<PackageReference Include="Iced" Version="1.6.0" />
<PackageReference Include="Iced" Version="1.10.0" />
<PackageReference Include="MonoMod.RuntimeDetour" Version="20.11.26.2" />
</ItemGroup>
<Import Project="..\BepInEx.Shared\BepInEx.Shared.projitems" Label="Shared" />
Expand Down
2 changes: 1 addition & 1 deletion BepInEx.Shared/BepInEx.Shared.projitems
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<HasSharedItems>true</HasSharedItems>
<SharedGUID>E312EFD4-47ED-4DCE-B279-6B0EE314989F</SharedGUID>
<Copyright>Copyright © 2020 BepInEx Team</Copyright>
<Version>6.0.0</Version>
<Version>6.0.0-reactor</Version>
</PropertyGroup>
<PropertyGroup Label="Configuration">
<Import_RootNamespace>BepInEx.Shared</Import_RootNamespace>
Expand Down
2 changes: 1 addition & 1 deletion BepInExTests/BepInExTests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
</PropertyGroup>
<Import Project="$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets" Condition="Exists('$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets')" />
<ItemGroup>
<PackageReference Include="Iced" Version="1.6.0" />
<PackageReference Include="Iced" Version="1.10.0" />
<PackageReference Include="MSTest.TestAdapter" Version="1.3.2" />
<PackageReference Include="MSTest.TestFramework" Version="1.3.2" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.8.3" />
Expand Down
21 changes: 15 additions & 6 deletions build.cake
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
#addin nuget:?package=Cake.Json&version=5.2.0
#addin nuget:?package=Newtonsoft.Json&version=12.0.3

var target = Argument("target", "Build");
var isBleedingEdge = Argument("bleeding_edge", false);
var buildId = Argument("build_id", 0);
var target = Argument("target", "Pack");
var buildId = Argument("build_id", EnvironmentVariable("GITHUB_RUN_NUMBER", 0));
var isBleedingEdge = Argument("bleeding_edge", buildId != 0);
var lastBuildCommit = Argument("last_build_commit", "");

var buildVersion = "";
Expand Down Expand Up @@ -53,7 +53,7 @@ Task("Build")
{
var bepinExProperties = Directory("./BepInEx.Shared");
buildVersion = FindRegexMatchGroupInFile(bepinExProperties + File("BepInEx.Shared.projitems"), @"\<Version\>([0-9]+\.[0-9]+\.[0-9]+)\<\/Version\>", 1, System.Text.RegularExpressions.RegexOptions.None).Value;
buildVersion = FindRegexMatchGroupInFile(bepinExProperties + File("BepInEx.Shared.projitems"), @"\<Version\>([0-9]+\.[0-9]+\.[0-9]+)-reactor\<\/Version\>", 1, System.Text.RegularExpressions.RegexOptions.None).Value;
var buildSettings = new MSBuildSettings {
Configuration = "Release",
Expand All @@ -72,9 +72,13 @@ Task("Build")
buildSettings.Properties["AssemblyVersion"] = new[] { buildVersion + "." + buildId };
buildVersion += "-be." + buildId;
buildVersion += "-reactor." + buildId;
buildSettings.Properties["Version"] = new[] { buildVersion };
}
else
{
buildVersion += "-reactor";
}
//buildSettings.Properties["TargetFrameworks"] = new []{ "net35" };
Expand Down Expand Up @@ -122,6 +126,7 @@ Task("DownloadDependencies")
var monoPath = Directory("./bin/doorstop/mono");
var monoX64Path = doorstopPath + File("mono_x64.zip");
var monoX86Path = doorstopPath + File("mono_x86.zip");
var baseLibs = doorstopPath + File("2019.4.9.zip");
CreateDirectory(monoPath);
DownloadFile($"https://github.com/BepInEx/mono/releases/download/{MONO_VER}/mono-x64.zip", monoX64Path);
Expand All @@ -131,6 +136,9 @@ Task("DownloadDependencies")
ZipUncompress(monoX64Path, monoPath + Directory("x64"));
ZipUncompress(monoX86Path, monoPath + Directory("x86"));
DownloadFile("http://raw.githubusercontent.com/HerpDerpinstine/MelonLoader/master/BaseLibs/UnityDependencies/2019.4.9.zip", baseLibs);
ZipUncompress(baseLibs, doorstopPath + Directory("BaseLibs"));
});

Task("MakeDist")
Expand Down Expand Up @@ -190,13 +198,14 @@ Task("MakeDist")
if (copyMono)
{
CopyDirectory("./bin/doorstop/mono/" + arch + "/mono", Directory(distArchDir) + Directory("mono"));
CopyDirectory("./bin/doorstop/BaseLibs", Directory(distArchDir) + Directory("BepInEx") + Directory("unhollowed") + Directory("base"));
}
}
CopyFiles("./bin/" + Directory(originDir) + "/*.*", Directory(bepinDir) + Directory("core"));
FileWriteText(distArchDir + File("changelog.txt"), changelog);
// FileWriteText(distArchDir + File("changelog.txt"), changelog);
if (platform == "NetLauncher")
{
Expand Down
Binary file removed lib/AssemblyUnhollower.exe
Binary file not shown.
Binary file removed lib/UnhollowerBaseLib.dll
Binary file not shown.
Binary file removed lib/UnhollowerRuntimeLib.dll
Binary file not shown.

0 comments on commit 19b8ca4

Please sign in to comment.