From 10d56da17c5ae40c0ca6534ad3ad64687ef86831 Mon Sep 17 00:00:00 2001 From: Morten Daniel Fornes Date: Sun, 28 Oct 2018 01:43:43 +0700 Subject: [PATCH 01/71] Native: don't show console window on Windows This will not open a console window when launching an app using explorer, but we'll still get console output when launching apps from the command-line. --- lib/UnoCore/Targets/Native/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/UnoCore/Targets/Native/CMakeLists.txt b/lib/UnoCore/Targets/Native/CMakeLists.txt index 7179aa790..197783531 100644 --- a/lib/UnoCore/Targets/Native/CMakeLists.txt +++ b/lib/UnoCore/Targets/Native/CMakeLists.txt @@ -31,7 +31,7 @@ endif() @(CMake.SourceGroups) -add_executable(@(Project.Name:QuoteSpace) +add_executable(@(Project.Name:QuoteSpace)@(WIN32:Defined:Test(' WIN32', '')) @(HeaderFile:Join('\n ', '"@(HeaderDirectory)/', '"')) @(SourceFile:Join('\n ', '"@(SourceDirectory)/', '"')) ${EXTRA_FILES}) From 75179637a03c84991d4d50a0baf3b0eca2fae221 Mon Sep 17 00:00:00 2001 From: Morten Daniel Fornes Date: Sat, 27 Oct 2018 23:30:27 +0700 Subject: [PATCH 02/71] Android: support both Landscape modes Currently, setting orientation to Landscape will lock the app in only one landscape mode and the app will not rotate according to the sensor. This is not the expected behaviour. This fixes so that setting orientation to Landscape will rotate the app according to the sensor. It is also possible to specify LandscapeLeft or LandscapeRight to force only one of the landscape modes. --- .../Targets/Android/app/src/main/AndroidManifest.xml | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/lib/UnoCore/Targets/Android/app/src/main/AndroidManifest.xml b/lib/UnoCore/Targets/Android/app/src/main/AndroidManifest.xml index d986f4400..282a2081e 100644 --- a/lib/UnoCore/Targets/Android/app/src/main/AndroidManifest.xml +++ b/lib/UnoCore/Targets/Android/app/src/main/AndroidManifest.xml @@ -27,10 +27,16 @@ android:taskAffinity="" android:windowSoftInputMode="adjustResize" android:configChanges="orientation|keyboardHidden|screenSize|smallestScreenSize" -#if @(Project.Mobile.Orientations:Equals('Portrait')) || @(Project.Mobile.Orientations:Equals('Landscape')) -android:screenOrientation="@(Project.Mobile.Orientations:Replace('Landscape', 'landscape'):Replace('Portrait', 'portrait'))" +#if @(Project.Mobile.Orientations:Equals('Portrait')) + android:screenOrientation="portrait" +#elif @(Project.Mobile.Orientations:Equals('LandscapeLeft')) + android:screenOrientation="landscape" +#elif @(Project.Mobile.Orientations:Equals('LandscapeRight')) + android:screenOrientation="reverseLandscape" +#elif @(Project.Mobile.Orientations:Equals('Landscape')) + android:screenOrientation="sensorLandscape" #else -android:screenOrientation="user" + android:screenOrientation="user" #endif android:windowActionBar="false"> From 85b203e4b5ea91e9efa3a68c5e2014857d1fb09a Mon Sep 17 00:00:00 2001 From: Morten Daniel Fornes Date: Mon, 14 Jan 2019 07:50:58 +0700 Subject: [PATCH 03/71] CIL: extract functionality from CilGenerator Now it's easier to reuse the functionality in a new backend based on .NET. --- .../CilGenerator.Compile.cs | 37 --- .../CilGenerator.Generate.cs | 23 +- .../CilGenerator.Populate.cs | 208 ------------ .../Uno.Compiler.Backends.CIL/CilGenerator.cs | 3 +- .../Uno.Compiler.Backends.CIL/CilLinker.cs | 8 +- .../Uno.Compiler.Backends.CIL/CilMember.cs | 2 +- .../Uno.Compiler.Backends.CIL/CilType.cs | 305 +++++++++++++++++- ...lGenerator.Create.cs => CilTypeFactory.cs} | 57 ++-- .../Uno.Compiler.Backends.CIL/Extensions.cs | 2 +- .../Uno.Compiler.Backends.CIL.csproj | 5 +- 10 files changed, 327 insertions(+), 323 deletions(-) delete mode 100644 src/compiler/Uno.Compiler.Backends.CIL/CilGenerator.Populate.cs rename src/compiler/Uno.Compiler.Backends.CIL/{CilGenerator.Create.cs => CilTypeFactory.cs} (68%) diff --git a/src/compiler/Uno.Compiler.Backends.CIL/CilGenerator.Compile.cs b/src/compiler/Uno.Compiler.Backends.CIL/CilGenerator.Compile.cs index ba7e6298d..69efc2c12 100644 --- a/src/compiler/Uno.Compiler.Backends.CIL/CilGenerator.Compile.cs +++ b/src/compiler/Uno.Compiler.Backends.CIL/CilGenerator.Compile.cs @@ -7,7 +7,6 @@ using Uno.Compiler.API.Domain.IL.Expressions; using Uno.Compiler.API.Domain.IL.Members; using Uno.Compiler.API.Domain.IL.Types; -using ParameterModifier = Uno.Compiler.API.Domain.ParameterModifier; using Type = IKVM.Reflection.Type; namespace Uno.Compiler.Backends.CIL @@ -16,21 +15,12 @@ partial class CilGenerator { void CompileType(CilType data) { - if (data.IsCompiled) - return; - - data.IsCompiled = true; - try { if (data.Definition.Attributes != null) foreach (var a in data.Definition.Attributes) data.Builder.SetCustomAttribute(CreateAttributeBuilder(a)); - if (data.Definition.IsStatic) - data.Builder.SetCustomAttribute( - new CustomAttributeBuilder(_linker.System_Runtime_CompilerServices_ExtensionAttribute_ctor, new object[0])); - foreach (var m in data.Fields) if (m.Definition.Attributes != null) foreach (var a in m.Definition.Attributes) @@ -47,39 +37,12 @@ void CompileType(CilType data) m.Builder.SetCustomAttribute(CreateAttributeBuilder(a)); foreach (var m in data.Constructors) - { - if (m.Definition.Attributes != null) - foreach (var a in m.Definition.Attributes) - m.Builder.SetCustomAttribute(CreateAttributeBuilder(a)); - - for (int i = 0; i < m.Definition.Parameters.Length; i++) - { - var p = m.Definition.Parameters[i]; - PopulateParameter(p, m.Builder.DefineParameter(i + 1, p.CilParameterAttributes(), p.Name)); - } - EmitFunction(m.Builder.GetILGenerator(), m.Definition); - } foreach (var m in data.Methods) { - if (m.Definition.Attributes != null) - foreach (var a in m.Definition.Attributes) - m.Builder.SetCustomAttribute(CreateAttributeBuilder(a)); - if (_backend.IsPInvokable(_essentials, m.Definition)) - { continue; - } - - for (int i = 0; i < m.Definition.Parameters.Length; i++) - { - var p = m.Definition.Parameters[i]; - PopulateParameter(p, m.Builder.DefineParameter(i + 1, p.CilParameterAttributes(), p.Name)); - } - - if (m.Definition.Parameters.Length > 0 && m.Definition.Parameters[0].Modifier == ParameterModifier.This) - m.Builder.SetCustomAttribute(new CustomAttributeBuilder(_linker.System_Runtime_CompilerServices_ExtensionAttribute_ctor, new object[0])); var method = m.Definition as Method; if (method?.ImplementedMethod != null) diff --git a/src/compiler/Uno.Compiler.Backends.CIL/CilGenerator.Generate.cs b/src/compiler/Uno.Compiler.Backends.CIL/CilGenerator.Generate.cs index 155f797cd..ab7937e20 100644 --- a/src/compiler/Uno.Compiler.Backends.CIL/CilGenerator.Generate.cs +++ b/src/compiler/Uno.Compiler.Backends.CIL/CilGenerator.Generate.cs @@ -14,30 +14,13 @@ public void Generate() Process(_data.IL); foreach (var e in _types) - { - foreach (var g in e.GenericParameters) - SetConstraints(g.Builder, g.Definition); - - switch (e.Definition.TypeType) - { - case TypeType.Enum: - PopulateEnum(e); - break; - case TypeType.Delegate: - PopulateDelegate(e); - break; - default: - PopulateClassStructOrInterface(e); - break; - } - } - + e.Populate(); foreach (var e in _types) CompileType(e); foreach (var e in _linkedTypes) ValidateType(e); - Log.Verbose("Generated " + _types.Count + " .NET type".Plural(_types) + " for " + Assembly.GetName().Name.Quote() + " assembly"); + Log.Verbose("Generated " + _types.Count + " .NET type".Plural(_types) + " for " + _assembly.GetName().Name.Quote() + " assembly"); } void Process(Namespace root) @@ -60,7 +43,7 @@ void Process(Namespace root) else if (prebuiltType != null) LinkType(dt, prebuiltType); else - DefineType(dt); + _types.DefineType(dt); } for (int i = 0, l = root.Namespaces.Count; i < l; i++) diff --git a/src/compiler/Uno.Compiler.Backends.CIL/CilGenerator.Populate.cs b/src/compiler/Uno.Compiler.Backends.CIL/CilGenerator.Populate.cs deleted file mode 100644 index 62c9a14a8..000000000 --- a/src/compiler/Uno.Compiler.Backends.CIL/CilGenerator.Populate.cs +++ /dev/null @@ -1,208 +0,0 @@ -using IKVM.Reflection; -using IKVM.Reflection.Emit; -using Uno.Compiler.API.Domain.IL; -using Uno.Compiler.API.Domain.IL.Expressions; -using Uno.Compiler.API.Domain.IL.Members; -using Uno.Compiler.API.Domain.IL.Types; -using Uno.Compiler.Backends.PInvoke; -using ParameterModifier = Uno.Compiler.API.Domain.ParameterModifier; - -namespace Uno.Compiler.Backends.CIL -{ - partial class CilGenerator - { - void PopulateClassStructOrInterface(CilType data) - { - if (data.Definition is ClassType && data.Definition.Base != null) - data.Builder.SetParent(_linker.GetType(data.Definition.Base)); - - foreach (var it in data.Definition.Interfaces) - data.Builder.AddInterfaceImplementation(_linker.GetType(it)); - - foreach (var m in data.Definition.Fields) - _linker.AddField(m, data.DefineField(m, _linker.GetType(m.ReturnType))); - - foreach (var m in data.Definition.Events) - { - var eb = data.DefineEvent(m, _linker.GetType(m.ReturnType)); - - if (m.ImplicitField != null) - _linker.AddField(m.ImplicitField, - data.DefineField(m.ImplicitField, _linker.GetType(m.ImplicitField.ReturnType))); - - if (m.AddMethod != null) - { - var mb = data.DefineMethod(m.AddMethod, MethodAttributes.SpecialName, _linker.GetType(m.AddMethod.ReturnType), _linker.GetParameterTypes(m.AddMethod.Parameters)); - _linker.AddMethod(m.AddMethod, mb); - eb.SetAddOnMethod(mb); - } - - if (m.RemoveMethod != null) - { - var mb = data.DefineMethod(m.RemoveMethod, MethodAttributes.SpecialName, _linker.GetType(m.RemoveMethod.ReturnType), _linker.GetParameterTypes(m.RemoveMethod.Parameters)); - _linker.AddMethod(m.RemoveMethod, mb); - eb.SetRemoveOnMethod(mb); - } - } - - foreach (var m in data.Definition.Properties) - { - var pb = data.DefineProperty(m, m.Parameters.Length > 0 ? PropertyAttributes.SpecialName : 0, _linker.GetType(m.ReturnType), _linker.GetParameterTypes(m.Parameters)); - - if (m.ImplicitField != null) - _linker.AddField(m.ImplicitField, - data.DefineField(m.ImplicitField, _linker.GetType(m.ImplicitField.ReturnType))); - - if (m.GetMethod != null) - { - var mb = data.DefineMethod(m.GetMethod, MethodAttributes.SpecialName, _linker.GetType(m.GetMethod.ReturnType), _linker.GetParameterTypes(m.GetMethod.Parameters)); - _linker.AddMethod(m.GetMethod, mb); - pb.SetGetMethod(mb); - } - - if (m.SetMethod != null) - { - var mb = data.DefineMethod(m.SetMethod, MethodAttributes.SpecialName, _linker.GetType(m.SetMethod.ReturnType), _linker.GetParameterTypes(m.SetMethod.Parameters)); - _linker.AddMethod(m.SetMethod, mb); - pb.SetSetMethod(mb); - } - } - - foreach (var m in data.Definition.Methods) - { - if (_backend.IsPInvokable(_essentials, m)) - { - var mb = PInvokeBackend.CreateCilPInvokeMethod( - _linker.Universe, - _essentials, - data.Builder, - m, - m.CilMethodAttributes(), - _linker.GetType(m.ReturnType), - _linker.GetParameterTypes(m.Parameters)); - m.SetBody(null); - data.Methods.Add(new CilMember(mb, m)); - _linker.AddMethod(m, mb); - } - else - { - var mb = data.DefineMethod(m); - - if (m.IsGenericDefinition) - { - var paramNames = new string[m.GenericParameters.Length]; - for (int i = 0; i < paramNames.Length; i++) - paramNames[i] = m.GenericParameters[i].UnoName; - - var paramTypes = mb.DefineGenericParameters(paramNames); - for (int i = 0; i < paramTypes.Length; i++) - _linker.AddType(m.GenericParameters[i], paramTypes[i]); - for (int i = 0; i < paramTypes.Length; i++) - SetConstraints(paramTypes[i], m.GenericParameters[i]); - } - - mb.SetReturnType(_linker.GetType(m.ReturnType)); - mb.SetParameters(_linker.GetParameterTypes(m.Parameters)); - _linker.AddMethod(m, mb); - - if (m.Prototype != null && m.Prototype != m && - m.Prototype.HasAttribute(_essentials.DotNetOverrideAttribute)) - _linker.AddMethod(m.Prototype, mb); - } - } - - foreach (var m in data.Definition.Constructors) - { - var cb = data.DefineConstructor(m, _linker.GetParameterTypes(m.Parameters)); - _linker.AddConstructor(m, cb); - } - - foreach (var m in data.Definition.Casts) - { - var mb = data.DefineMethod(m, MethodAttributes.SpecialName, _linker.GetType(m.ReturnType), _linker.GetParameterTypes(m.Parameters)); - _linker.AddMethod(m, mb); - } - - foreach (var m in data.Definition.Operators) - { - var mb = data.DefineMethod(m, MethodAttributes.SpecialName, _linker.GetType(m.ReturnType), _linker.GetParameterTypes(m.Parameters)); - _linker.AddMethod(m, mb); - } - - if (data.Definition.Initializer != null) - data.DefineTypeInitializer(data.Definition.Initializer); - - if (data.Definition.Finalizer != null) - data.DefineTypeFinalizer(data.Definition.Finalizer); - - // Add dummy field if [TargetSpecificType] - if (data.Definition.HasAttribute(_essentials.TargetSpecificTypeAttribute)) - data.Builder.DefineField("__ptr", _linker.System_IntPtr, FieldAttributes.Private); - } - - void PopulateDelegate(CilType data) - { - var dt = (DelegateType)data.Definition; - var cb = data.Builder.DefineConstructor( - MethodAttributes.RTSpecialName | MethodAttributes.HideBySig | MethodAttributes.Public, - CallingConventions.Standard, new[] {_linker.System_Object, _linker.System_IntPtr}); - - cb.SetImplementationFlags(MethodImplAttributes.Runtime | MethodImplAttributes.Managed); - - var mb = data.Builder.DefineMethod("Invoke", - MethodAttributes.Public | MethodAttributes.HideBySig | MethodAttributes.NewSlot | MethodAttributes.Virtual, - _linker.GetType(dt.ReturnType), _linker.GetParameterTypes(dt.Parameters)); - - mb.SetImplementationFlags(MethodImplAttributes.Runtime | MethodImplAttributes.Managed); - - if (_backend.IsPInvokable(_essentials, dt)) - { - for (int i = 0; i < dt.Parameters.Length; i++) - { - var p = dt.Parameters[i]; - var pb = PInvokeBackend.DefineCilDelegateParameter(_linker.Universe, _essentials, mb, p, i); - PopulateParameter(p, pb); - } - } - else - { - for (int i = 0; i < dt.Parameters.Length; i++) - { - var p = dt.Parameters[i]; - PopulateParameter(p, mb.DefineParameter(i + 1, p.CilParameterAttributes(), p.Name)); - } - } - - _linker.AddConstructor(data.Definition, cb); - _linker.AddMethod(data.Definition, mb); - } - - void PopulateEnum(CilType data) - { - data.Builder.DefineField("value__", _linker.GetType(data.Definition.Base), FieldAttributes.Public | FieldAttributes.SpecialName | FieldAttributes.RTSpecialName); - - for (int i = 0, l = data.Definition.Literals.Count; i < l; i++) - { - var v = data.Definition.Literals[i]; - var f = data.Builder.DefineField(v.UnoName, data.Builder, FieldAttributes.Public | FieldAttributes.Static | FieldAttributes.Literal); - f.SetConstant(v.Value); - } - } - - void PopulateParameter(Parameter p, ParameterBuilder pb) - { - try - { - if (p.OptionalDefault is Constant) - pb.SetConstant(p.OptionalDefault.ConstantValue); - } - catch - { - // TODO - } - - if (p.Modifier == ParameterModifier.Params) - pb.SetCustomAttribute(new CustomAttributeBuilder(_linker.System_ParamAttribute_ctor, new object[0])); - } - } -} diff --git a/src/compiler/Uno.Compiler.Backends.CIL/CilGenerator.cs b/src/compiler/Uno.Compiler.Backends.CIL/CilGenerator.cs index 844111d20..3cedf78c3 100644 --- a/src/compiler/Uno.Compiler.Backends.CIL/CilGenerator.cs +++ b/src/compiler/Uno.Compiler.Backends.CIL/CilGenerator.cs @@ -23,7 +23,7 @@ partial class CilGenerator : DiskObject readonly CilBackend _backend; readonly ModuleBuilder _module; readonly AssemblyBuilder _assembly; - readonly List _types = new List(); + readonly CilTypeFactory _types; readonly List _linkedTypes = new List(); readonly Dictionary _documents = new Dictionary(); readonly string _outputDir; @@ -50,6 +50,7 @@ public CilGenerator(Disk disk, IBuildData data, IEssentials essentials, package.Name, package.Name + ".dll", true); + _types = new CilTypeFactory(backend, essentials, linker, _module); } public void Configure(bool debug) diff --git a/src/compiler/Uno.Compiler.Backends.CIL/CilLinker.cs b/src/compiler/Uno.Compiler.Backends.CIL/CilLinker.cs index 920ea2fff..e214ceeb6 100644 --- a/src/compiler/Uno.Compiler.Backends.CIL/CilLinker.cs +++ b/src/compiler/Uno.Compiler.Backends.CIL/CilLinker.cs @@ -13,7 +13,7 @@ namespace Uno.Compiler.Backends.CIL { - class CilLinker : LogObject + public class CilLinker : LogObject { const BindingFlags _ctorFlags = BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance; const BindingFlags _memberFlags = _ctorFlags | BindingFlags.Static; @@ -30,6 +30,7 @@ class CilLinker : LogObject readonly Dictionary _typeConstructors = new Dictionary(); readonly Dictionary _typeMethods = new Dictionary(); readonly Dictionary _types = new Dictionary(); + readonly bool _isReferenceAssembly; public IEnumerable CopyAssemblies => _copyAssemblies; public IReadOnlyDictionary TypeMap => _types; @@ -50,10 +51,11 @@ class CilLinker : LogObject public readonly MethodInfo System_Activator_CreateInstance; public readonly MethodInfo System_Type_GetTypeFromHandle; - public CilLinker(Log log, IEssentials essentials) + public CilLinker(Log log, IEssentials essentials, bool isReferenceAssembly = false) : base(log) { _essentials = essentials; + _isReferenceAssembly = isReferenceAssembly; System_Object = Universe.Import(typeof(object)); System_String = Universe.Import(typeof(string)); System_ValueType = Universe.Import(typeof(ValueType)); @@ -232,7 +234,7 @@ public Type GetType(DataType dt) { var asm = dt.Package.Tag as Assembly; - if (dt.HasAttribute(_essentials.DotNetTypeAttribute)) + if (dt.HasAttribute(_essentials.DotNetTypeAttribute) && !_isReferenceAssembly) result = TryGetType(dt.TryGetAttributeString(_essentials.DotNetTypeAttribute) ?? dt.CilTypeName()); else if (asm != null) result = asm.GetType(dt.CilTypeName()); diff --git a/src/compiler/Uno.Compiler.Backends.CIL/CilMember.cs b/src/compiler/Uno.Compiler.Backends.CIL/CilMember.cs index 5246f52ff..c432a5927 100644 --- a/src/compiler/Uno.Compiler.Backends.CIL/CilMember.cs +++ b/src/compiler/Uno.Compiler.Backends.CIL/CilMember.cs @@ -1,6 +1,6 @@ namespace Uno.Compiler.Backends.CIL { - struct CilMember + public struct CilMember { public readonly TBuilder Builder; public readonly TDefinition Definition; diff --git a/src/compiler/Uno.Compiler.Backends.CIL/CilType.cs b/src/compiler/Uno.Compiler.Backends.CIL/CilType.cs index 197423405..6e0908b59 100644 --- a/src/compiler/Uno.Compiler.Backends.CIL/CilType.cs +++ b/src/compiler/Uno.Compiler.Backends.CIL/CilType.cs @@ -2,15 +2,23 @@ using System.Collections.Generic; using IKVM.Reflection; using IKVM.Reflection.Emit; +using Uno.Compiler.API; +using Uno.Compiler.API.Backends; using Uno.Compiler.API.Domain.IL; +using Uno.Compiler.API.Domain.IL.Expressions; using Uno.Compiler.API.Domain.IL.Members; using Uno.Compiler.API.Domain.IL.Types; +using Uno.Compiler.Backends.PInvoke; +using Uno.Logging; +using ParameterModifier = Uno.Compiler.API.Domain.ParameterModifier; using Type = IKVM.Reflection.Type; namespace Uno.Compiler.Backends.CIL { - class CilType + public class CilType : LogObject { + readonly Backend _backend; + readonly IEssentials _essentials; readonly CilLinker _linker; public readonly TypeBuilder Builder; public readonly DataType Definition; @@ -20,37 +28,312 @@ class CilType public readonly List> Events = new List>(); public readonly List> Methods = new List>(); public readonly List> Constructors = new List>(); - public bool IsCompiled; - public CilType(CilLinker linker, TypeBuilder builder, DataType definition) + internal CilType(Backend backend, IEssentials essentials, CilLinker linker, TypeBuilder builder, DataType definition) + : base(backend.Log) { + _backend = backend; + _essentials = essentials; _linker = linker; Builder = builder; Definition = definition; } - public FieldBuilder DefineField(Field m, Type type) + public void Populate() + { + foreach (var g in GenericParameters) + SetConstraints(g.Builder, g.Definition); + + switch (Definition.TypeType) + { + case TypeType.Enum: + PopulateEnum(); + break; + case TypeType.Delegate: + PopulateDelegate(); + break; + default: + PopulateClassStructOrInterface(); + break; + } + } + + void PopulateClassStructOrInterface() + { + if (Definition is ClassType && Definition.Base != null) + Builder.SetParent(_linker.GetType(Definition.Base)); + + foreach (var it in Definition.Interfaces) + Builder.AddInterfaceImplementation(_linker.GetType(it)); + + foreach (var m in Definition.Fields) + _linker.AddField(m, DefineField(m, _linker.GetType(m.ReturnType))); + + foreach (var m in Definition.Events) + { + var eb = DefineEvent(m, _linker.GetType(m.ReturnType)); + + if (m.ImplicitField != null) + _linker.AddField(m.ImplicitField, + DefineField(m.ImplicitField, _linker.GetType(m.ImplicitField.ReturnType))); + + if (m.AddMethod != null) + { + var mb = DefineMethod(m.AddMethod, MethodAttributes.SpecialName, _linker.GetType(m.AddMethod.ReturnType), _linker.GetParameterTypes(m.AddMethod.Parameters)); + _linker.AddMethod(m.AddMethod, mb); + eb.SetAddOnMethod(mb); + } + + if (m.RemoveMethod != null) + { + var mb = DefineMethod(m.RemoveMethod, MethodAttributes.SpecialName, _linker.GetType(m.RemoveMethod.ReturnType), _linker.GetParameterTypes(m.RemoveMethod.Parameters)); + _linker.AddMethod(m.RemoveMethod, mb); + eb.SetRemoveOnMethod(mb); + } + } + + foreach (var m in Definition.Properties) + { + var pb = DefineProperty(m, m.Parameters.Length > 0 ? PropertyAttributes.SpecialName : 0, _linker.GetType(m.ReturnType), _linker.GetParameterTypes(m.Parameters)); + + if (m.ImplicitField != null) + _linker.AddField(m.ImplicitField, + DefineField(m.ImplicitField, _linker.GetType(m.ImplicitField.ReturnType))); + + if (m.GetMethod != null) + { + var mb = DefineMethod(m.GetMethod, MethodAttributes.SpecialName, _linker.GetType(m.GetMethod.ReturnType), _linker.GetParameterTypes(m.GetMethod.Parameters)); + _linker.AddMethod(m.GetMethod, mb); + pb.SetGetMethod(mb); + } + + if (m.SetMethod != null) + { + var mb = DefineMethod(m.SetMethod, MethodAttributes.SpecialName, _linker.GetType(m.SetMethod.ReturnType), _linker.GetParameterTypes(m.SetMethod.Parameters)); + _linker.AddMethod(m.SetMethod, mb); + pb.SetSetMethod(mb); + } + } + + foreach (var m in Definition.Methods) + { + if (_backend.IsPInvokable(_essentials, m)) + { + var mb = PInvokeBackend.CreateCilPInvokeMethod( + _linker.Universe, + _essentials, + Builder, + m, + m.CilMethodAttributes(), + _linker.GetType(m.ReturnType), + _linker.GetParameterTypes(m.Parameters)); + m.SetBody(null); + Methods.Add(new CilMember(mb, m)); + _linker.AddMethod(m, mb); + } + else + { + var mb = DefineMethod(m); + + if (m.IsGenericDefinition) + { + var paramNames = new string[m.GenericParameters.Length]; + for (int i = 0; i < paramNames.Length; i++) + paramNames[i] = m.GenericParameters[i].UnoName; + + var paramTypes = mb.DefineGenericParameters(paramNames); + for (int i = 0; i < paramTypes.Length; i++) + _linker.AddType(m.GenericParameters[i], paramTypes[i]); + for (int i = 0; i < paramTypes.Length; i++) + SetConstraints(paramTypes[i], m.GenericParameters[i]); + } + + mb.SetReturnType(_linker.GetType(m.ReturnType)); + mb.SetParameters(_linker.GetParameterTypes(m.Parameters)); + _linker.AddMethod(m, mb); + + if (m.Prototype != null && m.Prototype != m && + m.Prototype.HasAttribute(_essentials.DotNetOverrideAttribute)) + _linker.AddMethod(m.Prototype, mb); + } + } + + foreach (var m in Definition.Constructors) + { + var cb = DefineConstructor(m, _linker.GetParameterTypes(m.Parameters)); + _linker.AddConstructor(m, cb); + } + + foreach (var m in Definition.Casts) + { + var mb = DefineMethod(m, MethodAttributes.SpecialName, _linker.GetType(m.ReturnType), _linker.GetParameterTypes(m.Parameters)); + _linker.AddMethod(m, mb); + } + + foreach (var m in Definition.Operators) + { + var mb = DefineMethod(m, MethodAttributes.SpecialName, _linker.GetType(m.ReturnType), _linker.GetParameterTypes(m.Parameters)); + _linker.AddMethod(m, mb); + } + + if (Definition.Initializer != null) + DefineTypeInitializer(Definition.Initializer); + + if (Definition.Finalizer != null) + DefineTypeFinalizer(Definition.Finalizer); + + // Add dummy field if [TargetSpecificType] + if (Definition.HasAttribute(_essentials.TargetSpecificTypeAttribute)) + Builder.DefineField("__ptr", _linker.System_IntPtr, FieldAttributes.Private); + + if (Definition.IsStatic) + Builder.SetCustomAttribute( + new CustomAttributeBuilder(_linker.System_Runtime_CompilerServices_ExtensionAttribute_ctor, new object[0])); + + foreach (var m in Constructors) + { + for (int i = 0; i < m.Definition.Parameters.Length; i++) + { + var p = m.Definition.Parameters[i]; + PopulateParameter(p, m.Builder.DefineParameter(i + 1, p.CilParameterAttributes(), p.Name)); + } + } + + foreach (var m in Methods) + { + for (int i = 0; i < m.Definition.Parameters.Length; i++) + { + var p = m.Definition.Parameters[i]; + PopulateParameter(p, m.Builder.DefineParameter(i + 1, p.CilParameterAttributes(), p.Name)); + } + + if (m.Definition.Parameters.Length > 0 && m.Definition.Parameters[0].Modifier == ParameterModifier.This) + m.Builder.SetCustomAttribute(new CustomAttributeBuilder(_linker.System_Runtime_CompilerServices_ExtensionAttribute_ctor, new object[0])); + } + } + + void PopulateDelegate() + { + var dt = (DelegateType)Definition; + var cb = Builder.DefineConstructor( + MethodAttributes.RTSpecialName | MethodAttributes.HideBySig | MethodAttributes.Public, + CallingConventions.Standard, new[] { _linker.System_Object, _linker.System_IntPtr }); + + cb.SetImplementationFlags(MethodImplAttributes.Runtime | MethodImplAttributes.Managed); + + var mb = Builder.DefineMethod("Invoke", + MethodAttributes.Public | MethodAttributes.HideBySig | MethodAttributes.NewSlot | MethodAttributes.Virtual, + _linker.GetType(dt.ReturnType), _linker.GetParameterTypes(dt.Parameters)); + + mb.SetImplementationFlags(MethodImplAttributes.Runtime | MethodImplAttributes.Managed); + + if (_backend.IsPInvokable(_essentials, dt)) + { + for (int i = 0; i < dt.Parameters.Length; i++) + { + var p = dt.Parameters[i]; + var pb = PInvokeBackend.DefineCilDelegateParameter(_linker.Universe, _essentials, mb, p, i); + PopulateParameter(p, pb); + } + } + else + { + for (int i = 0; i < dt.Parameters.Length; i++) + { + var p = dt.Parameters[i]; + PopulateParameter(p, mb.DefineParameter(i + 1, p.CilParameterAttributes(), p.Name)); + } + } + + _linker.AddConstructor(Definition, cb); + _linker.AddMethod(Definition, mb); + } + + void PopulateEnum() + { + Builder.DefineField("value__", _linker.GetType(Definition.Base), FieldAttributes.Public | FieldAttributes.SpecialName | FieldAttributes.RTSpecialName); + + for (int i = 0, l = Definition.Literals.Count; i < l; i++) + { + var v = Definition.Literals[i]; + var f = Builder.DefineField(v.UnoName, Builder, FieldAttributes.Public | FieldAttributes.Static | FieldAttributes.Literal); + f.SetConstant(v.Value); + } + } + + void PopulateParameter(Parameter p, ParameterBuilder pb) + { + try + { + if (p.OptionalDefault is Constant) + pb.SetConstant(p.OptionalDefault.ConstantValue); + } + catch + { + // TODO + } + + if (p.Modifier == ParameterModifier.Params) + pb.SetCustomAttribute(new CustomAttributeBuilder(_linker.System_ParamAttribute_ctor, new object[0])); + } + + void SetConstraints(GenericTypeParameterBuilder builder, GenericParameterType definition) + { + var attrs = GenericParameterAttributes.None; + + switch (definition.ConstraintType) + { + case GenericConstraintType.Class: + if (definition.Base != _essentials.Object) + builder.SetBaseTypeConstraint(_linker.GetType(definition.Base)); + else + attrs |= GenericParameterAttributes.ReferenceTypeConstraint; + break; + + case GenericConstraintType.Struct: + attrs |= GenericParameterAttributes.NotNullableValueTypeConstraint; + break; + } + + if (definition.Constructors.Count > 0) + attrs |= GenericParameterAttributes.DefaultConstructorConstraint; + + if (attrs != GenericParameterAttributes.None) + builder.SetGenericParameterAttributes(attrs); + + if (definition.Interfaces.Length > 0) + { + var interfaceTypes = new Type[definition.Interfaces.Length]; + + for (int j = 0; j < definition.Interfaces.Length; j++) + interfaceTypes[j] = _linker.GetType(definition.Interfaces[j]); + + builder.SetInterfaceConstraints(interfaceTypes); + } + } + + FieldBuilder DefineField(Field m, Type type) { var b = Builder.DefineField(m.Name, type, m.CilFieldAttributes()); Fields.Add(new CilMember(b, m)); return b; } - public EventBuilder DefineEvent(Event m, Type type) + EventBuilder DefineEvent(Event m, Type type) { var b = Builder.DefineEvent(m.Name, EventAttributes.None, type); Events.Add(new CilMember(b, m)); return b; } - public PropertyBuilder DefineProperty(Property m, PropertyAttributes attributes, Type returnType, Type[] paramTypes) + PropertyBuilder DefineProperty(Property m, PropertyAttributes attributes, Type returnType, Type[] paramTypes) { var b = Builder.DefineProperty(m.Name, attributes, returnType, paramTypes); Properties.Add(new CilMember(b, m)); return b; } - public MethodBuilder DefineMethod(Function m, MethodAttributes attributes, Type returnType, Type[] paramTypes) + MethodBuilder DefineMethod(Function m, MethodAttributes attributes, Type returnType, Type[] paramTypes) { var b = DefineMethod(m, attributes); b.SetReturnType(returnType); @@ -58,7 +341,7 @@ public MethodBuilder DefineMethod(Function m, MethodAttributes attributes, Type return b; } - public MethodBuilder DefineMethod(Function m, MethodAttributes attributes = 0) + MethodBuilder DefineMethod(Function m, MethodAttributes attributes = 0) { if ((m as Method)?.ImplementedMethod != null) attributes |= MethodAttributes.SpecialName | MethodAttributes.HideBySig | MethodAttributes.Final; @@ -71,19 +354,19 @@ public MethodBuilder DefineMethod(Function m, MethodAttributes attributes = 0) return b; } - public ConstructorBuilder DefineConstructor(Constructor m, Type[] paramTypes) + ConstructorBuilder DefineConstructor(Constructor m, Type[] paramTypes) { var b = Builder.DefineConstructor(m.CilMethodAttributes() | MethodAttributes.SpecialName | MethodAttributes.RTSpecialName, CallingConventions.Standard, paramTypes); Constructors.Add(new CilMember(b, m)); return b; } - public void DefineTypeInitializer(Constructor m) + void DefineTypeInitializer(Constructor m) { Constructors.Add(new CilMember(Builder.DefineTypeInitializer(), m)); } - public void DefineTypeFinalizer(Finalizer m) + void DefineTypeFinalizer(Finalizer m) { Methods.Add(new CilMember(Builder.DefineMethod("Finalize", MethodAttributes.Family | MethodAttributes.Virtual | MethodAttributes.HideBySig, CallingConventions.Standard, _linker.System_Void, Type.EmptyTypes), m)); } diff --git a/src/compiler/Uno.Compiler.Backends.CIL/CilGenerator.Create.cs b/src/compiler/Uno.Compiler.Backends.CIL/CilTypeFactory.cs similarity index 68% rename from src/compiler/Uno.Compiler.Backends.CIL/CilGenerator.Create.cs rename to src/compiler/Uno.Compiler.Backends.CIL/CilTypeFactory.cs index 566b1d2d1..1a6168c46 100644 --- a/src/compiler/Uno.Compiler.Backends.CIL/CilGenerator.Create.cs +++ b/src/compiler/Uno.Compiler.Backends.CIL/CilTypeFactory.cs @@ -1,5 +1,8 @@ using IKVM.Reflection; using IKVM.Reflection.Emit; +using System.Collections.Generic; +using Uno.Compiler.API; +using Uno.Compiler.API.Backends; using Uno.Compiler.API.Domain.IL; using Uno.Compiler.API.Domain.IL.Types; using Uno.Logging; @@ -7,8 +10,21 @@ namespace Uno.Compiler.Backends.CIL { - partial class CilGenerator + public class CilTypeFactory : List { + readonly Backend _backend; + readonly IEssentials _essentials; + readonly CilLinker _linker; + readonly ModuleBuilder _module; + + public CilTypeFactory(Backend backend, IEssentials essentials, CilLinker linker, ModuleBuilder module) + { + _backend = backend; + _essentials = essentials; + _linker = linker; + _module = module; + } + public void DefineType(DataType dt, TypeBuilder parent = null) { switch (dt.TypeType) @@ -39,7 +55,7 @@ public void DefineType(DataType dt, TypeBuilder parent = null) TypeBuilder CreateTypeBuilder(DataType dt, TypeBuilder parent, TypeAttributes typeAttrs, Type typeBase) { var result = parent?.DefineNestedType(dt.CilTypeName(), dt.CilTypeAttributes(true) | typeAttrs, typeBase) ?? _module.DefineType(dt.CilTypeName(), dt.CilTypeAttributes(false) | typeAttrs, typeBase); - var data = new CilType(_linker, result, dt); + var data = new CilType(_backend, _essentials, _linker, result, dt); if (!dt.IsEnum && dt.IsFlattenedDefinition) { @@ -64,43 +80,8 @@ TypeBuilder CreateTypeBuilder(DataType dt, TypeBuilder parent, TypeAttributes ty } _linker.AddType(dt, result); - _types.Add(data); + Add(data); return result; } - - void SetConstraints(GenericTypeParameterBuilder builder, GenericParameterType definition) - { - var attrs = GenericParameterAttributes.None; - - switch (definition.ConstraintType) - { - case GenericConstraintType.Class: - if (definition.Base != _essentials.Object) - builder.SetBaseTypeConstraint(_linker.GetType(definition.Base)); - else - attrs |= GenericParameterAttributes.ReferenceTypeConstraint; - break; - - case GenericConstraintType.Struct: - attrs |= GenericParameterAttributes.NotNullableValueTypeConstraint; - break; - } - - if (definition.Constructors.Count > 0) - attrs |= GenericParameterAttributes.DefaultConstructorConstraint; - - if (attrs != GenericParameterAttributes.None) - builder.SetGenericParameterAttributes(attrs); - - if (definition.Interfaces.Length > 0) - { - var interfaceTypes = new Type[definition.Interfaces.Length]; - - for (int j = 0; j < definition.Interfaces.Length; j++) - interfaceTypes[j] = _linker.GetType(definition.Interfaces[j]); - - builder.SetInterfaceConstraints(interfaceTypes); - } - } } } diff --git a/src/compiler/Uno.Compiler.Backends.CIL/Extensions.cs b/src/compiler/Uno.Compiler.Backends.CIL/Extensions.cs index b95fd88d3..b44ae6059 100644 --- a/src/compiler/Uno.Compiler.Backends.CIL/Extensions.cs +++ b/src/compiler/Uno.Compiler.Backends.CIL/Extensions.cs @@ -9,7 +9,7 @@ namespace Uno.Compiler.Backends.CIL { - static class Extensions + public static class Extensions { private static readonly System.Type _IKVM_Reflection_GenericTypeInstance = typeof(Type).Assembly.GetType("IKVM.Reflection.GenericTypeInstance"); diff --git a/src/compiler/Uno.Compiler.Backends.CIL/Uno.Compiler.Backends.CIL.csproj b/src/compiler/Uno.Compiler.Backends.CIL/Uno.Compiler.Backends.CIL.csproj index 92e9b547b..88a8e0fca 100644 --- a/src/compiler/Uno.Compiler.Backends.CIL/Uno.Compiler.Backends.CIL.csproj +++ b/src/compiler/Uno.Compiler.Backends.CIL/Uno.Compiler.Backends.CIL.csproj @@ -52,6 +52,7 @@ + @@ -62,10 +63,8 @@ - - - + From 55c8aadc5dd9695a6621fa8b13981b5f69abc7f4 Mon Sep 17 00:00:00 2001 From: Morten Daniel Fornes Date: Mon, 14 Jan 2019 08:07:29 +0700 Subject: [PATCH 04/71] add build target for metadata Example: uno build metadata --out-dir .uno/metadata This will produce reference assemblies (one for each package) that contain metadata suitable for code-completion and refactoring plugins, saved to the specified location. --- .../ErrorCode.cs | 8 ++ .../MetadataBackend.cs | 55 ++++++++++++ .../MetadataGenerator.cs | 80 +++++++++++++++++ .../Uno.Compiler.Backends.Metadata.csproj | 86 +++++++++++++++++++ .../packages.config | 4 + src/engine/Uno.Build.Targets/BuildTargets.cs | 3 +- .../Uno.Build.Targets/DotNet/MetadataBuild.cs | 19 ++++ .../Uno.Build.Targets.csproj | 7 +- uno.sln | 17 ++-- 9 files changed, 272 insertions(+), 7 deletions(-) create mode 100644 src/compiler/Uno.Compiler.Backends.Metadata/ErrorCode.cs create mode 100644 src/compiler/Uno.Compiler.Backends.Metadata/MetadataBackend.cs create mode 100644 src/compiler/Uno.Compiler.Backends.Metadata/MetadataGenerator.cs create mode 100644 src/compiler/Uno.Compiler.Backends.Metadata/Uno.Compiler.Backends.Metadata.csproj create mode 100644 src/compiler/Uno.Compiler.Backends.Metadata/packages.config create mode 100644 src/engine/Uno.Build.Targets/DotNet/MetadataBuild.cs diff --git a/src/compiler/Uno.Compiler.Backends.Metadata/ErrorCode.cs b/src/compiler/Uno.Compiler.Backends.Metadata/ErrorCode.cs new file mode 100644 index 000000000..74560b331 --- /dev/null +++ b/src/compiler/Uno.Compiler.Backends.Metadata/ErrorCode.cs @@ -0,0 +1,8 @@ +namespace Uno.Compiler.Backends.Metadata +{ + enum ErrorCode + { + E0000, + I0000, + } +} \ No newline at end of file diff --git a/src/compiler/Uno.Compiler.Backends.Metadata/MetadataBackend.cs b/src/compiler/Uno.Compiler.Backends.Metadata/MetadataBackend.cs new file mode 100644 index 000000000..211a7d1e6 --- /dev/null +++ b/src/compiler/Uno.Compiler.Backends.Metadata/MetadataBackend.cs @@ -0,0 +1,55 @@ +using Uno.Compiler.Backends.CIL; +using Uno.Compiler.API.Backends; +using Uno.Compiler.API.Domain.IL; + +namespace Uno.Compiler.Backends.Metadata +{ + public class MetadataBackend : Backend + { + CilLinker _linker; + + public override string Name => "Meta"; + + public MetadataBackend(ShaderBackend shaderBackend) + : base(shaderBackend) + { + } + + public override void Configure() + { + _linker = new CilLinker(Log, Essentials, true); + } + + public override bool CanLink(SourcePackage upk) + { + return Environment.IsUpToDate(upk, upk.Name + ".dll"); + } + + public override bool CanLink(DataType dt) + { + return dt.Package.CanLink; + } + + public override bool CanLink(Function function) + { + return true; + } + + public override BackendResult Build(SourcePackage package) + { + if (package.CanLink) + { + package.Tag = _linker.AddAssemblyFile(Environment.Combine(package.Name + ".dll")); + return null; + } + + var g = new MetadataGenerator(Disk, Data, Essentials, + this, _linker, package, + Environment.OutputDirectory); + g.Configure(); + g.Generate(); + g.Save(); + return null; + } + } +} diff --git a/src/compiler/Uno.Compiler.Backends.Metadata/MetadataGenerator.cs b/src/compiler/Uno.Compiler.Backends.Metadata/MetadataGenerator.cs new file mode 100644 index 000000000..f34c514b1 --- /dev/null +++ b/src/compiler/Uno.Compiler.Backends.Metadata/MetadataGenerator.cs @@ -0,0 +1,80 @@ +using IKVM.Reflection; +using IKVM.Reflection.Emit; +using Uno.Compiler.API; +using Uno.Compiler.API.Domain.IL; +using Uno.Compiler.Backends.CIL; +using Uno.IO; + +namespace Uno.Compiler.Backends.Metadata +{ + class MetadataGenerator : DiskObject + { + readonly SourcePackage _package; + readonly IBuildData _data; + readonly IEssentials _essentials; + readonly CilLinker _linker; + readonly MetadataBackend _backend; + readonly AssemblyBuilder _assembly; + readonly CilTypeFactory _types; + readonly string _outputDir; + + public MetadataGenerator(Disk disk, IBuildData data, IEssentials essentials, + MetadataBackend backend, CilLinker linker, SourcePackage package, + string outputDir) + : base(disk) + { + _data = data; + _essentials = essentials; + _backend = backend; + _package = package; + _linker = linker; + _outputDir = outputDir; + _assembly = _linker.Universe.DefineDynamicAssembly( + new AssemblyName(package.Name), + AssemblyBuilderAccess.Save, + outputDir); + var module = _assembly.DefineDynamicModule( + package.Name, + package.Name + ".dll", + true); + _types = new CilTypeFactory(backend, essentials, linker, module); + } + + public void Configure() + { + foreach (var name in _package.InternalsVisibleTo) + _assembly.SetCustomAttribute( + new CustomAttributeBuilder( + _linker.System_Runtime_CompilerServices_InternalsVisibleToAttribute_ctor, + new object[] {name})); + } + + public void Save() + { + Disk.CreateDirectory(_outputDir); + _assembly.Save(_assembly.GetName().Name + ".dll"); + } + + public void Generate() + { + Process(_data.IL); + + foreach (var e in _types) + e.Populate(); + foreach (var e in _types) + e.Builder.CreateType(); + + Log.Verbose("Generated " + _types.Count + " .NET type".Plural(_types) + " for " + _assembly.GetName().Name.Quote() + " assembly"); + } + + void Process(Namespace root) + { + foreach (var dt in root.Types) + if (dt.Source.Package == _package) + _types.DefineType(dt); + + foreach (var ns in root.Namespaces) + Process(ns); + } + } +} diff --git a/src/compiler/Uno.Compiler.Backends.Metadata/Uno.Compiler.Backends.Metadata.csproj b/src/compiler/Uno.Compiler.Backends.Metadata/Uno.Compiler.Backends.Metadata.csproj new file mode 100644 index 000000000..36eafa7f5 --- /dev/null +++ b/src/compiler/Uno.Compiler.Backends.Metadata/Uno.Compiler.Backends.Metadata.csproj @@ -0,0 +1,86 @@ + + + + Debug + AnyCPU + {0A4E8B45-E8A4-4371-9E66-B0EF3C9D3B6F} + Library + Properties + Uno.Compiler.Backends.Metadata + Uno.Compiler.Backends.Metadata + v4.5 + 512 + + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + false + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + false + + + + + ..\..\..\packages\Mono.Cecil.0.10.0\lib\net40\Mono.Cecil.dll + + + ..\..\..\packages\Mono.Cecil.0.10.0\lib\net40\Mono.Cecil.Mdb.dll + + + ..\..\..\packages\Mono.Cecil.0.10.0\lib\net40\Mono.Cecil.Pdb.dll + + + ..\..\..\packages\Mono.Cecil.0.10.0\lib\net40\Mono.Cecil.Rocks.dll + + + + + + + + + + + + + {4cb170ef-dfe6-4a56-9e1b-a85449e827a7} + IKVM.Reflection + + + {B819B724-1A1F-458E-A4AF-4A5BB330C2C4} + Uno.Compiler.API + + + {D159DC86-F510-4FCF-9573-E339BDD6D166} + Uno.Common + + + {b3b455c8-dd3d-4655-b10c-3c6be878911e} + Uno.Compiler.Backends.CIL + + + + + + + + \ No newline at end of file diff --git a/src/compiler/Uno.Compiler.Backends.Metadata/packages.config b/src/compiler/Uno.Compiler.Backends.Metadata/packages.config new file mode 100644 index 000000000..91bb45ec2 --- /dev/null +++ b/src/compiler/Uno.Compiler.Backends.Metadata/packages.config @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/src/engine/Uno.Build.Targets/BuildTargets.cs b/src/engine/Uno.Build.Targets/BuildTargets.cs index 05012020f..1b7736112 100644 --- a/src/engine/Uno.Build.Targets/BuildTargets.cs +++ b/src/engine/Uno.Build.Targets/BuildTargets.cs @@ -20,8 +20,9 @@ public static class BuildTargets Default, new Uno.CorelibBuild(), new Uno.DocsBuild(), + new DotNet.MetadataBuild(), new PInvoke.PInvokeBuild(), - Package + Package, }; public static IEnumerable Enumerate(bool experimental = true, bool obsolete = false) diff --git a/src/engine/Uno.Build.Targets/DotNet/MetadataBuild.cs b/src/engine/Uno.Build.Targets/DotNet/MetadataBuild.cs new file mode 100644 index 000000000..e6bb2ebcc --- /dev/null +++ b/src/engine/Uno.Build.Targets/DotNet/MetadataBuild.cs @@ -0,0 +1,19 @@ +using Uno.Compiler.API.Backends; +using Uno.Compiler.Backends.Metadata; +using Uno.Compiler.Backends.OpenGL; + +namespace Uno.Build.Targets.DotNet +{ + public class MetadataBuild : BuildTarget + { + public override string Identifier => "Metadata"; + public override string Description => "Metadata for code completion."; + public override bool IsExperimental => true; + public override bool DefaultStrip => false; + + public override Backend CreateBackend() + { + return new MetadataBackend(new GLBackend()); + } + } +} diff --git a/src/engine/Uno.Build.Targets/Uno.Build.Targets.csproj b/src/engine/Uno.Build.Targets/Uno.Build.Targets.csproj index aadf9e148..a0e631974 100644 --- a/src/engine/Uno.Build.Targets/Uno.Build.Targets.csproj +++ b/src/engine/Uno.Build.Targets/Uno.Build.Targets.csproj @@ -54,6 +54,7 @@ + @@ -83,6 +84,10 @@ {90D050F9-B619-4F5F-8CFE-27C2B94CCD1B} Uno.Compiler.Backends.CSharp + + {0a4e8b45-e8a4-4371-9e66-b0ef3c9d3b6f} + Uno.Compiler.Backends.Metadata + {AFCAAF4E-198D-45F5-A019-ACED9CDCCADF} Uno.Compiler.Backends.OpenGL @@ -140,4 +145,4 @@ - + \ No newline at end of file diff --git a/uno.sln b/uno.sln index cfa1c4e82..440e9a123 100644 --- a/uno.sln +++ b/uno.sln @@ -96,12 +96,18 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Uno.Stuff", "src\engine\Uno EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Uno.AppLoader-MonoMac", "src\runtime\Uno.AppLoader-MonoMac\Uno.AppLoader-MonoMac.csproj", "{C919203A-A0FD-41E4-A8D7-3E1B1C12DDAE}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Uno.Compiler.Backends.Metadata", "src\compiler\Uno.Compiler.Backends.Metadata\Uno.Compiler.Backends.Metadata.csproj", "{0A4E8B45-E8A4-4371-9E66-B0EF3C9D3B6F}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU Release|Any CPU = Release|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution + {AE4B5DFC-F0FA-46A0-9ADB-C284E70A7BA5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {AE4B5DFC-F0FA-46A0-9ADB-C284E70A7BA5}.Debug|Any CPU.Build.0 = Debug|Any CPU + {AE4B5DFC-F0FA-46A0-9ADB-C284E70A7BA5}.Release|Any CPU.ActiveCfg = Release|Any CPU + {AE4B5DFC-F0FA-46A0-9ADB-C284E70A7BA5}.Release|Any CPU.Build.0 = Release|Any CPU {5813CAEE-0804-45C2-A0C7-E30720EFBB45}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {5813CAEE-0804-45C2-A0C7-E30720EFBB45}.Debug|Any CPU.Build.0 = Debug|Any CPU {5813CAEE-0804-45C2-A0C7-E30720EFBB45}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -110,10 +116,6 @@ Global {8AE4FBD3-302B-46AC-B0AB-5E8B7604DBCC}.Debug|Any CPU.Build.0 = Debug|Any CPU {8AE4FBD3-302B-46AC-B0AB-5E8B7604DBCC}.Release|Any CPU.ActiveCfg = Release|Any CPU {8AE4FBD3-302B-46AC-B0AB-5E8B7604DBCC}.Release|Any CPU.Build.0 = Release|Any CPU - {AE4B5DFC-F0FA-46A0-9ADB-C284E70A7BA5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {AE4B5DFC-F0FA-46A0-9ADB-C284E70A7BA5}.Debug|Any CPU.Build.0 = Debug|Any CPU - {AE4B5DFC-F0FA-46A0-9ADB-C284E70A7BA5}.Release|Any CPU.ActiveCfg = Release|Any CPU - {AE4B5DFC-F0FA-46A0-9ADB-C284E70A7BA5}.Release|Any CPU.Build.0 = Release|Any CPU {D159DC86-F510-4FCF-9573-E339BDD6D166}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {D159DC86-F510-4FCF-9573-E339BDD6D166}.Debug|Any CPU.Build.0 = Debug|Any CPU {D159DC86-F510-4FCF-9573-E339BDD6D166}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -262,14 +264,18 @@ Global {C919203A-A0FD-41E4-A8D7-3E1B1C12DDAE}.Debug|Any CPU.Build.0 = Debug|Any CPU {C919203A-A0FD-41E4-A8D7-3E1B1C12DDAE}.Release|Any CPU.ActiveCfg = Release|Any CPU {C919203A-A0FD-41E4-A8D7-3E1B1C12DDAE}.Release|Any CPU.Build.0 = Release|Any CPU + {0A4E8B45-E8A4-4371-9E66-B0EF3C9D3B6F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {0A4E8B45-E8A4-4371-9E66-B0EF3C9D3B6F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {0A4E8B45-E8A4-4371-9E66-B0EF3C9D3B6F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {0A4E8B45-E8A4-4371-9E66-B0EF3C9D3B6F}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection GlobalSection(NestedProjects) = preSolution + {AE4B5DFC-F0FA-46A0-9ADB-C284E70A7BA5} = {4E38220C-6F5B-7B70-8691-9CB2BFD3D400} {5813CAEE-0804-45C2-A0C7-E30720EFBB45} = {4E38220C-6F5B-7B70-8691-9CB2BFD3D400} {8AE4FBD3-302B-46AC-B0AB-5E8B7604DBCC} = {4E38220C-6F5B-7B70-8691-9CB2BFD3D400} - {AE4B5DFC-F0FA-46A0-9ADB-C284E70A7BA5} = {4E38220C-6F5B-7B70-8691-9CB2BFD3D400} {D159DC86-F510-4FCF-9573-E339BDD6D166} = {4E38220C-6F5B-7B70-8691-9CB2BFD3D401} {B819B724-1A1F-458E-A4AF-4A5BB330C2C4} = {4E38220C-6F5B-7B70-8691-9CB2BFD3D402} {B3B455C8-DD3D-4655-B10C-3C6BE878911E} = {4E38220C-6F5B-7B70-8691-9CB2BFD3D402} @@ -307,6 +313,7 @@ Global {4CB170EF-DFE6-4A56-9E1B-A85449E827A7} = {4E38220C-6F5B-7B70-8691-9CB2BFD3D402} {33DFB596-4314-4EA9-B00E-65E18D818A97} = {4E38220C-6F5B-7B70-8691-9CB2BFD3D404} {C919203A-A0FD-41E4-A8D7-3E1B1C12DDAE} = {4E38220C-6F5B-7B70-8691-9CB2BFD3D405} + {0A4E8B45-E8A4-4371-9E66-B0EF3C9D3B6F} = {4E38220C-6F5B-7B70-8691-9CB2BFD3D402} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {B2804552-8993-4386-8F1F-49F98D24EBAA} From 52cf4dbb816169be2bd1cd61ab01ca2368816edc Mon Sep 17 00:00:00 2001 From: Morten Daniel Fornes Date: Mon, 14 Jan 2019 08:46:50 +0700 Subject: [PATCH 05/71] Uno.Compiler: move build cache directories When we write metadata to .uno/metadata/, then this will avoid colliding with the build cache location used by the the metadata target. Now build caches get a more generic name instead, e.g. .uno/builds/76598222/. --- src/compiler/Uno.Compiler.Core/BuildEnvironment.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compiler/Uno.Compiler.Core/BuildEnvironment.cs b/src/compiler/Uno.Compiler.Core/BuildEnvironment.cs index cb60e5997..52c1ad74c 100644 --- a/src/compiler/Uno.Compiler.Core/BuildEnvironment.cs +++ b/src/compiler/Uno.Compiler.Core/BuildEnvironment.cs @@ -54,7 +54,7 @@ internal BuildEnvironment( Extensions = extensions; Options = options; BundleDirectory = Path.Combine(project.CacheDirectory, "bundle"); - CacheDirectory = Path.Combine(project.CacheDirectory, options.BuildTarget, options.Configuration); + CacheDirectory = Path.Combine(project.CacheDirectory, "builds", (options.BuildTarget + options.Configuration).GetHashCode().ToString("X8")); Essentials = ilf.Essentials; MacroExpander = new MacroExpander(backend, this, extensions, ilf, compiler); Compiler = compiler; From 6139b55cad32ec289e1ce43d605b3c20cba80c95 Mon Sep 17 00:00:00 2001 From: Morten Daniel Fornes Date: Sun, 16 Dec 2018 00:14:45 +0700 Subject: [PATCH 06/71] UnoCore: make sure life-cycle events are called on Native This fixes a bug in apps trying to do something on exit, and nothing gets done, because the life-cycle callbacks are never called. --- lib/UnoCore/Backends/CPlusPlus/Uno/_main.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/UnoCore/Backends/CPlusPlus/Uno/_main.cpp b/lib/UnoCore/Backends/CPlusPlus/Uno/_main.cpp index b60ffbaa1..6b93827fa 100644 --- a/lib/UnoCore/Backends/CPlusPlus/Uno/_main.cpp +++ b/lib/UnoCore/Backends/CPlusPlus/Uno/_main.cpp @@ -248,14 +248,14 @@ struct uMainLoop : Xli::WindowEventHandler virtual bool OnClosing(Xli::Window* wnd, bool& cancel) { uAutoReleasePool pool; - - // TODO + @{Uno.Platform.CoreApp.EnterBackground():Call()}; return false; } virtual void OnClosed(Xli::Window* wnd) { uAutoReleasePool pool; + @{Uno.Platform.CoreApp.Terminate():Call()}; } virtual void OnAppLowMemory(Xli::Window* wnd) From 9c1e0a4009b250459a1543d69822929532154121 Mon Sep 17 00:00:00 2001 From: Morten Daniel Fornes Date: Sat, 1 Dec 2018 08:42:27 +0700 Subject: [PATCH 07/71] Uno.Compiler: report image filename when WriteImageFile() fails I experienced a problem with an image in an incompatible pixel format, and this makes it easier to see which image file is causing the problem. --- src/compiler/Uno.Compiler.Core/Syntax/UxlProcessor.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/compiler/Uno.Compiler.Core/Syntax/UxlProcessor.cs b/src/compiler/Uno.Compiler.Core/Syntax/UxlProcessor.cs index a8972501a..d69961736 100644 --- a/src/compiler/Uno.Compiler.Core/Syntax/UxlProcessor.cs +++ b/src/compiler/Uno.Compiler.Core/Syntax/UxlProcessor.cs @@ -664,7 +664,8 @@ void WriteImageFile(ImageFile f) } catch (Exception e) { - Log.Error(f.SourceName.Source, ErrorCode.E0000, e.Message); + Log.Error(new Source(src), ErrorCode.E0000, e.Message); + Log.Error(f.SourceName.Source, ErrorCode.E0000, "Failed to convert " + src.Quote()); } } From c11c9e58e7250cf43eaac71a7cf666c7c25d3a7e Mon Sep 17 00:00:00 2001 From: Morten Daniel Fornes Date: Sun, 4 Nov 2018 22:08:17 +0700 Subject: [PATCH 08/71] Uno.Net.Sockets: fix linker error This fixes the following linker error on WIN32 if IPAddress is used without Socket: Uno.Net.g.obj : error LNK2019: unresolved external symbol inet_ntop referenced in function "public: static struct uString * __cdecl g::Uno::Net::IPAddress::IPv6AddressToString(struct uArray *)" (?IPv6AddressToString@IPAddress@Net@Uno@g@@SAPEAUuString@@PEAUuArray@@@Z) --- lib/Uno.Net.Sockets/IPAddress.uno | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/Uno.Net.Sockets/IPAddress.uno b/lib/Uno.Net.Sockets/IPAddress.uno index c10c0da7c..38b98f820 100644 --- a/lib/Uno.Net.Sockets/IPAddress.uno +++ b/lib/Uno.Net.Sockets/IPAddress.uno @@ -43,6 +43,7 @@ namespace Uno.Net [extern(!MSVC) Require("Source.Include", "arpa/inet.h")] [extern(MSVC) Require("Source.Include", "ws2tcpip.h")] + [extern(MSVC) Require("LinkLibrary", "ws2_32")] [DotNetType("System.Net.IPAddress")] public class IPAddress { From 3feaae9fb2407a62b14d48388c5be5651e765883 Mon Sep 17 00:00:00 2001 From: Morten Daniel Fornes Date: Sat, 1 Dec 2018 08:44:30 +0700 Subject: [PATCH 09/71] C++: don't output source line numbers The source line numbers aren't really useful, and I think the output is cleaner without. --- src/compiler/Uno.Compiler.Backends.CPlusPlus/CppWriter.cs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/compiler/Uno.Compiler.Backends.CPlusPlus/CppWriter.cs b/src/compiler/Uno.Compiler.Backends.CPlusPlus/CppWriter.cs index 1ad21e4dc..0a24b296f 100644 --- a/src/compiler/Uno.Compiler.Backends.CPlusPlus/CppWriter.cs +++ b/src/compiler/Uno.Compiler.Backends.CPlusPlus/CppWriter.cs @@ -179,7 +179,7 @@ public void WriteComment(DataType dt) if (dt.IsDelegate) Write(dt.Parameters.BuildString("(", ")", true)); - EndLine(" :" + dt.Source.Line); + EndLine(); } public void WriteComment(Function f, string text = null) @@ -213,8 +213,7 @@ public void WriteComment(Function f, string text = null) } EndLine(f.Prototype.Parameters.BuildString("(", ")", true) + - (text != null ? " [" + text + "]" : null) + - " :" + f.Source.Line); + (text != null ? " [" + text + "]" : null)); } public void WriteUnoName(DataType dt) From df33207fdbc2447ac290c44e281cc32a80794242 Mon Sep 17 00:00:00 2001 From: Morten Daniel Fornes Date: Tue, 13 Nov 2018 04:03:12 +0700 Subject: [PATCH 10/71] Native: disable warning on MSVC 'op_Implicit' is a reserved word in the C++ backend and is output as 'op_Implicit1' in generated code. MSVC still isn't happy, so this patch disables the following warning: warning C4674: 'op_Implicit' should be declared 'static' and have exactly one parameter --- lib/UnoCore/Targets/Native/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/UnoCore/Targets/Native/CMakeLists.txt b/lib/UnoCore/Targets/Native/CMakeLists.txt index 197783531..638b11f5f 100644 --- a/lib/UnoCore/Targets/Native/CMakeLists.txt +++ b/lib/UnoCore/Targets/Native/CMakeLists.txt @@ -24,7 +24,7 @@ if (APPLE) elseif (MSVC) add_definitions(-DUNICODE -D_UNICODE -D_CRT_SECURE_NO_WARNINGS) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /MP") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /GR- /MP /wd4065 /wd4101 /wd4390") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /GR- /MP /wd4065 /wd4101 /wd4390 /wd4674") set(CMAKE_CONFIGURATION_TYPES "Debug;Release" CACHE STRING "Build Configurations (forced)" FORCE) set(EXTRA_FILES "natvis/uno.natstepfilter" "natvis/uno.natvis") endif() From 46572ce4220993a1ce3b2799225fd8142897662a Mon Sep 17 00:00:00 2001 From: Morten Daniel Fornes Date: Sat, 24 Nov 2018 17:27:18 +0700 Subject: [PATCH 11/71] Uno.Compiler: remove unused code This code isn't used and can be removed. --- src/compiler/Uno.Compiler.API/IUtilities.cs | 1 - .../IL/Utilities/Analyzing/ParameterFinder.cs | 31 ---------------- .../IL/Utilities/Analyzing/ReturnFinder.cs | 36 ------------------- .../IL/Utilities/Analyzing/ThisFinder.cs | 30 ---------------- .../IL/Utilities/Utilities.cs | 17 --------- .../Uno.Compiler.Core.csproj | 3 -- 6 files changed, 118 deletions(-) delete mode 100644 src/compiler/Uno.Compiler.Core/IL/Utilities/Analyzing/ParameterFinder.cs delete mode 100644 src/compiler/Uno.Compiler.Core/IL/Utilities/Analyzing/ReturnFinder.cs delete mode 100644 src/compiler/Uno.Compiler.Core/IL/Utilities/Analyzing/ThisFinder.cs diff --git a/src/compiler/Uno.Compiler.API/IUtilities.cs b/src/compiler/Uno.Compiler.API/IUtilities.cs index c67228913..9ef796353 100644 --- a/src/compiler/Uno.Compiler.API/IUtilities.cs +++ b/src/compiler/Uno.Compiler.API/IUtilities.cs @@ -10,6 +10,5 @@ public interface IUtilities HashSet FindAllTypes(); HashSet FindDependencies(Statement s); HashSet FindDependencies(Function f); - ListDictionary FindDescendants(); } } \ No newline at end of file diff --git a/src/compiler/Uno.Compiler.Core/IL/Utilities/Analyzing/ParameterFinder.cs b/src/compiler/Uno.Compiler.Core/IL/Utilities/Analyzing/ParameterFinder.cs deleted file mode 100644 index b50285824..000000000 --- a/src/compiler/Uno.Compiler.Core/IL/Utilities/Analyzing/ParameterFinder.cs +++ /dev/null @@ -1,31 +0,0 @@ -using System.Collections.Generic; -using Uno.Compiler.API.Domain.IL; -using Uno.Compiler.API.Domain.IL.Expressions; - -namespace Uno.Compiler.Core.IL.Utilities.Analyzing -{ - class ParameterFinder : Pass - { - readonly HashSet UnsafeParameters = new HashSet(); - - ParameterFinder(Pass parent) - : base(parent) - { - } - - public override void Begin(ref Expression e, ExpressionUsage u) - { - if (e is LoadArgument && u.IsObject()) - UnsafeParameters.Add((e as LoadArgument).Index); - else if (e is StoreArgument) - UnsafeParameters.Add((e as StoreArgument).Index); - } - - public static HashSet FindUnsafeParameters(Pass parent, Function f) - { - var p = new ParameterFinder(parent); - f.Visit(p); - return p.UnsafeParameters; - } - } -} \ No newline at end of file diff --git a/src/compiler/Uno.Compiler.Core/IL/Utilities/Analyzing/ReturnFinder.cs b/src/compiler/Uno.Compiler.Core/IL/Utilities/Analyzing/ReturnFinder.cs deleted file mode 100644 index 6e59582f1..000000000 --- a/src/compiler/Uno.Compiler.Core/IL/Utilities/Analyzing/ReturnFinder.cs +++ /dev/null @@ -1,36 +0,0 @@ -using Uno.Compiler.API.Domain.IL; -using Uno.Compiler.API.Domain.IL.Expressions; -using Uno.Compiler.API.Domain.IL.Statements; - -namespace Uno.Compiler.Core.IL.Utilities.Analyzing -{ - class ReturnFinder : Pass - { - bool DidNotReturnNewObject; - - ReturnFinder(Pass parent) - : base(parent) - { - } - - public override void Begin(ref Statement s) - { - if (s is Return && !((s as Return).Value is NewObject) && !((s as Return).Value is LoadLocal)) - DidNotReturnNewObject = true; - - // TODO: Check method calls recursively - } - - public static bool IsAlwaysReturningNewObject(Pass parent, Function f) - { - // TODO: UXL can be handled using MethodProperties - - if (!f.HasBody) - return false; - - var p = new ReturnFinder(parent); - f.Visit(p); - return !p.DidNotReturnNewObject; - } - } -} \ No newline at end of file diff --git a/src/compiler/Uno.Compiler.Core/IL/Utilities/Analyzing/ThisFinder.cs b/src/compiler/Uno.Compiler.Core/IL/Utilities/Analyzing/ThisFinder.cs deleted file mode 100644 index 01de88b7d..000000000 --- a/src/compiler/Uno.Compiler.Core/IL/Utilities/Analyzing/ThisFinder.cs +++ /dev/null @@ -1,30 +0,0 @@ -using Uno.Compiler.API.Domain.IL; -using Uno.Compiler.API.Domain.IL.Expressions; - -namespace Uno.Compiler.Core.IL.Utilities.Analyzing -{ - class ThisFinder : Pass - { - bool WritesToThis; - - ThisFinder(Pass parent) - : base(parent) - { - } - - public override void Begin(ref Expression e, ExpressionUsage u) - { - if (e is This && u.IsObject() || e is StoreThis) - WritesToThis = true; - - // TODO: Check method calls recursively - } - - public static bool IsWritingToThis(Pass parent, Function f) - { - var p = new ThisFinder(parent); - f.Visit(p); - return p.WritesToThis; - } - } -} \ No newline at end of file diff --git a/src/compiler/Uno.Compiler.Core/IL/Utilities/Utilities.cs b/src/compiler/Uno.Compiler.Core/IL/Utilities/Utilities.cs index 27eb200fe..e813b7fed 100644 --- a/src/compiler/Uno.Compiler.Core/IL/Utilities/Utilities.cs +++ b/src/compiler/Uno.Compiler.Core/IL/Utilities/Utilities.cs @@ -19,23 +19,6 @@ public Utilities(Namespace il, Pass parent) _parent = parent; } - public ListDictionary FindDescendants() - { - var result = new ListDictionary(); - foreach (var e in FindAllTypes()) - { - if (e.TypeType == TypeType.Class && e.Base != null) - { - result.Add(e.Base, e); - - if (!e.Base.IsMasterDefinition) - result.Add(e.Base.MasterDefinition, e); - } - } - - return result; - } - public HashSet FindDependencies(Statement s) { return DependencyFinder.FindDependencies(_parent, s); diff --git a/src/compiler/Uno.Compiler.Core/Uno.Compiler.Core.csproj b/src/compiler/Uno.Compiler.Core/Uno.Compiler.Core.csproj index 8cea4508a..9dceaec22 100644 --- a/src/compiler/Uno.Compiler.Core/Uno.Compiler.Core.csproj +++ b/src/compiler/Uno.Compiler.Core/Uno.Compiler.Core.csproj @@ -67,9 +67,6 @@ - - - From de0f19f0cdc6bd3cfa8588b1c64ad4123a3744b1 Mon Sep 17 00:00:00 2001 From: Morten Daniel Fornes Date: Sat, 24 Nov 2018 17:31:54 +0700 Subject: [PATCH 12/71] Uno.Compiler: fix name resolver bug This fixes bugs when accessing members of a parent class from inside a nested block. Use a loop to scan all parent classes, and add a separate loop for static context. --- .../FunctionCompiler.NameResolver.Identifier.cs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/compiler/Uno.Compiler.Core/Syntax/Compilers/FunctionCompiler.NameResolver.Identifier.cs b/src/compiler/Uno.Compiler.Core/Syntax/Compilers/FunctionCompiler.NameResolver.Identifier.cs index c52c5887c..374a91cea 100644 --- a/src/compiler/Uno.Compiler.Core/Syntax/Compilers/FunctionCompiler.NameResolver.Identifier.cs +++ b/src/compiler/Uno.Compiler.Core/Syntax/Compilers/FunctionCompiler.NameResolver.Identifier.cs @@ -139,14 +139,21 @@ public PartialExpression ResolveIdentifier(AstIdentifier id, int? typeParamCount return new PartialValue(new GetMetaProperty(id.Source, mp.ReturnType, mp.Name)); } - var dt = block.TryFindTypeParent(); - - if (dt != null) + // Object context + for (var dt = block.TryFindTypeParent(); dt != null; dt = dt.ParentType) { var p = TryResolveTypeMember(dt, id, typeParamCount, null, new GetMetaObject(id.Source, TypeBuilder.Parameterize(dt))); if (p != null) return p; } + + // Static context + for (var dt = block.ParentType; dt != null; dt = dt.ParentType) + { + var p = TryResolveTypeMember(dt, id, typeParamCount, null, null); + if (p != null) + return p; + } } parentScope = Namescope; From 6932454b0f25a47b8dfa28663d15d53bbc7a719e Mon Sep 17 00:00:00 2001 From: Morten Daniel Fornes Date: Sat, 24 Nov 2018 17:32:03 +0700 Subject: [PATCH 13/71] UnoTest: add test for nested block --- .../UnoTest/ShaderGenerator/NestedBlock.uno | 31 +++++++++++++++++++ tests/src/UnoTest/UnoTest.unoproj | 1 + 2 files changed, 32 insertions(+) create mode 100644 tests/src/UnoTest/ShaderGenerator/NestedBlock.uno diff --git a/tests/src/UnoTest/ShaderGenerator/NestedBlock.uno b/tests/src/UnoTest/ShaderGenerator/NestedBlock.uno new file mode 100644 index 000000000..532422ecb --- /dev/null +++ b/tests/src/UnoTest/ShaderGenerator/NestedBlock.uno @@ -0,0 +1,31 @@ +namespace UnoTest +{ + class NestedBlock + { + static float4 GetColor() + { + return float4(1, 1, 0, 1); + } + + class Class + { + public void Draw() + { + draw Block; + } + + block Block + { + float2[] VertexData: + new[] { + float2(0, 0), float2(1, 0), float2(1, 1), + float2(0, 0), float2(1, 1), float2(0, 1) + }; + ClipPosition: + float4(vertex_attrib(VertexData), 0, 0); + PixelColor: + GetColor(); + } + } + } +} diff --git a/tests/src/UnoTest/UnoTest.unoproj b/tests/src/UnoTest/UnoTest.unoproj index aa0bcb4ba..cb9335391 100644 --- a/tests/src/UnoTest/UnoTest.unoproj +++ b/tests/src/UnoTest/UnoTest.unoproj @@ -970,6 +970,7 @@ "ShaderGenerator/DefaultPrimitivesBlock.uno:Source", "ShaderGenerator/DefaultShading.uno:Source", "ShaderGenerator/Lights.uno:Source", + "ShaderGenerator/NestedBlock.uno:Source", "ShaderGenerator/PixelInputs.uno:Source", "ShaderGenerator/Quad.uno:Source", "ShaderGenerator/ShaderControlFlow.uno:Source", From b2cdb9bb12243cbcbef4598226806df8140547a7 Mon Sep 17 00:00:00 2001 From: Morten Daniel Fornes Date: Wed, 21 Nov 2018 19:47:37 +0700 Subject: [PATCH 14/71] Uno.Compiler: verify visibility of generic arguments This will catch some more compile-time errors, such as E4128: X is less accessible than Y --- .../Uno.Compiler.Core/IL/Validation/ILVerifier.Type.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/compiler/Uno.Compiler.Core/IL/Validation/ILVerifier.Type.cs b/src/compiler/Uno.Compiler.Core/IL/Validation/ILVerifier.Type.cs index 03869dd7e..8b85308d7 100644 --- a/src/compiler/Uno.Compiler.Core/IL/Validation/ILVerifier.Type.cs +++ b/src/compiler/Uno.Compiler.Core/IL/Validation/ILVerifier.Type.cs @@ -374,6 +374,9 @@ void VerifyVisibility(SourceObject owner, Visibility visibility, DataType dt) !Environment.IsGeneratingCode || !Backend.Has(TypeOptions.IgnoreProtection))) Log.Error(owner.Source, ErrorCode.E4128, dt.Quote() + " is less accessible than " + owner.Quote()); + else if (dt.IsGenericParameterization) + foreach (var pt in dt.GenericArguments) + VerifyVisibility(owner, visibility, pt); } } } From 15e432b1f6fe223b8c50e6604ba072ba52c73a86 Mon Sep 17 00:00:00 2001 From: Morten Daniel Fornes Date: Wed, 21 Nov 2018 19:56:22 +0700 Subject: [PATCH 15/71] Uno.Compiler: early-out faster in VerifyVisibility() If backend ignores protection modifiers and we're in code generating mode, we can skip the following checks completely. --- .../Uno.Compiler.Core/IL/Validation/ILVerifier.Type.cs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/compiler/Uno.Compiler.Core/IL/Validation/ILVerifier.Type.cs b/src/compiler/Uno.Compiler.Core/IL/Validation/ILVerifier.Type.cs index 8b85308d7..27cfc2627 100644 --- a/src/compiler/Uno.Compiler.Core/IL/Validation/ILVerifier.Type.cs +++ b/src/compiler/Uno.Compiler.Core/IL/Validation/ILVerifier.Type.cs @@ -369,10 +369,12 @@ void VerifyGenericConstraints(DataType dt) void VerifyVisibility(SourceObject owner, Visibility visibility, DataType dt) { + if (Backend.Has(TypeOptions.IgnoreProtection) && + Environment.IsGeneratingCode) + return; + if (VerifyAccessibleEntity(owner.Source, dt) && - !visibility.IsVisibile(dt) && ( - !Environment.IsGeneratingCode || - !Backend.Has(TypeOptions.IgnoreProtection))) + !visibility.IsVisibile(dt)) Log.Error(owner.Source, ErrorCode.E4128, dt.Quote() + " is less accessible than " + owner.Quote()); else if (dt.IsGenericParameterization) foreach (var pt in dt.GenericArguments) From 53c0595d27c88fcff068c83cdbf3e2794208f8f0 Mon Sep 17 00:00:00 2001 From: Morten Daniel Fornes Date: Sun, 25 Nov 2018 17:00:43 +0700 Subject: [PATCH 16/71] UnoCore.Test: fix visibility problem lib\UnoCore\Tests\Collections\HashSet.Test.uno(29.36): E4128: Collections.Test.HashSetTest.DummyClass is less accessible than 'Collections.Test.HashSetTest.CreateHashSetRandomDummyClass(int)' --- lib/UnoCore/Tests/Collections/HashSet.Test.uno | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/UnoCore/Tests/Collections/HashSet.Test.uno b/lib/UnoCore/Tests/Collections/HashSet.Test.uno index f1e130bad..171263161 100644 --- a/lib/UnoCore/Tests/Collections/HashSet.Test.uno +++ b/lib/UnoCore/Tests/Collections/HashSet.Test.uno @@ -7,7 +7,7 @@ namespace Collections.Test { public class HashSetTest { - class DummyClass + public class DummyClass { string _f; string _b; From 369ada188f266f5d7dc57d4f5051535d6fbafe13 Mon Sep 17 00:00:00 2001 From: Morten Daniel Fornes Date: Tue, 13 Nov 2018 03:40:31 +0700 Subject: [PATCH 17/71] UnoCore: deprecate MSVC12 define We're using MSVC version 15 and not 12, so this define is outdated and should be removed in the future. --- lib/UnoCore/Targets/Native/Native.uxl | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/UnoCore/Targets/Native/Native.uxl b/lib/UnoCore/Targets/Native/Native.uxl index 89f43fbad..8335d0377 100644 --- a/lib/UnoCore/Targets/Native/Native.uxl +++ b/lib/UnoCore/Targets/Native/Native.uxl @@ -10,6 +10,7 @@ + From 25da68bb2f117650840c80596d08cf0d0eb35711 Mon Sep 17 00:00:00 2001 From: Morten Daniel Fornes Date: Tue, 13 Nov 2018 03:38:54 +0700 Subject: [PATCH 18/71] Uno.Net.Http: check MSVC instead of MSVC12 MSVC12 is deprecated so check the unversioned define instead. --- lib/Uno.Net.Http/HttpMessageHandler.uno | 6 +++--- lib/Uno.Net.Http/HttpMessageHandlerRequest.uno | 2 +- .../Implementation/Xli/XliHttpRequest.cpp.uxl | 2 +- lib/Uno.Net.Http/Implementation/Xli/XliHttpRequest.uno | 8 ++++---- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/lib/Uno.Net.Http/HttpMessageHandler.uno b/lib/Uno.Net.Http/HttpMessageHandler.uno index 1fce4acbf..9d7d2fb24 100644 --- a/lib/Uno.Net.Http/HttpMessageHandler.uno +++ b/lib/Uno.Net.Http/HttpMessageHandler.uno @@ -14,7 +14,7 @@ namespace Uno.Net.Http internal static void IncrementPendingRequests() { - if defined(CIL || LINUX || MSVC12) + if defined(CIL || LINUX || MSVC) { lock (_syncLock) { @@ -26,7 +26,7 @@ namespace Uno.Net.Http internal static void DecrementPendingRequests() { - if defined(CIL || LINUX || MSVC12) + if defined(CIL || LINUX || MSVC) { lock (_syncLock) { @@ -40,7 +40,7 @@ namespace Uno.Net.Http { if defined(CIL) CilHttpMessageHandler.ProcessEvents(); - if defined(LINUX || MSVC12) + if defined(LINUX || MSVC) XliHttpMessageHandler.ProcessEvents(); } } diff --git a/lib/Uno.Net.Http/HttpMessageHandlerRequest.uno b/lib/Uno.Net.Http/HttpMessageHandlerRequest.uno index e35383518..6247e03f0 100644 --- a/lib/Uno.Net.Http/HttpMessageHandlerRequest.uno +++ b/lib/Uno.Net.Http/HttpMessageHandlerRequest.uno @@ -40,7 +40,7 @@ namespace Uno.Net.Http if defined(ANDROID) _httpRequest = new AndroidHttpRequest(this, method, url); - if defined(LINUX || MSVC12) + if defined(LINUX || MSVC) _httpRequest = new XliHttpRequest(this, method, url); if defined(APPLE) _httpRequest = new iOSHttpRequest(this, method, url); diff --git a/lib/Uno.Net.Http/Implementation/Xli/XliHttpRequest.cpp.uxl b/lib/Uno.Net.Http/Implementation/Xli/XliHttpRequest.cpp.uxl index ce09468f3..c5e7224d9 100644 --- a/lib/Uno.Net.Http/Implementation/Xli/XliHttpRequest.cpp.uxl +++ b/lib/Uno.Net.Http/Implementation/Xli/XliHttpRequest.cpp.uxl @@ -1,4 +1,4 @@ - + diff --git a/lib/Uno.Net.Http/Implementation/Xli/XliHttpRequest.uno b/lib/Uno.Net.Http/Implementation/Xli/XliHttpRequest.uno index 154680cc5..23498ba0b 100644 --- a/lib/Uno.Net.Http/Implementation/Xli/XliHttpRequest.uno +++ b/lib/Uno.Net.Http/Implementation/Xli/XliHttpRequest.uno @@ -4,17 +4,17 @@ using Uno.Compiler.ExportTargetInterop; namespace Uno.Net.Http.Implementation { [TargetSpecificType] - extern(LINUX || MSVC12) struct XliHttpClientHandle + extern(LINUX || MSVC) struct XliHttpClientHandle { } [TargetSpecificType] - extern(LINUX || MSVC12) struct XliHttpRequestHandle + extern(LINUX || MSVC) struct XliHttpRequestHandle { } [TargetSpecificImplementation] - internal extern(LINUX || MSVC12) static class XliHttpMessageHandler + internal extern(LINUX || MSVC) static class XliHttpMessageHandler { internal static XliHttpClientHandle _clientHandle; @@ -33,7 +33,7 @@ namespace Uno.Net.Http.Implementation } [TargetSpecificImplementation] - internal extern(LINUX || MSVC12) class XliHttpRequest : IHttpRequest + internal extern(LINUX || MSVC) class XliHttpRequest : IHttpRequest { HttpMessageHandlerRequest _request; XliHttpRequestHandle _requestHandle; From e3ea1d0b403b0db549a7e2d38bdbe4498324af18 Mon Sep 17 00:00:00 2001 From: Morten Daniel Fornes Date: Tue, 13 Nov 2018 03:39:17 +0700 Subject: [PATCH 19/71] Uno.Net.Sockets: check MSVC instead of MSVC12 MSVC12 is deprecated so check the unversioned define instead. --- lib/Uno.Net.Sockets/Dns.uno | 2 +- lib/Uno.Net.Sockets/Socket.uno | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/Uno.Net.Sockets/Dns.uno b/lib/Uno.Net.Sockets/Dns.uno index 6b13ebade..2fdeed09a 100644 --- a/lib/Uno.Net.Sockets/Dns.uno +++ b/lib/Uno.Net.Sockets/Dns.uno @@ -135,7 +135,7 @@ namespace Uno.Net (hostNameOrAddress.Length == 255 && hostNameOrAddress[254] != '.')) throw new ArgumentOutOfRangeException("hostNameOrAddress"); - if defined(MSVC12) + if defined(MSVC) NetworkHelpers.EnsureWinsockInitialized(); if defined(CPLUSPLUS) diff --git a/lib/Uno.Net.Sockets/Socket.uno b/lib/Uno.Net.Sockets/Socket.uno index d916953d5..d9fe3fb51 100644 --- a/lib/Uno.Net.Sockets/Socket.uno +++ b/lib/Uno.Net.Sockets/Socket.uno @@ -291,7 +291,7 @@ namespace Uno.Net.Sockets { if defined(CPLUSPLUS) { - if defined(MSVC12) + if defined(MSVC) NetworkHelpers.EnsureWinsockInitialized(); var family = SocketHelpers.GetFamily(addressFamily); @@ -541,7 +541,7 @@ namespace Uno.Net.Sockets if defined(CPLUSPLUS) { int result; - if defined(MSVC12) + if defined(MSVC) result = extern(_handle) "closesocket($0)"; else result = extern(_handle) "close($0)"; From dae22158873e4a7221e6f01027dcb328186546b8 Mon Sep 17 00:00:00 2001 From: Morten Daniel Fornes Date: Tue, 13 Nov 2018 03:43:39 +0700 Subject: [PATCH 20/71] Uno.Net.Sockets: check for UNIX instead of !MSVC This seems more descriptive. --- lib/Uno.Net.Sockets/Dns.uno | 8 ++++---- lib/Uno.Net.Sockets/IPAddress.uno | 2 +- lib/Uno.Net.Sockets/NetworkHelpers.uno | 4 ++-- lib/Uno.Net.Sockets/Socket.uno | 24 ++++++++++++------------ 4 files changed, 19 insertions(+), 19 deletions(-) diff --git a/lib/Uno.Net.Sockets/Dns.uno b/lib/Uno.Net.Sockets/Dns.uno index 2fdeed09a..487b7db2a 100644 --- a/lib/Uno.Net.Sockets/Dns.uno +++ b/lib/Uno.Net.Sockets/Dns.uno @@ -7,9 +7,9 @@ namespace Uno.Net { [DotNetType("System.Net.Dns")] [extern(APPLE) Require("Source.Include", "ifaddrs.h")] - [extern(!MSVC) Require("Source.Include", "sys/socket.h")] - [extern(!MSVC) Require("Source.Include", "netdb.h")] - [extern(!MSVC) Require("Source.Include", "netinet/in.h")] + [extern(UNIX) Require("Source.Include", "sys/socket.h")] + [extern(UNIX) Require("Source.Include", "netdb.h")] + [extern(UNIX) Require("Source.Include", "netinet/in.h")] [extern(MSVC) Require("Source.Include", "ws2tcpip.h")] [Require("Source.Include", "vector")] [ForeignInclude(Language.Java, "java.util.*", "java.net.*")] @@ -140,7 +140,7 @@ namespace Uno.Net if defined(CPLUSPLUS) { - if defined(!MSVC) + if defined(UNIX) { if (hostNameOrAddress.Length == 0) { diff --git a/lib/Uno.Net.Sockets/IPAddress.uno b/lib/Uno.Net.Sockets/IPAddress.uno index c10c0da7c..e5b62619b 100644 --- a/lib/Uno.Net.Sockets/IPAddress.uno +++ b/lib/Uno.Net.Sockets/IPAddress.uno @@ -41,7 +41,7 @@ namespace Uno.Net } - [extern(!MSVC) Require("Source.Include", "arpa/inet.h")] + [extern(UNIX) Require("Source.Include", "arpa/inet.h")] [extern(MSVC) Require("Source.Include", "ws2tcpip.h")] [DotNetType("System.Net.IPAddress")] public class IPAddress diff --git a/lib/Uno.Net.Sockets/NetworkHelpers.uno b/lib/Uno.Net.Sockets/NetworkHelpers.uno index a435dd64b..3af813dd0 100644 --- a/lib/Uno.Net.Sockets/NetworkHelpers.uno +++ b/lib/Uno.Net.Sockets/NetworkHelpers.uno @@ -4,7 +4,7 @@ namespace Uno.Net { [extern(MSVC) Require("Source.Include", "winsock2.h")] [extern(MSVC) Require("LinkLibrary", "ws2_32")] - [extern(!MSVC) Require("Source.Include", "errno.h")] + [extern(UNIX) Require("Source.Include", "errno.h")] extern(CPLUSPLUS) internal class NetworkHelpers { extern(MSVC) public static string GetError() @@ -24,7 +24,7 @@ namespace Uno.Net return ret; @} - extern(!MSVC) public static string GetError() + extern(UNIX) public static string GetError() @{ return uString::Utf8(strerror(errno)); @} diff --git a/lib/Uno.Net.Sockets/Socket.uno b/lib/Uno.Net.Sockets/Socket.uno index d9fe3fb51..0302378b5 100644 --- a/lib/Uno.Net.Sockets/Socket.uno +++ b/lib/Uno.Net.Sockets/Socket.uno @@ -47,12 +47,12 @@ namespace Uno.Net.Sockets None = 0 } - [extern(!MSVC) Require("Source.Include", "sys/socket.h")] + [extern(UNIX) Require("Source.Include", "sys/socket.h")] [extern(MSVC) Require("Source.Declaration", "typedef ULONG in_addr_t;")] [extern(MSVC) Require("Source.Declaration", "#define SHUT_RD SD_RECEIVE")] [extern(MSVC) Require("Source.Declaration", "#define SHUT_WR SD_SEND")] [extern(MSVC) Require("Source.Declaration", "#define SHUT_RDWR SD_BOTH")] - [extern(!MSVC) Require("Source.Include", "errno.h")] + [extern(UNIX) Require("Source.Include", "errno.h")] extern(CPLUSPLUS) internal class SocketHelpers { public static int GetFamily(AddressFamily addressFamily) @@ -228,7 +228,7 @@ namespace Uno.Net.Sockets return ret; @} - extern(!MSVC) public static int Ioctl(Socket.SocketHandle sock, int request, out int arg) + extern(UNIX) public static int Ioctl(Socket.SocketHandle sock, int request, out int arg) @{ return ioctl(sock, request, arg); @} @@ -241,7 +241,7 @@ namespace Uno.Net.Sockets return result; @} - extern(!MSVC) public static int Shutdown(Socket.SocketHandle sock, int how) + extern(UNIX) public static int Shutdown(Socket.SocketHandle sock, int how) @{ int result = shutdown(sock, how); if (result < 0 && errno == ENOTCONN) @@ -254,19 +254,19 @@ namespace Uno.Net.Sockets [extern(MSVC) Require("Header.Include", "ws2tcpip.h")] [extern(MSVC) Require("LinkLibrary", "ws2_32")] [extern(ANDROID) Require("Source.Include", "arpa/inet.h")] - [extern(!MSVC) Require("Source.Include", "netdb.h")] - [extern(!MSVC) Require("Source.Include", "netinet/in.h")] - [extern(!MSVC) Require("Source.Include", "sys/ioctl.h")] - [extern(!MSVC) Require("Source.Include", "sys/socket.h")] - [extern(!MSVC) Require("Source.Include", "sys/types.h")] - [extern(!MSVC) Require("Source.Include", "unistd.h")] + [extern(UNIX) Require("Source.Include", "netdb.h")] + [extern(UNIX) Require("Source.Include", "netinet/in.h")] + [extern(UNIX) Require("Source.Include", "sys/ioctl.h")] + [extern(UNIX) Require("Source.Include", "sys/socket.h")] + [extern(UNIX) Require("Source.Include", "sys/types.h")] + [extern(UNIX) Require("Source.Include", "unistd.h")] public class Socket : IDisposable { [TargetSpecificType] [extern(MSVC) Set("TypeName", "SOCKET")] [extern(MSVC) Set("DefaultValue", "INVALID_SOCKET")] - [extern(CPLUSPLUS && !MSVC) Set("TypeName", "int")] - [extern(CPLUSPLUS && !MSVC) Set("DefaultValue", "-1")] + [extern(CPLUSPLUS && UNIX) Set("TypeName", "int")] + [extern(CPLUSPLUS && UNIX) Set("DefaultValue", "-1")] extern(CPLUSPLUS) internal struct SocketHandle { public static readonly SocketHandle Invalid; From c45b9922ae185b37806b02ca74ef82850af44069 Mon Sep 17 00:00:00 2001 From: Morten Daniel Fornes Date: Mon, 14 Jan 2019 10:42:17 +0700 Subject: [PATCH 21/71] disable C# tests on Travis The C# test runner have (randomly) failed a lot on Travis lately, even if all tests have actually passed, with the following error message: NUnit.Engine.NUnitEngineUnloadException : Multiple exceptions encountered. Retrieve AggregatedExceptions property for more information ----> System.Runtime.Remoting.RemotingException : Tcp transport error. ----> System.Runtime.Remoting.RemotingException : Connection closed The command "mono NUnit.ConsoleRunner.3.8.0/tools/nunit3-console.exe --agents=1 \ src/testing/Uno.TestRunner.Tests/bin/Debug/Uno.TestRunner.Tests.dll \ src/ux/Uno.UX.Markup.AST/Tests/bin/Debug/Uno.UX.Markup.AST.Tests.dll \ src/ux/Uno.UX.Markup.UXIL/Tests/bin/Debug/Uno.UX.Markup.UXIL.Tests.dll " exited with 251. The C# tests are run on AppVeyor in any case. I think that is safe enough and that we can simply stop running these tests on Travis to avoid this problem. --- .travis.yml | 8 -------- 1 file changed, 8 deletions(-) diff --git a/.travis.yml b/.travis.yml index 73a059ff7..bf1de628a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,20 +8,12 @@ env: - TARGET=dotnet - TARGET=native -install: - - nuget install NUnit.ConsoleRunner -Version 3.8.0 - before_script: - ulimit -c unlimited -S - rm -rf /cores/core.* script: - scripts/build.sh - - | - mono NUnit.ConsoleRunner.3.8.0/tools/nunit3-console.exe --agents=1 \ - src/testing/Uno.TestRunner.Tests/bin/Debug/Uno.TestRunner.Tests.dll \ - src/ux/Uno.UX.Markup.AST/Tests/bin/Debug/Uno.UX.Markup.AST.Tests.dll \ - src/ux/Uno.UX.Markup.UXIL/Tests/bin/Debug/Uno.UX.Markup.UXIL.Tests.dll - bin/uno test --target=$TARGET lib - bin/uno test-gen lib /tmp/PackageCompilationTest - bin/uno build --target=$TARGET --no-strip /tmp/PackageCompilationTest From 0eb66d6b624bfa76b771dd358a2319c1dde9f8cc Mon Sep 17 00:00:00 2001 From: Morten Daniel Fornes Date: Fri, 26 Oct 2018 22:25:49 +0700 Subject: [PATCH 22/71] Android: add google repository to all projects #130 Myself and others have occasionally experienced trouble when downloading dependencies when building for Android, and this seems to fix the problem. I haven't seen this problem in a while and it seems to have been caused by temporary issues on Google servers, but it doesn't cause any harm to add the fix anyway, hopefully avoiding similar trouble in the future. --- lib/UnoCore/Targets/Android/Dependencies.uxl | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/UnoCore/Targets/Android/Dependencies.uxl b/lib/UnoCore/Targets/Android/Dependencies.uxl index ce5e348c2..5d2bd6e78 100644 --- a/lib/UnoCore/Targets/Android/Dependencies.uxl +++ b/lib/UnoCore/Targets/Android/Dependencies.uxl @@ -1,5 +1,6 @@ + From 67b7cfd22e4b4a567872f6080dd3c6fef7da689a Mon Sep 17 00:00:00 2001 From: Morten Daniel Fornes Date: Thu, 10 May 2018 03:48:10 +0200 Subject: [PATCH 23/71] drop legacy bat scripts We have cross-platform bash scripts doing the same tasks, and to avoid inconsistency and to simplify maintenance work, I think it's time to say goodbye. It's also possible to open uno.sln in Visual Studio and build without bash. --- build.bat | 21 -------------------- scripts/build-unocore-csproj.bat | 33 -------------------------------- scripts/peverify-dlls.bat | 9 --------- scripts/test.bat | 5 ----- 4 files changed, 68 deletions(-) delete mode 100644 build.bat delete mode 100644 scripts/build-unocore-csproj.bat delete mode 100644 scripts/peverify-dlls.bat delete mode 100644 scripts/test.bat diff --git a/build.bat b/build.bat deleted file mode 100644 index 84296057f..000000000 --- a/build.bat +++ /dev/null @@ -1,21 +0,0 @@ -@echo off -:: Please see Makefile for more build options. They also work on Windows. Usually. -pushd "%~dp0" -set MSBUILD=%PROGRAMFILES(X86)%\MSBuild\14.0\bin\MSBuild -set UNO=bin\uno - -echo. -echo WARNING: This script is deprecated, please run 'make' or 'bash scripts/build.sh' instead -echo. - -:: Do required things || goto ERROR -"%MSBUILD%" /m uno.sln || goto MSBUILD_ERROR -%UNO% doctor -e || goto ERROR -popd && exit /b 0 - -:MSBUILD_ERROR -echo Note: If a command was not found, please make sure you have Microsoft Build Tools 2015 installed (C# 6/.NET 4.5 support) - -:ERROR -echo BUILD FAILED! -popd && pause && exit /b 1 diff --git a/scripts/build-unocore-csproj.bat b/scripts/build-unocore-csproj.bat deleted file mode 100644 index 608acae5c..000000000 --- a/scripts/build-unocore-csproj.bat +++ /dev/null @@ -1,33 +0,0 @@ -@echo off -:: Note to BASH users: -:: Non-cmd.exe users should use 'make unocore' or 'bash build.sh --unocore' instead. -:: This Windows port is only for the weak. -pushd "%~dp0.." -set SRC_DIR=lib\UnoCore -set OUT_DIR=%SRC_DIR%\build\corelib\Debug -set DST_DIR=src\runtime\Uno.Runtime.Core -set MSBUILD=%PROGRAMFILES(X86)%\MSBuild\14.0\bin\MSBuild -set UNO=bin\uno - -:: Build uno.exe -"%MSBUILD%" /m /p:Configuration=Debug uno.sln || goto ERROR - -:: Build Uno project -%UNO% build corelib %SRC_DIR% || goto ERROR - -:: Build VS project -"%MSBUILD%" /m %OUT_DIR%\Uno.Runtime.Core.sln || goto ERROR - -:: Replace VS project -rd /s /q %OUT_DIR%\bin -rd /s /q %OUT_DIR%\obj -del /f /s /q %DST_DIR%\* -xcopy /y /s /r /h %OUT_DIR%\* %DST_DIR%\* || goto ERROR -del /f /s /q %DST_DIR%\*.sln - -:: Done -popd && exit /b 0 - -:ERROR -pause -popd && exit /b 1 diff --git a/scripts/peverify-dlls.bat b/scripts/peverify-dlls.bat deleted file mode 100644 index 263097524..000000000 --- a/scripts/peverify-dlls.bat +++ /dev/null @@ -1,9 +0,0 @@ -@echo off -for /r %~dp0\.. %%x in (*Test.dll) do peverify "%%x" || goto ERROR - -exit /b 0 - -:ERROR -echo. -echo ERROR: peverify returned non-zero! -exit /b 1 diff --git a/scripts/test.bat b/scripts/test.bat deleted file mode 100644 index e38fa7820..000000000 --- a/scripts/test.bat +++ /dev/null @@ -1,5 +0,0 @@ -@echo off - -%~dp0\..\bin\uno test %~dp0\..\lib -%~dp0\..\bin\uno test-gen %~dp0\..\lib %TEMP%\PackageCompilationTest -%~dp0\..\bin\uno build --target=dotnetexe --no-strip --clean %TEMP%\PackageCompilationTest From c86b91244f1c80e3f3bfe9f710147722e93f92d2 Mon Sep 17 00:00:00 2001 From: Morten Daniel Fornes Date: Sun, 25 Nov 2018 19:52:03 +0700 Subject: [PATCH 24/71] C++: switch to size_t in uArray and uString size_t is commonly used to represent indices and lengths in C/C++ code, and instead of adding casts to int32_t, we change the interface of uArray and uString to accept size_t. This seems to align better with a lot of C/C++ code, and is non-breaking since int32_t implicitly converts to size_t and vice versa. Since many call sites were size_t to begin with we can remove some explicit casts to int32_t, and since we can remove some often called "< 0" checks the code is in theory a bit faster now than it was before. This fixes a few instances of the following warning: warning C4267: 'argument': conversion from 'size_t' to 'int32_t', possible loss of data --- lib/Uno.Net.Sockets/Dns.uno | 2 +- lib/UnoCore/Backends/CPlusPlus/Uno/Memory.cpp | 4 +- .../Backends/CPlusPlus/Uno/ObjectModel.cpp | 30 +++++------ .../Backends/CPlusPlus/Uno/ObjectModel.h | 50 +++++++++---------- .../Foreign/ObjC/uObjC.String.mm | 4 +- lib/UnoCore/Source/Uno/String.uno | 6 +-- lib/UnoCore/Source/Uno/Text/Utf8.uno | 2 +- lib/UnoCore/Source/Uno/Type.uno | 4 +- 8 files changed, 51 insertions(+), 51 deletions(-) diff --git a/lib/Uno.Net.Sockets/Dns.uno b/lib/Uno.Net.Sockets/Dns.uno index 6b13ebade..02a926923 100644 --- a/lib/Uno.Net.Sockets/Dns.uno +++ b/lib/Uno.Net.Sockets/Dns.uno @@ -123,7 +123,7 @@ namespace Uno.Net } freeaddrinfo(addr); - return uArray::New(@{IPAddress[]:TypeOf}, (@{int})addresses.size(), &addresses[0]); + return uArray::New(@{IPAddress[]:TypeOf}, addresses.size(), &addresses[0]); @} public static IPAddress[] GetHostAddresses(string hostNameOrAddress) diff --git a/lib/UnoCore/Backends/CPlusPlus/Uno/Memory.cpp b/lib/UnoCore/Backends/CPlusPlus/Uno/Memory.cpp index fe65d1c74..cebd974ba 100644 --- a/lib/UnoCore/Backends/CPlusPlus/Uno/Memory.cpp +++ b/lib/UnoCore/Backends/CPlusPlus/Uno/Memory.cpp @@ -723,7 +723,7 @@ uObject* uNew(uType* type, size_t size) return uInitObject(type, calloc(1, size), size); } -static uString* uInitString(int32_t length) +static uString* uInitString(size_t length) { size_t size = sizeof(uString) + sizeof(char16_t) * length + sizeof(char16_t); uString* string = (uString*)uInitObject(@{string:TypeOf}, calloc(1, size), size); @@ -732,7 +732,7 @@ static uString* uInitString(int32_t length) return string; } -uString* uString::New(int32_t length) +uString* uString::New(size_t length) { if (length == 0) { diff --git a/lib/UnoCore/Backends/CPlusPlus/Uno/ObjectModel.cpp b/lib/UnoCore/Backends/CPlusPlus/Uno/ObjectModel.cpp index be49ddefd..cb3b24bed 100644 --- a/lib/UnoCore/Backends/CPlusPlus/Uno/ObjectModel.cpp +++ b/lib/UnoCore/Backends/CPlusPlus/Uno/ObjectModel.cpp @@ -953,7 +953,7 @@ uClassType* uClassType::New(const char* name, uTypeOptions& options) uString* uString::Ansi(const char* cstr, size_t length) { - uString* string = New((int32_t)length); + uString* string = New(length); for (size_t i = 0; i < length; i++) string->_ptr[i] = (char16_t)cstr[i]; @@ -1010,7 +1010,7 @@ uString* uString::Utf8(const char* mutf8, size_t length) } // Convert UTF-8 to UTF-16 - uString* string = New((int32_t) length); + uString* string = New(length); const UTF8* src_p = (const UTF8*)src; UTF16* dst_p = (UTF16*)string->_ptr; @@ -1024,7 +1024,7 @@ uString* uString::Utf8(const char* mutf8, size_t length) if (src != mutf8) free(src); - string->_length = (int32_t)(dst_p - (UTF16*)string->_ptr); + string->_length = (size_t)(dst_p - (UTF16*)string->_ptr); string->_ptr[string->_length] = 0; return string; } @@ -1038,7 +1038,7 @@ uString* uString::Utf8(const char* mutf8) uString* uString::Utf16(const char16_t* utf16, size_t length) { - uString* string = New((int32_t)length); + uString* string = New(length); memcpy(string->_ptr, utf16, sizeof(char16_t) * length); return string; } @@ -1069,15 +1069,15 @@ uString* uString::CharArray(const uArray* array) return string; } -uString* uString::CharArrayRange(const uArray* array, int32_t startIndex, int32_t length) +uString* uString::CharArrayRange(const uArray* array, size_t startIndex, size_t length) { if (!array) throw uThrowable(@{Uno.ArgumentNullException(string):New(uString::Utf8("array"))}, __FILE__, __LINE__); - if (startIndex < 0 || startIndex > array->Length()) + if (startIndex > array->_length) throw uThrowable(@{Uno.ArgumentOutOfRangeException(string):New(uString::Utf8("startIndex"))}, __FILE__, __LINE__); - if (length < 0 || startIndex + length > array->Length()) + if (startIndex + length > array->_length) throw uThrowable(@{Uno.ArgumentOutOfRangeException(string):New(uString::Utf8("length"))}, __FILE__, __LINE__); U_ASSERT(array->GetType() == @{char[]:TypeOf}); @@ -1101,11 +1101,11 @@ uString* uString::Const(const char* mutf8) return string; } -static bool uCompareCharStrings(const char16_t* a, const char16_t* b, int32_t length, bool ignoreCase) +static bool uCompareCharStrings(const char16_t* a, const char16_t* b, size_t length, bool ignoreCase) { if (ignoreCase) { - for (int32_t i = 0; i < length; i++) + for (size_t i = 0; i < length; i++) if (a[i] != b[i] && @{char.ToUpper(char):Call(a[i])} != @{char.ToUpper(char):Call(b[i])}) return false; @@ -1718,7 +1718,7 @@ uDelegate* uDelegate::New(uType* type, const uInterface& iface, size_t offset, u return New(type, iface._object, (size_t)((uint8_t*)iface._vtable - (uint8_t*)iface._object->__type) + offset, generic); } -void uArray::MarshalPtr(int32_t index, const void* value, size_t size) +void uArray::MarshalPtr(size_t index, const void* value, size_t size) { uType* type = ((uArrayType*)__type)->ElementType; void* item = (uint8_t*)_ptr + type->ValueSize * index; @@ -1769,13 +1769,13 @@ void uArray::MarshalPtr(int32_t index, const void* value, size_t size) } } -uArray* uArray::InitT(uType* type, int32_t length, ...) +uArray* uArray::InitT(uType* type, size_t length, ...) { va_list ap; va_start(ap, length); uArray* array = New(type, length); - for (int32_t i = 0; i < length; i++) + for (size_t i = 0; i < length; i++) { const void* src = va_arg(ap, const void*); array->TUnsafe(i) = src; @@ -1785,7 +1785,7 @@ uArray* uArray::InitT(uType* type, int32_t length, ...) return array; } -uArray* uArray::New(uType* type, int32_t length, const void* optionalData) +uArray* uArray::New(uType* type, size_t length, const void* optionalData) { U_ASSERT(type && type->Type == uTypeTypeArray); uArrayType* arrayType = (uArrayType*)type; @@ -1800,10 +1800,10 @@ uArray* uArray::New(uType* type, int32_t length, const void* optionalData) memcpy(array->Ptr(), optionalData, elementSize * length); if (U_IS_OBJECT(elementType)) - for (int32_t i = 0; i < length; i++) + for (size_t i = 0; i < length; i++) uRetain(((uObject**)array->Ptr())[i]); else if (elementType->Flags & uTypeFlagsRetainStruct) - for (int32_t i = 0; i < length; i++) + for (size_t i = 0; i < length; i++) uRetainStruct(elementType, (uint8_t*)array->Ptr() + elementType->ValueSize * i); } diff --git a/lib/UnoCore/Backends/CPlusPlus/Uno/ObjectModel.h b/lib/UnoCore/Backends/CPlusPlus/Uno/ObjectModel.h index b66b8570b..50c45b6ce 100644 --- a/lib/UnoCore/Backends/CPlusPlus/Uno/ObjectModel.h +++ b/lib/UnoCore/Backends/CPlusPlus/Uno/ObjectModel.h @@ -477,52 +477,52 @@ struct uArrayType : uType struct uArray : uObject { void* _ptr; - int32_t _length; + size_t _length; - int32_t Length() const { return _length; } + int32_t Length() const { return (int32_t) _length; } const void* Ptr() const { return _ptr; } void* Ptr() { return _ptr; } - void MarshalPtr(int32_t index, const void* value, size_t size); - uTField TItem(int32_t index); - uTField TUnsafe(int32_t index); + void MarshalPtr(size_t index, const void* value, size_t size); + uTField TItem(size_t index); + uTField TUnsafe(size_t index); template - T& Item(int32_t index) { + T& Item(size_t index) { U_ASSERT(sizeof(T) == ((uArrayType*)__type)->ElementType->ValueSize); - if (index < 0 || index >= _length) + if (index >= _length) U_THROW_IOORE(); return ((T*)_ptr)[index]; } template - uStrong& Strong(int32_t index) { + uStrong& Strong(size_t index) { U_ASSERT(sizeof(T) == ((uArrayType*)__type)->ElementType->ValueSize); - if (index < 0 || index >= _length) + if (index >= _length) U_THROW_IOORE(); return ((uStrong*)_ptr)[index]; } template - T& Unsafe(int32_t index) { + T& Unsafe(size_t index) { U_ASSERT(sizeof(T) == ((uArrayType*)__type)->ElementType->ValueSize && index >= 0 && index < _length); return ((T*)_ptr)[index]; } template - uStrong& UnsafeStrong(int32_t index) { + uStrong& UnsafeStrong(size_t index) { U_ASSERT(sizeof(T) == ((uArrayType*)__type)->ElementType->ValueSize && index >= 0 && index < _length); return ((uStrong*)_ptr)[index]; } - static uArray* New(uType* type, int32_t length, const void* optionalData = NULL); - static uArray* InitT(uType* type, int32_t length, ...); + static uArray* New(uType* type, size_t length, const void* optionalData = NULL); + static uArray* InitT(uType* type, size_t length, ...); template - static uArray* Init(uType* type, int32_t length, ...) { + static uArray* Init(uType* type, size_t length, ...) { va_list ap; va_start(ap, length); uArray* array = New(type, length); - for (int32_t i = 0; i < length; i++) { + for (size_t i = 0; i < length; i++) { T item = va_arg(ap, T); array->MarshalPtr(i, &item, sizeof(T)); } @@ -539,21 +539,21 @@ struct uArray : uObject struct uString : uObject { char16_t* _ptr; - int32_t _length; + size_t _length; - int32_t Length() const { return _length; } + int32_t Length() const { return (int32_t) _length; } const char16_t* Ptr() const { return _ptr; } - const char16_t& Item(int32_t index) const { - if (index < 0 || index >= _length) + const char16_t& Item(size_t index) const { + if (index >= _length) U_THROW_IOORE(); return _ptr[index]; } - const char16_t& Unsafe(int32_t index) const { + const char16_t& Unsafe(size_t index) const { return _ptr[index]; } - static uString* New(int32_t length); + static uString* New(size_t length); static uString* Ansi(const char* cstr); static uString* Ansi(const char* cstr, size_t length); static uString* Utf8(const char* mutf8); @@ -562,7 +562,7 @@ struct uString : uObject static uString* Utf16(const char16_t* utf16, size_t length); static uString* Const(const char* mutf8); static uString* CharArray(const uArray* chars); - static uString* CharArrayRange(const uArray* chars, int32_t startIndex, int32_t length); + static uString* CharArrayRange(const uArray* chars, size_t startIndex, size_t length); static bool Equals(const uString* left, const uString* right, bool ignoreCase = false); }; @@ -810,12 +810,12 @@ inline uTPtr uUnboxAny(const uType* type, uObject* object) { ? (uint8_t*)uPtr(object) + sizeof(uObject) : (void*)object; } -inline uTField uArray::TItem(int32_t index) { - if (index < 0 || index >= _length) U_THROW_IOORE(); +inline uTField uArray::TItem(size_t index) { + if (index >= _length) U_THROW_IOORE(); uType* type = ((uArrayType*)__type)->ElementType; return uTField(type, (uint8_t*)_ptr + type->ValueSize * index); } -inline uTField uArray::TUnsafe(int32_t index) { +inline uTField uArray::TUnsafe(size_t index) { uType* type = ((uArrayType*)__type)->ElementType; return uTField(type, (uint8_t*)_ptr + type->ValueSize * index); } diff --git a/lib/UnoCore/Source/Uno/Compiler/ExportTargetInterop/Foreign/ObjC/uObjC.String.mm b/lib/UnoCore/Source/Uno/Compiler/ExportTargetInterop/Foreign/ObjC/uObjC.String.mm index e53706538..2cc7d0760 100644 --- a/lib/UnoCore/Source/Uno/Compiler/ExportTargetInterop/Foreign/ObjC/uObjC.String.mm +++ b/lib/UnoCore/Source/Uno/Compiler/ExportTargetInterop/Foreign/ObjC/uObjC.String.mm @@ -20,7 +20,7 @@ NSUInteger bytes = [string lengthOfBytesUsingEncoding: NativeUTF16Encoding]; - uString* result = uString::New((int)(bytes / sizeof(char16_t))); + uString* result = uString::New(bytes / sizeof(char16_t)); NSUInteger usedBytes = 0; if ([string @@ -34,7 +34,7 @@ { if (usedBytes != bytes) { - result->_length = (int)(usedBytes / sizeof(char16_t)); + result->_length = usedBytes / sizeof(char16_t); result->_ptr[result->_length] = 0; } return result; diff --git a/lib/UnoCore/Source/Uno/String.uno b/lib/UnoCore/Source/Uno/String.uno index bd30d544f..df00031da 100644 --- a/lib/UnoCore/Source/Uno/String.uno +++ b/lib/UnoCore/Source/Uno/String.uno @@ -507,7 +507,7 @@ namespace Uno public string PadLeft(int totalLength, char paddingSymbol) @{ - int padLength = $0 - $$->_length; + int padLength = $0 - $$->Length(); if (padLength <= 0) return $$; @@ -527,13 +527,13 @@ namespace Uno public string PadRight(int totalLength, char paddingSymbol) @{ - if ($0 <= $$->_length) + if ($0 <= $$->Length()) return $$; uString* result = uString::New($0); memcpy(result->_ptr, $$->_ptr, $$->_length * sizeof(@{char})); - for (int i = $$->_length; i < $0; i++) + for (int i = $$->Length(); i < $0; i++) result->_ptr[i] = $1; return result; diff --git a/lib/UnoCore/Source/Uno/Text/Utf8.uno b/lib/UnoCore/Source/Uno/Text/Utf8.uno index beda1b940..cca3505f5 100644 --- a/lib/UnoCore/Source/Uno/Text/Utf8.uno +++ b/lib/UnoCore/Source/Uno/Text/Utf8.uno @@ -296,7 +296,7 @@ namespace Uno.Text if defined(CPLUSPLUS) @{ uCString cstr($0); - return uArray::New(@{byte[]:TypeOf}, (int32_t) cstr.Length, cstr.Ptr); + return uArray::New(@{byte[]:TypeOf}, cstr.Length, cstr.Ptr); @} else if defined(DOTNET) return Encoding.UTF8.GetBytes(value); diff --git a/lib/UnoCore/Source/Uno/Type.uno b/lib/UnoCore/Source/Uno/Type.uno index d585d0f0a..8f989e966 100644 --- a/lib/UnoCore/Source/Uno/Type.uno +++ b/lib/UnoCore/Source/Uno/Type.uno @@ -223,7 +223,7 @@ namespace Uno { if defined(CPLUSPLUS) { - var array = new Type[extern "(int32_t) $$->GenericCount"]; + var array = new Type[extern "$$->GenericCount"]; for (int i = 0; i < array.Length; i++) array[i] = extern(i) "$$->Generics[$0]"; return array; @@ -244,7 +244,7 @@ namespace Uno { if defined(CPLUSPLUS) { - var array = new Type[extern "(int32_t) $$->InterfaceCount"]; + var array = new Type[extern "$$->InterfaceCount"]; for (int i = 0; i < array.Length; i++) array[i] = extern(i) "$$->Interfaces[$0].Type"; return array; From 6ee2c2519cf377d993b07a89bbf04ff091b3311a Mon Sep 17 00:00:00 2001 From: Morten Daniel Fornes Date: Sat, 1 Dec 2018 10:12:52 +0700 Subject: [PATCH 25/71] Uno.Build: don't return null in GetSourceDirectories() Now we can remove a null coalescing operator. --- src/engine/Uno.Build/Packages/LibraryBuilder.cs | 5 ++--- src/engine/Uno.Build/Packages/UpkBuilder.cs | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/engine/Uno.Build/Packages/LibraryBuilder.cs b/src/engine/Uno.Build/Packages/LibraryBuilder.cs index fc0811525..25375f5b9 100644 --- a/src/engine/Uno.Build/Packages/LibraryBuilder.cs +++ b/src/engine/Uno.Build/Packages/LibraryBuilder.cs @@ -37,16 +37,15 @@ public LibraryBuilder(Disk disk, BuildTarget target) public HashSet GetSourceDirectories(UnoConfig config = null) { + var sourceDirectories = new HashSet(); var configSourcePaths = (config ?? UnoConfig.Current).GetFullPathArray("Packages.SourcePaths", "PackageSourcePaths"); if (configSourcePaths.Length == 0) { Log.VeryVerbose("'Packages.SourcePaths' was not found in .unoconfig"); - return null; + return sourceDirectories; } - var sourceDirectories = new HashSet(); - foreach (var source in configSourcePaths) { if (!Directory.Exists(source)) diff --git a/src/engine/Uno.Build/Packages/UpkBuilder.cs b/src/engine/Uno.Build/Packages/UpkBuilder.cs index cc59f32fa..97b4eb81d 100644 --- a/src/engine/Uno.Build/Packages/UpkBuilder.cs +++ b/src/engine/Uno.Build/Packages/UpkBuilder.cs @@ -112,7 +112,7 @@ string GetBuildDirectory(Project project, out bool isUpToDate) try { var upper = project.FullPath.ToUpperInvariant(); - foreach (var source in _libBuilder.GetSourceDirectories(project.Config) ?? new HashSet()) + foreach (var source in _libBuilder.GetSourceDirectories(project.Config)) { if (upper.StartsWith(source.ToUpperInvariant())) { From 3b581f937183ac270d05fdfe4385edeef44dbcf3 Mon Sep 17 00:00:00 2001 From: Morten Daniel Fornes Date: Sat, 1 Dec 2018 10:23:19 +0700 Subject: [PATCH 26/71] uno doctor: specify source paths as arguments When the first argument is a directory name, global Packages.SourcePaths is ignored and we only build projects found in directories specified as arguments. Pass --force if you want to rebuild a package in Packages.SourcePaths and the name of the package collides with a directory name. --- Documentation/CommandLineReference.md | 9 ++++---- .../Uno.Build/Packages/LibraryBuilder.cs | 12 +++++++++-- src/main/Uno.CLI/Packages/Doctor.cs | 21 +++++++++++++------ 3 files changed, 29 insertions(+), 13 deletions(-) diff --git a/Documentation/CommandLineReference.md b/Documentation/CommandLineReference.md index bbde7bc60..44ca68a52 100644 --- a/Documentation/CommandLineReference.md +++ b/Documentation/CommandLineReference.md @@ -231,19 +231,19 @@ Usage: uno test-gen [--exclude=n ## $ uno doctor ``` -Usage: uno doctor [options] [package ...] +Usage: uno doctor [options] [source-dir|package-name ...] + or uno doctor [options] --force [package-name ...] Repair/rebuild packages found in search paths. Available options - -a, --all Build all projects, regardless of modification time - -f, --force Update all package caches, regardless of modification time + -a, --all Build all projects regardless of modification time + -f, --force Update package caches regardless of modification time -e, --express Express mode. Don't rebuild packages depending on a modified package -z, --clean Clean projects before building them -c, --configuration=NAME Set build configuration (Debug|Release) [optional] -b, --build-number=VERSION Override version for all packages built [optional] -C, --no-cache Disable in-memory AST & IL caches - -P, --no-parallel Disable multi-threading -s, --silent Very quiet build log ``` @@ -261,7 +261,6 @@ Install options -n, --version=STRING Install a specific version of -s, --source=URL Install from a specific source -f, --force Install a package even if already installed - -P, --no-parallel Disable multi-threading ``` ## $ uno uninstall diff --git a/src/engine/Uno.Build/Packages/LibraryBuilder.cs b/src/engine/Uno.Build/Packages/LibraryBuilder.cs index 25375f5b9..764b89cfe 100644 --- a/src/engine/Uno.Build/Packages/LibraryBuilder.cs +++ b/src/engine/Uno.Build/Packages/LibraryBuilder.cs @@ -18,6 +18,7 @@ public class LibraryBuilder : LogObject public bool RebuildAll; public bool SilentBuild; public bool CanCache = true; + public bool RebuiltListIsSourcePaths; public string Version; public BuildConfiguration? Configuration; public List RebuildList; @@ -38,6 +39,13 @@ public LibraryBuilder(Disk disk, BuildTarget target) public HashSet GetSourceDirectories(UnoConfig config = null) { var sourceDirectories = new HashSet(); + + if (RebuiltListIsSourcePaths) + { + sourceDirectories.AddRange(RebuildList); + return sourceDirectories; + } + var configSourcePaths = (config ?? UnoConfig.Current).GetFullPathArray("Packages.SourcePaths", "PackageSourcePaths"); if (configSourcePaths.Length == 0) @@ -224,7 +232,7 @@ List GetBuildList(IReadOnlyList all) foreach (var lib in dirty) AddDependenciesFirst(lib, list, added, dirty); - if (RebuildList != null) + if (RebuildList != null && !RebuiltListIsSourcePaths) foreach (var p in RebuildList) if (!_libMap.ContainsKey(p.ToUpperInvariant())) Log.Warning("Package " + p.Quote() + " was not found"); @@ -255,7 +263,7 @@ IEnumerable EnumerateDirty(IReadOnlyList all) if (RebuildAll) return all; - if (RebuildList != null) + if (RebuildList != null && !RebuiltListIsSourcePaths) foreach (var p in RebuildList) _dirty.Add(p.ToUpperInvariant()); diff --git a/src/main/Uno.CLI/Packages/Doctor.cs b/src/main/Uno.CLI/Packages/Doctor.cs index 05c1790b4..ccb987449 100644 --- a/src/main/Uno.CLI/Packages/Doctor.cs +++ b/src/main/Uno.CLI/Packages/Doctor.cs @@ -1,4 +1,5 @@ using System.Collections.Generic; +using System.IO; using Mono.Options; using Uno.Build; using Uno.Build.Packages; @@ -13,11 +14,12 @@ class Doctor : Command public override void Help() { - WriteUsage("[options] [package ...]"); + WriteUsage("[options] [source-dir|package-name ...]", + "[options] --force [package-name ...]"); WriteHead("Available options", 27); - WriteRow("-a, --all", "Build all projects, regardless of modification time"); - WriteRow("-f, --force", "Update all package caches, regardless of modification time"); + WriteRow("-a, --all", "Build all projects regardless of modification time"); + WriteRow("-f, --force", "Update package caches regardless of modification time"); WriteRow("-e, --express", "Express mode. Don't rebuild packages depending on a modified package"); WriteRow("-z, --clean", "Clean projects before building them"); WriteRow("-c, --configuration=NAME", "Set build configuration (Debug|Release)", true); @@ -43,9 +45,16 @@ public override void Execute(IEnumerable args) Log.ProductHeader(); - // Repair package caches first - new PackageDoctor(Log) - .Repair(lib.RebuildList, force); + // Interpret RebuildList as SourcePaths when a directory is specified. + if (!force && lib.RebuildList.Count > 0 && ( + Directory.Exists(lib.RebuildList[0]) || + lib.RebuildList[0].IndexOf('/') != -1 || + lib.RebuildList[0].IndexOf('\\') != -1)) + lib.RebuiltListIsSourcePaths = true; + // Repair package caches + else + new PackageDoctor(Log) + .Repair(lib.RebuildList, force); lib.Build(); } From 0cf9f50e4dd0d37ae29618edefb3668d5be15578 Mon Sep 17 00:00:00 2001 From: Morten Daniel Fornes Date: Sat, 1 Dec 2018 10:29:22 +0700 Subject: [PATCH 27/71] uno doctor: add --version option --version is more descriptive than --build-number since the value contains a complete version number (X.Y.Z-suffix) and not only a build number (N). Using --build-number will now print a deprecation warning. --- Documentation/CommandLineReference.md | 2 +- src/main/Uno.CLI/Packages/Doctor.cs | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Documentation/CommandLineReference.md b/Documentation/CommandLineReference.md index 44ca68a52..b5c69870d 100644 --- a/Documentation/CommandLineReference.md +++ b/Documentation/CommandLineReference.md @@ -242,7 +242,7 @@ Available options -e, --express Express mode. Don't rebuild packages depending on a modified package -z, --clean Clean projects before building them -c, --configuration=NAME Set build configuration (Debug|Release) [optional] - -b, --build-number=VERSION Override version for all packages built [optional] + -n, --version=X.Y.Z-SUFFIX Override version number for all packages built [optional] -C, --no-cache Disable in-memory AST & IL caches -s, --silent Very quiet build log ``` diff --git a/src/main/Uno.CLI/Packages/Doctor.cs b/src/main/Uno.CLI/Packages/Doctor.cs index ccb987449..006422ad0 100644 --- a/src/main/Uno.CLI/Packages/Doctor.cs +++ b/src/main/Uno.CLI/Packages/Doctor.cs @@ -23,7 +23,7 @@ public override void Help() WriteRow("-e, --express", "Express mode. Don't rebuild packages depending on a modified package"); WriteRow("-z, --clean", "Clean projects before building them"); WriteRow("-c, --configuration=NAME", "Set build configuration (Debug|Release)", true); - WriteRow("-b, --build-number=VERSION", "Override version for all packages built", true); + WriteRow("-n, --version=X.Y.Z-SUFFIX", "Override version number for all packages built", true); WriteRow("-C, --no-cache", "Disable in-memory AST & IL caches"); WriteRow("-s, --silent", "Very quiet build log"); } @@ -38,7 +38,8 @@ public override void Execute(IEnumerable args) { "x|e|express", value => lib.Express = true }, { "z|clean", value => lib.Clean = true }, { "c=|configuration=", value => lib.Configuration = value.ParseEnum("configuration") }, - { "b=|build-number=", value => lib.Version = value.ParseString("build-number") }, + { "b=|build-number=", value => { lib.Version = value.ParseString("build-number"); Log.Warning("--build-number is deprecated, please use --version instead."); }}, + { "n=|version=", value => lib.Version = value.ParseString("version") }, { "C|no-cache", value => lib.CanCache = false }, { "s|silent", value => lib.SilentBuild = true }, }.Parse(args); From 100fb180ad28c4cae14e64e50dd46fd63d0aa3cb Mon Sep 17 00:00:00 2001 From: Morten Daniel Fornes Date: Sat, 1 Dec 2018 10:31:14 +0700 Subject: [PATCH 28/71] build.sh: only build core library Pass core 'lib' directory to avoid conflicts with any user-specified Packages.SourcePaths, and switch to the new --version option. --- README.md | 2 +- scripts/build.sh | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 65c9eda7f..2c1a2df63 100644 --- a/README.md +++ b/README.md @@ -80,7 +80,7 @@ Uno is built using the command-line on Linux, macOS or Windows – or [from insi | Build command | Action | |:----------------------|:------------------------------------------------------------------| -| `make`[3] | Builds `uno` and standard library. Works on all platforms. | +| `make`[3] | Builds `uno` and core library. Works on all platforms. | 1. On Windows, we need [vswhere] to locate your Visual Studio 2017 installation. Please make sure we can find `vswhere` in `%PATH%` or at `%PROGRAMFILES(x86)%\Microsoft Visual Studio\Installer`. diff --git a/scripts/build.sh b/scripts/build.sh index a71eeca09..361a388be 100755 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -82,10 +82,10 @@ if [ "$BUILD_LIBRARY" = 1 ]; then # Get version number VERSION=`cat VERSION.txt` - h1 "Building standard library" + h1 "Building core library" if [ "$REBUILD_LIBRARY" = 1 ]; then - uno doctor -ac$CONFIGURATION --build-number=$VERSION + uno doctor -ac$CONFIGURATION --version=$VERSION lib else - uno doctor -ec$CONFIGURATION --build-number=$VERSION + uno doctor -ec$CONFIGURATION --version=$VERSION lib fi fi From f2cec6265fdee30d887fe74aac132e58c240624f Mon Sep 17 00:00:00 2001 From: Morten Daniel Fornes Date: Tue, 15 Jan 2019 12:39:39 +0700 Subject: [PATCH 29/71] Uno.Build: detect existing build of LibraryProject A LibraryProject could already be built with overridden version number, and maybe we don't have to build it again if the build is up-to-date. --- .../Uno.Build/Packages/LibraryBuilder.cs | 7 +++++ .../Uno.Build/Packages/LibraryProject.cs | 28 +++++++++++++++++-- 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/src/engine/Uno.Build/Packages/LibraryBuilder.cs b/src/engine/Uno.Build/Packages/LibraryBuilder.cs index 764b89cfe..caadb4746 100644 --- a/src/engine/Uno.Build/Packages/LibraryBuilder.cs +++ b/src/engine/Uno.Build/Packages/LibraryBuilder.cs @@ -299,6 +299,13 @@ bool IsDirty(LibraryProject lib) if (_dirty.Contains(lib.ToUpperInvariant())) return true; + // Check if a build with a different version number exists, possibly + // the project is already built using 'uno doctor --version=X.Y.Z'. + LibraryProject existing; + if (string.IsNullOrEmpty(Version) && lib.TryGetExistingBuild(out existing)) + // Test the existing build and maybe we don't need to built it again. + lib = existing; + if (!File.Exists(lib.PackageFile)) { Log.Event(IOEvent.Build, lib.Project.Name, "package not found"); diff --git a/src/engine/Uno.Build/Packages/LibraryProject.cs b/src/engine/Uno.Build/Packages/LibraryProject.cs index 69239a586..a3fd088d9 100644 --- a/src/engine/Uno.Build/Packages/LibraryProject.cs +++ b/src/engine/Uno.Build/Packages/LibraryProject.cs @@ -18,16 +18,40 @@ public class LibraryProject public bool Exists => File.Exists(PackageFile) && File.Exists(ConfigFile); public BuildConfiguration Configuration => (BuildConfiguration) Enum.Parse(typeof(BuildConfiguration), File.ReadAllText(ConfigFile).Trim()); - public LibraryProject(Project project, string source) + public LibraryProject(Project project, string sourceDir) { Project = project; - PackageDirectory = Path.Combine(source, "build", project.Name); + PackageDirectory = Path.Combine(sourceDir, "build", project.Name); VersionDirectory = Path.Combine(PackageDirectory, project.Version); CacheDirectory = Path.Combine(VersionDirectory, ".uno"); ConfigFile = Path.Combine(CacheDirectory, "config"); PackageFile = Path.Combine(CacheDirectory, "package"); } + LibraryProject(LibraryProject lib, string versionDir) + { + Project = lib.Project; + PackageDirectory = lib.PackageDirectory; + VersionDirectory = versionDir; + CacheDirectory = Path.Combine(VersionDirectory, ".uno"); + ConfigFile = Path.Combine(CacheDirectory, "config"); + PackageFile = Path.Combine(CacheDirectory, "package"); + } + + public bool TryGetExistingBuild(out LibraryProject existing) + { + existing = null; + if (!Directory.Exists(PackageDirectory)) + return false; + + var versions = Directory.EnumerateDirectories(PackageDirectory).ToArray(); + if (versions.Length != 1) + return false; + + existing = new LibraryProject(this, versions[0]); + return true; + } + int? _hash; public override int GetHashCode() { From 2af2b3e1964d17184bc25318afcd262a2ef161e3 Mon Sep 17 00:00:00 2001 From: Morten Daniel Fornes Date: Sun, 25 Nov 2018 18:26:03 +0700 Subject: [PATCH 30/71] run more tests on CI This fixes up test.sh and brings back UnoTest, UXTest and our old compiler tests, which are currently not being run. Both AppVeyor and Travis now run tests by invoking test.sh, which reduces duplication and seems to be cleaner than it was before. --- .appveyor.yml | 4 +--- .gitignore | 1 + .travis.yml | 4 +--- scripts/test.sh | 40 ++++++++++++++++++++++++++++++++++------ 4 files changed, 37 insertions(+), 12 deletions(-) diff --git a/.appveyor.yml b/.appveyor.yml index 0497fa9f5..8e07da2e1 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -29,12 +29,10 @@ before_test: Copy-Item -Path mesa\x64\opengl32.dll -Destination (Join-Path $buildDir opengl32.dll) } } - - bin\uno test-gen lib %TEMP%\PackageCompilationTest test_script: - nunit3-console src\testing\Uno.TestRunner.Tests\bin\Release\Uno.TestRunner.Tests.dll src\ux\Uno.UX.Markup.AST\Tests\bin\Release\Uno.UX.Markup.AST.Tests.dll src\ux\Uno.UX.Markup.UXIL\Tests\bin\Release\Uno.UX.Markup.UXIL.Tests.dll - - bin\uno test --target=%TARGET% lib - - bin\uno build --target=%TARGET% --no-strip %TEMP%\PackageCompilationTest + - bash scripts\test.sh %TARGET% diff --git a/.gitignore b/.gitignore index 07df9f948..bf369c831 100644 --- a/.gitignore +++ b/.gitignore @@ -43,6 +43,7 @@ build/ .uno/ .cache/ .stuff/ +.test/ .unobuild .vs/ **/bin/ diff --git a/.travis.yml b/.travis.yml index bf1de628a..411b5a28d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,9 +14,7 @@ before_script: script: - scripts/build.sh - - bin/uno test --target=$TARGET lib - - bin/uno test-gen lib /tmp/PackageCompilationTest - - bin/uno build --target=$TARGET --no-strip /tmp/PackageCompilationTest + - scripts/test.sh $TARGET after_failure: - for c in $(ls /cores/core.*); do diff --git a/scripts/test.sh b/scripts/test.sh index c249c1150..57222f73d 100755 --- a/scripts/test.sh +++ b/scripts/test.sh @@ -1,8 +1,36 @@ -#!/bin/sh +#!/bin/bash +SELF=`echo $0 | sed 's/\\\\/\\//g'` +cd "`dirname "$SELF"`/.." || exit 1 +source scripts/common.sh -ROOT=`dirname $0`/.. -COMPILATION_DIR=/tmp/PackageCompilationTest +# Arguments +TARGET=$1 -"$ROOT/bin/uno" test lib $* -"$ROOT/bin/uno" test-gen "$ROOT/lib" "$COMPILATION_DIR" -"$ROOT/bin/uno" build --target=cmake --no-strip --clean "$COMPILATION_DIR" +# Run uno tests +uno test $TARGET lib +uno test $TARGET tests/src/{Uno,UX}Test + +# Run compiler tests +function uno-compiler-test { + for config in Debug Release; do + exe=src/testing/Uno.CompilerTestRunner/bin/$config/uno-compiler-test.exe + if [ -f $exe ]; then + dotnet-clr $exe + return $? + fi + done + + echo "ERROR: uno-compiler-test.exe was not found" + return 1 +} + +uno-compiler-test + +# Check that all packages build without errors +function packages-build-test { + dir=.test/build-$1 + uno test-gen $1 $dir + uno build $TARGET --no-strip $dir +} + +packages-build-test lib From c1adc9819212eda759861ad63b974a7075bc6036 Mon Sep 17 00:00:00 2001 From: Morten Daniel Fornes Date: Thu, 17 Jan 2019 09:33:53 +0700 Subject: [PATCH 31/71] test.sh: skip {Uno,UX}Test when testing 'native' on AppVeyor Testing this currently fails with a "timed out" error. --- scripts/test.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/scripts/test.sh b/scripts/test.sh index 57222f73d..71c54d0f1 100755 --- a/scripts/test.sh +++ b/scripts/test.sh @@ -8,7 +8,11 @@ TARGET=$1 # Run uno tests uno test $TARGET lib -uno test $TARGET tests/src/{Uno,UX}Test + +# Skip when testing 'native' on AppVeyor +if [[ "$APPVEYOR" != True || "$TARGET" != native ]]; then + uno test $TARGET tests/src/{Uno,UX}Test +fi # Run compiler tests function uno-compiler-test { From 663ba5b9b54e20f9a1de7e04932b22a8fdf95705 Mon Sep 17 00:00:00 2001 From: Morten Daniel Fornes Date: Sun, 16 Dec 2018 05:17:28 +0700 Subject: [PATCH 32/71] pack.sh: drop creating packages --- .appveyor.yml | 4 ---- Makefile | 2 +- README.md | 2 +- scripts/pack.sh | 26 ++------------------------ 4 files changed, 4 insertions(+), 30 deletions(-) diff --git a/.appveyor.yml b/.appveyor.yml index 8e07da2e1..1412f9779 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -15,10 +15,6 @@ install: build_script: - bash -l scripts\pack.sh - - 7z a uno-artifacts-%APPVEYOR_BUILD_NUMBER%.zip upload\*.* - -artifacts: - - path: uno-artifacts-%APPVEYOR_BUILD_NUMBER%.zip before_test: - ps: | diff --git a/Makefile b/Makefile index f0f884712..45ec16da4 100644 --- a/Makefile +++ b/Makefile @@ -8,7 +8,7 @@ rebuild: all: @bash scripts/build.sh --all release: - @bash -l scripts/pack.sh + @bash scripts/pack.sh diagrams: @bash scripts/build-diagrams.sh check: diff --git a/README.md b/README.md index 2c1a2df63..43b6209e3 100644 --- a/README.md +++ b/README.md @@ -94,7 +94,7 @@ Uno is built using the command-line on Linux, macOS or Windows – or [from insi | Build command | Action | |:----------------|:------------------------------------------------------------------------| | `make install` | Creates a symlink for `uno` in `/usr/local/bin`. | -| `make release` | Creates a packaged release build for distribution. | +| `make release` | Prepares a release directory for distribution. | | `make unocore` | Generates C# code for Uno.Runtime.Core.dll, based on Uno code. | | `make clean` | Removes build artifacts from the repository and `Packages.SourcePaths`. | | `make check` | Runs the local test suite. | diff --git a/scripts/pack.sh b/scripts/pack.sh index e8a371a41..f290b5ec2 100755 --- a/scripts/pack.sh +++ b/scripts/pack.sh @@ -7,7 +7,6 @@ source scripts/common.sh DST="release" BIN="$DST/bin" LIB="$DST/lib" -OUT="upload" # Detect version info COMMIT=`git rev-parse HEAD` @@ -59,9 +58,9 @@ h1 "Preparing release" ###################### # Initialize -rm -rf ${BIN:?}/* ${LIB:?}/* ${OUT:?}/* +rm -rf ${BIN:?}/* ${LIB:?}/* rm ${DST:?}/* 2> /dev/null || : -mkdir -p $BIN $LIB $OUT +mkdir -p $BIN $LIB # Core assemblies p cp src/main/Uno.CLI.Main/bin/Release/*.{dll,exe,dylib} $BIN @@ -90,24 +89,3 @@ cat config/common.unoconfig >> $BIN/.unoconfig p cp bin/uno bin/uno.exe $DST echo "Packages.InstallDirectory: lib" > $DST/.unoconfig echo "bin" > $DST/.unopath - -h1 "Creating packages" -###################### - -# Create NuGet packages -for i in `find src -iname "*.nuspec" | sed -e 's/.nuspec$/.csproj/'`; do - p nuget pack -OutputDirectory "$OUT" -Properties Configuration=Release -IncludeReferencedProjects "$i" -done - -p nuget pack -OutputDirectory "$OUT" -Version "$VERSION" "`dirname "$SELF"`/FuseOpen.Uno.Tool.nuspec" - -# Create Uno packages -for f in lib/*; do - NAME=`basename "$f"` - PROJECT=$f/$NAME.unoproj - if [ -f "$PROJECT" ]; then - uno pack $PROJECT \ - --version $VERSION \ - --out-dir $OUT - fi -done From e657ae35f72b41e5765f5773f7db6606a0da4349 Mon Sep 17 00:00:00 2001 From: Morten Daniel Fornes Date: Sun, 16 Dec 2018 23:45:12 +0700 Subject: [PATCH 33/71] common.unoconfig: drop myget feed We'll not use MyGet for distribution of Uno packages anymore. --- config/common.unoconfig | 5 ----- 1 file changed, 5 deletions(-) diff --git a/config/common.unoconfig b/config/common.unoconfig index b0653e6b0..cd51d8044 100644 --- a/config/common.unoconfig +++ b/config/common.unoconfig @@ -10,8 +10,3 @@ Packages.Default += [ Fuse FuseJS ] - -// Package feeds -Packages.Feeds += [ - "https://www.myget.org/F/fuse/api/v2" -] From 62613e504923e6cf9c1f274028b7d097758b5f5d Mon Sep 17 00:00:00 2001 From: Morten Daniel Fornes Date: Tue, 15 Jan 2019 14:17:51 +0700 Subject: [PATCH 34/71] pack.sh: inline build commands Don't invoke build.sh and as a side-effect both C# and Uno code are now built using the same VERSION, including SUFFIX generated by pack.sh. --- scripts/pack.sh | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/scripts/pack.sh b/scripts/pack.sh index f290b5ec2..b3f1684aa 100755 --- a/scripts/pack.sh +++ b/scripts/pack.sh @@ -48,8 +48,15 @@ sed -e 's/\(AssemblyVersion("\)[^"]*\(")\)/\1'$VERSION_TRIPLET.$BUILD_NUMBER'\2/ -e 's/\(AssemblyConfiguration("\)[^"]*\(")\)/\1'$COMMIT'\2/' \ src/GlobalAssemblyInfo.cs > src/GlobalAssemblyInfo.Override.cs -# Build release configuration -bash scripts/build.sh --release +# Trigger release builds +h1 "Installing packages" +nuget restore uno.sln + +h1 "Building platform tools" +CONFIGURATION=Release csharp-build uno.sln + +h1 "Building core library" +uno doctor --configuration=Release --version=$VERSION lib # Remove GlobalAssemblyInfo.Override.cs rm -f src/GlobalAssemblyInfo.Override.cs From 750f12c1c1b3922c721b6a1a7ed5f46baf00e5b5 Mon Sep 17 00:00:00 2001 From: Morten Daniel Fornes Date: Tue, 15 Jan 2019 14:27:55 +0700 Subject: [PATCH 35/71] pack.sh: drop launcher and libs from release/ The release/ directory is now what used to be release/bin/, and instead we can use the launcher and libs directly from their original locations. --- bin/.unopath | 1 + config/pack.unoconfig | 2 -- scripts/pack.sh | 59 ++++++++++++++++++------------------------- 3 files changed, 25 insertions(+), 37 deletions(-) diff --git a/bin/.unopath b/bin/.unopath index 4ed4d85ab..8772ed9fa 100644 --- a/bin/.unopath +++ b/bin/.unopath @@ -1,2 +1,3 @@ ../src/main/Uno.CLI/bin/Debug ../src/main/Uno.CLI/bin/Release +../release diff --git a/config/pack.unoconfig b/config/pack.unoconfig index 5a7c9bde6..2190878a7 100644 --- a/config/pack.unoconfig +++ b/config/pack.unoconfig @@ -1,5 +1,3 @@ -require *.unoconfig -IsRoot: false Assemblies.Plugins: Uno.Compiler.Extensions.dll Assemblies.Test: uno-test.exe Assemblies.TestGen: uno-test-gen.exe diff --git a/scripts/pack.sh b/scripts/pack.sh index b3f1684aa..a96d5a199 100755 --- a/scripts/pack.sh +++ b/scripts/pack.sh @@ -3,10 +3,11 @@ SELF=`echo $0 | sed 's/\\\\/\\//g'` cd "`dirname "$SELF"`/.." || exit 1 source scripts/common.sh -# Configuration +# Initialize DST="release" -BIN="$DST/bin" -LIB="$DST/lib" +shopt -s dotglob +rm -rf ${DST:?}/* 2> /dev/null || : +mkdir -p $DST # Detect version info COMMIT=`git rev-parse HEAD` @@ -64,35 +65,23 @@ rm -f src/GlobalAssemblyInfo.Override.cs h1 "Preparing release" ###################### -# Initialize -rm -rf ${BIN:?}/* ${LIB:?}/* -rm ${DST:?}/* 2> /dev/null || : -mkdir -p $BIN $LIB - -# Core assemblies -p cp src/main/Uno.CLI.Main/bin/Release/*.{dll,exe,dylib} $BIN -p cp -f src/testing/Uno.CompilerTestRunner/bin/Release/uno-compiler-test.exe $BIN -p cp -f src/testing/Uno.TestGenerator/bin/Release/uno-test-gen.exe $BIN -p cp -f src/testing/Uno.TestRunner.CLI/bin/Release/*.{dll,exe} $BIN - -# Core packages (used for testing) -p cp -R lib/build/* $LIB - -# Put app loaders for macOS and Windows in subdirectories, to avoid conflicts -mkdir -p $BIN/apploader-mac -p cp -f src/runtime/Uno.AppLoader-MonoMac/bin/Release/*.{dll,exe,dylib} $BIN/apploader-mac -p cp -f src/runtime/Uno.AppLoader-MonoMac/bin/Release/monostub $BIN/apploader-mac - -mkdir -p $BIN/apploader-win -p cp -f src/runtime/Uno.AppLoader-WinForms/bin/Release/*.{dll,exe} $BIN/apploader-win -p cp -rf src/runtime/Uno.AppLoader-WinForms/bin/Release/x86 $BIN/apploader-win -p cp -rf src/runtime/Uno.AppLoader-WinForms/bin/Release/x64 $BIN/apploader-win - -# Generate config -p cp config/pack.unoconfig $BIN/.unoconfig -cat config/common.unoconfig >> $BIN/.unoconfig - -# Generate launcher -p cp bin/uno bin/uno.exe $DST -echo "Packages.InstallDirectory: lib" > $DST/.unoconfig -echo "bin" > $DST/.unopath +# Copy assemblies +p cp src/main/Uno.CLI.Main/bin/Release/*.{dll,exe,dylib} $DST +p cp -f src/testing/Uno.CompilerTestRunner/bin/Release/uno-compiler-test.exe $DST +p cp -f src/testing/Uno.TestGenerator/bin/Release/uno-test-gen.exe $DST +p cp -f src/testing/Uno.TestRunner.CLI/bin/Release/*.{dll,exe} $DST + +# Put app loaders for macOS and Windows in subdirectories to avoid conflicts +mkdir -p $DST/apploader-mac +p cp -f src/runtime/Uno.AppLoader-MonoMac/bin/Release/*.{dll,exe,dylib} $DST/apploader-mac +p cp -f src/runtime/Uno.AppLoader-MonoMac/bin/Release/monostub $DST/apploader-mac + +mkdir -p $DST/apploader-win +p cp -f src/runtime/Uno.AppLoader-WinForms/bin/Release/*.{dll,exe} $DST/apploader-win +p cp -rf src/runtime/Uno.AppLoader-WinForms/bin/Release/x86 $DST/apploader-win +p cp -rf src/runtime/Uno.AppLoader-WinForms/bin/Release/x64 $DST/apploader-win + +# Generate config file +p cp config/pack.unoconfig $DST/.unoconfig +cat config/common.unoconfig >> $DST/.unoconfig +echo "Packages.SearchPaths += ../lib" >> $DST/.unoconfig From 76952aa8c9329e5d8d01862ca51665f9eb2dd6a9 Mon Sep 17 00:00:00 2001 From: Morten Daniel Fornes Date: Tue, 15 Jan 2019 16:39:08 +0700 Subject: [PATCH 36/71] build.sh: drop VERSION --- scripts/build.sh | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/scripts/build.sh b/scripts/build.sh index 361a388be..bfcdf2dbc 100755 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -79,13 +79,10 @@ if [ "$BUILD_PLATFORM" = 1 ]; then fi if [ "$BUILD_LIBRARY" = 1 ]; then - # Get version number - VERSION=`cat VERSION.txt` - h1 "Building core library" if [ "$REBUILD_LIBRARY" = 1 ]; then - uno doctor -ac$CONFIGURATION --version=$VERSION lib + uno doctor -ac$CONFIGURATION lib else - uno doctor -ec$CONFIGURATION --version=$VERSION lib + uno doctor -ec$CONFIGURATION lib fi fi From 7b7e2319c09320edc769e5d8400a93a8df594b5f Mon Sep 17 00:00:00 2001 From: Morten Daniel Fornes Date: Tue, 15 Jan 2019 17:00:38 +0700 Subject: [PATCH 37/71] build.sh: drop --all and --rebuild options These old options aren't useful. --- Makefile | 4 ---- scripts/build.sh | 18 +----------------- 2 files changed, 1 insertion(+), 21 deletions(-) diff --git a/Makefile b/Makefile index 45ec16da4..f670eb837 100644 --- a/Makefile +++ b/Makefile @@ -3,10 +3,6 @@ default: @bash scripts/build.sh unocore: @bash scripts/build.sh --unocore -rebuild: - @bash scripts/build.sh --rebuild -all: - @bash scripts/build.sh --all release: @bash scripts/pack.sh diagrams: diff --git a/scripts/build.sh b/scripts/build.sh index bfcdf2dbc..30eaa06e4 100755 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -8,7 +8,6 @@ BUILD_PLATFORM=1 BUILD_UNOCORE=0 BUILD_LIBRARY=1 CONFIGURATION="Debug" -REBUILD_LIBRARY=0 # Parse options for arg in "$@"; do @@ -16,8 +15,6 @@ for arg in "$@"; do -h|--help) echo "Build options:" echo " --unocore Generate Uno.Runtime.Core.csproj" - echo " --rebuild Rebuild package library" - echo " --all Build everything" echo "" echo "Configuration options:" echo " --debug Use 'Debug' configuration (default)" @@ -35,15 +32,6 @@ for arg in "$@"; do BUILD_UNOCORE=1 BUILD_LIBRARY=0 ;; - --all) - BUILD_PLATFORM=1 - BUILD_UNOCORE=1 - BUILD_LIBRARY=1 - REBUILD_LIBRARY=1 - ;; - --rebuild) - REBUILD_LIBRARY=1 - ;; *) echo "ERROR: Invalid argument '$arg'" >&2 exit 1 @@ -80,9 +68,5 @@ fi if [ "$BUILD_LIBRARY" = 1 ]; then h1 "Building core library" - if [ "$REBUILD_LIBRARY" = 1 ]; then - uno doctor -ac$CONFIGURATION lib - else - uno doctor -ec$CONFIGURATION lib - fi + uno doctor -ec$CONFIGURATION lib fi From 2b5974f844994704bba86da3d248d60c4c2e7ecc Mon Sep 17 00:00:00 2001 From: Morten Daniel Fornes Date: Wed, 16 Jan 2019 02:08:36 +0700 Subject: [PATCH 38/71] build.sh: extract build-unocore.sh to separate script --- Makefile | 2 +- scripts/build-unocore.sh | 20 +++++++++++++++++ scripts/build.sh | 46 ++++++---------------------------------- scripts/common.sh | 4 ++++ 4 files changed, 31 insertions(+), 41 deletions(-) create mode 100644 scripts/build-unocore.sh diff --git a/Makefile b/Makefile index f670eb837..be3ffcbf9 100644 --- a/Makefile +++ b/Makefile @@ -2,7 +2,7 @@ default: @bash scripts/build.sh unocore: - @bash scripts/build.sh --unocore + @bash scripts/build-unocore.sh release: @bash scripts/pack.sh diagrams: diff --git a/scripts/build-unocore.sh b/scripts/build-unocore.sh new file mode 100644 index 000000000..38cd32ceb --- /dev/null +++ b/scripts/build-unocore.sh @@ -0,0 +1,20 @@ +#!/bin/bash +SELF=`echo $0 | sed 's/\\\\/\\//g'` +cd "`dirname "$SELF"`/.." || exit 1 +source scripts/common.sh + +SRC_DIR="lib/UnoCore" +OUT_DIR="$SRC_DIR/build/corelib/Debug" +DST_DIR="src/runtime/Uno.Runtime.Core" + +# Build Uno project +uno build corelib $SRC_DIR -z + +# Build C# project +csharp-build $OUT_DIR/*.sln + +# Replace C# project +rm -rf ${OUT_DIR:?}/{bin,obj} +rm -rf $DST_DIR +p cp -R $OUT_DIR $DST_DIR +rm $DST_DIR/*.sln diff --git a/scripts/build.sh b/scripts/build.sh index 30eaa06e4..92e6022ea 100755 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -4,9 +4,6 @@ cd "`dirname "$SELF"`/.." || exit 1 source scripts/common.sh # Configuration -BUILD_PLATFORM=1 -BUILD_UNOCORE=0 -BUILD_LIBRARY=1 CONFIGURATION="Debug" # Parse options @@ -14,9 +11,6 @@ for arg in "$@"; do case $arg in -h|--help) echo "Build options:" - echo " --unocore Generate Uno.Runtime.Core.csproj" - echo "" - echo "Configuration options:" echo " --debug Use 'Debug' configuration (default)" echo " --release Use 'Release' configuration" exit 0 @@ -27,11 +21,6 @@ for arg in "$@"; do --release) CONFIGURATION="Release" ;; - --unocore) - BUILD_PLATFORM=0 - BUILD_UNOCORE=1 - BUILD_LIBRARY=0 - ;; *) echo "ERROR: Invalid argument '$arg'" >&2 exit 1 @@ -39,34 +28,11 @@ for arg in "$@"; do esac done -if [ "$BUILD_UNOCORE" = 1 ]; then - h1 "Building Uno.Runtime.Core.csproj" - SRC_DIR="lib/UnoCore" - OUT_DIR="$SRC_DIR/build/corelib/Debug" - DST_DIR="src/runtime/Uno.Runtime.Core" - - # Build Uno project - uno build corelib $SRC_DIR -z - - # Build C# project - csharp-build $OUT_DIR/*.sln - - # Replace C# project - rm -rf ${OUT_DIR:?}/{bin,obj} - rm -rf $DST_DIR - p cp -R $OUT_DIR $DST_DIR - rm $DST_DIR/*.sln -fi - -if [ "$BUILD_PLATFORM" = 1 ]; then - h1 "Installing packages" - nuget restore uno.sln +h1 "Installing packages" +nuget restore uno.sln - h1 "Building platform tools" - csharp-build uno.sln -fi +h1 "Building platform tools" +csharp-build uno.sln -if [ "$BUILD_LIBRARY" = 1 ]; then - h1 "Building core library" - uno doctor -ec$CONFIGURATION lib -fi +h1 "Building core library" +uno doctor -ec$CONFIGURATION lib diff --git a/scripts/common.sh b/scripts/common.sh index f71d4e75a..3743d6bbc 100644 --- a/scripts/common.sh +++ b/scripts/common.sh @@ -6,6 +6,10 @@ function find-msbuild { } function csharp-build { + if [ -z "$CONFIGURATION" ]; then + CONFIGURATION="Debug" + fi + if [ "$OSTYPE" = msys ]; then msbuild=`find-msbuild` if [ $? != 0 ]; then From acb125e97fbba89957ebd3d8e69ea71684a52888 Mon Sep 17 00:00:00 2001 From: Morten Daniel Fornes Date: Sun, 16 Dec 2018 05:21:11 +0700 Subject: [PATCH 39/71] add bin/uno.js This script can launch Uno from Node.js. --- bin/uno.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 bin/uno.js diff --git a/bin/uno.js b/bin/uno.js new file mode 100644 index 000000000..ae8f76252 --- /dev/null +++ b/bin/uno.js @@ -0,0 +1,19 @@ +#!/usr/bin/env node +const path = require('path'); +const {spawn} = require('child_process'); + +function uno(args) { + const filename = path.join(__dirname, 'uno'); + const options = {stdio: 'inherit'}; + + if (path.sep == '\\') + return spawn(filename + '.exe', args, options); + else { + args.unshift(filename); + return spawn('bash', args, options); + } +} + +uno(process.argv.slice(2)).on('exit', function(code) { + process.exit(code); +}); From 8f5f143a50079ebda18b800437bc3c697398918e Mon Sep 17 00:00:00 2001 From: Morten Daniel Fornes Date: Sun, 16 Dec 2018 05:21:11 +0700 Subject: [PATCH 40/71] add package.json We can run 'npm pack' to create a distribution package for NPM. --- package-lock.json | 5 +++++ package.json | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+) create mode 100644 package-lock.json create mode 100644 package.json diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 000000000..2f50a7892 --- /dev/null +++ b/package-lock.json @@ -0,0 +1,5 @@ +{ + "name": "@fuse-open/uno", + "version": "1.10.0-rc1", + "lockfileVersion": 1 +} diff --git a/package.json b/package.json new file mode 100644 index 000000000..a361abc8c --- /dev/null +++ b/package.json @@ -0,0 +1,35 @@ +{ + "name": "@fuse-open/uno", + "version": "1.10.0-rc1", + "description": "Fast, native C# dialect and cross-compiler.", + "scripts": { + "build": "bash scripts/build.sh", + "prepack": "bash scripts/pack.sh", + "test": "bash scripts/test.sh" + }, + "bin": { + "uno": "bin/uno.js" + }, + "files": [ + "bin/*", + "lib/build/*", + "release/*" + ], + "repository": { + "type": "git", + "url": "git+https://github.com/fuse-open/uno.git" + }, + "keywords": [ + "uno", + "programming-language", + "fuse", + "cross-platform", + "c-sharp" + ], + "author": "Fuse Open", + "license": "MIT", + "bugs": { + "url": "https://github.com/fuse-open/uno/issues" + }, + "homepage": "https://github.com/fuse-open/uno#readme" +} From 0e8dbe591a989358221e1a5c77fafb356ee3d74d Mon Sep 17 00:00:00 2001 From: Morten Daniel Fornes Date: Wed, 16 Jan 2019 04:31:06 +0700 Subject: [PATCH 41/71] pack.sh: get version info from package.json VERSION.txt is no longer needed. --- VERSION.txt | 1 - scripts/pack.sh | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) delete mode 100644 VERSION.txt diff --git a/VERSION.txt b/VERSION.txt deleted file mode 100644 index 70cd4f3fd..000000000 --- a/VERSION.txt +++ /dev/null @@ -1 +0,0 @@ -1.10.0-rc1 diff --git a/scripts/pack.sh b/scripts/pack.sh index a96d5a199..fff913a13 100755 --- a/scripts/pack.sh +++ b/scripts/pack.sh @@ -11,7 +11,7 @@ mkdir -p $DST # Detect version info COMMIT=`git rev-parse HEAD` -VERSION=`cat VERSION.txt` +VERSION=`cat package.json | grep version | head -1 | awk -F: '{ print $2 }' | sed 's/[\",]//g' | tr -d '[[:space:]]'` if [ -n "$APPVEYOR_REPO_BRANCH" ]; then BRANCH=$APPVEYOR_REPO_BRANCH From 0db0156d569512d5af5fb6e2762912793650b595 Mon Sep 17 00:00:00 2001 From: Morten Daniel Fornes Date: Wed, 16 Jan 2019 04:34:33 +0700 Subject: [PATCH 42/71] .appveyor: publish NPM package --- .appveyor.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.appveyor.yml b/.appveyor.yml index 1412f9779..7e033a122 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -14,7 +14,10 @@ install: } build_script: - - bash -l scripts\pack.sh + - npm pack + +artifacts: + - path: '*.tgz' before_test: - ps: | From bcdb50fe7e0d9bb63c2d09ccceda1f8b57b0d3bc Mon Sep 17 00:00:00 2001 From: Morten Daniel Fornes Date: Wed, 16 Jan 2019 08:14:21 +0700 Subject: [PATCH 43/71] Uno.Build: don't automatically run 'npm install' in Uno projects This feature can be problematic when using Uno installed via NPM, and the easiest solution to this problem is to remove the feature. --- Documentation/Configuration.md | 7 +- src/engine/Uno.Build/BuildDriver.cs | 5 -- src/engine/Uno.Build/JavaScript/NPM.cs | 65 ------------------- .../Uno.Build/Packages/PackageDoctor.cs | 4 -- src/engine/Uno.Build/Uno.Build.csproj | 1 - 5 files changed, 3 insertions(+), 79 deletions(-) delete mode 100644 src/engine/Uno.Build/JavaScript/NPM.cs diff --git a/Documentation/Configuration.md b/Documentation/Configuration.md index 69a240ddd..fe0b74f11 100644 --- a/Documentation/Configuration.md +++ b/Documentation/Configuration.md @@ -63,19 +63,18 @@ To support building native apps, we need [CMake](https://cmake.org/) and C++ com - **macOS:** Xcode with command line tools - **Windows:** Visual Studio 2017 -If `cmake` isn't in your *PATH*, the location can be provided like this: +If `cmake` isn't in found your *PATH*, the location can be provided like this: ```javascript Tools.CMake: `%PROGRAMFILES%\CMake\bin\cmake.exe` ``` ## Node.js -We need `node` / `npm` to install and use JavaScript packages. +We need [Node.js](https://nodejs.org/en/download/) to support transpiling FuseJS files to ES5. -If the commands aren't in your *PATH*, their locations can be provided like this: +If `node` isn't found in your *PATH*, the location can be provided like this: ```javascript Tools.Node: `%PROGRAMFILES%\nodejs\node.exe` -Tools.NPM: `%PROGRAMFILES%\nodejs\npm.cmd` ``` ## Package manager diff --git a/src/engine/Uno.Build/BuildDriver.cs b/src/engine/Uno.Build/BuildDriver.cs index 34972e17e..93a843d47 100644 --- a/src/engine/Uno.Build/BuildDriver.cs +++ b/src/engine/Uno.Build/BuildDriver.cs @@ -182,11 +182,6 @@ public BackendResult Build() if (Log.HasErrors) return null; - // Install NPM packages if package.json exists - foreach (var p in _input.Packages) - if (p.IsProject && NPM.NeedsInstall(p)) - new NPM(Log).Install(p); - using (Log.StartProfiler(typeof(UXProcessor))) UXProcessor.Build(_compiler.Disk, _input.Packages); diff --git a/src/engine/Uno.Build/JavaScript/NPM.cs b/src/engine/Uno.Build/JavaScript/NPM.cs deleted file mode 100644 index 40d2b047e..000000000 --- a/src/engine/Uno.Build/JavaScript/NPM.cs +++ /dev/null @@ -1,65 +0,0 @@ -using System; -using System.IO; -using Uno.Compiler; -using Uno.Configuration; -using Uno.Diagnostics; -using Uno.IO; -using Uno.Logging; - -namespace Uno.Build.JavaScript -{ - class NPM : DiskObject - { - static readonly string _npm = UnoConfig.Current.GetFullPath("Tools.NPM", false) ?? "npm"; - readonly Shell _shell; - - public NPM(Log log) - : base(log) - { - _shell = new Shell(log); - } - - public static bool NeedsInstall(SourcePackage upk) - { - var packageFile = Path.Combine(upk.SourceDirectory, "package.json"); - if (!File.Exists(packageFile)) - return false; - - var timestampFile = Path.Combine(upk.CacheDirectory, "npm-install"); - if (File.Exists(timestampFile) && - File.GetLastWriteTime(timestampFile) >= File.GetLastWriteTime(packageFile)) - return false; - - return true; - } - - public void Install(SourcePackage upk) - { - Log.WriteLine("Installing NPM packages for " + upk.Name, ConsoleColor.Blue); - Run("install", upk.SourceDirectory); - Disk.CreateFile(Path.Combine(upk.CacheDirectory, "npm-install")).Dispose(); - } - - void Run(string command, string workingDirectory) - { - var filename = _npm; - var args = command; - - // NPM doesn't work properly unless run via cmd.exe on Windows - if (PlatformDetection.IsWindows) - { - filename = "cmd.exe"; - args = "/C " + _npm.QuoteSpace() + " " + command; - } - - // Don't print warnings unless --verbose - if (!Log.IsVerbose) - args += " --loglevel error"; - - var result = _shell.Run(filename, args, workingDirectory, RunFlags.Colors); - - if (result != 0) - throw new InvalidOperationException("'npm " + command + "' returned with error (" + result + ")"); - } - } -} diff --git a/src/engine/Uno.Build/Packages/PackageDoctor.cs b/src/engine/Uno.Build/Packages/PackageDoctor.cs index b1299e113..f43dbc0b5 100644 --- a/src/engine/Uno.Build/Packages/PackageDoctor.cs +++ b/src/engine/Uno.Build/Packages/PackageDoctor.cs @@ -48,10 +48,6 @@ public bool Repair(PackageFile file, bool force = false) var upk = file.CreateSourcePackage(); var reader = new SourceReader(Log, upk, this); - // Install NPM packages if package.json exists - if (NPM.NeedsInstall(upk)) - new NPM(Log).Install(upk); - if (force || !reader.CacheExists || reader.HasAnythingChangedSince(reader.CacheTime, false)) { diff --git a/src/engine/Uno.Build/Uno.Build.csproj b/src/engine/Uno.Build/Uno.Build.csproj index 74e2bee74..e6f0723bb 100644 --- a/src/engine/Uno.Build/Uno.Build.csproj +++ b/src/engine/Uno.Build/Uno.Build.csproj @@ -74,7 +74,6 @@ - From 0d401409fd1f6a8754a9c9284f406741d435cb7c Mon Sep 17 00:00:00 2001 From: Morten Daniel Fornes Date: Wed, 16 Jan 2019 11:44:36 +0700 Subject: [PATCH 44/71] Uno.ProjectFormat: skip 'node_modules' directory in glob patterns When installing Uno via NPM it will be common to have a 'node_modules' directory inside the Uno project, and since this is likely to cause problems for glob users we should always skip this directory. --- src/engine/Uno.ProjectFormat/IncludeGlobber.cs | 1 + src/engine/Uno.ProjectFormat/ProjectGlobber.cs | 1 + 2 files changed, 2 insertions(+) diff --git a/src/engine/Uno.ProjectFormat/IncludeGlobber.cs b/src/engine/Uno.ProjectFormat/IncludeGlobber.cs index 654e4f325..9662ecc60 100644 --- a/src/engine/Uno.ProjectFormat/IncludeGlobber.cs +++ b/src/engine/Uno.ProjectFormat/IncludeGlobber.cs @@ -39,6 +39,7 @@ internal static void FindItems( _result = result; _log = log ?? Log.Default; _disk = new Disk(_log); + SkipFile(Path.Combine(project.RootDirectory, "node_modules")); SkipFile(project.BuildDirectory); SkipFile(project.CacheDirectory); } diff --git a/src/engine/Uno.ProjectFormat/ProjectGlobber.cs b/src/engine/Uno.ProjectFormat/ProjectGlobber.cs index 83ff01097..5c46eee2c 100644 --- a/src/engine/Uno.ProjectFormat/ProjectGlobber.cs +++ b/src/engine/Uno.ProjectFormat/ProjectGlobber.cs @@ -37,6 +37,7 @@ internal static void FindItems( _result = result; _log = log ?? Log.Default; _disk = new Disk(_log); + SkipFile(Path.Combine(project.RootDirectory, "node_modules")); SkipFile(project.BuildDirectory); SkipFile(project.CacheDirectory); SkipFile(project.FullPath); From 7854d04e51f3930b8369a4bf950d626d71779afd Mon Sep 17 00:00:00 2001 From: Morten Daniel Fornes Date: Wed, 16 Jan 2019 11:50:07 +0700 Subject: [PATCH 45/71] Uno.Configuration: scan node_modules This will pick up .unoconfig files inside installed NPM packages. Since an NPM package can contain Uno packages, .unoconfig can be used to add the included Uno packages to search paths, or add other config such as Android SDK locations (maybe a future 'npm install uno-android-sdk'), etc. --- src/engine/Uno.Configuration/UnoConfig.cs | 30 ++++++++++++++++++++--- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/src/engine/Uno.Configuration/UnoConfig.cs b/src/engine/Uno.Configuration/UnoConfig.cs index 58bc01f40..18946e0bb 100644 --- a/src/engine/Uno.Configuration/UnoConfig.cs +++ b/src/engine/Uno.Configuration/UnoConfig.cs @@ -27,7 +27,7 @@ public static void LoadDirectory(string dir) public static void LoadFile(string filename) { - Current.LoadRecursive(Path.GetDirectoryName(filename), filename); + Current.LoadFile(Path.GetDirectoryName(filename), filename); } readonly List _files = new List(); @@ -246,15 +246,37 @@ void LoadRecursive(string dir) if (PlatformDetection.IsWindows && dir.Length >= 2 && dir[1] == ':' && char.IsLower(dir[0])) dir = char.ToUpper(dir[0]) + dir.Substring(1); + var node_modules = Path.Combine(dir, "node_modules"); + + if (Directory.Exists(node_modules)) + LoadNodeModules(node_modules); + var filename = Path.Combine(dir, ".unoconfig"); if (!File.Exists(filename)) LoadRecursive(Path.GetDirectoryName(dir)); else - LoadRecursive(dir, filename); + LoadFile(dir, filename); + } + + void LoadNodeModules(string node_modules) + { + foreach (var dir in Directory.EnumerateDirectories(node_modules)) + { + if (Path.GetFileName(dir).StartsWith("@")) + { + LoadNodeModules(dir); + continue; + } + + var filename = Path.Combine(dir, ".unoconfig"); + + if (File.Exists(filename)) + LoadFile(dir, filename, false); + } } - void LoadRecursive(string dir, string filename) + void LoadFile(string dir, string filename, bool scanParentDir = true) { var file = GetFile(filename); @@ -274,7 +296,7 @@ void LoadRecursive(string dir, string filename) // Load parent configuration files StuffItem isRoot; - if (file.GetData().TryGetValue("IsRoot", out isRoot) && !bool.Parse(isRoot.Value)) + if (scanParentDir && file.GetData().TryGetValue("IsRoot", out isRoot) && !bool.Parse(isRoot.Value)) LoadRecursive(Path.GetDirectoryName(dir)); } From a1147e159c115b866d21bc062c9118e7b764a9bb Mon Sep 17 00:00:00 2001 From: Morten Daniel Fornes Date: Wed, 16 Jan 2019 11:50:07 +0700 Subject: [PATCH 46/71] Uno.Configuration: don't scan directory multiple times We want to avoid scanning the node_modules directory or look for .unoconfig files multiple times. --- src/engine/Uno.Configuration/UnoConfig.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/engine/Uno.Configuration/UnoConfig.cs b/src/engine/Uno.Configuration/UnoConfig.cs index 18946e0bb..e44f79922 100644 --- a/src/engine/Uno.Configuration/UnoConfig.cs +++ b/src/engine/Uno.Configuration/UnoConfig.cs @@ -34,6 +34,7 @@ public static void LoadFile(string filename) readonly Dictionary _configCache = new Dictionary(); readonly Dictionary _fileCache = new Dictionary(); readonly Dictionary> _stringCache = new Dictionary>(); + readonly HashSet _visitedDirectories = new HashSet(); public IReadOnlyList Files => _files; @@ -246,6 +247,11 @@ void LoadRecursive(string dir) if (PlatformDetection.IsWindows && dir.Length >= 2 && dir[1] == ':' && char.IsLower(dir[0])) dir = char.ToUpper(dir[0]) + dir.Substring(1); + if (_visitedDirectories.Contains(dir)) + return; + + _visitedDirectories.Add(dir); + var node_modules = Path.Combine(dir, "node_modules"); if (Directory.Exists(node_modules)) From 7df6c68329d94ffba685e67b01bbab11090ce78d Mon Sep 17 00:00:00 2001 From: Morten Daniel Fornes Date: Wed, 16 Jan 2019 12:18:01 +0700 Subject: [PATCH 47/71] Uno.Configuration: remove unused methods --- src/engine/Uno.Configuration/UnoConfig.cs | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/src/engine/Uno.Configuration/UnoConfig.cs b/src/engine/Uno.Configuration/UnoConfig.cs index e44f79922..94bee95b9 100644 --- a/src/engine/Uno.Configuration/UnoConfig.cs +++ b/src/engine/Uno.Configuration/UnoConfig.cs @@ -20,16 +20,6 @@ public static UnoConfig Get(IPathObject obj) return Current.GetDirectoryConfig(Path.GetDirectoryName(obj.FullPath)); } - public static void LoadDirectory(string dir) - { - Current.LoadRecursive(dir); - } - - public static void LoadFile(string filename) - { - Current.LoadFile(Path.GetDirectoryName(filename), filename); - } - readonly List _files = new List(); readonly Dictionary _configCache = new Dictionary(); readonly Dictionary _fileCache = new Dictionary(); From 0a1316431127b4fd99b89d174b3abbfc9582371c Mon Sep 17 00:00:00 2001 From: Morten Daniel Fornes Date: Wed, 16 Jan 2019 12:16:58 +0700 Subject: [PATCH 48/71] common.unoconfig: require ~/.unoconfig We don't want to scan node_modules in ~/ or look for .unoconfig files recursively from ~/. Requiring the user config from another .unoconfig instead of using LoadRecursive() avoids the problem. --- config/common.unoconfig | 3 +++ src/engine/Uno.Configuration/UnoConfig.cs | 1 - 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/config/common.unoconfig b/config/common.unoconfig index cd51d8044..df4e73843 100644 --- a/config/common.unoconfig +++ b/config/common.unoconfig @@ -5,6 +5,9 @@ if WIN32 { require "%HOME%/Library/Application Support/Fusetools/Fuse/Android/.sdkconfig" } +// User config +require ~/.unoconfig + // Project defaults Packages.Default += [ Fuse diff --git a/src/engine/Uno.Configuration/UnoConfig.cs b/src/engine/Uno.Configuration/UnoConfig.cs index 94bee95b9..a35db9f4c 100644 --- a/src/engine/Uno.Configuration/UnoConfig.cs +++ b/src/engine/Uno.Configuration/UnoConfig.cs @@ -204,7 +204,6 @@ public IReadOnlyList GetStrings(string key) { LoadRecursive(GetAssemblyDirectory(Assembly.GetEntryAssembly())); LoadRecursive(GetAssemblyDirectory(typeof(UnoConfig).Assembly)); - LoadRecursive(Environment.GetEnvironmentVariable("HOME")); try { From d1c5834f1b874d6f719c8378a25c7f2562006de1 Mon Sep 17 00:00:00 2001 From: Morten Daniel Fornes Date: Fri, 18 Jan 2019 06:41:03 +0700 Subject: [PATCH 49/71] .travis: build release configuration This makes sure we're testing the same configuration we ship to users. --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 411b5a28d..c8e402325 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,7 +13,7 @@ before_script: - rm -rf /cores/core.* script: - - scripts/build.sh + - scripts/build.sh --release - scripts/test.sh $TARGET after_failure: From 21e344de6b26d939f2b3bccca28dd8be196d1989 Mon Sep 17 00:00:00 2001 From: Morten Daniel Fornes Date: Fri, 18 Jan 2019 08:39:18 +0700 Subject: [PATCH 50/71] common.unoconfig: drop {Fuse, FuseJS} default packages This config should be moved to Fuselibs. --- config/common.unoconfig | 6 ------ 1 file changed, 6 deletions(-) diff --git a/config/common.unoconfig b/config/common.unoconfig index df4e73843..7cf4934c9 100644 --- a/config/common.unoconfig +++ b/config/common.unoconfig @@ -7,9 +7,3 @@ if WIN32 { // User config require ~/.unoconfig - -// Project defaults -Packages.Default += [ - Fuse - FuseJS -] From e1a68c5d4e4796ce70d2d3d86470fa963b6d418b Mon Sep 17 00:00:00 2001 From: Morten Daniel Fornes Date: Fri, 18 Jan 2019 08:40:28 +0700 Subject: [PATCH 51/71] .unoconfig: remove old fuselibs search paths Cloning fuselibs and premiumlibs inside the lib/ directory is not a common practice anymore, and this can safely be removed. --- .unoconfig | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/.unoconfig b/.unoconfig index ce8f385e7..b4b3823b8 100644 --- a/.unoconfig +++ b/.unoconfig @@ -15,11 +15,7 @@ if WIN32 { // Package config Packages.InstallDirectory: prebuilt/lib -Packages.SourcePaths += [ - lib - lib/fuselibs/Source - lib/premiumlibs/Source -] +Packages.SourcePaths += lib // Avoid overriding core settings when running an uno.exe other than 'src/main/Uno.CLI.Main/bin/$(Configuration)/uno.exe', // to make sure assembly paths remain consistent. From 8f3672f0da42bf7be3b0511b78e5a3577e2c0839 Mon Sep 17 00:00:00 2001 From: Morten Daniel Fornes Date: Fri, 18 Jan 2019 08:40:46 +0700 Subject: [PATCH 52/71] .vscode: exclude node_modules directories --- .vscode/settings.json | 1 + 1 file changed, 1 insertion(+) diff --git a/.vscode/settings.json b/.vscode/settings.json index 66bc4c8c6..70a3cf216 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -5,6 +5,7 @@ }, "files.exclude": { "**/build": true, + "**/node_modules": true, "**/.uno": true } } \ No newline at end of file From bc5b8bd3c5cb21aa76fe9c8d30a432e2cf09cf3d Mon Sep 17 00:00:00 2001 From: Morten Daniel Fornes Date: Fri, 18 Jan 2019 11:06:42 +0700 Subject: [PATCH 53/71] .appveyor: silence npm pack This command generates a lot of unnecessary output. --- .appveyor.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.appveyor.yml b/.appveyor.yml index 7e033a122..532db7e63 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -14,7 +14,7 @@ install: } build_script: - - npm pack + - npm pack --silent artifacts: - path: '*.tgz' From 605f52fcc79516e0c4822d94ae959ea5c504d847 Mon Sep 17 00:00:00 2001 From: Morten Daniel Fornes Date: Fri, 18 Jan 2019 11:07:22 +0700 Subject: [PATCH 54/71] pack.sh: stop printing commands Not really useful. --- scripts/pack.sh | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/scripts/pack.sh b/scripts/pack.sh index fff913a13..da8961c46 100755 --- a/scripts/pack.sh +++ b/scripts/pack.sh @@ -66,22 +66,22 @@ h1 "Preparing release" ###################### # Copy assemblies -p cp src/main/Uno.CLI.Main/bin/Release/*.{dll,exe,dylib} $DST -p cp -f src/testing/Uno.CompilerTestRunner/bin/Release/uno-compiler-test.exe $DST -p cp -f src/testing/Uno.TestGenerator/bin/Release/uno-test-gen.exe $DST -p cp -f src/testing/Uno.TestRunner.CLI/bin/Release/*.{dll,exe} $DST +cp src/main/Uno.CLI.Main/bin/Release/*.{dll,exe,dylib} $DST +cp -f src/testing/Uno.CompilerTestRunner/bin/Release/uno-compiler-test.exe $DST +cp -f src/testing/Uno.TestGenerator/bin/Release/uno-test-gen.exe $DST +cp -f src/testing/Uno.TestRunner.CLI/bin/Release/*.{dll,exe} $DST # Put app loaders for macOS and Windows in subdirectories to avoid conflicts mkdir -p $DST/apploader-mac -p cp -f src/runtime/Uno.AppLoader-MonoMac/bin/Release/*.{dll,exe,dylib} $DST/apploader-mac -p cp -f src/runtime/Uno.AppLoader-MonoMac/bin/Release/monostub $DST/apploader-mac +cp -f src/runtime/Uno.AppLoader-MonoMac/bin/Release/*.{dll,exe,dylib} $DST/apploader-mac +cp -f src/runtime/Uno.AppLoader-MonoMac/bin/Release/monostub $DST/apploader-mac mkdir -p $DST/apploader-win -p cp -f src/runtime/Uno.AppLoader-WinForms/bin/Release/*.{dll,exe} $DST/apploader-win -p cp -rf src/runtime/Uno.AppLoader-WinForms/bin/Release/x86 $DST/apploader-win -p cp -rf src/runtime/Uno.AppLoader-WinForms/bin/Release/x64 $DST/apploader-win +cp -f src/runtime/Uno.AppLoader-WinForms/bin/Release/*.{dll,exe} $DST/apploader-win +cp -rf src/runtime/Uno.AppLoader-WinForms/bin/Release/x86 $DST/apploader-win +cp -rf src/runtime/Uno.AppLoader-WinForms/bin/Release/x64 $DST/apploader-win # Generate config file -p cp config/pack.unoconfig $DST/.unoconfig +cp config/pack.unoconfig $DST/.unoconfig cat config/common.unoconfig >> $DST/.unoconfig echo "Packages.SearchPaths += ../lib" >> $DST/.unoconfig From 7e947d9f2635b147848d639355416a0e4aee38e6 Mon Sep 17 00:00:00 2001 From: Morten Daniel Fornes Date: Sun, 20 Jan 2019 12:51:26 +0700 Subject: [PATCH 55/71] include global android-build-tools config android-build-tools is an NPM package that automatically installs Android SDK and NDK, required to build Android apps, and generates a config file for Uno, similar to 'fuse install android'. This package can be installed globally like this npm install -g android-build-tools The good thing about this is that we no longer need to install Fuse Studio to get automatic access to the Android SDK and NDK which is especially convenient when setting up CI for Fuse apps. --- config/common.unoconfig | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/config/common.unoconfig b/config/common.unoconfig index 7cf4934c9..e73bd0571 100644 --- a/config/common.unoconfig +++ b/config/common.unoconfig @@ -1,8 +1,10 @@ -// SDK config +// Android build tools config if WIN32 { - require %LOCALAPPDATA%/Fusetools/Fuse/Android/.sdkconfig + require %LOCALAPPDATA%/Fusetools/Fuse/Android/.sdkconfig // For legacy 'fuse install android' + require %APPDATA%/npm/node_modules/android-build-tools/.unoconfig // For 'npm install -g android-build-tools' } else { - require "%HOME%/Library/Application Support/Fusetools/Fuse/Android/.sdkconfig" + require "%HOME%/Library/Application Support/Fusetools/Fuse/Android/.sdkconfig" // For legacy 'fuse install android' + require /usr/local/lib/node_modules/android-build-tools/.unoconfig // For 'npm install -g android-build-tools' } // User config From fb81219b85b9ec25f74232db30633204954575c1 Mon Sep 17 00:00:00 2001 From: Morten Daniel Fornes Date: Sun, 20 Jan 2019 15:04:39 +0700 Subject: [PATCH 56/71] recommend installing android-build-tools --- Documentation/Configuration.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Documentation/Configuration.md b/Documentation/Configuration.md index fe0b74f11..f5fcd31d6 100644 --- a/Documentation/Configuration.md +++ b/Documentation/Configuration.md @@ -28,7 +28,8 @@ To build your standard library, type `uno doctor -e`. ## Android To support building Android apps, we need to know where your [Android SDKs](https://developer.android.com/studio/index.html) -are installed. +are installed. Running `npm install -g android-build-tools` will set this up automatically, or you can +specify other locations as demonstrated below. ### Windows @@ -45,8 +46,6 @@ Android.NDK.Directory: %HOME%/Library/Android/sdk/ndk-bundle Android.SDK.Directory: %HOME%/Library/Android/sdk ``` -If you have Fuse Studio, running `fuse install android` will set this up automatically. - ## iOS To support building iOS apps, we need macOS and Xcode. From 7a530778c480a542905a06dcd442e306b078a300 Mon Sep 17 00:00:00 2001 From: Morten Daniel Fornes Date: Fri, 25 Jan 2019 19:13:19 +0700 Subject: [PATCH 57/71] pack.sh: fix Packages.SearchPaths --- scripts/pack.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/pack.sh b/scripts/pack.sh index da8961c46..f6e61dd0e 100755 --- a/scripts/pack.sh +++ b/scripts/pack.sh @@ -84,4 +84,4 @@ cp -rf src/runtime/Uno.AppLoader-WinForms/bin/Release/x64 $DST/apploader-win # Generate config file cp config/pack.unoconfig $DST/.unoconfig cat config/common.unoconfig >> $DST/.unoconfig -echo "Packages.SearchPaths += ../lib" >> $DST/.unoconfig +echo "Packages.SearchPaths += ../lib/build" >> $DST/.unoconfig From dfa0a1bb89bfa8fd5ff83be33b10e69b6601910b Mon Sep 17 00:00:00 2001 From: Morten Daniel Fornes Date: Tue, 16 Oct 2018 03:19:36 +0700 Subject: [PATCH 58/71] upgrade Mono.Cecil package --- .../Uno.Compiler.Backends.CIL.csproj | 16 ++++++++-------- .../Uno.Compiler.Backends.CIL/packages.config | 2 +- .../Uno.Compiler.Backends.Metadata.csproj | 16 ++++++++-------- .../packages.config | 2 +- 4 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/compiler/Uno.Compiler.Backends.CIL/Uno.Compiler.Backends.CIL.csproj b/src/compiler/Uno.Compiler.Backends.CIL/Uno.Compiler.Backends.CIL.csproj index 88a8e0fca..0125c794c 100644 --- a/src/compiler/Uno.Compiler.Backends.CIL/Uno.Compiler.Backends.CIL.csproj +++ b/src/compiler/Uno.Compiler.Backends.CIL/Uno.Compiler.Backends.CIL.csproj @@ -33,17 +33,17 @@ - - ..\..\..\packages\Mono.Cecil.0.10.0\lib\net40\Mono.Cecil.dll + + ..\..\..\packages\Mono.Cecil.0.10.1\lib\net40\Mono.Cecil.dll - - ..\..\..\packages\Mono.Cecil.0.10.0\lib\net40\Mono.Cecil.Mdb.dll + + ..\..\..\packages\Mono.Cecil.0.10.1\lib\net40\Mono.Cecil.Mdb.dll - - ..\..\..\packages\Mono.Cecil.0.10.0\lib\net40\Mono.Cecil.Pdb.dll + + ..\..\..\packages\Mono.Cecil.0.10.1\lib\net40\Mono.Cecil.Pdb.dll - - ..\..\..\packages\Mono.Cecil.0.10.0\lib\net40\Mono.Cecil.Rocks.dll + + ..\..\..\packages\Mono.Cecil.0.10.1\lib\net40\Mono.Cecil.Rocks.dll diff --git a/src/compiler/Uno.Compiler.Backends.CIL/packages.config b/src/compiler/Uno.Compiler.Backends.CIL/packages.config index 91bb45ec2..bdb149094 100644 --- a/src/compiler/Uno.Compiler.Backends.CIL/packages.config +++ b/src/compiler/Uno.Compiler.Backends.CIL/packages.config @@ -1,4 +1,4 @@  - + \ No newline at end of file diff --git a/src/compiler/Uno.Compiler.Backends.Metadata/Uno.Compiler.Backends.Metadata.csproj b/src/compiler/Uno.Compiler.Backends.Metadata/Uno.Compiler.Backends.Metadata.csproj index 36eafa7f5..c78071e3b 100644 --- a/src/compiler/Uno.Compiler.Backends.Metadata/Uno.Compiler.Backends.Metadata.csproj +++ b/src/compiler/Uno.Compiler.Backends.Metadata/Uno.Compiler.Backends.Metadata.csproj @@ -33,17 +33,17 @@ - - ..\..\..\packages\Mono.Cecil.0.10.0\lib\net40\Mono.Cecil.dll + + ..\..\..\packages\Mono.Cecil.0.10.1\lib\net40\Mono.Cecil.dll - - ..\..\..\packages\Mono.Cecil.0.10.0\lib\net40\Mono.Cecil.Mdb.dll + + ..\..\..\packages\Mono.Cecil.0.10.1\lib\net40\Mono.Cecil.Mdb.dll - - ..\..\..\packages\Mono.Cecil.0.10.0\lib\net40\Mono.Cecil.Pdb.dll + + ..\..\..\packages\Mono.Cecil.0.10.1\lib\net40\Mono.Cecil.Pdb.dll - - ..\..\..\packages\Mono.Cecil.0.10.0\lib\net40\Mono.Cecil.Rocks.dll + + ..\..\..\packages\Mono.Cecil.0.10.1\lib\net40\Mono.Cecil.Rocks.dll diff --git a/src/compiler/Uno.Compiler.Backends.Metadata/packages.config b/src/compiler/Uno.Compiler.Backends.Metadata/packages.config index 91bb45ec2..bdb149094 100644 --- a/src/compiler/Uno.Compiler.Backends.Metadata/packages.config +++ b/src/compiler/Uno.Compiler.Backends.Metadata/packages.config @@ -1,4 +1,4 @@  - + \ No newline at end of file From aa5a8a11263409f12a5236b274d9ed7424c05f95 Mon Sep 17 00:00:00 2001 From: Morten Daniel Fornes Date: Tue, 16 Oct 2018 03:20:09 +0700 Subject: [PATCH 59/71] upgrade OpenTK package --- .../Uno.AppLoader-WinForms/Uno.AppLoader-WinForms.csproj | 6 +++--- src/runtime/Uno.AppLoader-WinForms/packages.config | 2 +- src/runtime/Uno.Support.OpenTK/GL.cs | 4 ++-- src/runtime/Uno.Support.OpenTK/Uno.Support.OpenTK.csproj | 6 +++--- src/runtime/Uno.Support.OpenTK/packages.config | 2 +- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/runtime/Uno.AppLoader-WinForms/Uno.AppLoader-WinForms.csproj b/src/runtime/Uno.AppLoader-WinForms/Uno.AppLoader-WinForms.csproj index fbac3e6b2..64150b698 100644 --- a/src/runtime/Uno.AppLoader-WinForms/Uno.AppLoader-WinForms.csproj +++ b/src/runtime/Uno.AppLoader-WinForms/Uno.AppLoader-WinForms.csproj @@ -43,15 +43,15 @@ app.manifest - - ..\..\..\packages\OpenTK.2.0.0\lib\net20\OpenTK.dll + + ..\..\..\packages\OpenTK.3.0.1\lib\net20\OpenTK.dll - + diff --git a/src/runtime/Uno.AppLoader-WinForms/packages.config b/src/runtime/Uno.AppLoader-WinForms/packages.config index b3717663e..8fda3decd 100644 --- a/src/runtime/Uno.AppLoader-WinForms/packages.config +++ b/src/runtime/Uno.AppLoader-WinForms/packages.config @@ -1,4 +1,4 @@  - + \ No newline at end of file diff --git a/src/runtime/Uno.Support.OpenTK/GL.cs b/src/runtime/Uno.Support.OpenTK/GL.cs index 687c2582e..f9dbf8fdc 100644 --- a/src/runtime/Uno.Support.OpenTK/GL.cs +++ b/src/runtime/Uno.Support.OpenTK/GL.cs @@ -217,13 +217,13 @@ public void BindFramebuffer(GLFramebufferTarget target, GLFramebufferHandle fb) public void FramebufferTexture2D(GLFramebufferTarget target, GLFramebufferAttachment attachment, GLTextureTarget textarget, GLTextureHandle texture, int level) { - TKGL.FramebufferTexture2D((FramebufferTarget)target, (All)attachment, TextureTarget2d.Texture2D, (int)texture, level); + TKGL.FramebufferTexture2D((FramebufferTarget)target, (FramebufferAttachment)attachment, TextureTarget2d.Texture2D, (int)texture, level); } public void FramebufferRenderbuffer(GLFramebufferTarget target, GLFramebufferAttachment attachment, GLRenderbufferTarget renderbuffertarget, GLRenderbufferHandle renderbuffer) { TKGL.FramebufferRenderbuffer((FramebufferTarget)target, - (All)attachment, + (FramebufferAttachment)attachment, (RenderbufferTarget)renderbuffertarget, (int) renderbuffer); } diff --git a/src/runtime/Uno.Support.OpenTK/Uno.Support.OpenTK.csproj b/src/runtime/Uno.Support.OpenTK/Uno.Support.OpenTK.csproj index 8e0ebdc6f..0fe987bc9 100644 --- a/src/runtime/Uno.Support.OpenTK/Uno.Support.OpenTK.csproj +++ b/src/runtime/Uno.Support.OpenTK/Uno.Support.OpenTK.csproj @@ -34,13 +34,13 @@ true - - ..\..\..\packages\OpenTK.2.0.0\lib\net20\OpenTK.dll + + ..\..\..\packages\OpenTK.3.0.1\lib\net20\OpenTK.dll - + diff --git a/src/runtime/Uno.Support.OpenTK/packages.config b/src/runtime/Uno.Support.OpenTK/packages.config index b3717663e..8fda3decd 100644 --- a/src/runtime/Uno.Support.OpenTK/packages.config +++ b/src/runtime/Uno.Support.OpenTK/packages.config @@ -1,4 +1,4 @@  - + \ No newline at end of file From 8d5524abfc8681caad6db165621a612a5dfc9bc3 Mon Sep 17 00:00:00 2001 From: Morten Daniel Fornes Date: Tue, 16 Oct 2018 03:28:18 +0700 Subject: [PATCH 60/71] upgrade NUnit package --- .../Uno.TestRunner.Tests/Uno.TestRunner.Tests.csproj | 10 +++++----- src/testing/Uno.TestRunner.Tests/packages.config | 2 +- .../Tests/Uno.UX.Markup.AST.Tests.csproj | 12 ++++++------ src/ux/Uno.UX.Markup.AST/Tests/packages.config | 2 +- .../Tests/Uno.UX.Markup.UXIL.Tests.csproj | 8 ++++---- src/ux/Uno.UX.Markup.UXIL/Tests/packages.config | 2 +- 6 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/testing/Uno.TestRunner.Tests/Uno.TestRunner.Tests.csproj b/src/testing/Uno.TestRunner.Tests/Uno.TestRunner.Tests.csproj index 236c518cb..9f6c0c0e2 100644 --- a/src/testing/Uno.TestRunner.Tests/Uno.TestRunner.Tests.csproj +++ b/src/testing/Uno.TestRunner.Tests/Uno.TestRunner.Tests.csproj @@ -1,6 +1,6 @@  - + Debug @@ -34,7 +34,7 @@ prompt 4 - + @@ -45,8 +45,8 @@ ..\..\..\packages\Moq.4.8.2\lib\net45\Moq.dll - - ..\..\..\packages\NUnit.3.10.1\lib\net45\nunit.framework.dll + + ..\..\..\packages\NUnit.3.11.0\lib\net45\nunit.framework.dll @@ -83,7 +83,7 @@ This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - +