From bee735b029b7bffc14fdca7c3e8215d56063e9e1 Mon Sep 17 00:00:00 2001 From: Hugo Pointcheval Date: Mon, 6 Nov 2023 20:35:31 +0100 Subject: [PATCH] fix: exclude coreRT types and fix android x64 compilation --- MyLib.Generated/MyLib.Generated.csproj | 5 + MyLib.Managed/publish.sh | 12 ++ beyondnetgen.config.json | 255 ++++++++++++++++++++++++- build.sh | 12 +- 4 files changed, 277 insertions(+), 7 deletions(-) create mode 100755 MyLib.Managed/publish.sh diff --git a/MyLib.Generated/MyLib.Generated.csproj b/MyLib.Generated/MyLib.Generated.csproj index 7b2bab1..0fd0033 100644 --- a/MyLib.Generated/MyLib.Generated.csproj +++ b/MyLib.Generated/MyLib.Generated.csproj @@ -11,6 +11,11 @@ Link true true + latest + true + true + true + disable diff --git a/MyLib.Managed/publish.sh b/MyLib.Managed/publish.sh new file mode 100755 index 0000000..3391e53 --- /dev/null +++ b/MyLib.Managed/publish.sh @@ -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 diff --git a/beyondnetgen.config.json b/beyondnetgen.config.json index 70e8549..62ad0f5 100644 --- a/beyondnetgen.config.json +++ b/beyondnetgen.config.json @@ -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" ] } diff --git a/build.sh b/build.sh index 0d012be..99fc607 100755 --- a/build.sh +++ b/build.sh @@ -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."