feat: add support for external dll
This commit is contained in:
parent
a7cd7a824a
commit
4e2e5aa14a
29
MathLib/Math.cs
Normal file
29
MathLib/Math.cs
Normal file
@ -0,0 +1,29 @@
|
||||
namespace MathLib;
|
||||
|
||||
public class Math
|
||||
{
|
||||
public float Substract(float a, float b)
|
||||
{
|
||||
return a - b;
|
||||
}
|
||||
|
||||
public float Multiply(float a, float b)
|
||||
{
|
||||
return a * b;
|
||||
}
|
||||
|
||||
public float Devide(float a, float b)
|
||||
{
|
||||
return a / b;
|
||||
}
|
||||
|
||||
public float Power(float a)
|
||||
{
|
||||
return a * a;
|
||||
}
|
||||
|
||||
public float Add(float a, float b)
|
||||
{
|
||||
return a + b;
|
||||
}
|
||||
}
|
9
MathLib/MathLib.csproj
Normal file
9
MathLib/MathLib.csproj
Normal file
@ -0,0 +1,9 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
@ -1,9 +1,20 @@
|
||||
namespace MyLib;
|
||||
|
||||
public class Hello
|
||||
public class Hello(float a, float b)
|
||||
{
|
||||
public int Sum(int a, int b)
|
||||
public float A { get; } = a;
|
||||
public float B { get; } = b;
|
||||
|
||||
public float Sum()
|
||||
{
|
||||
return a + b;
|
||||
// Declare class from MathLib.dll
|
||||
MathLib.Math math = new();
|
||||
|
||||
return math.Add(A, B);
|
||||
}
|
||||
|
||||
public MathLib.Math GetMath()
|
||||
{
|
||||
return new();
|
||||
}
|
||||
}
|
||||
|
@ -6,4 +6,8 @@
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Reference Include="../MathLib/bin/Release/net8.0/publish/MathLib.dll"></Reference>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
10
build.sh
10
build.sh
@ -23,6 +23,7 @@ help() {
|
||||
echo " -i Input project name (required)"
|
||||
echo " -g Generated project name (default: <input-project-name>.Generated)"
|
||||
echo " -o Output folder name (default: libs)"
|
||||
echo " -y Assume yes to all prompts"
|
||||
echo " --ndk Android NDK path (default: ANDROID_NDK_HOME environment variable)"
|
||||
echo " --no-android Disable Android build (default: false)"
|
||||
echo " --no-ios Disable iOS build (default: false)"
|
||||
@ -56,6 +57,9 @@ replace_project_names() {
|
||||
# Function to ask for confirmation before continuing
|
||||
# $1: message
|
||||
ask_confirmation() {
|
||||
if [ "$assume_yes" = true ]; then
|
||||
return
|
||||
fi
|
||||
read -p "$1 (y/n) " -n 1 -r
|
||||
echo
|
||||
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
|
||||
@ -100,7 +104,7 @@ build_android() {
|
||||
for arch in "${!abis[@]}"; do
|
||||
log "Building Android library for $arch"
|
||||
|
||||
run "dotnet publish -r linux-bionic-$arch -v normal -c Release -p:DisableUnsupportedError=true -p:PublishAotUsingRuntimePack=true -p:RemoveSections=true"
|
||||
run "dotnet publish -r linux-bionic-$arch -v normal -c Release -p:DisableUnsupportedError=true -p:PublishAotUsingRuntimePack=true -p:RemoveSections=true -p:AllowUnsafeBlocks=true $generated_project_name.csproj"
|
||||
|
||||
# Copy the generated library to the output directory
|
||||
mkdir -p $output_dir/${abis[$arch]}
|
||||
@ -166,6 +170,10 @@ while [ "$1" != "" ]; do
|
||||
shift
|
||||
output=$1
|
||||
;;
|
||||
-y)
|
||||
shift
|
||||
assume_yes=true
|
||||
;;
|
||||
--ndk)
|
||||
shift
|
||||
export ANDROID_NDK_HOME=$1
|
||||
|
@ -3,144 +3,32 @@
|
||||
"CSharpUnmanagedOutputPath": "GENERATED_PROJECT_NAME/Generated.cs",
|
||||
"COutputPath": "GENERATED_PROJECT_NAME/Generated.h",
|
||||
"ExcludedTypeNames": [
|
||||
"System.ICloneable",
|
||||
"System.Collections.IEnumerable",
|
||||
"System.Collections.ICollection",
|
||||
"System.Collections.IList",
|
||||
"System.Collections.IEnumerator",
|
||||
"System.Reflection.MemberInfo",
|
||||
"System.Array",
|
||||
"System.Enum",
|
||||
"System.Boolean",
|
||||
"System.ValueType",
|
||||
"System.Int32",
|
||||
"System.IComparable",
|
||||
"System.GC",
|
||||
"System.Math",
|
||||
"System.Convert",
|
||||
"System.Version",
|
||||
"System.Guid",
|
||||
"System.DateTime",
|
||||
"System.Threading.Thread",
|
||||
"System.Threading.Timer",
|
||||
"System.Threading.CancellationTokenSource",
|
||||
"System.Threading.CancellationToken",
|
||||
"System.Threading.Tasks.TaskFactory",
|
||||
"System.Threading.Tasks.Task",
|
||||
"System.AppDomain",
|
||||
"System.Random",
|
||||
"System.Text.Encoding",
|
||||
"System.Text.StringBuilder",
|
||||
"System.IO.Path",
|
||||
"System.IO.File",
|
||||
"System.IO.FileInfo",
|
||||
"System.IO.Directory",
|
||||
"System.IO.DirectoryInfo",
|
||||
"System.Security.SecureString",
|
||||
"System.Reflection.MemberInfo",
|
||||
"System.WeakReference",
|
||||
"System.WeakReference`1",
|
||||
"System.Runtime.CompilerServices.ConditionalWeakTable`2",
|
||||
"System.Threading.Tasks.Task`1",
|
||||
"System.Collections.Generic.IEnumerable`1",
|
||||
"System.Collections.Generic.List`1",
|
||||
"System.Collections.Generic.IList`1",
|
||||
"System.Collections.Generic.Dictionary`2",
|
||||
"System.Collections.Generic.IDictionary`2",
|
||||
"System.Collections.ObjectModel.ReadOnlyCollection`1",
|
||||
"System.Collections.Generic.IReadOnlyDictionary`2",
|
||||
"System.Collections.Generic.IAsyncEnumerable`1",
|
||||
"System.Tuple`1",
|
||||
"System.Tuple`2",
|
||||
"System.Tuple`3",
|
||||
"System.Tuple`4",
|
||||
"System.Tuple`5",
|
||||
"System.Tuple`6",
|
||||
"System.Tuple`7",
|
||||
"System.Tuple`8",
|
||||
"System.Reflection.MemberInfo",
|
||||
"System.Reflection.ICustomAttributeProvider",
|
||||
"System.Array",
|
||||
"System.ICloneable",
|
||||
"System.Collections.IList",
|
||||
"System.Collections.ICollection",
|
||||
"System.Collections.IEnumerable",
|
||||
"System.Collections.IEnumerator",
|
||||
"System.Boolean",
|
||||
"System.ValueType",
|
||||
"System.Int32",
|
||||
"System.IComparable",
|
||||
"System.IConvertible",
|
||||
"System.TypeCode",
|
||||
"System.Enum",
|
||||
"System.ISpanFormattable",
|
||||
"System.IFormattable",
|
||||
"System.String",
|
||||
"System.StringComparison",
|
||||
"System.Globalization.CultureInfo",
|
||||
"System.IFormatProvider",
|
||||
"System.Collections.IStructuralComparable",
|
||||
"System.Collections.IComparer",
|
||||
"System.Collections.IStructuralEquatable",
|
||||
"System.Collections.IEqualityComparer",
|
||||
"System.Globalization.CultureTypes",
|
||||
"System.Globalization.CompareInfo",
|
||||
"System.Runtime.Serialization.IDeserializationCallback",
|
||||
"System.Reflection.Assembly",
|
||||
"System.Runtime.Serialization.ISerializable",
|
||||
"System.Runtime.Serialization.SerializationInfo",
|
||||
"System.Runtime.Serialization.SerializationInfoEnumerator",
|
||||
"System.Runtime.Serialization.SerializationEntry",
|
||||
"System.Char",
|
||||
"System.IUtf8SpanFormattable",
|
||||
"System.Globalization.UnicodeCategory",
|
||||
"System.Double",
|
||||
"System.Globalization.NumberStyles",
|
||||
"System.MidpointRounding",
|
||||
"System.SByte",
|
||||
"System.Byte",
|
||||
"System.Int16",
|
||||
"System.UInt16",
|
||||
"System.UInt32",
|
||||
"System.Int64",
|
||||
"System.UInt64",
|
||||
"System.Single",
|
||||
"System.Decimal",
|
||||
"System.DateTime",
|
||||
"System.TimeSpan",
|
||||
"System.Globalization.TimeSpanStyles",
|
||||
"System.DateTimeKind",
|
||||
"System.DayOfWeek",
|
||||
"System.Globalization.DateTimeStyles",
|
||||
"System.DateOnly",
|
||||
"System.TimeOnly",
|
||||
"System.Globalization.Calendar",
|
||||
"System.Globalization.CalendarAlgorithmType",
|
||||
"System.Globalization.CalendarWeekRule",
|
||||
"System.Runtime.Serialization.IFormatterConverter",
|
||||
"System.Runtime.Serialization.StreamingContext",
|
||||
"System.Runtime.Serialization.StreamingContextStates",
|
||||
"System.Reflection.AssemblyName",
|
||||
"System.Version",
|
||||
"System.Reflection.ProcessorArchitecture",
|
||||
"System.Reflection.AssemblyContentType",
|
||||
"System.Reflection.AssemblyNameFlags",
|
||||
"System.Configuration.Assemblies.AssemblyHashAlgorithm",
|
||||
"System.Configuration.Assemblies.AssemblyVersionCompatibility",
|
||||
"System.Reflection.StrongNameKeyPair",
|
||||
"System.IO.FileStream",
|
||||
"System.IO.Stream",
|
||||
"System.MarshalByRefObject",
|
||||
"System.IDisposable",
|
||||
"System.IAsyncDisposable",
|
||||
"System.Threading.Tasks.ValueTask",
|
||||
"System.Threading.CancellationToken",
|
||||
"System.Threading.WaitHandle",
|
||||
"System.IntPtr",
|
||||
"Microsoft.Win32.SafeHandles.SafeWaitHandle",
|
||||
"Microsoft.Win32.SafeHandles.SafeHandleZeroOrMinusOneIsInvalid",
|
||||
"System.Runtime.InteropServices.SafeHandle",
|
||||
"System.Runtime.ConstrainedExecution.CriticalFinalizerObject",
|
||||
"System.Threading.CancellationTokenRegistration",
|
||||
"System.Action",
|
||||
"System.MulticastDelegate",
|
||||
"System.Delegate",
|
||||
@ -165,80 +53,29 @@
|
||||
"System.Reflection.PropertyInfo",
|
||||
"System.Reflection.PropertyAttributes",
|
||||
"System.Reflection.MethodInfo",
|
||||
"System.Collections.IDictionary",
|
||||
"System.Collections.IDictionaryEnumerator",
|
||||
"System.Collections.DictionaryEntry",
|
||||
"System.Threading.Tasks.Task",
|
||||
"System.IAsyncResult",
|
||||
"System.Threading.Tasks.TaskScheduler",
|
||||
"System.AggregateException",
|
||||
"System.Threading.Tasks.TaskStatus",
|
||||
"System.Threading.Tasks.TaskCreationOptions",
|
||||
"System.Threading.Tasks.TaskFactory",
|
||||
"System.Threading.Tasks.TaskContinuationOptions",
|
||||
"System.Runtime.CompilerServices.TaskAwaiter",
|
||||
"System.Runtime.CompilerServices.ICriticalNotifyCompletion",
|
||||
"System.Runtime.CompilerServices.INotifyCompletion",
|
||||
"System.Runtime.CompilerServices.ConfiguredTaskAwaitable",
|
||||
"System.Threading.Tasks.ConfigureAwaitOptions",
|
||||
"System.Runtime.CompilerServices.YieldAwaitable",
|
||||
"System.TimeProvider",
|
||||
"System.DateTimeOffset",
|
||||
"System.TimeZoneInfo",
|
||||
"System.Threading.ITimer",
|
||||
"System.Threading.TimerCallback",
|
||||
"System.Runtime.CompilerServices.ValueTaskAwaiter",
|
||||
"System.Runtime.CompilerServices.ConfiguredValueTaskAwaitable",
|
||||
"System.Threading.Tasks.Sources.IValueTaskSource",
|
||||
"System.Threading.Tasks.Sources.ValueTaskSourceStatus",
|
||||
"System.Threading.Tasks.Sources.ValueTaskSourceOnCompletedFlags",
|
||||
"System.AsyncCallback",
|
||||
"System.IO.SeekOrigin",
|
||||
"Microsoft.Win32.SafeHandles.SafeFileHandle",
|
||||
"System.IO.FileAccess",
|
||||
"System.IO.FileMode",
|
||||
"System.IO.FileShare",
|
||||
"System.IO.FileOptions",
|
||||
"System.IO.FileStreamOptions",
|
||||
"System.Reflection.ManifestResourceInfo",
|
||||
"System.Reflection.ResourceLocation",
|
||||
"System.Reflection.ModuleResolveEventHandler",
|
||||
"System.Reflection.Module",
|
||||
"System.Guid",
|
||||
"System.Reflection.PortableExecutableKinds",
|
||||
"System.Reflection.ImageFileMachine",
|
||||
"System.Reflection.TypeFilter",
|
||||
"System.ResolveEventArgs",
|
||||
"System.EventArgs",
|
||||
"System.Security.SecurityRuleSet",
|
||||
"System.Text.Rune",
|
||||
"System.Buffers.OperationStatus",
|
||||
"System.Globalization.CompareOptions",
|
||||
"System.Globalization.SortKey",
|
||||
"System.Globalization.SortVersion",
|
||||
"System.Globalization.TextInfo",
|
||||
"System.Globalization.NumberFormatInfo",
|
||||
"System.Globalization.DigitShapes",
|
||||
"System.Globalization.DateTimeFormatInfo",
|
||||
"System.CharEnumerator",
|
||||
"System.Text.StringRuneEnumerator",
|
||||
"System.Text.NormalizationForm",
|
||||
"System.Text.CompositeFormat",
|
||||
"System.StringSplitOptions",
|
||||
"System.Text.Encoding",
|
||||
"System.Text.EncodingProvider",
|
||||
"System.Text.EncoderFallback",
|
||||
"System.Text.EncoderFallbackBuffer",
|
||||
"System.Text.DecoderFallback",
|
||||
"System.Text.DecoderFallbackBuffer",
|
||||
"System.Text.EncodingInfo",
|
||||
"System.Text.Decoder",
|
||||
"System.Text.Encoder",
|
||||
"System.Reflection.IReflect",
|
||||
"System.Reflection.GenericParameterAttributes",
|
||||
"System.Reflection.TypeAttributes",
|
||||
"System.Runtime.InteropServices.StructLayoutAttribute",
|
||||
"System.Attribute",
|
||||
"System.Runtime.InteropServices.LayoutKind",
|
||||
"System.Runtime.InteropServices.CharSet",
|
||||
"System.Reflection.ConstructorInfo",
|
||||
@ -247,12 +84,9 @@
|
||||
"System.Reflection.InterfaceMapping",
|
||||
"System.Reflection.MemberFilter",
|
||||
"System.Runtime.InteropServices.Marshal",
|
||||
"System.Security.SecureString",
|
||||
"System.Runtime.InteropServices.CustomQueryInterfaceMode",
|
||||
"System.NullReferenceException",
|
||||
"System.PlatformNotSupportedException",
|
||||
"System.NotSupportedException",
|
||||
"System.UIntPtr",
|
||||
"System.AppContext"
|
||||
"System.NotSupportedException"
|
||||
]
|
||||
}
|
||||
|
@ -2,6 +2,9 @@
|
||||
"AssemblyPath": "INPUT_PROJECT_NAME/bin/Release/NET_SPEC/INPUT_PROJECT_NAME.dll",
|
||||
"CSharpUnmanagedOutputPath": "GENERATED_PROJECT_NAME/Generated.cs",
|
||||
"COutputPath": "GENERATED_PROJECT_NAME/Generated.h",
|
||||
"AssemblySearchPaths": [
|
||||
"MathLib/bin/Release/net8.0/publish/MathLib.dll"
|
||||
],
|
||||
"Build": {
|
||||
"Target": "apple-universal"
|
||||
}
|
||||
|
@ -90,6 +90,7 @@
|
||||
<!-- Project References -->
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\INPUT_PROJECT_NAME\INPUT_PROJECT_NAME.csproj" />
|
||||
<Reference Include="../MathLib/bin/Release/net8.0/publish/MathLib.dll" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
Loading…
x
Reference in New Issue
Block a user