Skip to content

Commit

Permalink
Added: Readme, Logo, Changelog to R-II Package
Browse files Browse the repository at this point in the history
  • Loading branch information
Sewer56 committed Oct 10, 2022
1 parent 44484e2 commit 2c242e9
Show file tree
Hide file tree
Showing 9 changed files with 144 additions and 93 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/reloaded.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ jobs:
}
- name: Build
run: ./External/Reloaded.Memory.SigScan.ReloadedII/Publish.ps1 -ChangelogPath "$env:PUBLISH_CHANGELOG_PATH"
run: ./External/Reloaded.Memory.SigScan.ReloadedII/Publish.ps1 -ChangelogPath "$env:PUBLISH_CHANGELOG_PATH" -ReadmePath "./External/Reloaded.Memory.SigScan.ReloadedII/README-RII.md"

- name: Upload GitHub Release Artifact
uses: actions/[email protected]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Split-Path $MyInvocation.MyCommand.Path | Push-Location
[Environment]::CurrentDirectory = $PWD

Remove-Item "$env:RELOADEDIIMODS/Reloaded.Memory.SigScan.ReloadedII/*" -Force -Recurse
dotnet publish "./Reloaded.Memory.SigScan.ReloadedII.csproj" -c Release -o "$env:RELOADEDIIMODS/Reloaded.Memory.SigScan.ReloadedII" /p:OutputPath="./bin/Release" /p:RobustILLink="true"
dotnet publish "./Reloaded.Memory.SigScan.ReloadedII.csproj" -c Release -o "$env:RELOADEDIIMODS/Reloaded.Memory.SigScan.ReloadedII" /p:OutputPath="./bin/Release" /p:ReloadedILLink="true"

# Restore Working Directory
Pop-Location
5 changes: 3 additions & 2 deletions External/Reloaded.Memory.SigScan.ReloadedII/ModConfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"ModId": "Reloaded.Memory.SigScan.ReloadedII",
"ModName": "Library: Reloaded.Memory.Sigscan for Reloaded II",
"ModAuthor": "Sewer56",
"ModVersion": "1.2.3",
"ModVersion": "1.2.4",
"ModDescription": "Shared implementation of Reloaded.Memory.Sigscan",
"ModDll": "Reloaded.Memory.SigScan.ReloadedII.dll",
"ModIcon": "Preview.png",
Expand All @@ -29,5 +29,6 @@
"IsUniversalMod": false,
"ModDependencies": [],
"OptionalDependencies": [],
"SupportedAppId": []
"SupportedAppId": [],
"ProjectUrl": "https://github.com/Reloaded-Project/Reloaded.Memory.SigScan"
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
37 changes: 30 additions & 7 deletions External/Reloaded.Memory.SigScan.ReloadedII/Publish.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@
Full or relative path to a file containing the changelog for the mod.
The changelog should be written in Markdown format.
.PARAMETER ReadmePath
Full or relative path to a file containing the changelog for the mod.
The changelog should be written in Markdown format.
.PARAMETER IsPrerelease
Default: $False
Expand Down Expand Up @@ -131,6 +135,11 @@
Removes executables from build output. Useful when performing R2R Optimisation.
.PARAMETER UseScriptDirectory
Default: $True
Uses script directory for performing build. Otherwise uses current directory.
.EXAMPLE
.\Publish.ps1 -ProjectPath "Reloaded.Hooks.ReloadedII/Reloaded.Hooks.ReloadedII.csproj" -PackageName "Reloaded.Hooks.ReloadedII" -PublishOutputDir "Publish/ToUpload"
Expand All @@ -146,10 +155,12 @@ param (
$IsPrerelease=$False,
$MakeDelta=$False,
$ChangelogPath="",
$ReadmePath="",
$Build=$True,
$BuildR2R=$True,
$RemoveExe = $True,

$BuildR2R=$False,
$RemoveExe=$True,
$UseScriptDirectory=$True,

## => User Config <= ##
$ProjectPath = "Reloaded.Memory.SigScan.ReloadedII.csproj",
$PackageName = "Reloaded.Memory.SigScan.ReloadedII",
Expand Down Expand Up @@ -193,12 +204,18 @@ $reloadedToolsPath = "./Publish/Tools/Reloaded-Tools" # Used to check if tool
$updateToolsPath = "./Publish/Tools/Update-Tools" # Used to check if update tools are installed.
$reloadedToolPath = "$reloadedToolsPath/Reloaded.Publisher.exe" # Path to Reloaded publishing tool.
$updateToolPath = "$updateToolsPath/Sewer56.Update.Tool.dll" # Path to Update tool.
$changelogFullPath = $([System.IO.Path]::GetFullPath($ChangelogPath))
$changelogFullPath = $null
$readmeFullPath = $null
if ($ChangelogPath) { $changelogFullPath = [System.IO.Path]::GetFullPath($ChangelogPath) }
if ($ReadmePath) { $readmeFullPath = [System.IO.Path]::GetFullPath($ReadmePath) }

## => Script <= ##
# Set Working Directory
Split-Path $MyInvocation.MyCommand.Path | Push-Location
[Environment]::CurrentDirectory = $PWD
$UseScriptDirectory = [bool]::Parse($UseScriptDirectory)
if ($UseScriptDirectory) {
Split-Path $MyInvocation.MyCommand.Path | Push-Location
[Environment]::CurrentDirectory = $PWD
}

# Convert Booleans
$IsPrerelease = [bool]::Parse($IsPrerelease)
Expand Down Expand Up @@ -302,6 +319,10 @@ function Get-Common-Publish-Args {
if ($ChangelogPath) {
$arguments += " --changelogpath `"$changelogFullPath`""
}

if ($ReadmePath) {
$arguments += " --readmepath `"$readmeFullPath`""
}

if ($AllowDeltas -and $MakeDelta) {
$arguments += " --olderversionfolders `"$deltaDirectory`""
Expand Down Expand Up @@ -382,4 +403,6 @@ Remove-Item $TempDirectory -Recurse -ErrorAction SilentlyContinue
# Restore Working Directory
Write-Host "Done."
Write-Host "Upload the files in folder `"$PublishOutputDir`" to respective location or website."
Pop-Location
if ($UseScriptDirectory) {
Pop-Location
}
37 changes: 37 additions & 0 deletions External/Reloaded.Memory.SigScan.ReloadedII/README-RII.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
## Reloaded-II Shared Library

[For information on consuming Shared Libraries, see [Dependency Injection in Reloaded II](https://reloaded-project.github.io/Reloaded-II/DependencyInjection_Consumer/).]

[![NuGet](https://img.shields.io/nuget/v/Reloaded.Memory.SigScan.ReloadedII.Interfaces)](https://www.nuget.org/packages/Reloaded.Memory.SigScan.ReloadedII.Interfaces)

`Reloaded.Memory.SigScan.ReloadedII.Interfaces` [(NuGet)](https://www.nuget.org/packages/Reloaded.Memory.SigScan.ReloadedII.Interfaces) exposes the following APIs:
- `IStartupScanner`: Queues signature scans for batch parallel scanning.
- `IScannerFactory`: Creates `Scanner` instances.

It is highly recommended that you use `IStartupScanner` in your mods.
Running signature scans in parallel provides very significant gains to startup time.

Scans submitted to this class are performed in the order they are submitted.
There is no need to worry about conflicts/race conditions.

Example:
```csharp
void Start()
{
// ... code omitted
_modLoader.GetController<IStartupScanner>().TryGetTarget(out var startupScanner);
startupScanner.AddMainModuleScan("C3", OnMainModuleScan);
}

private void OnMainModuleScan(PatternScanResult result)
{
_logger.WriteLine($"Found `ret` at: {result.Offset}");
}
```

If you need additional APIs in `IStartupScanner`, such as scanning custom/different ranges, please let me know. For now the API only handles the common use case.

## Acknowledgements

Vectorised implementations of `Reloaded.Memory.Sigscan` are based off of a modified version of `LazySIMD` by [uberhalit](https://github.com/uberhalit).
[Binary by ismail abdurrasyid from Noun Project](https://thenounproject.com/browse/icons/term/binary/).
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,25 @@
<TargetFramework>net5.0-windows</TargetFramework>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
<LangVersion>preview</LangVersion>
<LangVersion>10.0</LangVersion>
<Nullable>enable</Nullable>
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
<OutputPath>$(RELOADEDIIMODS)/Reloaded.Memory.SigScan.ReloadedII</OutputPath>

<!-- IL Trimming Support forked from https://github.com/space-wizards/RobustToolbox, under the MIT License -->
<!-- If you set this to true, trimming will be enabled when you publish the mod. . Test it using
<!-- IL Trimming Support for Framework Dependent Apps. Unofficial.
If you set this to true, trimming will be enabled when you publish the mod.
Test trimming with: `BuildLinked.ps1` in PowerShell. -->
<RobustILLink>true</RobustILLink>
<ReloadedILLink>true</ReloadedILLink>
</PropertyGroup>

<ItemGroup>
<RobustLinkRoots Include="Reloaded.Memory.SigScan.ReloadedII" />
<ReloadedLinkRoots Include="Reloaded.Memory.SigScan.ReloadedII" />
<!-- Add assemblies to be trimmed. You might need to add their dependencies too! -->
<RobustLinkAssemblies Include="Reloaded.Memory.Sigscan" />
<RobustLinkAssemblies Include="Reloaded.Memory" />
<ReloadedLinkAssemblies Include="Reloaded.Memory.Sigscan" />
<ReloadedLinkAssemblies Include="Reloaded.Memory" />
</ItemGroup>

<Import Project="Robust.Trimming.targets" />
<Import Project="Reloaded.Trimming.targets" />

<ItemGroup>
<None Remove="ModConfig.json" />
Expand All @@ -39,7 +39,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Reloaded.Mod.Interfaces" Version="2.1.0" />
<PackageReference Include="Reloaded.Mod.Interfaces" Version="2.3.0" ExcludeAssets="runtime" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,84 +1,104 @@
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="12.0">
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="12.0">
<!--
Taken from https://github.com/space-wizards/RobustToolbox under the MIT License
Stuff for using ILLink trimming without self-contained deployments.
This is not something officially supported by the .NET SDK currently, but we can simply run ILLink ourselves.
Originally inspired by https://github.com/space-wizards/RobustToolbox , under the MIT License
Modified by Sewer56 to include support for .NET6 IsTrimmable property.
-->

<!--
Stuff for using ILLink trimming without self-contained deployments.
This is not something officially supported by the .NET SDK currently, but we can simply run ILLink ourselves.
A lot of stuff taken from Microsoft.NET.ILLink.targets in the SDK files.
-->

<ItemDefinitionGroup>
<RobustLinkRoots>
<ReloadedLinkRoots>
<Visible>false</Visible>
</RobustLinkRoots>
<RobustLinkAssemblies>
</ReloadedLinkRoots>
<ReloadedLinkAssemblies>
<Visible>false</Visible>
</RobustLinkAssemblies>
</ReloadedLinkAssemblies>
</ItemDefinitionGroup>

<Target Name="RobustILLink"
<Target Name="ReloadedILLink"
BeforeTargets="ILLink"
Condition="'$(PublishTrimmed)' != 'true' And
'$(RobustILLink)' == 'true'"
'$(ReloadedILLink)' == 'true'"
DependsOnTargets="_ComputeAssembliesToPostprocessOnPublish">

<ComputeManagedAssemblies Assemblies="@(ResolvedFileToPublish)">
<Output TaskParameter="ManagedAssemblies" ItemName="_ResolvedFileToPublishFiltered" />
<!-- Original Target: ComputeManagedAssemblyToLink -->
<ComputeManagedAssemblies Assemblies="@(ResolvedFileToPublish->WithMetadataValue('PostprocessAssembly', 'true'))">
<Output TaskParameter="ManagedAssemblies" ItemName="ManagedAssemblyToLink" />
</ComputeManagedAssemblies>

<JoinItems Left="@(_ResolvedFileToPublishFiltered)" LeftKey="FileName" LeftMetadata="*"
Right="@(RobustLinkRoots)"
ItemSpecToUse="Left">
<Output TaskParameter="JoinResult" ItemName="_RobustLinkRootsJoined" />
</JoinItems>
<ItemGroup>
<!-- The linker implicitly picks up PDBs next to input assemblies. We will filter these out of the publish set. -->
<__PDBToLink Include="@(ResolvedFileToPublish)" Exclude="@(ManagedAssemblyToLink->'%(RelativeDir)%(Filename).pdb')" />
<_PDBToLink Include="@(ResolvedFileToPublish)" Exclude="@(__PDBToLink)" />
</ItemGroup>

<JoinItems Left="@(_ResolvedFileToPublishFiltered)" LeftKey="FileName" LeftMetadata="*"
Right="@(RobustLinkAssemblies)"
ItemSpecToUse="Left">
<Output TaskParameter="JoinResult" ItemName="_RobustLinkAssembliesJoined" />
</JoinItems>
<ItemGroup>
<_LinkedResolvedFileToPublishCandidate Include="@(ManagedAssemblyToLink->'$(IntermediateLinkDir)%(Filename)%(Extension)')" />
<_LinkedResolvedFileToPublishCandidate Include="@(_PDBToLink->'$(IntermediateLinkDir)%(Filename)%(Extension)')" />
</ItemGroup>

<!-- Original Target: PrepareForILLink -->
<!-- Set IsTrimmable for any assemblies that already have customized TrimMode. -->
<ItemGroup>
<ManagedAssemblyToLink>
<IsTrimmable>true</IsTrimmable>
</ManagedAssemblyToLink>
</ItemGroup>

<PropertyGroup>
<TrimMode Condition=" '$(TrimMode)' == '' ">link</TrimMode>
<!-- For .NET 6+, assemblies without IsTrimmable attribute get the "copy" action. -->
<TrimmerDefaultAction Condition=" '$(TrimmerDefaultAction)' == '' ">copy</TrimmerDefaultAction>
<_ExtraTrimmerArgs>--skip-unresolved true $(_ExtraTrimmerArgs)</_ExtraTrimmerArgs>
<ILLinkTreatWarningsAsErrors Condition=" '$(ILLinkTreatWarningsAsErrors)' == '' ">$(TreatWarningsAsErrors)</ILLinkTreatWarningsAsErrors>
<_ExtraTrimmerArgs>--skip-unresolved true $(_ExtraTrimmerArgs)</_ExtraTrimmerArgs>
<TrimmerSingleWarn Condition=" '$(TrimmerSingleWarn)' == '' ">true</TrimmerSingleWarn>
</PropertyGroup>

<!-- SetIsTrimmable for any assemblies listed in TrimmableAssembly.
TrimmableAssembly -> ReloadedLinkAssemblies
-->
<JoinItems Left="@(ManagedAssemblyToLink)" LeftKey="FileName" LeftMetadata="*"
Right="@(ReloadedLinkAssemblies)"
ItemSpecToUse="Left">
<Output TaskParameter="JoinResult" ItemName="_TrimmableManagedAssemblyToLink" />
</JoinItems>
<ItemGroup>
<RobustAssemblyToLink Include="@(_RobustLinkRootsJoined)">
<TrimMode>Copy</TrimMode>
</RobustAssemblyToLink>
<RobustAssemblyToLink Include="@(_RobustLinkAssembliesJoined)">
<TrimMode>Link</TrimMode>
</RobustAssemblyToLink>
<!-- Set trimmable for assemblies which we wish to trim. -->
<ManagedAssemblyToLink Remove="@(_TrimmableManagedAssemblyToLink)" />
<ManagedAssemblyToLink Include="@(_TrimmableManagedAssemblyToLink)" IsTrimmable="true" />
</ItemGroup>

<!-- Root the main assembly, whether or not it has IsTrimmable set. -->
<ItemGroup>
<!-- The linker implicitly picks up PDBs next to input assemblies. We will filter these out of the publish set. -->
<__PDBToLink Include="@(ResolvedFileToPublish)" Exclude="@(RobustAssemblyToLink->'%(RelativeDir)%(Filename).pdb')" />
<_PDBToLink Include="@(ResolvedFileToPublish)" Exclude="@(__PDBToLink)" />
<ReloadedLinkRoots Include="@(IntermediateAssembly)" />
</ItemGroup>

<!-- In .NET6+, set the action explicitly for any with IsTrimmable MSBuild metadata -->
<ItemGroup>
<_LinkedResolvedFileToPublishCandidate Include="@(RobustAssemblyToLink->'$(IntermediateLinkDir)%(Filename)%(Extension)')" />
<_LinkedResolvedFileToPublishCandidate Include="@(_PDBToLink->'$(IntermediateLinkDir)%(Filename)%(Extension)')" />

</ItemGroup>

<!--<Message Text="@(ResolvedFileToPublish)" Importance="high" />-->

<!-- Custom: Print assemblies for trimming. -->
<ItemGroup>
<TrimmingItemsToPrint Include="@(ManagedAssemblyToLink)">
<Text>Input Assembly: %(filename) [Mode: %(ManagedAssemblyToLink.TrimMode)]</Text>
</TrimmingItemsToPrint>
</ItemGroup>

<Message Text="%(TrimmingItemsToPrint.Text)" Importance="high" />

<!-- Do the trimming. -->
<Delete Files="@(_LinkedResolvedFileToPublishCandidate)" />
<ILLink AssemblyPaths="@(RobustAssemblyToLink)"
<ILLink AssemblyPaths="@(ManagedAssemblyToLink)"
ReferenceAssemblyPaths="@(ReferencePath)"
RootAssemblyNames="@(RobustLinkRoots)"
TrimMode="Skip"
RootAssemblyNames="@(ReloadedLinkRoots)"
TrimMode="$(TrimMode)"
DefaultAction="$(TrimmerDefaultAction)"
RemoveSymbols="false"
FeatureSettings="@(_TrimmerFeatureSettings)"
Expand Down Expand Up @@ -111,12 +131,13 @@

<Touch Files="$(_LinkSemaphore)" AlwaysCreate="true" Condition=" '$(_ILLinkExitCode)' == '0' " />

<!-- Original Target: ILLink -->
<ItemGroup>
<_LinkedResolvedFileToPublish Include="@(_LinkedResolvedFileToPublishCandidate)" Condition="Exists('%(Identity)')" />
<ResolvedFileToPublish Remove="@(RobustAssemblyToLink)" />
<ResolvedFileToPublish Remove="@(ManagedAssemblyToLink)" />
<ResolvedFileToPublish Remove="@(_PDBToLink)" />
<ResolvedFileToPublish Include="@(_LinkedResolvedFileToPublish)" />
</ItemGroup>
</Target>

</Target>
</Project>
Loading

0 comments on commit 2c242e9

Please sign in to comment.