Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
ied206 committed Apr 4, 2021
2 parents 8212c0c + a44d985 commit c62d830
Show file tree
Hide file tree
Showing 64 changed files with 36,045 additions and 455 deletions.
5 changes: 5 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
###############################################################################
* text=auto

###############################################################################
# magic.mgc / magic.txt
###############################################################################
Joveler.DynLoader.Tests/contentFiles/any/any/magic.txt text eol=lf

###############################################################################
# Set default behavior for command prompt diff.
#
Expand Down
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,16 @@

## v2.x

### v2.1.0

Release in 2021.04.05.

- Avoid calling virtual methods from constructors in `DynLoaderBase`.
- Users must call `DynLoaderBase.LoadLibrary` after creating an instance.
- Constructor with a library path is now obsolete. Pass a path into `LoadLibrary` instead.
- It breaks the ABI compatibility of `DynLoaderBase`. However, `LoadManagerBase` was also patched to accommodate these changes.
- If you used the `LoadManagerBase` interface, you can safely update Joveler.DynLoader without any code change.

### v2.0.0

Released in 2020.04.24.
Expand Down
2 changes: 0 additions & 2 deletions Joveler.DynLoader.Tests/GhostError.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ public unsafe sealed class GhostError : DynLoaderBase
{
#region Constructor
public GhostError() : base() { }
public GhostError(string libPath) : base(libPath) { }
#endregion

#region Properties
Expand Down Expand Up @@ -55,7 +54,6 @@ public unsafe sealed class GhostFunction : DynLoaderBase
{
#region Constructor
public GhostFunction() : base() { }
public GhostFunction(string libPath) : base(libPath) { }
#endregion

#region Properties
Expand Down
6 changes: 4 additions & 2 deletions Joveler.DynLoader.Tests/GhostErrorTests.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright (C) 2019 Hajin Jang
Copyright (C) 2019-2021 Hajin Jang
Licensed under MIT License.
MIT License
Expand Down Expand Up @@ -40,6 +40,7 @@ public void LoadModuleError()
try
{
GhostError lib = new GhostError();
lib.LoadLibrary();
}
catch (DllNotFoundException e)
{
Expand All @@ -60,7 +61,8 @@ public void LoadFunctionError()
{
try
{
GhostFunction lib = new GhostFunction(TestSetup.PackagedZLibPath);
GhostFunction lib = new GhostFunction();
lib.LoadLibrary(TestSetup.PackagedZLibPath);
}
catch (EntryPointNotFoundException e)
{
Expand Down
72 changes: 67 additions & 5 deletions Joveler.DynLoader.Tests/Joveler.DynLoader.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,84 @@
<IsPackable>false</IsPackable>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<Import Project="$(MSBuildProjectDirectory)\SimpleZLib.targets" />
<Import Project="$(MSBuildProjectDirectory)\SimpleFileMagic.targets" />

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.5.0" />
<PackageReference Include="MSTest.TestAdapter" Version="2.1.1" />
<PackageReference Include="MSTest.TestFramework" Version="2.1.1" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Joveler.DynLoader\Joveler.DynLoader.csproj" />
</ItemGroup>

<!-- Magic Database -->
<ItemGroup>
<Content Include="contentFiles\any\any\magic.txt">
<Link>%(FileName)%(Extension)</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<Pack>true</Pack>
<PackagePath>contentFiles\any\any\magic.txt</PackagePath>
<PackageCopyToOutput>true</PackageCopyToOutput>
<!--
[content] is for package.config (.NET Framework), and [contentFiles] is for PacakageReference (.NET Standard, .NET Core)
Instead, store files in contentFiles and copy file with .target on .NET Framework.
<PackagePath>content/magic.txt;contentFiles/any/any/magic.txt</PackagePath>
-->
</Content>
</ItemGroup>

<!-- Native Library for .NET Framework 4.8 -->
<ItemGroup Condition=" '$(TargetFramework)' == 'net48' ">
<None Include="runtimes\win-x86\native\*.dll">
<Link>x86\%(FileName)%(Extension)</Link> <!-- Project Reference -->
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="runtimes\win-x64\native\*.dll">
<Link>x64\%(FileName)%(Extension)</Link> <!-- Project Reference -->
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
<!-- Unfortanately, MSBuild does not support Condition on Import. -->
<!-- <Import Project="$(MSBuildProjectDirectory)\SampleScript.netfx.targets" -->

<!-- Native Library for .NET Core 2.1 & 3.1 -->
<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp2.1' or '$(TargetFramework)' == 'netcoreapp3.1'">
<None Include="runtimes\win-x86\native\*.dll">
<Link>runtimes\win-x86\native\%(FileName)%(Extension)</Link> <!-- Project Reference -->
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="runtimes\win-x64\native\*.dll">
<Link>runtimes\win-x64\native\%(FileName)%(Extension)</Link> <!-- Project Reference -->
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="runtimes\win-arm64\native\*.dll">
<Link>runtimes\win-arm64\native\%(FileName)%(Extension)</Link> <!-- Project Reference -->
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="runtimes\linux-x64\native\*.so">
<Link>runtimes\linux-x64\native\%(FileName)%(Extension)</Link> <!-- Project Reference -->
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="runtimes\linux-arm\native\*.so">
<Link>runtimes\linux-arm\native\%(FileName)%(Extension)</Link> <!-- Project Reference -->
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="runtimes\linux-arm64\native\*.so">
<Link>runtimes\linux-arm64\native\%(FileName)%(Extension)</Link> <!-- Project Reference -->
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="runtimes\osx-x64\native\*.dylib">
<Link>runtimes\osx-x64\native\%(FileName)%(Extension)</Link> <!-- Project Reference -->
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>


</Project>
1 change: 1 addition & 0 deletions Joveler.DynLoader.Tests/PlatformConventionTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public class PlatformConventionTests
public void DataModel()
{
DynLoaderBase instance = new EmptyLoader();
instance.LoadLibrary();

if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
Expand Down
Binary file not shown.
Binary file removed Joveler.DynLoader.Tests/Precompiled/arm64/libz.so
Binary file not shown.
Binary file not shown.
Binary file removed Joveler.DynLoader.Tests/Precompiled/armhf/libz.so
Binary file not shown.
Binary file removed Joveler.DynLoader.Tests/Precompiled/magic.mgc
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed Joveler.DynLoader.Tests/Precompiled/x64/libmagic.so
Binary file not shown.
Binary file not shown.
Binary file removed Joveler.DynLoader.Tests/Precompiled/x64/libtre-5.dll
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed Joveler.DynLoader.Tests/Precompiled/x86/libtre-5.dll
Binary file not shown.
Binary file not shown.
Binary file not shown.
205 changes: 205 additions & 0 deletions Joveler.DynLoader.Tests/SampleScript.netfx.targets
Original file line number Diff line number Diff line change
@@ -0,0 +1,205 @@
<!--
*
* WARNING: This MSBuild file requires MSBuild 4.0 features.
*
* Based on System.Data.SQLite.Core.targets, written by Joe Mistachkin and David Archer.
* Released to the public domain, use at your own risk!
*
-->
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<!--
******************************************************************************
** Load Per-User Settings **
******************************************************************************
-->

<!--
Create "Joveler.Compression.ZLib.Precompiled.Exclude" file in project directory
to disable copying precompiled zlib binaries.
-->
<PropertyGroup>
<ExcludeInteropLib Condition="Exists('$(MSBuildProjectDirectory)\Joveler.DynLoader.Tests.Lib.Exclude')">true</ExcludeInteropLib>
<ExcludeInteropMgc Condition="Exists('$(MSBuildProjectDirectory)\Joveler.DynLoader.Tests.Mgc.Exclude')">true</ExcludeInteropMgc>
</PropertyGroup>

<!--
******************************************************************************
** Interop Library Build Items **
******************************************************************************
-->

<ItemGroup Condition="'$(ExcludeInteropLib)' != 'true' And
'$(MSBuildThisFileDirectory)' != '' And
HasTrailingSlash('$(MSBuildThisFileDirectory)')">
<InteropLibFiles_x86 Include="$(MSBuildThisFileDirectory)..\..\runtimes\win-x86\native\*.dll" />
<InteropLibFiles_x64 Include="$(MSBuildThisFileDirectory)..\..\runtimes\win-x64\native\*.dll" />
</ItemGroup>
<ItemGroup Condition="'$(ExcludeInteropMgc)' != 'true' And
'$(MSBuildThisFileDirectory)' != '' And
HasTrailingSlash('$(MSBuildThisFileDirectory)')">
<InteropMgcFiles Include="$(MSBuildThisFileDirectory)..\..\contentFiles\any\any\*" />
</ItemGroup>

<!--
******************************************************************************
** Interop Library Content Items **
******************************************************************************
-->

<ItemGroup Condition="'$(ExcludeInteropLib)' != 'true'">
<None Condition="'@(InteropLibFiles_x86)' != ''" Include="@(InteropLibFiles_x86)">
<Link>x86\%(FileName)%(Extension)</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Condition="'@(InteropLibFiles_x64)' != ''" Include="@(InteropLibFiles_x64)">
<Link>x64\%(FileName)%(Extension)</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
<ItemGroup Condition="'$(ExcludeInteropMgc)' != 'true'">
<None Condition="'@(InteropMgcFiles)' != ''" Include="@(InteropMgcFiles)">
<Link>%(FileName)%(Extension)</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>

<!--
******************************************************************************
** Interop Library Build Targets **
******************************************************************************
-->

<Target Name="CopyInteropLibFiles_x86"
Condition="'$(CopyInteropLibFiles_x86)' != 'false' And
'$(OutDir)' != '' And
HasTrailingSlash('$(OutDir)') And
Exists('$(OutDir)')"
Inputs="@(InteropLibFiles_x86)"
Outputs="@(InteropLibFiles_x86 -> '$(OutDir)x86\%(Filename)%(Extension)')">
<Copy SourceFiles="@(InteropLibFiles_x86)"
DestinationFiles="@(InteropLibFiles_x86 -> '$(OutDir)x86\%(Filename)%(Extension)')" />
</Target>
<Target Name="CopyInteropLibFiles_x64"
Condition="'$(CopyInteropLibFiles_x64)' != 'false' And
'$(OutDir)' != '' And
HasTrailingSlash('$(OutDir)') And
Exists('$(OutDir)')"
Inputs="@(InteropLibFiles_x64)"
Outputs="@(InteropLibFiles_x64 -> '$(OutDir)x86\%(Filename)%(Extension)')">
<Copy SourceFiles="@(InteropLibFiles_x64)"
DestinationFiles="@(InteropLibFiles_x64 -> '$(OutDir)x64\%(Filename)%(Extension)')" />
</Target>
<Target Name="CopyInteropMgcFiles"
Condition="'$(CopyInteropMgcFiles)' != 'false' And
'$(OutDir)' != '' And
HasTrailingSlash('$(OutDir)') And
Exists('$(OutDir)')"
Inputs="@(InteropMgcFiles)"
Outputs="@(InteropMgcFiles -> '$(OutDir)x86\%(Filename)%(Extension)')">
<Copy SourceFiles="@(InteropMgcFiles)"
DestinationFiles="@(InteropMgcFiles -> '$(OutDir)%(Filename)%(Extension)')" />
</Target>

<!--
******************************************************************************
-->

<Target Name="CleanInteropLibFiles_x86"
Condition="'$(CleanInteropLibFiles_x86)' != 'false' And
'$(OutDir)' != '' And
HasTrailingSlash('$(OutDir)') And
Exists('$(OutDir)')">
<Delete Files="@(InteropLibFiles_x86 -> '$(OutDir)x86\%(Filename)%(Extension)')" />
</Target>
<Target Name="CleanInteropLibFiles_x64"
Condition="'$(CleanInteropLibFiles_x64)' != 'false' And
'$(OutDir)' != '' And
HasTrailingSlash('$(OutDir)') And
Exists('$(OutDir)')">
<Delete Files="@(InteropLibFiles_x64 -> '$(OutDir)x64\%(Filename)%(Extension)')" />
</Target>
<Target Name="CleanInteropMgcFiles"
Condition="'$(CleanInteropMgcFiles)' != 'false' And
'$(OutDir)' != '' And
HasTrailingSlash('$(OutDir)') And
Exists('$(OutDir)')">
<Delete Files="@(InteropMgcFiles -> '$(OutDir)mgc\%(Filename)%(Extension)')" />
</Target>

<!--
******************************************************************************
-->

<Target Name="CollectInteropLibFiles_x86"
Condition="'$(CollectInteropLibFiles_x86)' != 'false'">
<ItemGroup>
<FilesForPackagingFromProject Include="@(InteropLibFiles_x86)">
<DestinationRelativePath>bin\x86\%(Filename)%(Extension)</DestinationRelativePath>
</FilesForPackagingFromProject>
</ItemGroup>
</Target>
<Target Name="CollectInteropLibFiles_x64"
Condition="'$(CollectInteropLibFiles_x64)' != 'false'">
<ItemGroup>
<FilesForPackagingFromProject Include="@(InteropLibFiles_x64)">
<DestinationRelativePath>bin\x64\%(Filename)%(Extension)</DestinationRelativePath>
</FilesForPackagingFromProject>
</ItemGroup>
</Target>
<Target Name="CollectInteropMgcFiles"
Condition="'$(CollectInteropMgcFiles)' != 'false'">
<ItemGroup>
<FilesForPackagingFromProject Include="@(InteropMgcFiles)">
<DestinationRelativePath>bin\%(Filename)%(Extension)</DestinationRelativePath>
</FilesForPackagingFromProject>
</ItemGroup>
</Target>

<!--
******************************************************************************
** Interop Library Build Properties **
******************************************************************************
-->

<PropertyGroup>
<PostBuildEventDependsOn>
$(PostBuildEventDependsOn);
CopyInteropLibFiles_x86;
CopyInteropLibFiles_x64;
CopyInteropMgcFiles;
</PostBuildEventDependsOn>
<BuildDependsOn>
$(BuildDependsOn);
CopyInteropLibFiles_x86;
CopyInteropLibFiles_x64;
CopyInteropMgcFiles;
</BuildDependsOn>
<CleanDependsOn>
$(CleanDependsOn);
CleanInteropLibFiles_x86;
CleanInteropLibFiles_x64;
CleanInteropMgcFiles;
</CleanDependsOn>
</PropertyGroup>

<!--
******************************************************************************
** Interop Library Publish Properties for Visual Studio 201x **
******************************************************************************
-->

<PropertyGroup Condition="'$(VisualStudioVersion)' == '' Or
'$(VisualStudioVersion)' == '10.0' Or
'$(VisualStudioVersion)' == '11.0' Or
'$(VisualStudioVersion)' == '12.0' Or
'$(VisualStudioVersion)' == '14.0' Or
'$(VisualStudioVersion)' == '15.0' Or
'$(VisualStudioVersion)' == '16.0'">
<PipelineCollectFilesPhaseDependsOn>
CollectInteropLibFiles_x86;
CollectInteropLibFiles_x64;
CollectInteropMgcFiles;
$(PipelineCollectFilesPhaseDependsOn);
</PipelineCollectFilesPhaseDependsOn>
</PropertyGroup>
</Project>
5 changes: 0 additions & 5 deletions Joveler.DynLoader.Tests/SimpleFIleMagicManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,6 @@ protected override SimpleFileMagic CreateLoader()
return new SimpleFileMagic();
}

protected override SimpleFileMagic CreateLoader(string libPath)
{
return new SimpleFileMagic(libPath);
}

protected override void PreInitHook()
{
PreInitHookCalled = true;
Expand Down
1 change: 0 additions & 1 deletion Joveler.DynLoader.Tests/SimpleFileMagic.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ public unsafe sealed class SimpleFileMagic : DynLoaderBase
{
#region Constructor
public SimpleFileMagic() : base() { }
public SimpleFileMagic(string libPath) : base(libPath) { }
#endregion

#region Properties
Expand Down
Loading

0 comments on commit c62d830

Please sign in to comment.