fix: exclude coreRT types and fix android x64 compilation

This commit is contained in:
Hugo Pointcheval 2023-11-06 20:35:31 +01:00
parent a745fd9838
commit bee735b029
Signed by: hugo
GPG Key ID: 3AAC487E131E00BC
4 changed files with 277 additions and 7 deletions

View File

@ -11,6 +11,11 @@
<TrimMode>Link</TrimMode>
<InvariantGlobalization>true</InvariantGlobalization>
<PublishAot>true</PublishAot>
<LangVersion>latest</LangVersion>
<PublishTrimmed>true</PublishTrimmed>
<DisableFastUpToDateCheck>true</DisableFastUpToDateCheck>
<EnablePreviewFeatures>true</EnablePreviewFeatures>
<Nullable>disable</Nullable>
</PropertyGroup>
<PropertyGroup>

12
MyLib.Managed/publish.sh Executable file
View File

@ -0,0 +1,12 @@
#!/usr/bin/env sh
set -e
OUTPUT_PRODUCT_NAME="MyLib.Managed"
DOTNET_PATH=`which dotnet`
VERBOSITY_LEVEL="normal"
echo "Building ${OUTPUT_PRODUCT_NAME}"
${DOTNET_PATH} publish -v "${VERBOSITY_LEVEL}" /p:Configuration=Release

View File

@ -2,8 +2,259 @@
"AssemblyPath": "MyLib.Managed/bin/Release/net8.0/MyLib.Managed.dll",
"CSharpUnmanagedOutputPath": "MyLib.Generated/Hello.cs",
"COutputPath": "MyLib.Generated/Hello.h",
"IncludedTypeNames": [
"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.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.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",
"System.Exception",
"System.Reflection.MethodBase",
"System.RuntimeMethodHandle",
"System.RuntimeTypeHandle",
"System.ModuleHandle",
"System.RuntimeFieldHandle",
"System.Reflection.ParameterInfo",
"System.Runtime.Serialization.IObjectReference",
"System.Reflection.ParameterAttributes",
"System.Reflection.MethodAttributes",
"System.Reflection.MethodImplAttributes",
"System.Reflection.MethodBody",
"System.Reflection.CallingConventions",
"System.Reflection.BindingFlags",
"System.Reflection.Binder",
"System.Reflection.FieldInfo",
"System.Reflection.MemberTypes",
"System.Reflection.FieldAttributes",
"System.Reflection.ParameterModifier",
"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",
"System.Reflection.EventInfo",
"System.Reflection.EventAttributes",
"System.Reflection.InterfaceMapping",
"System.Reflection.MemberFilter",
"System.Runtime.InteropServices.Marshal",
"System.Security.SecureString",
"System.Runtime.InteropServices.CustomQueryInterfaceMode",
"System.NullReferenceException",
"System.SystemException",
"System.PlatformNotSupportedException",
"System.NotSupportedException",
"System.UIntPtr",
"System.AppContext"
]
}

View File

@ -18,14 +18,14 @@ log_file="$script_dir/build.log"
rm -f $log_file
cd ./MyLib.Managed
dotnet publish >> $log_file 2>&1
./publish.sh 2>&1 | tee -a $log_file
cd ../
beyondnetgen beyondnetgen.config.json >> $log_file 2>&1
beyondnetgen beyondnetgen.config.json 2>&1 | tee -a $log_file
cd ./MyLib.Generated
./build-android-arm64.sh >> $log_file 2>&1
./build-android-arm64.sh 2>&1 | tee -a $log_file
# Create the directory if it doesn't exist
mkdir -p ../flutter_example/android/app/src/main/jniLibs/arm64-v8a
@ -34,7 +34,7 @@ mkdir -p ../flutter_example/android/app/src/main/jniLibs/arm64-v8a
cp ./bin/Release/net8.0/linux-bionic-arm64/native/MyLib.Generated.so \
../flutter_example/android/app/src/main/jniLibs/arm64-v8a/libMyLib.so
./build-android-x64.sh >> $log_file 2>&1
./build-android-x64.sh 2>&1 | tee -a $log_file
# Create the directory if it doesn't exist
mkdir -p ../flutter_example/android/app/src/main/jniLibs/x86_64
@ -46,4 +46,6 @@ cp ./bin/Release/net8.0/linux-bionic-x64/native/MyLib.Generated.so \
cp Hello.h ../flutter_example/Hello.h
cd ../flutter_example
dart run ffigen --config ffigen.yaml
dart run ffigen --config ffigen.yaml 2>&1 | tee -a $log_file
echo "Build completed. See $log_file for details."