From 18d59ff64988c3d725cb6f3407257975eaddd466 Mon Sep 17 00:00:00 2001 From: Nikita Tsukanov Date: Thu, 14 Mar 2019 14:36:07 +0300 Subject: [PATCH 01/41] Custom draw operations, exposed SkCanvas and reduced Skia api visibility --- samples/RenderDemo/MainWindow.xaml | 3 + samples/RenderDemo/Pages/CustomSkiaPage.cs | 119 ++++++++++++++++++ src/Avalonia.Visuals/Media/DrawingContext.cs | 7 ++ .../Platform/IDrawingContextImpl.cs | 7 ++ .../SceneGraph/CustomDrawOperation.cs | 39 ++++++ .../SceneGraph/DeferredDrawingContextImpl.cs | 9 ++ src/Skia/Avalonia.Skia/DrawingContextImpl.cs | 7 +- src/Skia/Avalonia.Skia/FormattedTextImpl.cs | 2 +- .../Avalonia.Skia/FramebufferRenderTarget.cs | 2 +- src/Skia/Avalonia.Skia/GeometryImpl.cs | 2 +- src/Skia/Avalonia.Skia/GlRenderTarget.cs | 2 +- .../Avalonia.Skia/ISkiaDrawingContextImpl.cs | 10 ++ src/Skia/Avalonia.Skia/ImmutableBitmap.cs | 2 +- .../Avalonia.Skia/PlatformRenderInterface.cs | 2 +- src/Skia/Avalonia.Skia/StreamGeometryImpl.cs | 2 +- src/Skia/Avalonia.Skia/SurfaceRenderTarget.cs | 2 +- .../Avalonia.Skia/TransformedGeometryImpl.cs | 2 +- src/Skia/Avalonia.Skia/WriteableBitmapImpl.cs | 2 +- .../Media/DrawingContextImpl.cs | 3 + .../Media/FormattedTextImpl.cs | 2 +- 20 files changed, 214 insertions(+), 12 deletions(-) create mode 100644 samples/RenderDemo/Pages/CustomSkiaPage.cs create mode 100644 src/Avalonia.Visuals/Rendering/SceneGraph/CustomDrawOperation.cs create mode 100644 src/Skia/Avalonia.Skia/ISkiaDrawingContextImpl.cs diff --git a/samples/RenderDemo/MainWindow.xaml b/samples/RenderDemo/MainWindow.xaml index 41164c7780..c15abad188 100644 --- a/samples/RenderDemo/MainWindow.xaml +++ b/samples/RenderDemo/MainWindow.xaml @@ -33,6 +33,9 @@ + + + diff --git a/samples/RenderDemo/Pages/CustomSkiaPage.cs b/samples/RenderDemo/Pages/CustomSkiaPage.cs new file mode 100644 index 0000000000..2e59d934a1 --- /dev/null +++ b/samples/RenderDemo/Pages/CustomSkiaPage.cs @@ -0,0 +1,119 @@ +using System; +using System.Diagnostics; +using Avalonia; +using Avalonia.Controls; +using Avalonia.Media; +using Avalonia.Platform; +using Avalonia.Rendering.SceneGraph; +using Avalonia.Skia; +using Avalonia.Threading; +using SkiaSharp; + +namespace RenderDemo.Pages +{ + public class CustomSkiaPage : Control + { + public CustomSkiaPage() + { + ClipToBounds = true; + } + + class CustomDrawOp : ICustomDrawOperation + { + private readonly FormattedText _noSkia; + + public CustomDrawOp(Rect bounds, FormattedText noSkia) + { + _noSkia = noSkia; + Bounds = bounds; + } + + public void Dispose() + { + // No-op + } + + public Rect Bounds { get; } + public bool HitTest(Point p) => false; + public bool Equals(ICustomDrawOperation other) => false; + static Stopwatch St = Stopwatch.StartNew(); + public void Render(IDrawingContextImpl context) + { + var canvas = (context as ISkiaDrawingContextImpl)?.SkCanvas; + if (canvas == null) + context.DrawText(Brushes.Black, new Point(), _noSkia.PlatformImpl); + else + { + canvas.Save(); + // create the first shader + var colors = new SKColor[] { + new SKColor(0, 255, 255), + new SKColor(255, 0, 255), + new SKColor(255, 255, 0), + new SKColor(0, 255, 255) + }; + + var sx = Animate(100, 2, 10); + var sy = Animate(1000, 5, 15); + var lightPosition = new SKPoint( + (float)(Bounds.Width / 2 + Math.Cos(St.Elapsed.TotalSeconds) * Bounds.Width / 4), + (float)(Bounds.Height / 2 + Math.Sin(St.Elapsed.TotalSeconds) * Bounds.Height / 4)); + using (var sweep = + SKShader.CreateSweepGradient(new SKPoint((int)Bounds.Width / 2, (int)Bounds.Height / 2), colors, + null)) + using(var turbulence = SKShader.CreatePerlinNoiseFractalNoise(0.05f, 0.05f, 4, 0)) + using(var shader = SKShader.CreateCompose(sweep, turbulence, SKBlendMode.SrcATop)) + using(var blur = SKImageFilter.CreateBlur(Animate(100, 2, 10), Animate(100, 5, 15))) + using (var paint = new SKPaint + { + Shader = shader, + ImageFilter = blur + }) + canvas.DrawPaint(paint); + + using (var pseudoLight = SKShader.CreateRadialGradient( + lightPosition, + (float) (Bounds.Width/3), + new [] { + new SKColor(255, 200, 200, 100), + SKColors.Transparent, + new SKColor(40,40,40, 220), + new SKColor(20,20,20, (byte)Animate(100, 200,220)) }, + new float[] { 0.3f, 0.3f, 0.8f, 1 }, + SKShaderTileMode.Clamp)) + using (var paint = new SKPaint + { + Shader = pseudoLight + }) + canvas.DrawPaint(paint); + canvas.Restore(); + } + } + static int Animate(int d, int from, int to) + { + var ms = (int)(St.ElapsedMilliseconds / d); + var diff = to - from; + var range = diff * 2; + var v = ms % range; + if (v > diff) + v = range - v; + var rv = v + from; + if (rv < from || rv > to) + throw new Exception("WTF"); + return rv; + } + } + + + + public override void Render(DrawingContext context) + { + var noSkia = new FormattedText() + { + Text = "Current rendering API is not Skia" + }; + context.Custom(new CustomDrawOp(new Rect(0, 0, Bounds.Width, Bounds.Height), noSkia)); + Dispatcher.UIThread.InvokeAsync(InvalidateVisual, DispatcherPriority.Background); + } + } +} diff --git a/src/Avalonia.Visuals/Media/DrawingContext.cs b/src/Avalonia.Visuals/Media/DrawingContext.cs index fd593db991..d3af71ffcb 100644 --- a/src/Avalonia.Visuals/Media/DrawingContext.cs +++ b/src/Avalonia.Visuals/Media/DrawingContext.cs @@ -2,6 +2,7 @@ using System; using System.Collections.Generic; using Avalonia.Media.Imaging; using Avalonia.Platform; +using Avalonia.Rendering.SceneGraph; using Avalonia.Threading; using Avalonia.Visuals.Media.Imaging; @@ -131,6 +132,12 @@ namespace Avalonia.Media } } + /// + /// Draws a custom drawing operation + /// + /// custom operation + public void Custom(ICustomDrawOperation custom) => PlatformImpl.Custom(custom); + /// /// Draws text. /// diff --git a/src/Avalonia.Visuals/Platform/IDrawingContextImpl.cs b/src/Avalonia.Visuals/Platform/IDrawingContextImpl.cs index 57b974f900..e5be04ebf9 100644 --- a/src/Avalonia.Visuals/Platform/IDrawingContextImpl.cs +++ b/src/Avalonia.Visuals/Platform/IDrawingContextImpl.cs @@ -3,6 +3,7 @@ using System; using Avalonia.Media; +using Avalonia.Rendering.SceneGraph; using Avalonia.Utilities; using Avalonia.Visuals.Media.Imaging; @@ -139,5 +140,11 @@ namespace Avalonia.Platform /// Pops the latest pushed geometry clip. /// void PopGeometryClip(); + + /// + /// Adds a custom draw operation + /// + /// Custom draw operation + void Custom(ICustomDrawOperation custom); } } diff --git a/src/Avalonia.Visuals/Rendering/SceneGraph/CustomDrawOperation.cs b/src/Avalonia.Visuals/Rendering/SceneGraph/CustomDrawOperation.cs new file mode 100644 index 0000000000..68e2237430 --- /dev/null +++ b/src/Avalonia.Visuals/Rendering/SceneGraph/CustomDrawOperation.cs @@ -0,0 +1,39 @@ +using System; +using Avalonia.Media; +using Avalonia.Platform; + +namespace Avalonia.Rendering.SceneGraph +{ + internal sealed class CustomDrawOperation : DrawOperation + { + public Matrix Transform { get; } + public ICustomDrawOperation Custom { get; } + public CustomDrawOperation(ICustomDrawOperation custom, Matrix transform) + : base(custom.Bounds, transform, null) + { + Transform = transform; + Custom = custom; + } + + public override bool HitTest(Point p) + { + return Custom.HitTest(p * Transform); + } + + public override void Render(IDrawingContextImpl context) + { + context.Transform = Transform; + Custom.Render(context); + } + + public override void Dispose() => Custom.Dispose(); + + public bool Equals(Matrix transform, ICustomDrawOperation custom) => + Transform == transform && Custom?.Equals(custom) == true; + } + + public interface ICustomDrawOperation : IDrawOperation, IEquatable + { + + } +} diff --git a/src/Avalonia.Visuals/Rendering/SceneGraph/DeferredDrawingContextImpl.cs b/src/Avalonia.Visuals/Rendering/SceneGraph/DeferredDrawingContextImpl.cs index dfed0d911c..0b33851911 100644 --- a/src/Avalonia.Visuals/Rendering/SceneGraph/DeferredDrawingContextImpl.cs +++ b/src/Avalonia.Visuals/Rendering/SceneGraph/DeferredDrawingContextImpl.cs @@ -165,6 +165,15 @@ namespace Avalonia.Rendering.SceneGraph ++_drawOperationindex; } } + + public void Custom(ICustomDrawOperation custom) + { + var next = NextDrawAs(); + if (next == null || !next.Item.Equals(Transform, custom)) + Add(new CustomDrawOperation(custom, Transform)); + else + ++_drawOperationindex; + } /// public void DrawText(IBrush foreground, Point origin, IFormattedTextImpl text) diff --git a/src/Skia/Avalonia.Skia/DrawingContextImpl.cs b/src/Skia/Avalonia.Skia/DrawingContextImpl.cs index 10e746cbd5..af6b0fe22f 100644 --- a/src/Skia/Avalonia.Skia/DrawingContextImpl.cs +++ b/src/Skia/Avalonia.Skia/DrawingContextImpl.cs @@ -9,6 +9,7 @@ using System.Threading; using Avalonia.Media; using Avalonia.Platform; using Avalonia.Rendering; +using Avalonia.Rendering.SceneGraph; using Avalonia.Rendering.Utilities; using Avalonia.Utilities; using Avalonia.Visuals.Media.Imaging; @@ -19,7 +20,7 @@ namespace Avalonia.Skia /// /// Skia based drawing context. /// - public class DrawingContextImpl : IDrawingContextImpl + internal class DrawingContextImpl : IDrawingContextImpl, ISkiaDrawingContextImpl { private IDisposable[] _disposables; private readonly Vector _dpi; @@ -99,6 +100,8 @@ namespace Avalonia.Skia /// public SKCanvas Canvas { get; } + SKCanvas ISkiaDrawingContextImpl.SkCanvas => Canvas; + /// public void Clear(Color color) { @@ -296,6 +299,8 @@ namespace Avalonia.Skia Canvas.Restore(); } + public void Custom(ICustomDrawOperation custom) => custom.Render(this); + /// public void PushOpacityMask(IBrush mask, Rect bounds) { diff --git a/src/Skia/Avalonia.Skia/FormattedTextImpl.cs b/src/Skia/Avalonia.Skia/FormattedTextImpl.cs index 7e3f4aa40a..47852a4d9e 100644 --- a/src/Skia/Avalonia.Skia/FormattedTextImpl.cs +++ b/src/Skia/Avalonia.Skia/FormattedTextImpl.cs @@ -13,7 +13,7 @@ namespace Avalonia.Skia /// /// Skia formatted text implementation. /// - public class FormattedTextImpl : IFormattedTextImpl + internal class FormattedTextImpl : IFormattedTextImpl { public FormattedTextImpl( string text, diff --git a/src/Skia/Avalonia.Skia/FramebufferRenderTarget.cs b/src/Skia/Avalonia.Skia/FramebufferRenderTarget.cs index 0cb4c3db67..1af3d2968c 100644 --- a/src/Skia/Avalonia.Skia/FramebufferRenderTarget.cs +++ b/src/Skia/Avalonia.Skia/FramebufferRenderTarget.cs @@ -13,7 +13,7 @@ namespace Avalonia.Skia /// /// Skia render target that renders to a framebuffer surface. No gpu acceleration available. /// - public class FramebufferRenderTarget : IRenderTarget + internal class FramebufferRenderTarget : IRenderTarget { private readonly IFramebufferPlatformSurface _platformSurface; private SKImageInfo _currentImageInfo; diff --git a/src/Skia/Avalonia.Skia/GeometryImpl.cs b/src/Skia/Avalonia.Skia/GeometryImpl.cs index fbbd6eb58c..5940de418e 100644 --- a/src/Skia/Avalonia.Skia/GeometryImpl.cs +++ b/src/Skia/Avalonia.Skia/GeometryImpl.cs @@ -11,7 +11,7 @@ namespace Avalonia.Skia /// /// A Skia implementation of . /// - public abstract class GeometryImpl : IGeometryImpl + internal abstract class GeometryImpl : IGeometryImpl { private PathCache _pathCache; diff --git a/src/Skia/Avalonia.Skia/GlRenderTarget.cs b/src/Skia/Avalonia.Skia/GlRenderTarget.cs index cd8c334b53..7c0c42ca37 100644 --- a/src/Skia/Avalonia.Skia/GlRenderTarget.cs +++ b/src/Skia/Avalonia.Skia/GlRenderTarget.cs @@ -8,7 +8,7 @@ using static Avalonia.OpenGL.GlConsts; namespace Avalonia.Skia { - public class GlRenderTarget : IRenderTarget + internal class GlRenderTarget : IRenderTarget { private readonly GRContext _grContext; private IGlPlatformSurfaceRenderTarget _surface; diff --git a/src/Skia/Avalonia.Skia/ISkiaDrawingContextImpl.cs b/src/Skia/Avalonia.Skia/ISkiaDrawingContextImpl.cs new file mode 100644 index 0000000000..ff82990c47 --- /dev/null +++ b/src/Skia/Avalonia.Skia/ISkiaDrawingContextImpl.cs @@ -0,0 +1,10 @@ +using Avalonia.Platform; +using SkiaSharp; + +namespace Avalonia.Skia +{ + public interface ISkiaDrawingContextImpl : IDrawingContextImpl + { + SKCanvas SkCanvas { get; } + } +} diff --git a/src/Skia/Avalonia.Skia/ImmutableBitmap.cs b/src/Skia/Avalonia.Skia/ImmutableBitmap.cs index 49992df395..f283040eac 100644 --- a/src/Skia/Avalonia.Skia/ImmutableBitmap.cs +++ b/src/Skia/Avalonia.Skia/ImmutableBitmap.cs @@ -12,7 +12,7 @@ namespace Avalonia.Skia /// /// Immutable Skia bitmap. /// - public class ImmutableBitmap : IDrawableBitmapImpl + internal class ImmutableBitmap : IDrawableBitmapImpl { private readonly SKImage _image; diff --git a/src/Skia/Avalonia.Skia/PlatformRenderInterface.cs b/src/Skia/Avalonia.Skia/PlatformRenderInterface.cs index c6e68b1c8b..6e13b154b4 100644 --- a/src/Skia/Avalonia.Skia/PlatformRenderInterface.cs +++ b/src/Skia/Avalonia.Skia/PlatformRenderInterface.cs @@ -15,7 +15,7 @@ namespace Avalonia.Skia /// /// Skia platform render interface. /// - public class PlatformRenderInterface : IPlatformRenderInterface + internal class PlatformRenderInterface : IPlatformRenderInterface { private GRContext GrContext { get; } diff --git a/src/Skia/Avalonia.Skia/StreamGeometryImpl.cs b/src/Skia/Avalonia.Skia/StreamGeometryImpl.cs index c19ff79d87..2764c65c6f 100644 --- a/src/Skia/Avalonia.Skia/StreamGeometryImpl.cs +++ b/src/Skia/Avalonia.Skia/StreamGeometryImpl.cs @@ -10,7 +10,7 @@ namespace Avalonia.Skia /// /// A Skia implementation of a . /// - public class StreamGeometryImpl : GeometryImpl, IStreamGeometryImpl + internal class StreamGeometryImpl : GeometryImpl, IStreamGeometryImpl { private Rect _bounds; private readonly SKPath _effectivePath; diff --git a/src/Skia/Avalonia.Skia/SurfaceRenderTarget.cs b/src/Skia/Avalonia.Skia/SurfaceRenderTarget.cs index 4b7eae1af4..9340c9add4 100644 --- a/src/Skia/Avalonia.Skia/SurfaceRenderTarget.cs +++ b/src/Skia/Avalonia.Skia/SurfaceRenderTarget.cs @@ -14,7 +14,7 @@ namespace Avalonia.Skia /// /// Skia render target that writes to a surface. /// - public class SurfaceRenderTarget : IRenderTargetBitmapImpl, IDrawableBitmapImpl + internal class SurfaceRenderTarget : IRenderTargetBitmapImpl, IDrawableBitmapImpl { private readonly SKSurface _surface; private readonly SKCanvas _canvas; diff --git a/src/Skia/Avalonia.Skia/TransformedGeometryImpl.cs b/src/Skia/Avalonia.Skia/TransformedGeometryImpl.cs index e95069eef3..9826bc2ce3 100644 --- a/src/Skia/Avalonia.Skia/TransformedGeometryImpl.cs +++ b/src/Skia/Avalonia.Skia/TransformedGeometryImpl.cs @@ -9,7 +9,7 @@ namespace Avalonia.Skia /// /// A Skia implementation of a . /// - public class TransformedGeometryImpl : GeometryImpl, ITransformedGeometryImpl + internal class TransformedGeometryImpl : GeometryImpl, ITransformedGeometryImpl { /// /// Initializes a new instance of the class. diff --git a/src/Skia/Avalonia.Skia/WriteableBitmapImpl.cs b/src/Skia/Avalonia.Skia/WriteableBitmapImpl.cs index c9d6fa6c11..fea21cde58 100644 --- a/src/Skia/Avalonia.Skia/WriteableBitmapImpl.cs +++ b/src/Skia/Avalonia.Skia/WriteableBitmapImpl.cs @@ -13,7 +13,7 @@ namespace Avalonia.Skia /// /// Skia based writeable bitmap. /// - public class WriteableBitmapImpl : IWriteableBitmapImpl, IDrawableBitmapImpl + internal class WriteableBitmapImpl : IWriteableBitmapImpl, IDrawableBitmapImpl { private static readonly SKBitmapReleaseDelegate s_releaseDelegate = ReleaseProc; private readonly SKBitmap _bitmap; diff --git a/src/Windows/Avalonia.Direct2D1/Media/DrawingContextImpl.cs b/src/Windows/Avalonia.Direct2D1/Media/DrawingContextImpl.cs index 5e150ff647..8ecada1ced 100644 --- a/src/Windows/Avalonia.Direct2D1/Media/DrawingContextImpl.cs +++ b/src/Windows/Avalonia.Direct2D1/Media/DrawingContextImpl.cs @@ -6,6 +6,7 @@ using System.Collections.Generic; using Avalonia.Media; using Avalonia.Platform; using Avalonia.Rendering; +using Avalonia.Rendering.SceneGraph; using Avalonia.Utilities; using SharpDX; using SharpDX.Direct2D1; @@ -508,5 +509,7 @@ namespace Avalonia.Direct2D1.Media { PopLayer(); } + + public void Custom(ICustomDrawOperation custom) => custom.Render(this); } } diff --git a/src/Windows/Avalonia.Direct2D1/Media/FormattedTextImpl.cs b/src/Windows/Avalonia.Direct2D1/Media/FormattedTextImpl.cs index 7164ec7c0d..91adc29214 100644 --- a/src/Windows/Avalonia.Direct2D1/Media/FormattedTextImpl.cs +++ b/src/Windows/Avalonia.Direct2D1/Media/FormattedTextImpl.cs @@ -9,7 +9,7 @@ using DWrite = SharpDX.DirectWrite; namespace Avalonia.Direct2D1.Media { - public class FormattedTextImpl : IFormattedTextImpl + internal class FormattedTextImpl : IFormattedTextImpl { public FormattedTextImpl( string text, From 1db8031b02578e250707893c497ff8e4b0d0deed Mon Sep 17 00:00:00 2001 From: Dariusz Komosinski Date: Thu, 14 Mar 2019 15:16:30 +0100 Subject: [PATCH 02/41] Custom skia gpu support. --- src/Skia/Avalonia.Skia/CustomRenderTarget.cs | 39 +++++++++++++++++++ src/Skia/Avalonia.Skia/ICustomSkiaGpu.cs | 23 +++++++++++ .../Avalonia.Skia/ICustomSkiaRenderSession.cs | 26 +++++++++++++ .../Avalonia.Skia/ICustomSkiaRenderTarget.cs | 16 ++++++++ .../Avalonia.Skia/PlatformRenderInterface.cs | 32 ++++++++++++--- .../SkiaApplicationExtensions.cs | 7 +++- src/Skia/Avalonia.Skia/SkiaPlatform.cs | 6 +-- 7 files changed, 138 insertions(+), 11 deletions(-) create mode 100644 src/Skia/Avalonia.Skia/CustomRenderTarget.cs create mode 100644 src/Skia/Avalonia.Skia/ICustomSkiaGpu.cs create mode 100644 src/Skia/Avalonia.Skia/ICustomSkiaRenderSession.cs create mode 100644 src/Skia/Avalonia.Skia/ICustomSkiaRenderTarget.cs diff --git a/src/Skia/Avalonia.Skia/CustomRenderTarget.cs b/src/Skia/Avalonia.Skia/CustomRenderTarget.cs new file mode 100644 index 0000000000..dd62237b0c --- /dev/null +++ b/src/Skia/Avalonia.Skia/CustomRenderTarget.cs @@ -0,0 +1,39 @@ +using Avalonia.Platform; +using Avalonia.Rendering; + +namespace Avalonia.Skia +{ + /// + /// Adapts to be used within Skia rendering pipeline. + /// + internal class CustomRenderTarget : IRenderTarget + { + private readonly ICustomSkiaRenderTarget _renderTarget; + + public CustomRenderTarget(ICustomSkiaRenderTarget renderTarget) + { + _renderTarget = renderTarget; + } + + public void Dispose() + { + _renderTarget.Dispose(); + } + + public IDrawingContextImpl CreateDrawingContext(IVisualBrushRenderer visualBrushRenderer) + { + ICustomSkiaRenderSession session = _renderTarget.BeginRendering(); + + var nfo = new DrawingContextImpl.CreateInfo + { + GrContext = session.GrContext, + Canvas = session.Canvas, + Dpi = SkiaPlatform.DefaultDpi * session.ScaleFactor, + VisualBrushRenderer = visualBrushRenderer, + DisableTextLcdRendering = true + }; + + return new DrawingContextImpl(nfo, session); + } + } +} diff --git a/src/Skia/Avalonia.Skia/ICustomSkiaGpu.cs b/src/Skia/Avalonia.Skia/ICustomSkiaGpu.cs new file mode 100644 index 0000000000..0cd2e346ff --- /dev/null +++ b/src/Skia/Avalonia.Skia/ICustomSkiaGpu.cs @@ -0,0 +1,23 @@ +using System.Collections.Generic; +using SkiaSharp; + +namespace Avalonia.Skia +{ + /// + /// Custom Skia gpu instance. + /// + public interface ICustomSkiaGpu + { + /// + /// Skia GrContext used. + /// + GRContext GrContext { get; } + + /// + /// Attempts to create custom render target from given surfaces. + /// + /// Surfaces. + /// Created render target or if it fails. + ICustomSkiaRenderTarget TryCreateRenderTarget(IEnumerable surfaces); + } +} diff --git a/src/Skia/Avalonia.Skia/ICustomSkiaRenderSession.cs b/src/Skia/Avalonia.Skia/ICustomSkiaRenderSession.cs new file mode 100644 index 0000000000..70b3a49bcf --- /dev/null +++ b/src/Skia/Avalonia.Skia/ICustomSkiaRenderSession.cs @@ -0,0 +1,26 @@ +using System; +using SkiaSharp; + +namespace Avalonia.Skia +{ + /// + /// Custom render session for Skia render target. + /// + public interface ICustomSkiaRenderSession : IDisposable + { + /// + /// GrContext used by this session. + /// + GRContext GrContext { get; } + + /// + /// Canvas that will be used to render. + /// + SKCanvas Canvas { get; } + + /// + /// Scaling factor. + /// + double ScaleFactor { get; } + } +} diff --git a/src/Skia/Avalonia.Skia/ICustomSkiaRenderTarget.cs b/src/Skia/Avalonia.Skia/ICustomSkiaRenderTarget.cs new file mode 100644 index 0000000000..1609eaf7fe --- /dev/null +++ b/src/Skia/Avalonia.Skia/ICustomSkiaRenderTarget.cs @@ -0,0 +1,16 @@ +using System; + +namespace Avalonia.Skia +{ + /// + /// Custom Skia render target. + /// + public interface ICustomSkiaRenderTarget : IDisposable + { + /// + /// Start rendering to this render target. + /// + /// + ICustomSkiaRenderSession BeginRendering(); + } +} diff --git a/src/Skia/Avalonia.Skia/PlatformRenderInterface.cs b/src/Skia/Avalonia.Skia/PlatformRenderInterface.cs index c6e68b1c8b..ec162f9767 100644 --- a/src/Skia/Avalonia.Skia/PlatformRenderInterface.cs +++ b/src/Skia/Avalonia.Skia/PlatformRenderInterface.cs @@ -15,14 +15,25 @@ namespace Avalonia.Skia /// /// Skia platform render interface. /// - public class PlatformRenderInterface : IPlatformRenderInterface + internal class PlatformRenderInterface : IPlatformRenderInterface { + private readonly ICustomSkiaGpu _customSkiaGpu; + private GRContext GrContext { get; } public IEnumerable InstalledFontNames => SKFontManager.Default.FontFamilies; - public PlatformRenderInterface() + public PlatformRenderInterface(ICustomSkiaGpu customSkiaGpu) { + if (customSkiaGpu != null) + { + _customSkiaGpu = customSkiaGpu; + + GrContext = _customSkiaGpu.GrContext; + + return; + } + var gl = AvaloniaLocator.Current.GetService(); if (gl != null) { @@ -32,12 +43,11 @@ namespace Avalonia.Skia ? GRGlInterface.AssembleGlInterface((_, proc) => display.GlInterface.GetProcAddress(proc)) : GRGlInterface.AssembleGlesInterface((_, proc) => display.GlInterface.GetProcAddress(proc))) { - GrContext = GRContext.Create(GRBackend.OpenGL, iface); } } } - + /// public IFormattedTextImpl CreateFormattedText( string text, @@ -98,13 +108,23 @@ namespace Avalonia.Skia DisableTextLcdRendering = false, GrContext = GrContext }; - + return new SurfaceRenderTarget(createInfo); } /// - public virtual IRenderTarget CreateRenderTarget(IEnumerable surfaces) + public IRenderTarget CreateRenderTarget(IEnumerable surfaces) { + if (_customSkiaGpu != null) + { + ICustomSkiaRenderTarget customRenderTarget = _customSkiaGpu.TryCreateRenderTarget(surfaces); + + if (customRenderTarget != null) + { + return new CustomRenderTarget(customRenderTarget); + } + } + foreach (var surface in surfaces) { if (surface is IGlPlatformSurface glSurface && GrContext != null) diff --git a/src/Skia/Avalonia.Skia/SkiaApplicationExtensions.cs b/src/Skia/Avalonia.Skia/SkiaApplicationExtensions.cs index f4412df473..0778c64736 100644 --- a/src/Skia/Avalonia.Skia/SkiaApplicationExtensions.cs +++ b/src/Skia/Avalonia.Skia/SkiaApplicationExtensions.cs @@ -1,6 +1,7 @@ // Copyright (c) The Avalonia Project. All rights reserved. // Licensed under the MIT license. See licence.md file in the project root for full license information. +using System; using Avalonia.Controls; using Avalonia.Skia; @@ -18,9 +19,11 @@ namespace Avalonia /// Builder type. /// Builder. /// Configure builder. - public static T UseSkia(this T builder) where T : AppBuilderBase, new() + public static T UseSkia(this T builder, Func gpuFactory = null) where T : AppBuilderBase, new() { - builder.UseRenderingSubsystem(() => SkiaPlatform.Initialize(), "Skia"); + var customGpu = gpuFactory?.Invoke(); + + builder.UseRenderingSubsystem(() => SkiaPlatform.Initialize(customGpu), "Skia"); return builder; } } diff --git a/src/Skia/Avalonia.Skia/SkiaPlatform.cs b/src/Skia/Avalonia.Skia/SkiaPlatform.cs index a9d69aea31..f287f58685 100644 --- a/src/Skia/Avalonia.Skia/SkiaPlatform.cs +++ b/src/Skia/Avalonia.Skia/SkiaPlatform.cs @@ -13,10 +13,10 @@ namespace Avalonia.Skia /// /// Initialize Skia platform. /// - public static void Initialize() + public static void Initialize(ICustomSkiaGpu customGpu) { - var renderInterface = new PlatformRenderInterface(); - + var renderInterface = new PlatformRenderInterface(customGpu); + AvaloniaLocator.CurrentMutable .Bind().ToConstant(renderInterface); } From 853476943539cb434378ce62696f692ddeb2a09e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dariusz=20Komosi=C5=84ski?= Date: Sat, 16 Mar 2019 16:45:30 +0100 Subject: [PATCH 03/41] Platform geometry implementations for D2D and Skia. --- samples/ControlCatalog/MainView.xaml | 3 ++ samples/ControlCatalog/Pages/EllipsePage.xaml | 23 ++++++++++++++ .../ControlCatalog/Pages/EllipsePage.xaml.cs | 18 +++++++++++ samples/ControlCatalog/Pages/LinePage.xaml | 21 +++++++++++++ samples/ControlCatalog/Pages/LinePage.xaml.cs | 18 +++++++++++ .../ControlCatalog/Pages/RectanglePage.xaml | 21 +++++++++++++ .../Pages/RectanglePage.xaml.cs | 18 +++++++++++ src/Avalonia.Visuals/Media/EllipseGeometry.cs | 31 +------------------ src/Avalonia.Visuals/Media/LineGeometry.cs | 10 +----- .../Media/RectangleGeometry.cs | 28 ++++++----------- .../Platform/IEllipseGeometryImpl.cs | 12 +++++++ .../Platform/ILineGeometryImpl.cs | 12 +++++++ .../Platform/IPlatformRenderInterface.cs | 22 +++++++++++++ .../Platform/IRectangleGeometryImpl.cs | 12 +++++++ src/Skia/Avalonia.Skia/EllipseGeometryImpl.cs | 26 ++++++++++++++++ src/Skia/Avalonia.Skia/LineGeometryImpl.cs | 30 ++++++++++++++++++ .../Avalonia.Skia/PlatformRenderInterface.cs | 6 ++++ .../Avalonia.Skia/RectangleGeometryImpl.cs | 26 ++++++++++++++++ .../Avalonia.Direct2D1/Direct2D1Platform.cs | 8 ++--- .../Media/EllipseGeometryImpl.cs | 28 +++++++++++++++++ .../Media/LineGeometryImpl.cs | 28 +++++++++++++++++ .../Media/RectangleGeometryImpl.cs | 27 ++++++++++++++++ .../Wpf/Direct2DImageSurface.cs | 2 +- .../MockPlatformRenderInterface.cs | 15 +++++++++ .../VisualTree/MockRenderInterface.cs | 15 +++++++++ 25 files changed, 398 insertions(+), 62 deletions(-) create mode 100644 samples/ControlCatalog/Pages/EllipsePage.xaml create mode 100644 samples/ControlCatalog/Pages/EllipsePage.xaml.cs create mode 100644 samples/ControlCatalog/Pages/LinePage.xaml create mode 100644 samples/ControlCatalog/Pages/LinePage.xaml.cs create mode 100644 samples/ControlCatalog/Pages/RectanglePage.xaml create mode 100644 samples/ControlCatalog/Pages/RectanglePage.xaml.cs create mode 100644 src/Avalonia.Visuals/Platform/IEllipseGeometryImpl.cs create mode 100644 src/Avalonia.Visuals/Platform/ILineGeometryImpl.cs create mode 100644 src/Avalonia.Visuals/Platform/IRectangleGeometryImpl.cs create mode 100644 src/Skia/Avalonia.Skia/EllipseGeometryImpl.cs create mode 100644 src/Skia/Avalonia.Skia/LineGeometryImpl.cs create mode 100644 src/Skia/Avalonia.Skia/RectangleGeometryImpl.cs create mode 100644 src/Windows/Avalonia.Direct2D1/Media/EllipseGeometryImpl.cs create mode 100644 src/Windows/Avalonia.Direct2D1/Media/LineGeometryImpl.cs create mode 100644 src/Windows/Avalonia.Direct2D1/Media/RectangleGeometryImpl.cs diff --git a/samples/ControlCatalog/MainView.xaml b/samples/ControlCatalog/MainView.xaml index 2ddb5887e5..874449c9b6 100644 --- a/samples/ControlCatalog/MainView.xaml +++ b/samples/ControlCatalog/MainView.xaml @@ -23,14 +23,17 @@ + + + diff --git a/samples/ControlCatalog/Pages/EllipsePage.xaml b/samples/ControlCatalog/Pages/EllipsePage.xaml new file mode 100644 index 0000000000..f66cca9cdb --- /dev/null +++ b/samples/ControlCatalog/Pages/EllipsePage.xaml @@ -0,0 +1,23 @@ + + + Ellipse + A control which represents an ellipse with a fill and a stroke. + + + + + + + + + + + + + + diff --git a/samples/ControlCatalog/Pages/EllipsePage.xaml.cs b/samples/ControlCatalog/Pages/EllipsePage.xaml.cs new file mode 100644 index 0000000000..e450e961ed --- /dev/null +++ b/samples/ControlCatalog/Pages/EllipsePage.xaml.cs @@ -0,0 +1,18 @@ +using Avalonia.Controls; +using Avalonia.Markup.Xaml; + +namespace ControlCatalog.Pages +{ + public class EllipsePage : UserControl + { + public EllipsePage() + { + this.InitializeComponent(); + } + + private void InitializeComponent() + { + AvaloniaXamlLoader.Load(this); + } + } +} diff --git a/samples/ControlCatalog/Pages/LinePage.xaml b/samples/ControlCatalog/Pages/LinePage.xaml new file mode 100644 index 0000000000..62ab917578 --- /dev/null +++ b/samples/ControlCatalog/Pages/LinePage.xaml @@ -0,0 +1,21 @@ + + + Line + A control which represents a line. + + + + + + + + + + + + diff --git a/samples/ControlCatalog/Pages/LinePage.xaml.cs b/samples/ControlCatalog/Pages/LinePage.xaml.cs new file mode 100644 index 0000000000..43b8049d45 --- /dev/null +++ b/samples/ControlCatalog/Pages/LinePage.xaml.cs @@ -0,0 +1,18 @@ +using Avalonia.Controls; +using Avalonia.Markup.Xaml; + +namespace ControlCatalog.Pages +{ + public class LinePage : UserControl + { + public LinePage() + { + this.InitializeComponent(); + } + + private void InitializeComponent() + { + AvaloniaXamlLoader.Load(this); + } + } +} diff --git a/samples/ControlCatalog/Pages/RectanglePage.xaml b/samples/ControlCatalog/Pages/RectanglePage.xaml new file mode 100644 index 0000000000..49701812c4 --- /dev/null +++ b/samples/ControlCatalog/Pages/RectanglePage.xaml @@ -0,0 +1,21 @@ + + + Rectangle + A control which represents a rectangle with a fill and a stroke. + + + + + + + + + + + + diff --git a/samples/ControlCatalog/Pages/RectanglePage.xaml.cs b/samples/ControlCatalog/Pages/RectanglePage.xaml.cs new file mode 100644 index 0000000000..0ee8a1a40f --- /dev/null +++ b/samples/ControlCatalog/Pages/RectanglePage.xaml.cs @@ -0,0 +1,18 @@ +using Avalonia.Controls; +using Avalonia.Markup.Xaml; + +namespace ControlCatalog.Pages +{ + public class RectanglePage : UserControl + { + public RectanglePage() + { + this.InitializeComponent(); + } + + private void InitializeComponent() + { + AvaloniaXamlLoader.Load(this); + } + } +} diff --git a/src/Avalonia.Visuals/Media/EllipseGeometry.cs b/src/Avalonia.Visuals/Media/EllipseGeometry.cs index ca84d4cc7b..c2df9db635 100644 --- a/src/Avalonia.Visuals/Media/EllipseGeometry.cs +++ b/src/Avalonia.Visuals/Media/EllipseGeometry.cs @@ -1,7 +1,6 @@ // Copyright (c) The Avalonia Project. All rights reserved. // Licensed under the MIT license. See licence.md file in the project root for full license information. -using System; using Avalonia.Platform; namespace Avalonia.Media @@ -57,36 +56,8 @@ namespace Avalonia.Media protected override IGeometryImpl CreateDefiningGeometry() { var factory = AvaloniaLocator.Current.GetService(); - var geometry = factory.CreateStreamGeometry(); - using (var ctx = geometry.Open()) - { - var rect = Rect; - double controlPointRatio = (Math.Sqrt(2) - 1) * 4 / 3; - var center = rect.Center; - var radius = new Vector(rect.Width / 2, rect.Height / 2); - - var x0 = center.X - radius.X; - var x1 = center.X - (radius.X * controlPointRatio); - var x2 = center.X; - var x3 = center.X + (radius.X * controlPointRatio); - var x4 = center.X + radius.X; - - var y0 = center.Y - radius.Y; - var y1 = center.Y - (radius.Y * controlPointRatio); - var y2 = center.Y; - var y3 = center.Y + (radius.Y * controlPointRatio); - var y4 = center.Y + radius.Y; - - ctx.BeginFigure(new Point(x2, y0), true); - ctx.CubicBezierTo(new Point(x3, y0), new Point(x4, y1), new Point(x4, y2)); - ctx.CubicBezierTo(new Point(x4, y3), new Point(x3, y4), new Point(x2, y4)); - ctx.CubicBezierTo(new Point(x1, y4), new Point(x0, y3), new Point(x0, y2)); - ctx.CubicBezierTo(new Point(x0, y1), new Point(x1, y0), new Point(x2, y0)); - ctx.EndFigure(true); - } - - return geometry; + return factory.CreateEllipseGeometry(Rect); } } } diff --git a/src/Avalonia.Visuals/Media/LineGeometry.cs b/src/Avalonia.Visuals/Media/LineGeometry.cs index f7ba4ccb0e..90577dabd8 100644 --- a/src/Avalonia.Visuals/Media/LineGeometry.cs +++ b/src/Avalonia.Visuals/Media/LineGeometry.cs @@ -73,16 +73,8 @@ namespace Avalonia.Media protected override IGeometryImpl CreateDefiningGeometry() { var factory = AvaloniaLocator.Current.GetService(); - var geometry = factory.CreateStreamGeometry(); - using (var context = geometry.Open()) - { - context.BeginFigure(StartPoint, false); - context.LineTo(EndPoint); - context.EndFigure(false); - } - - return geometry; + return factory.CreateLineGeometry(StartPoint, EndPoint); } } } diff --git a/src/Avalonia.Visuals/Media/RectangleGeometry.cs b/src/Avalonia.Visuals/Media/RectangleGeometry.cs index 3ccfd80f93..9250500644 100644 --- a/src/Avalonia.Visuals/Media/RectangleGeometry.cs +++ b/src/Avalonia.Visuals/Media/RectangleGeometry.cs @@ -16,12 +16,6 @@ namespace Avalonia.Media public static readonly StyledProperty RectProperty = AvaloniaProperty.Register(nameof(Rect)); - public Rect Rect - { - get => GetValue(RectProperty); - set => SetValue(RectProperty, value); - } - static RectangleGeometry() { AffectsGeometry(RectProperty); @@ -43,25 +37,23 @@ namespace Avalonia.Media Rect = rect; } + /// + /// Gets or sets the bounds of the rectangle. + /// + public Rect Rect + { + get => GetValue(RectProperty); + set => SetValue(RectProperty, value); + } + /// public override Geometry Clone() => new RectangleGeometry(Rect); protected override IGeometryImpl CreateDefiningGeometry() { var factory = AvaloniaLocator.Current.GetService(); - var geometry = factory.CreateStreamGeometry(); - - using (var context = geometry.Open()) - { - var rect = Rect; - context.BeginFigure(rect.TopLeft, true); - context.LineTo(rect.TopRight); - context.LineTo(rect.BottomRight); - context.LineTo(rect.BottomLeft); - context.EndFigure(true); - } - return geometry; + return factory.CreateRectangleGeometry(Rect); } } } diff --git a/src/Avalonia.Visuals/Platform/IEllipseGeometryImpl.cs b/src/Avalonia.Visuals/Platform/IEllipseGeometryImpl.cs new file mode 100644 index 0000000000..982cf286a3 --- /dev/null +++ b/src/Avalonia.Visuals/Platform/IEllipseGeometryImpl.cs @@ -0,0 +1,12 @@ +// Copyright (c) The Avalonia Project. All rights reserved. +// Licensed under the MIT license. See licence.md file in the project root for full license information. + +namespace Avalonia.Platform +{ + /// + /// Defines the platform-specific interface for a . + /// + public interface IEllipseGeometryImpl : IGeometryImpl + { + } +} diff --git a/src/Avalonia.Visuals/Platform/ILineGeometryImpl.cs b/src/Avalonia.Visuals/Platform/ILineGeometryImpl.cs new file mode 100644 index 0000000000..a8aa46fb13 --- /dev/null +++ b/src/Avalonia.Visuals/Platform/ILineGeometryImpl.cs @@ -0,0 +1,12 @@ +// Copyright (c) The Avalonia Project. All rights reserved. +// Licensed under the MIT license. See licence.md file in the project root for full license information. + +namespace Avalonia.Platform +{ + /// + /// Defines the platform-specific interface for a . + /// + public interface ILineGeometryImpl : IGeometryImpl + { + } +} diff --git a/src/Avalonia.Visuals/Platform/IPlatformRenderInterface.cs b/src/Avalonia.Visuals/Platform/IPlatformRenderInterface.cs index 3a1f79e32a..45ce8f5874 100644 --- a/src/Avalonia.Visuals/Platform/IPlatformRenderInterface.cs +++ b/src/Avalonia.Visuals/Platform/IPlatformRenderInterface.cs @@ -36,6 +36,28 @@ namespace Avalonia.Platform Size constraint, IReadOnlyList spans); + /// + /// Creates an ellipse geometry implementation. + /// + /// The bounds of the ellipse. + /// An . + IEllipseGeometryImpl CreateEllipseGeometry(Rect rect); + + /// + /// Creates a line geometry implementation. + /// + /// The start of the line. + /// The end of the line. + /// An . + ILineGeometryImpl CreateLineGeometry(Point p1, Point p2); + + /// + /// Creates a rectangle geometry implementation. + /// + /// The bounds of the rectangle. + /// An . + IRectangleGeometryImpl CreateRectangleGeometry(Rect rect); + /// /// Creates a stream geometry implementation. /// diff --git a/src/Avalonia.Visuals/Platform/IRectangleGeometryImpl.cs b/src/Avalonia.Visuals/Platform/IRectangleGeometryImpl.cs new file mode 100644 index 0000000000..7ada2c874d --- /dev/null +++ b/src/Avalonia.Visuals/Platform/IRectangleGeometryImpl.cs @@ -0,0 +1,12 @@ +// Copyright (c) The Avalonia Project. All rights reserved. +// Licensed under the MIT license. See licence.md file in the project root for full license information. + +namespace Avalonia.Platform +{ + /// + /// Defines the platform-specific interface for a . + /// + public interface IRectangleGeometryImpl : IGeometryImpl + { + } +} diff --git a/src/Skia/Avalonia.Skia/EllipseGeometryImpl.cs b/src/Skia/Avalonia.Skia/EllipseGeometryImpl.cs new file mode 100644 index 0000000000..92a0a5ff80 --- /dev/null +++ b/src/Skia/Avalonia.Skia/EllipseGeometryImpl.cs @@ -0,0 +1,26 @@ +// Copyright (c) The Avalonia Project. All rights reserved. +// Licensed under the MIT license. See licence.md file in the project root for full license information. + +using Avalonia.Platform; +using SkiaSharp; + +namespace Avalonia.Skia +{ + /// + /// A Skia implementation of a . + /// + internal class EllipseGeometryImpl : GeometryImpl, IEllipseGeometryImpl + { + public override Rect Bounds { get; } + public override SKPath EffectivePath { get; } + + public EllipseGeometryImpl(Rect rect) + { + var path = new SKPath(); + path.AddOval(rect.ToSKRect()); + + EffectivePath = path; + Bounds = rect; + } + } +} diff --git a/src/Skia/Avalonia.Skia/LineGeometryImpl.cs b/src/Skia/Avalonia.Skia/LineGeometryImpl.cs new file mode 100644 index 0000000000..a78c76d44a --- /dev/null +++ b/src/Skia/Avalonia.Skia/LineGeometryImpl.cs @@ -0,0 +1,30 @@ +// Copyright (c) The Avalonia Project. All rights reserved. +// Licensed under the MIT license. See licence.md file in the project root for full license information. + +using System; +using Avalonia.Platform; +using SkiaSharp; + +namespace Avalonia.Skia +{ + /// + /// A Skia implementation of a . + /// + internal class LineGeometryImpl : GeometryImpl, ILineGeometryImpl + { + public override Rect Bounds { get; } + public override SKPath EffectivePath { get; } + + public LineGeometryImpl(Point p1, Point p2) + { + var path = new SKPath(); + path.MoveTo(p1.ToSKPoint()); + path.LineTo(p2.ToSKPoint()); + + EffectivePath = path; + Bounds = new Rect( + new Point(Math.Min(p1.X, p2.X), Math.Min(p1.Y, p2.Y)), + new Point(Math.Max(p1.X, p2.X), Math.Max(p1.Y, p2.Y))); + } + } +} diff --git a/src/Skia/Avalonia.Skia/PlatformRenderInterface.cs b/src/Skia/Avalonia.Skia/PlatformRenderInterface.cs index c6e68b1c8b..f1e89bc464 100644 --- a/src/Skia/Avalonia.Skia/PlatformRenderInterface.cs +++ b/src/Skia/Avalonia.Skia/PlatformRenderInterface.cs @@ -50,6 +50,12 @@ namespace Avalonia.Skia return new FormattedTextImpl(text, typeface, textAlignment, wrapping, constraint, spans); } + public IEllipseGeometryImpl CreateEllipseGeometry(Rect rect) => new EllipseGeometryImpl(rect); + + public ILineGeometryImpl CreateLineGeometry(Point p1, Point p2) => new LineGeometryImpl(p1, p2); + + public IRectangleGeometryImpl CreateRectangleGeometry(Rect rect) => new RectangleGeometryImpl(rect); + /// public IStreamGeometryImpl CreateStreamGeometry() { diff --git a/src/Skia/Avalonia.Skia/RectangleGeometryImpl.cs b/src/Skia/Avalonia.Skia/RectangleGeometryImpl.cs new file mode 100644 index 0000000000..235cd37b56 --- /dev/null +++ b/src/Skia/Avalonia.Skia/RectangleGeometryImpl.cs @@ -0,0 +1,26 @@ +// Copyright (c) The Avalonia Project. All rights reserved. +// Licensed under the MIT license. See licence.md file in the project root for full license information. + +using Avalonia.Platform; +using SkiaSharp; + +namespace Avalonia.Skia +{ + /// + /// A Skia implementation of a . + /// + internal class RectangleGeometryImpl : GeometryImpl, IRectangleGeometryImpl + { + public override Rect Bounds { get; } + public override SKPath EffectivePath { get; } + + public RectangleGeometryImpl(Rect rect) + { + var path = new SKPath(); + path.AddRect(rect.ToSKRect()); + + EffectivePath = path; + Bounds = rect; + } + } +} diff --git a/src/Windows/Avalonia.Direct2D1/Direct2D1Platform.cs b/src/Windows/Avalonia.Direct2D1/Direct2D1Platform.cs index 8412a65e23..cb37a93bb3 100644 --- a/src/Windows/Avalonia.Direct2D1/Direct2D1Platform.cs +++ b/src/Windows/Avalonia.Direct2D1/Direct2D1Platform.cs @@ -182,10 +182,10 @@ namespace Avalonia.Direct2D1 return new WriteableWicBitmapImpl(size, dpi, format); } - public IStreamGeometryImpl CreateStreamGeometry() - { - return new StreamGeometryImpl(); - } + public IEllipseGeometryImpl CreateEllipseGeometry(Rect rect) => new EllipseGeometryImpl(rect); + public ILineGeometryImpl CreateLineGeometry(Point p1, Point p2) => new LineGeometryImpl(p1, p2); + public IRectangleGeometryImpl CreateRectangleGeometry(Rect rect) => new RectangleGeometryImpl(rect); + public IStreamGeometryImpl CreateStreamGeometry() => new StreamGeometryImpl(); public IBitmapImpl LoadBitmap(string fileName) { diff --git a/src/Windows/Avalonia.Direct2D1/Media/EllipseGeometryImpl.cs b/src/Windows/Avalonia.Direct2D1/Media/EllipseGeometryImpl.cs new file mode 100644 index 0000000000..c6bf475ed1 --- /dev/null +++ b/src/Windows/Avalonia.Direct2D1/Media/EllipseGeometryImpl.cs @@ -0,0 +1,28 @@ +// Copyright (c) The Avalonia Project. All rights reserved. +// Licensed under the MIT license. See licence.md file in the project root for full license information. + +using Avalonia.Platform; +using SharpDX.Direct2D1; + +namespace Avalonia.Direct2D1.Media +{ + /// + /// A Direct2D implementation of a . + /// + internal class EllipseGeometryImpl : GeometryImpl, IEllipseGeometryImpl + { + /// + /// Initializes a new instance of the class. + /// + public EllipseGeometryImpl(Rect rect) + : base(CreateGeometry(rect)) + { + } + + private static Geometry CreateGeometry(Rect rect) + { + var ellipse = new Ellipse(rect.Center.ToSharpDX(), (float)rect.Width / 2, (float)rect.Height / 2); + return new EllipseGeometry(Direct2D1Platform.Direct2D1Factory, ellipse); + } + } +} diff --git a/src/Windows/Avalonia.Direct2D1/Media/LineGeometryImpl.cs b/src/Windows/Avalonia.Direct2D1/Media/LineGeometryImpl.cs new file mode 100644 index 0000000000..b2d11247b9 --- /dev/null +++ b/src/Windows/Avalonia.Direct2D1/Media/LineGeometryImpl.cs @@ -0,0 +1,28 @@ +// Copyright (c) The Avalonia Project. All rights reserved. +// Licensed under the MIT license. See licence.md file in the project root for full license information. + +using Avalonia.Platform; +using SharpDX.Direct2D1; + +namespace Avalonia.Direct2D1.Media +{ + /// + /// A Direct2D implementation of a . + /// + internal class LineGeometryImpl : StreamGeometryImpl, ILineGeometryImpl + { + /// + /// Initializes a new instance of the class. + /// + public LineGeometryImpl(Point p1, Point p2) + { + using (var sink = ((PathGeometry)Geometry).Open()) + { + sink.BeginFigure(p1.ToSharpDX(), FigureBegin.Hollow); + sink.AddLine(p2.ToSharpDX()); + sink.EndFigure(FigureEnd.Open); + sink.Close(); + } + } + } +} diff --git a/src/Windows/Avalonia.Direct2D1/Media/RectangleGeometryImpl.cs b/src/Windows/Avalonia.Direct2D1/Media/RectangleGeometryImpl.cs new file mode 100644 index 0000000000..55b2b66b3f --- /dev/null +++ b/src/Windows/Avalonia.Direct2D1/Media/RectangleGeometryImpl.cs @@ -0,0 +1,27 @@ +// Copyright (c) The Avalonia Project. All rights reserved. +// Licensed under the MIT license. See licence.md file in the project root for full license information. + +using Avalonia.Platform; +using SharpDX.Direct2D1; + +namespace Avalonia.Direct2D1.Media +{ + /// + /// A Direct2D implementation of a . + /// + internal class RectangleGeometryImpl : GeometryImpl, IRectangleGeometryImpl + { + /// + /// Initializes a new instance of the class. + /// + public RectangleGeometryImpl(Rect rect) + : base(CreateGeometry(rect)) + { + } + + private static Geometry CreateGeometry(Rect rect) + { + return new RectangleGeometry(Direct2D1Platform.Direct2D1Factory, rect.ToDirect2D()); + } + } +} diff --git a/src/Windows/Avalonia.Win32.Interop/Wpf/Direct2DImageSurface.cs b/src/Windows/Avalonia.Win32.Interop/Wpf/Direct2DImageSurface.cs index 400dd59ea9..5b04c5d7ff 100644 --- a/src/Windows/Avalonia.Win32.Interop/Wpf/Direct2DImageSurface.cs +++ b/src/Windows/Avalonia.Win32.Interop/Wpf/Direct2DImageSurface.cs @@ -50,7 +50,7 @@ namespace Avalonia.Win32.Interop.Wpf { _resource = texture.QueryInterface(); - Target = new RenderTarget(AvaloniaLocator.Current.GetService(), surface, + Target = new RenderTarget(Direct2D1Platform.Direct2D1Factory, surface, new RenderTargetProperties { DpiX = (float) dpi.X, diff --git a/tests/Avalonia.UnitTests/MockPlatformRenderInterface.cs b/tests/Avalonia.UnitTests/MockPlatformRenderInterface.cs index 0e2abb314d..1aeaf6bf8b 100644 --- a/tests/Avalonia.UnitTests/MockPlatformRenderInterface.cs +++ b/tests/Avalonia.UnitTests/MockPlatformRenderInterface.cs @@ -22,6 +22,21 @@ namespace Avalonia.UnitTests return Mock.Of(); } + public IEllipseGeometryImpl CreateEllipseGeometry(Rect rect) + { + throw new NotImplementedException(); + } + + public ILineGeometryImpl CreateLineGeometry(Point p1, Point p2) + { + throw new NotImplementedException(); + } + + public IRectangleGeometryImpl CreateRectangleGeometry(Rect rect) + { + throw new NotImplementedException(); + } + public IRenderTarget CreateRenderTarget(IEnumerable surfaces) { return Mock.Of(); diff --git a/tests/Avalonia.Visuals.UnitTests/VisualTree/MockRenderInterface.cs b/tests/Avalonia.Visuals.UnitTests/VisualTree/MockRenderInterface.cs index fec0f0831a..34be5f1dde 100644 --- a/tests/Avalonia.Visuals.UnitTests/VisualTree/MockRenderInterface.cs +++ b/tests/Avalonia.Visuals.UnitTests/VisualTree/MockRenderInterface.cs @@ -56,6 +56,21 @@ namespace Avalonia.Visuals.UnitTests.VisualTree throw new NotImplementedException(); } + public IEllipseGeometryImpl CreateEllipseGeometry(Rect rect) + { + throw new NotImplementedException(); + } + + public ILineGeometryImpl CreateLineGeometry(Point p1, Point p2) + { + throw new NotImplementedException(); + } + + public IRectangleGeometryImpl CreateRectangleGeometry(Rect rect) + { + throw new NotImplementedException(); + } + class MockStreamGeometry : IStreamGeometryImpl { private MockStreamGeometryContext _impl = new MockStreamGeometryContext(); From 0f414d839177d34317fb4d87d9b12332ab45a8dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dariusz=20Komosi=C5=84ski?= Date: Sun, 17 Mar 2019 17:43:23 +0100 Subject: [PATCH 04/41] Fix unit tests. --- src/Skia/Avalonia.Skia/SkiaPlatform.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Skia/Avalonia.Skia/SkiaPlatform.cs b/src/Skia/Avalonia.Skia/SkiaPlatform.cs index f287f58685..e4185c43a2 100644 --- a/src/Skia/Avalonia.Skia/SkiaPlatform.cs +++ b/src/Skia/Avalonia.Skia/SkiaPlatform.cs @@ -13,7 +13,7 @@ namespace Avalonia.Skia /// /// Initialize Skia platform. /// - public static void Initialize(ICustomSkiaGpu customGpu) + public static void Initialize(ICustomSkiaGpu customGpu = null) { var renderInterface = new PlatformRenderInterface(customGpu); From adf92d2ecb3ba3111fd3cf3efddd58b0250e129a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dariusz=20Komosi=C5=84ski?= Date: Sun, 17 Mar 2019 17:57:15 +0100 Subject: [PATCH 05/41] Add license headers. --- src/Skia/Avalonia.Skia/CustomRenderTarget.cs | 3 +++ src/Skia/Avalonia.Skia/ICustomSkiaGpu.cs | 3 +++ src/Skia/Avalonia.Skia/ICustomSkiaRenderSession.cs | 3 +++ src/Skia/Avalonia.Skia/ICustomSkiaRenderTarget.cs | 3 +++ 4 files changed, 12 insertions(+) diff --git a/src/Skia/Avalonia.Skia/CustomRenderTarget.cs b/src/Skia/Avalonia.Skia/CustomRenderTarget.cs index dd62237b0c..23a509a2a4 100644 --- a/src/Skia/Avalonia.Skia/CustomRenderTarget.cs +++ b/src/Skia/Avalonia.Skia/CustomRenderTarget.cs @@ -1,3 +1,6 @@ +// Copyright (c) The Avalonia Project. All rights reserved. +// Licensed under the MIT license. See licence.md file in the project root for full license information. + using Avalonia.Platform; using Avalonia.Rendering; diff --git a/src/Skia/Avalonia.Skia/ICustomSkiaGpu.cs b/src/Skia/Avalonia.Skia/ICustomSkiaGpu.cs index 0cd2e346ff..751dd3c1e7 100644 --- a/src/Skia/Avalonia.Skia/ICustomSkiaGpu.cs +++ b/src/Skia/Avalonia.Skia/ICustomSkiaGpu.cs @@ -1,3 +1,6 @@ +// Copyright (c) The Avalonia Project. All rights reserved. +// Licensed under the MIT license. See licence.md file in the project root for full license information. + using System.Collections.Generic; using SkiaSharp; diff --git a/src/Skia/Avalonia.Skia/ICustomSkiaRenderSession.cs b/src/Skia/Avalonia.Skia/ICustomSkiaRenderSession.cs index 70b3a49bcf..6a4591921e 100644 --- a/src/Skia/Avalonia.Skia/ICustomSkiaRenderSession.cs +++ b/src/Skia/Avalonia.Skia/ICustomSkiaRenderSession.cs @@ -1,3 +1,6 @@ +// Copyright (c) The Avalonia Project. All rights reserved. +// Licensed under the MIT license. See licence.md file in the project root for full license information. + using System; using SkiaSharp; diff --git a/src/Skia/Avalonia.Skia/ICustomSkiaRenderTarget.cs b/src/Skia/Avalonia.Skia/ICustomSkiaRenderTarget.cs index 1609eaf7fe..f67b28b77b 100644 --- a/src/Skia/Avalonia.Skia/ICustomSkiaRenderTarget.cs +++ b/src/Skia/Avalonia.Skia/ICustomSkiaRenderTarget.cs @@ -1,3 +1,6 @@ +// Copyright (c) The Avalonia Project. All rights reserved. +// Licensed under the MIT license. See licence.md file in the project root for full license information. + using System; namespace Avalonia.Skia From 7363f7140bd008ec1cd31eb92c1d71b72c8c6478 Mon Sep 17 00:00:00 2001 From: Steven Kirk Date: Fri, 29 Mar 2019 00:50:50 +0100 Subject: [PATCH 06/41] Don't leak subs to CanExecuteChanged in Button. --- src/Avalonia.Controls/Button.cs | 69 ++++++++++++------- .../ButtonTests.cs | 46 ++++++++++++- 2 files changed, 89 insertions(+), 26 deletions(-) diff --git a/src/Avalonia.Controls/Button.cs b/src/Avalonia.Controls/Button.cs index 5ed0abf25d..b47c6fc9d4 100644 --- a/src/Avalonia.Controls/Button.cs +++ b/src/Avalonia.Controls/Button.cs @@ -7,6 +7,7 @@ using System.Windows.Input; using Avalonia.Data; using Avalonia.Input; using Avalonia.Interactivity; +using Avalonia.LogicalTree; using Avalonia.VisualTree; namespace Avalonia.Controls @@ -160,6 +161,40 @@ namespace Avalonia.Controls } } + /// + protected override void OnDetachedFromVisualTree(VisualTreeAttachmentEventArgs e) + { + base.OnDetachedFromVisualTree(e); + + if (IsDefault) + { + if (e.Root is IInputElement inputElement) + { + StopListeningForDefault(inputElement); + } + } + } + + protected override void OnAttachedToLogicalTree(LogicalTreeAttachmentEventArgs e) + { + base.OnAttachedToLogicalTree(e); + + if (Command != null) + { + Command.CanExecuteChanged += CanExecuteChanged; + } + } + + protected override void OnDetachedFromLogicalTree(LogicalTreeAttachmentEventArgs e) + { + base.OnAttachedToLogicalTree(e); + + if (Command != null) + { + Command.CanExecuteChanged -= CanExecuteChanged; + } + } + /// protected override void OnKeyDown(KeyEventArgs e) { @@ -195,20 +230,6 @@ namespace Avalonia.Controls } } - /// - protected override void OnDetachedFromVisualTree(VisualTreeAttachmentEventArgs e) - { - base.OnDetachedFromVisualTree(e); - - if (IsDefault) - { - if (e.Root is IInputElement inputElement) - { - StopListeningForDefault(inputElement); - } - } - } - /// /// Invokes the event. /// @@ -281,17 +302,17 @@ namespace Avalonia.Controls { if (e.Sender is Button button) { - var oldCommand = e.OldValue as ICommand; - var newCommand = e.NewValue as ICommand; - - if (oldCommand != null) - { - oldCommand.CanExecuteChanged -= button.CanExecuteChanged; - } - - if (newCommand != null) + if (((ILogical)button).IsAttachedToLogicalTree) { - newCommand.CanExecuteChanged += button.CanExecuteChanged; + if (e.OldValue is ICommand oldCommand) + { + oldCommand.CanExecuteChanged -= button.CanExecuteChanged; + } + + if (e.NewValue is ICommand newCommand) + { + newCommand.CanExecuteChanged += button.CanExecuteChanged; + } } button.CanExecuteChanged(button, EventArgs.Empty); diff --git a/tests/Avalonia.Controls.UnitTests/ButtonTests.cs b/tests/Avalonia.Controls.UnitTests/ButtonTests.cs index 91b37596b7..9a751d4953 100644 --- a/tests/Avalonia.Controls.UnitTests/ButtonTests.cs +++ b/tests/Avalonia.Controls.UnitTests/ButtonTests.cs @@ -5,6 +5,7 @@ using Avalonia.Input; using Avalonia.Media; using Avalonia.Platform; using Avalonia.Rendering; +using Avalonia.UnitTests; using Avalonia.VisualTree; using Moq; using Xunit; @@ -21,6 +22,7 @@ namespace Avalonia.Controls.UnitTests { Command = command, }; + var root = new TestRoot { Child = target }; Assert.False(target.IsEnabled); command.IsEnabled = true; @@ -215,6 +217,39 @@ namespace Avalonia.Controls.UnitTests Assert.True(clicked); } + [Fact] + public void Button_Does_Not_Subscribe_To_Command_CanExecuteChanged_Until_Added_To_Logical_Tree() + { + var command = new TestCommand(true); + var target = new Button + { + Command = command, + }; + + Assert.Equal(0, command.SubscriptionCount); + } + + [Fact] + public void Button_Subscribes_To_Command_CanExecuteChanged_When_Added_To_Logical_Tree() + { + var command = new TestCommand(true); + var target = new Button { Command = command }; + var root = new TestRoot { Child = target }; + + Assert.Equal(1, command.SubscriptionCount); + } + + [Fact] + public void Button_Unsubscribes_From_Command_CanExecuteChanged_When_Removed_From_Logical_Tree() + { + var command = new TestCommand(true); + var target = new Button { Command = command }; + var root = new TestRoot { Child = target }; + + root.Child = null; + Assert.Equal(0, command.SubscriptionCount); + } + private class TestButton : Button, IRenderRoot { public TestButton() @@ -298,6 +333,7 @@ namespace Avalonia.Controls.UnitTests private class TestCommand : ICommand { + private EventHandler _canExecuteChanged; private bool _enabled; public TestCommand(bool enabled) @@ -313,12 +349,18 @@ namespace Avalonia.Controls.UnitTests if (_enabled != value) { _enabled = value; - CanExecuteChanged?.Invoke(this, EventArgs.Empty); + _canExecuteChanged?.Invoke(this, EventArgs.Empty); } } } - public event EventHandler CanExecuteChanged; + public int SubscriptionCount { get; private set; } + + public event EventHandler CanExecuteChanged + { + add { _canExecuteChanged += value; ++SubscriptionCount; } + remove { _canExecuteChanged -= value; --SubscriptionCount; } + } public bool CanExecute(object parameter) => _enabled; From a48efd6b55cff7ef82431dd9cbc3cd6b6d661983 Mon Sep 17 00:00:00 2001 From: Steven Kirk Date: Fri, 29 Mar 2019 00:59:03 +0100 Subject: [PATCH 07/41] Don't leak subs to CanExecuteChanged in MenuItem. --- src/Avalonia.Controls/MenuItem.cs | 35 +++++++++--- .../MenuItemTests.cs | 54 +++++++++++++++++++ 2 files changed, 83 insertions(+), 6 deletions(-) diff --git a/src/Avalonia.Controls/MenuItem.cs b/src/Avalonia.Controls/MenuItem.cs index 64daa133a3..163c39b219 100644 --- a/src/Avalonia.Controls/MenuItem.cs +++ b/src/Avalonia.Controls/MenuItem.cs @@ -286,6 +286,26 @@ namespace Avalonia.Controls return new MenuItemContainerGenerator(this); } + protected override void OnAttachedToLogicalTree(LogicalTreeAttachmentEventArgs e) + { + base.OnAttachedToLogicalTree(e); + + if (Command != null) + { + Command.CanExecuteChanged += CanExecuteChanged; + } + } + + protected override void OnDetachedFromLogicalTree(LogicalTreeAttachmentEventArgs e) + { + base.OnAttachedToLogicalTree(e); + + if (Command != null) + { + Command.CanExecuteChanged -= CanExecuteChanged; + } + } + /// /// Called when the is clicked. /// @@ -399,14 +419,17 @@ namespace Avalonia.Controls { if (e.Sender is MenuItem menuItem) { - if (e.OldValue is ICommand oldCommand) + if (((ILogical)menuItem).IsAttachedToLogicalTree) { - oldCommand.CanExecuteChanged -= menuItem.CanExecuteChanged; - } + if (e.OldValue is ICommand oldCommand) + { + oldCommand.CanExecuteChanged -= menuItem.CanExecuteChanged; + } - if (e.NewValue is ICommand newCommand) - { - newCommand.CanExecuteChanged += menuItem.CanExecuteChanged; + if (e.NewValue is ICommand newCommand) + { + newCommand.CanExecuteChanged += menuItem.CanExecuteChanged; + } } menuItem.CanExecuteChanged(menuItem, EventArgs.Empty); diff --git a/tests/Avalonia.Controls.UnitTests/MenuItemTests.cs b/tests/Avalonia.Controls.UnitTests/MenuItemTests.cs index e7352af23e..32d154249c 100644 --- a/tests/Avalonia.Controls.UnitTests/MenuItemTests.cs +++ b/tests/Avalonia.Controls.UnitTests/MenuItemTests.cs @@ -1,6 +1,8 @@ using System; using System.Collections.Generic; using System.Text; +using System.Windows.Input; +using Avalonia.UnitTests; using Xunit; namespace Avalonia.Controls.UnitTests @@ -22,5 +24,57 @@ namespace Avalonia.Controls.UnitTests Assert.False(target.Focusable); } + + [Fact] + public void MenuItem_Does_Not_Subscribe_To_Command_CanExecuteChanged_Until_Added_To_Logical_Tree() + { + var command = new TestCommand(); + var target = new MenuItem + { + Command = command, + }; + + Assert.Equal(0, command.SubscriptionCount); + } + + [Fact] + public void MenuItem_Subscribes_To_Command_CanExecuteChanged_When_Added_To_Logical_Tree() + { + var command = new TestCommand(); + var target = new MenuItem { Command = command }; + var root = new TestRoot { Child = target }; + + Assert.Equal(1, command.SubscriptionCount); + } + + [Fact] + public void MenuItem_Unsubscribes_From_Command_CanExecuteChanged_When_Removed_From_Logical_Tree() + { + var command = new TestCommand(); + var target = new MenuItem { Command = command }; + var root = new TestRoot { Child = target }; + + root.Child = null; + Assert.Equal(0, command.SubscriptionCount); + } + + private class TestCommand : ICommand + { + private EventHandler _canExecuteChanged; + + public int SubscriptionCount { get; private set; } + + public event EventHandler CanExecuteChanged + { + add { _canExecuteChanged += value; ++SubscriptionCount; } + remove { _canExecuteChanged -= value; --SubscriptionCount; } + } + + public bool CanExecute(object parameter) => true; + + public void Execute(object parameter) + { + } + } } } From b05d8b42711346753714187c7b0c9d0ec241724b Mon Sep 17 00:00:00 2001 From: Dan Walmsley Date: Tue, 2 Apr 2019 18:46:29 +0100 Subject: [PATCH 08/41] fix popup root snap inside screen edges. --- src/Avalonia.Controls/Primitives/PopupRoot.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Avalonia.Controls/Primitives/PopupRoot.cs b/src/Avalonia.Controls/Primitives/PopupRoot.cs index 59a8933b4b..90020839d6 100644 --- a/src/Avalonia.Controls/Primitives/PopupRoot.cs +++ b/src/Avalonia.Controls/Primitives/PopupRoot.cs @@ -91,12 +91,12 @@ namespace Avalonia.Controls.Primitives if (screenX > screen.Bounds.Width) { - Position = Position.WithX(Position.X - screenX - bounds.Width); + Position = Position.WithX(Position.X - (screenX - screen.Bounds.Width)); } if (screenY > screen.Bounds.Height) { - Position = Position.WithY(Position.Y - screenY - bounds.Height); + Position = Position.WithY(Position.Y - (screenY - screen.Bounds.Height)); } } } From 6334314a901bd50a30c00ffc132530a8b8e6da5b Mon Sep 17 00:00:00 2001 From: Steven Kirk Date: Wed, 3 Apr 2019 01:18:16 +0200 Subject: [PATCH 09/41] Fix typo in calling base methods. --- src/Avalonia.Controls/Button.cs | 2 +- src/Avalonia.Controls/MenuItem.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Avalonia.Controls/Button.cs b/src/Avalonia.Controls/Button.cs index b47c6fc9d4..cc9e6b7444 100644 --- a/src/Avalonia.Controls/Button.cs +++ b/src/Avalonia.Controls/Button.cs @@ -187,7 +187,7 @@ namespace Avalonia.Controls protected override void OnDetachedFromLogicalTree(LogicalTreeAttachmentEventArgs e) { - base.OnAttachedToLogicalTree(e); + base.OnDetachedFromLogicalTree(e); if (Command != null) { diff --git a/src/Avalonia.Controls/MenuItem.cs b/src/Avalonia.Controls/MenuItem.cs index 163c39b219..d8473dc613 100644 --- a/src/Avalonia.Controls/MenuItem.cs +++ b/src/Avalonia.Controls/MenuItem.cs @@ -298,7 +298,7 @@ namespace Avalonia.Controls protected override void OnDetachedFromLogicalTree(LogicalTreeAttachmentEventArgs e) { - base.OnAttachedToLogicalTree(e); + base.OnDetachedFromLogicalTree(e); if (Command != null) { From b6ee0d025bc32469c17e56934e4981e164a424e1 Mon Sep 17 00:00:00 2001 From: Steven Kirk Date: Wed, 3 Apr 2019 17:48:34 +0200 Subject: [PATCH 10/41] Update version to 0.8.0. --- build/SharedVersion.props | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build/SharedVersion.props b/build/SharedVersion.props index b46ac16a79..7ea1dd0c65 100644 --- a/build/SharedVersion.props +++ b/build/SharedVersion.props @@ -2,7 +2,7 @@ xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> Avalonia - 0.7.1 + 0.8.0 Copyright 2018 © The AvaloniaUI Project https://github.com/AvaloniaUI/Avalonia/blob/master/licence.md https://github.com/AvaloniaUI/Avalonia/ @@ -11,4 +11,4 @@ CS1591 latest - \ No newline at end of file + From fe5d5bca1bfb616c9816891f051e80c4568894a3 Mon Sep 17 00:00:00 2001 From: Dariusz Komosinski Date: Mon, 8 Apr 2019 13:43:49 +0200 Subject: [PATCH 11/41] Make TreeView.SelectionModeProperty public so it can be set from styles. --- src/Avalonia.Controls/TreeView.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Avalonia.Controls/TreeView.cs b/src/Avalonia.Controls/TreeView.cs index 94989254dc..0c9bedfa93 100644 --- a/src/Avalonia.Controls/TreeView.cs +++ b/src/Avalonia.Controls/TreeView.cs @@ -48,7 +48,7 @@ namespace Avalonia.Controls /// /// Defines the property. /// - protected static readonly StyledProperty SelectionModeProperty = + public static readonly StyledProperty SelectionModeProperty = AvaloniaProperty.Register( nameof(SelectionMode)); From ebe92b661975e185c739aaed1481f30520691766 Mon Sep 17 00:00:00 2001 From: Dariusz Komosinski Date: Mon, 8 Apr 2019 13:56:31 +0200 Subject: [PATCH 12/41] Make sure that property is registered on a correct type. --- src/Avalonia.Controls/TreeView.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Avalonia.Controls/TreeView.cs b/src/Avalonia.Controls/TreeView.cs index 0c9bedfa93..2b1aa45dd4 100644 --- a/src/Avalonia.Controls/TreeView.cs +++ b/src/Avalonia.Controls/TreeView.cs @@ -49,7 +49,7 @@ namespace Avalonia.Controls /// Defines the property. /// public static readonly StyledProperty SelectionModeProperty = - AvaloniaProperty.Register( + AvaloniaProperty.Register( nameof(SelectionMode)); private static readonly IList Empty = new object[0]; From 9209c9be421f18e20ebf95647ffdf3dedf99120b Mon Sep 17 00:00:00 2001 From: Dariusz Komosinski Date: Mon, 8 Apr 2019 14:49:53 +0200 Subject: [PATCH 13/41] Implement platform options for Skia. --- .../SkiaApplicationExtensions.cs | 10 ++++------ src/Skia/Avalonia.Skia/SkiaOptions.cs | 19 +++++++++++++++++++ src/Skia/Avalonia.Skia/SkiaPlatform.cs | 8 +++++++- 3 files changed, 30 insertions(+), 7 deletions(-) create mode 100644 src/Skia/Avalonia.Skia/SkiaOptions.cs diff --git a/src/Skia/Avalonia.Skia/SkiaApplicationExtensions.cs b/src/Skia/Avalonia.Skia/SkiaApplicationExtensions.cs index 0778c64736..102f1f92aa 100644 --- a/src/Skia/Avalonia.Skia/SkiaApplicationExtensions.cs +++ b/src/Skia/Avalonia.Skia/SkiaApplicationExtensions.cs @@ -1,7 +1,6 @@ // Copyright (c) The Avalonia Project. All rights reserved. // Licensed under the MIT license. See licence.md file in the project root for full license information. -using System; using Avalonia.Controls; using Avalonia.Skia; @@ -19,12 +18,11 @@ namespace Avalonia /// Builder type. /// Builder. /// Configure builder. - public static T UseSkia(this T builder, Func gpuFactory = null) where T : AppBuilderBase, new() + public static T UseSkia(this T builder) where T : AppBuilderBase, new() { - var customGpu = gpuFactory?.Invoke(); - - builder.UseRenderingSubsystem(() => SkiaPlatform.Initialize(customGpu), "Skia"); - return builder; + return builder.UseRenderingSubsystem(() => SkiaPlatform.Initialize( + AvaloniaLocator.Current.GetService() ?? new SkiaOptions()), + "Skia"); } } } diff --git a/src/Skia/Avalonia.Skia/SkiaOptions.cs b/src/Skia/Avalonia.Skia/SkiaOptions.cs new file mode 100644 index 0000000000..bac1849be8 --- /dev/null +++ b/src/Skia/Avalonia.Skia/SkiaOptions.cs @@ -0,0 +1,19 @@ +// Copyright (c) The Avalonia Project. All rights reserved. +// Licensed under the MIT license. See licence.md file in the project root for full license information. + +using System; +using Avalonia.Skia; + +namespace Avalonia +{ + /// + /// Options for Skia rendering subsystem. + /// + public class SkiaOptions + { + /// + /// Custom gpu factory to use. Can be used to customize behavior of Skia renderer. + /// + public Func CustomGpuFactory { get; set; } + } +} diff --git a/src/Skia/Avalonia.Skia/SkiaPlatform.cs b/src/Skia/Avalonia.Skia/SkiaPlatform.cs index e4185c43a2..f16e967f42 100644 --- a/src/Skia/Avalonia.Skia/SkiaPlatform.cs +++ b/src/Skia/Avalonia.Skia/SkiaPlatform.cs @@ -13,8 +13,14 @@ namespace Avalonia.Skia /// /// Initialize Skia platform. /// - public static void Initialize(ICustomSkiaGpu customGpu = null) + public static void Initialize() { + Initialize(new SkiaOptions()); + } + + public static void Initialize(SkiaOptions options) + { + var customGpu = options.CustomGpuFactory?.Invoke(); var renderInterface = new PlatformRenderInterface(customGpu); AvaloniaLocator.CurrentMutable From 0961cc122ae9b3c0b75f1fc2bb955f6baa9acd4b Mon Sep 17 00:00:00 2001 From: artyom Date: Mon, 8 Apr 2019 17:07:01 +0300 Subject: [PATCH 14/41] Add xmlns, move files to Avalonia.ReactiveUI namespace --- .../AppBuilderExtensions.cs | 7 ++++++- src/Avalonia.ReactiveUI/Attributes.cs | 8 ++++++++ .../AvaloniaActivationForViewFetcher.cs | 18 +++++++++++++++++- src/Avalonia.ReactiveUI/ReactiveUserControl.cs | 2 +- src/Avalonia.ReactiveUI/ReactiveWindow.cs | 2 +- src/Avalonia.ReactiveUI/RoutedViewHost.cs | 8 ++++++-- .../AvaloniaActivationForViewFetcherTest.cs | 1 + .../RoutedViewHostTest.cs | 1 + 8 files changed, 41 insertions(+), 6 deletions(-) create mode 100644 src/Avalonia.ReactiveUI/Attributes.cs diff --git a/src/Avalonia.ReactiveUI/AppBuilderExtensions.cs b/src/Avalonia.ReactiveUI/AppBuilderExtensions.cs index d763febdf3..f67cb7f40a 100644 --- a/src/Avalonia.ReactiveUI/AppBuilderExtensions.cs +++ b/src/Avalonia.ReactiveUI/AppBuilderExtensions.cs @@ -6,10 +6,15 @@ using Avalonia.Threading; using ReactiveUI; using Splat; -namespace Avalonia +namespace Avalonia.ReactiveUI { public static class AppBuilderExtensions { + /// + /// Initializes ReactiveUI framework to use with Avalonia. Registers Avalonia + /// scheduler and Avalonia activation for view fetcher. Always remember to + /// call this method if you are using ReactiveUI in your application. + /// public static TAppBuilder UseReactiveUI(this TAppBuilder builder) where TAppBuilder : AppBuilderBase, new() { diff --git a/src/Avalonia.ReactiveUI/Attributes.cs b/src/Avalonia.ReactiveUI/Attributes.cs new file mode 100644 index 0000000000..e908d1de80 --- /dev/null +++ b/src/Avalonia.ReactiveUI/Attributes.cs @@ -0,0 +1,8 @@ +// Copyright (c) The Avalonia Project. All rights reserved. +// Licensed under the MIT license. See licence.md file in the project root for full license information. + +using System.Reflection; +using System.Runtime.CompilerServices; +using Avalonia.Metadata; + +[assembly: XmlnsDefinition("http://reactiveui.net", "Avalonia.ReactiveUI")] \ No newline at end of file diff --git a/src/Avalonia.ReactiveUI/AvaloniaActivationForViewFetcher.cs b/src/Avalonia.ReactiveUI/AvaloniaActivationForViewFetcher.cs index e1db604e95..cfa7a270be 100644 --- a/src/Avalonia.ReactiveUI/AvaloniaActivationForViewFetcher.cs +++ b/src/Avalonia.ReactiveUI/AvaloniaActivationForViewFetcher.cs @@ -9,15 +9,24 @@ using Avalonia.VisualTree; using Avalonia.Controls; using ReactiveUI; -namespace Avalonia +namespace Avalonia.ReactiveUI { + /// + /// Determines when Avalonia IVisuals get activated. + /// public class AvaloniaActivationForViewFetcher : IActivationForViewFetcher { + /// + /// Returns affinity for view. + /// public int GetAffinityForView(Type view) { return typeof(IVisual).GetTypeInfo().IsAssignableFrom(view.GetTypeInfo()) ? 10 : 0; } + /// + /// Returns activation observable for activatable Avalonia view. + /// public IObservable GetActivationForView(IActivatable view) { if (!(view is IVisual visual)) return Observable.Return(false); @@ -25,6 +34,9 @@ namespace Avalonia return GetActivationForVisual(visual); } + /// + /// Listens to Opened and Closed events for Avalonia windows. + /// private IObservable GetActivationForWindowBase(WindowBase window) { var windowLoaded = Observable @@ -42,6 +54,10 @@ namespace Avalonia .DistinctUntilChanged(); } + /// + /// Listens to AttachedToVisualTree and DetachedFromVisualTree + /// events for Avalonia IVisuals. + /// private IObservable GetActivationForVisual(IVisual visual) { var visualLoaded = Observable diff --git a/src/Avalonia.ReactiveUI/ReactiveUserControl.cs b/src/Avalonia.ReactiveUI/ReactiveUserControl.cs index 43e2ef93b6..010acc3ae0 100644 --- a/src/Avalonia.ReactiveUI/ReactiveUserControl.cs +++ b/src/Avalonia.ReactiveUI/ReactiveUserControl.cs @@ -6,7 +6,7 @@ using Avalonia.VisualTree; using Avalonia.Controls; using ReactiveUI; -namespace Avalonia +namespace Avalonia.ReactiveUI { /// /// A ReactiveUI UserControl that implements diff --git a/src/Avalonia.ReactiveUI/ReactiveWindow.cs b/src/Avalonia.ReactiveUI/ReactiveWindow.cs index bb50a37764..f0f115afbc 100644 --- a/src/Avalonia.ReactiveUI/ReactiveWindow.cs +++ b/src/Avalonia.ReactiveUI/ReactiveWindow.cs @@ -6,7 +6,7 @@ using Avalonia.VisualTree; using Avalonia.Controls; using ReactiveUI; -namespace Avalonia +namespace Avalonia.ReactiveUI { /// /// A ReactiveUI Window that implements diff --git a/src/Avalonia.ReactiveUI/RoutedViewHost.cs b/src/Avalonia.ReactiveUI/RoutedViewHost.cs index e364d5de0b..4bd86a67c0 100644 --- a/src/Avalonia.ReactiveUI/RoutedViewHost.cs +++ b/src/Avalonia.ReactiveUI/RoutedViewHost.cs @@ -1,13 +1,17 @@ +// Copyright (c) The Avalonia Project. All rights reserved. +// Licensed under the MIT license. See licence.md file in the project root for full license information. + using System; using System.Reactive.Disposables; using System.Reactive.Linq; using Avalonia.Animation; using Avalonia.Controls; using Avalonia.Styling; +using Avalonia; using ReactiveUI; using Splat; -namespace Avalonia +namespace Avalonia.ReactiveUI { /// /// This control hosts the View associated with ReactiveUI RoutingState, @@ -157,7 +161,7 @@ namespace Avalonia return; } - var viewLocator = ViewLocator ?? ReactiveUI.ViewLocator.Current; + var viewLocator = ViewLocator ?? global::ReactiveUI.ViewLocator.Current; var view = viewLocator.ResolveView(viewModel); if (view == null) throw new Exception($"Couldn't find view for '{viewModel}'. Is it registered?"); diff --git a/tests/Avalonia.ReactiveUI.UnitTests/AvaloniaActivationForViewFetcherTest.cs b/tests/Avalonia.ReactiveUI.UnitTests/AvaloniaActivationForViewFetcherTest.cs index 70a5504a7d..d9f1ce47dd 100644 --- a/tests/Avalonia.ReactiveUI.UnitTests/AvaloniaActivationForViewFetcherTest.cs +++ b/tests/Avalonia.ReactiveUI.UnitTests/AvaloniaActivationForViewFetcherTest.cs @@ -11,6 +11,7 @@ using DynamicData; using Xunit; using Splat; using Avalonia.Markup.Xaml; +using Avalonia.ReactiveUI; namespace Avalonia { diff --git a/tests/Avalonia.ReactiveUI.UnitTests/RoutedViewHostTest.cs b/tests/Avalonia.ReactiveUI.UnitTests/RoutedViewHostTest.cs index de09a1ea89..401d169896 100644 --- a/tests/Avalonia.ReactiveUI.UnitTests/RoutedViewHostTest.cs +++ b/tests/Avalonia.ReactiveUI.UnitTests/RoutedViewHostTest.cs @@ -14,6 +14,7 @@ using Avalonia.Markup.Xaml; using System.ComponentModel; using System.Threading.Tasks; using System.Reactive; +using Avalonia.ReactiveUI; namespace Avalonia { From a66a2d33aa5abe93160c2286d327820b6b4e4e39 Mon Sep 17 00:00:00 2001 From: artyom Date: Mon, 8 Apr 2019 17:55:55 +0300 Subject: [PATCH 15/41] Add missing usings --- samples/BindingDemo/App.xaml.cs | 1 + samples/ControlCatalog.Desktop/Program.cs | 1 + samples/ControlCatalog.NetCore/Program.cs | 1 + samples/RenderDemo/App.xaml.cs | 1 + samples/VirtualizationDemo/Program.cs | 1 + 5 files changed, 5 insertions(+) diff --git a/samples/BindingDemo/App.xaml.cs b/samples/BindingDemo/App.xaml.cs index 01c52a2a49..f2f44cd502 100644 --- a/samples/BindingDemo/App.xaml.cs +++ b/samples/BindingDemo/App.xaml.cs @@ -3,6 +3,7 @@ using Avalonia; using Avalonia.Controls; using Avalonia.Logging.Serilog; using Avalonia.Markup.Xaml; +using Avalonia.ReactiveUI; using Serilog; namespace BindingDemo diff --git a/samples/ControlCatalog.Desktop/Program.cs b/samples/ControlCatalog.Desktop/Program.cs index dd5644dd6b..b7aa34f5ba 100644 --- a/samples/ControlCatalog.Desktop/Program.cs +++ b/samples/ControlCatalog.Desktop/Program.cs @@ -4,6 +4,7 @@ using Avalonia; using Avalonia.Controls; using Avalonia.Logging.Serilog; using Avalonia.Platform; +using Avalonia.ReactiveUI; using Serilog; namespace ControlCatalog diff --git a/samples/ControlCatalog.NetCore/Program.cs b/samples/ControlCatalog.NetCore/Program.cs index d13a5b5ef3..c8f3fb9921 100644 --- a/samples/ControlCatalog.NetCore/Program.cs +++ b/samples/ControlCatalog.NetCore/Program.cs @@ -4,6 +4,7 @@ using System.Linq; using System.Threading; using Avalonia; using Avalonia.Skia; +using Avalonia.ReactiveUI; namespace ControlCatalog.NetCore { diff --git a/samples/RenderDemo/App.xaml.cs b/samples/RenderDemo/App.xaml.cs index 0f627961e6..d95018520a 100644 --- a/samples/RenderDemo/App.xaml.cs +++ b/samples/RenderDemo/App.xaml.cs @@ -4,6 +4,7 @@ using Avalonia; using Avalonia.Logging.Serilog; using Avalonia.Markup.Xaml; +using Avalonia.ReactiveUI; namespace RenderDemo { diff --git a/samples/VirtualizationDemo/Program.cs b/samples/VirtualizationDemo/Program.cs index 98f1f08d6c..9d8f7c1a3d 100644 --- a/samples/VirtualizationDemo/Program.cs +++ b/samples/VirtualizationDemo/Program.cs @@ -5,6 +5,7 @@ using System; using Avalonia; using Avalonia.Controls; using Avalonia.Logging.Serilog; +using Avalonia.ReactiveUI; using Serilog; namespace VirtualizationDemo From cf1401e5f20e2a08ec6b458729822f180d4bbdac Mon Sep 17 00:00:00 2001 From: Dariusz Komosinski Date: Mon, 8 Apr 2019 17:04:26 +0200 Subject: [PATCH 16/41] Use ListBox properties for TreeView implementation. --- src/Avalonia.Controls/ListBox.cs | 4 ++-- src/Avalonia.Controls/TreeView.cs | 6 ++---- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/Avalonia.Controls/ListBox.cs b/src/Avalonia.Controls/ListBox.cs index fce568e56d..041b81155a 100644 --- a/src/Avalonia.Controls/ListBox.cs +++ b/src/Avalonia.Controls/ListBox.cs @@ -30,13 +30,13 @@ namespace Avalonia.Controls /// /// Defines the property. /// - public static readonly new AvaloniaProperty SelectedItemsProperty = + public static readonly new DirectProperty SelectedItemsProperty = SelectingItemsControl.SelectedItemsProperty; /// /// Defines the property. /// - public static readonly new AvaloniaProperty SelectionModeProperty = + public static readonly new StyledProperty SelectionModeProperty = SelectingItemsControl.SelectionModeProperty; /// diff --git a/src/Avalonia.Controls/TreeView.cs b/src/Avalonia.Controls/TreeView.cs index 2b1aa45dd4..c3fbce1d83 100644 --- a/src/Avalonia.Controls/TreeView.cs +++ b/src/Avalonia.Controls/TreeView.cs @@ -40,8 +40,7 @@ namespace Avalonia.Controls /// Defines the property. /// public static readonly DirectProperty SelectedItemsProperty = - AvaloniaProperty.RegisterDirect( - nameof(SelectedItems), + ListBox.SelectedItemsProperty.AddOwner( o => o.SelectedItems, (o, v) => o.SelectedItems = v); @@ -49,8 +48,7 @@ namespace Avalonia.Controls /// Defines the property. /// public static readonly StyledProperty SelectionModeProperty = - AvaloniaProperty.Register( - nameof(SelectionMode)); + ListBox.SelectionModeProperty.AddOwner(); private static readonly IList Empty = new object[0]; private object _selectedItem; From 12fc28e2d08d9dfdb9da9dcbeb8517c0d7f01cf0 Mon Sep 17 00:00:00 2001 From: Dariusz Komosinski Date: Mon, 8 Apr 2019 17:24:17 +0200 Subject: [PATCH 17/41] Add mocks for geometry impls. --- tests/Avalonia.UnitTests/MockPlatformRenderInterface.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/Avalonia.UnitTests/MockPlatformRenderInterface.cs b/tests/Avalonia.UnitTests/MockPlatformRenderInterface.cs index 1aeaf6bf8b..c73c30365b 100644 --- a/tests/Avalonia.UnitTests/MockPlatformRenderInterface.cs +++ b/tests/Avalonia.UnitTests/MockPlatformRenderInterface.cs @@ -24,17 +24,17 @@ namespace Avalonia.UnitTests public IEllipseGeometryImpl CreateEllipseGeometry(Rect rect) { - throw new NotImplementedException(); + return Mock.Of(); } public ILineGeometryImpl CreateLineGeometry(Point p1, Point p2) { - throw new NotImplementedException(); + return Mock.Of(); } public IRectangleGeometryImpl CreateRectangleGeometry(Rect rect) { - throw new NotImplementedException(); + return Mock.Of(); } public IRenderTarget CreateRenderTarget(IEnumerable surfaces) From aad6bf703e19095b376d07f2e2e6b4194f11daf8 Mon Sep 17 00:00:00 2001 From: Dan Walmsley Date: Mon, 8 Apr 2019 20:03:33 +0100 Subject: [PATCH 18/41] bump version number and copyright year. --- build/SharedVersion.props | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build/SharedVersion.props b/build/SharedVersion.props index 7ea1dd0c65..4f0b1f0a5b 100644 --- a/build/SharedVersion.props +++ b/build/SharedVersion.props @@ -2,8 +2,8 @@ xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> Avalonia - 0.8.0 - Copyright 2018 © The AvaloniaUI Project + 0.8.1 + Copyright 2019 © The AvaloniaUI Project https://github.com/AvaloniaUI/Avalonia/blob/master/licence.md https://github.com/AvaloniaUI/Avalonia/ https://github.com/AvaloniaUI/Avalonia/ From 129f8ca535490a6fe22f4ec5a306329b0b45309d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Pedro?= Date: Tue, 9 Apr 2019 23:52:28 +0100 Subject: [PATCH 19/41] XML comment fixes. --- src/Avalonia.Base/Utilities/WeakEventHandlerManager.cs | 2 ++ src/Avalonia.Controls/Window.cs | 3 ++- src/Avalonia.Styling/StyledElement.cs | 1 + 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Avalonia.Base/Utilities/WeakEventHandlerManager.cs b/src/Avalonia.Base/Utilities/WeakEventHandlerManager.cs index 0ade1af249..b59ed166bc 100644 --- a/src/Avalonia.Base/Utilities/WeakEventHandlerManager.cs +++ b/src/Avalonia.Base/Utilities/WeakEventHandlerManager.cs @@ -19,6 +19,7 @@ namespace Avalonia.Utilities /// /// The type of the target. /// The type of the event arguments. + /// The type of the subscriber. /// The event source. /// The name of the event. /// The subscriber. @@ -40,6 +41,7 @@ namespace Avalonia.Utilities /// Unsubscribes from an event. /// /// The type of the event arguments. + /// The type of the subscriber. /// The event source. /// The name of the event. /// The subscriber. diff --git a/src/Avalonia.Controls/Window.cs b/src/Avalonia.Controls/Window.cs index f5af6774b5..c8e09b8f9c 100644 --- a/src/Avalonia.Controls/Window.cs +++ b/src/Avalonia.Controls/Window.cs @@ -291,7 +291,8 @@ namespace Avalonia.Controls /// /// The dialog result. /// - /// When the window is shown with the method, the + /// When the window is shown with the + /// or method, the /// resulting task will produce the value when the window /// is closed. /// diff --git a/src/Avalonia.Styling/StyledElement.cs b/src/Avalonia.Styling/StyledElement.cs index e52a1961ba..d314a8d44e 100644 --- a/src/Avalonia.Styling/StyledElement.cs +++ b/src/Avalonia.Styling/StyledElement.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Collections.Specialized; +using System.ComponentModel; using System.Linq; using System.Reactive.Linq; using System.Reactive.Subjects; From d448aad129b1f3320dc6a07021dd121960d5ed7d Mon Sep 17 00:00:00 2001 From: Steven Kirk Date: Wed, 10 Apr 2019 17:36:19 +0200 Subject: [PATCH 20/41] Update portable.xaml. #2307 updated the portable.xaml submodule but the changes were then lost in a subsequent merge. Re-updates the submodule to target the `fixes/moar-line-info` branch. --- .../Avalonia.Markup.Xaml/PortableXaml/portable.xaml.github | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Markup/Avalonia.Markup.Xaml/PortableXaml/portable.xaml.github b/src/Markup/Avalonia.Markup.Xaml/PortableXaml/portable.xaml.github index ab55261737..7452b23169 160000 --- a/src/Markup/Avalonia.Markup.Xaml/PortableXaml/portable.xaml.github +++ b/src/Markup/Avalonia.Markup.Xaml/PortableXaml/portable.xaml.github @@ -1 +1 @@ -Subproject commit ab5526173722b8988bc5ca3c03c8752ce89c0975 +Subproject commit 7452b23169e4948907fa10e2c115b672897d0e04 From 63da34f25a64f4c3a343ffe9d1da74e81f1f2006 Mon Sep 17 00:00:00 2001 From: Steven Kirk Date: Wed, 10 Apr 2019 17:38:44 +0200 Subject: [PATCH 21/41] Set `ProvideLineInfo` in XAML reader settings. --- src/Markup/Avalonia.Markup.Xaml/AvaloniaXamlLoader.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Markup/Avalonia.Markup.Xaml/AvaloniaXamlLoader.cs b/src/Markup/Avalonia.Markup.Xaml/AvaloniaXamlLoader.cs index a1f8bf6cf6..4c352f199f 100644 --- a/src/Markup/Avalonia.Markup.Xaml/AvaloniaXamlLoader.cs +++ b/src/Markup/Avalonia.Markup.Xaml/AvaloniaXamlLoader.cs @@ -162,7 +162,8 @@ namespace Avalonia.Markup.Xaml var readerSettings = new XamlXmlReaderSettings() { BaseUri = uri, - LocalAssembly = localAssembly + LocalAssembly = localAssembly, + ProvideLineInfo = true, }; var context = IsDesignMode ? AvaloniaXamlSchemaContext.DesignInstance : AvaloniaXamlSchemaContext.Instance; From baa7c9da69b232b13386bfb414ff537a744f4a81 Mon Sep 17 00:00:00 2001 From: Benedikt Schroeder Date: Thu, 11 Apr 2019 17:49:56 +0200 Subject: [PATCH 22/41] Makes ScrollBar Thumb stylable --- src/Avalonia.Themes.Default/ScrollBar.xaml | 34 +++++++++++++++------- 1 file changed, 24 insertions(+), 10 deletions(-) diff --git a/src/Avalonia.Themes.Default/ScrollBar.xaml b/src/Avalonia.Themes.Default/ScrollBar.xaml index 2cb8ce2d24..edd678ed56 100644 --- a/src/Avalonia.Themes.Default/ScrollBar.xaml +++ b/src/Avalonia.Themes.Default/ScrollBar.xaml @@ -31,11 +31,18 @@ Focusable="False"/> - - - - - + + + - - - - - + + + Date: Thu, 11 Apr 2019 18:53:43 +0200 Subject: [PATCH 23/41] Remove geometry pages. --- samples/ControlCatalog/MainView.xaml | 3 --- samples/ControlCatalog/Pages/EllipsePage.xaml | 23 ------------------- .../ControlCatalog/Pages/EllipsePage.xaml.cs | 18 --------------- samples/ControlCatalog/Pages/LinePage.xaml | 21 ----------------- samples/ControlCatalog/Pages/LinePage.xaml.cs | 18 --------------- .../ControlCatalog/Pages/RectanglePage.xaml | 21 ----------------- .../Pages/RectanglePage.xaml.cs | 18 --------------- 7 files changed, 122 deletions(-) delete mode 100644 samples/ControlCatalog/Pages/EllipsePage.xaml delete mode 100644 samples/ControlCatalog/Pages/EllipsePage.xaml.cs delete mode 100644 samples/ControlCatalog/Pages/LinePage.xaml delete mode 100644 samples/ControlCatalog/Pages/LinePage.xaml.cs delete mode 100644 samples/ControlCatalog/Pages/RectanglePage.xaml delete mode 100644 samples/ControlCatalog/Pages/RectanglePage.xaml.cs diff --git a/samples/ControlCatalog/MainView.xaml b/samples/ControlCatalog/MainView.xaml index 79bfc671ef..b79db9f053 100644 --- a/samples/ControlCatalog/MainView.xaml +++ b/samples/ControlCatalog/MainView.xaml @@ -24,17 +24,14 @@ - - - diff --git a/samples/ControlCatalog/Pages/EllipsePage.xaml b/samples/ControlCatalog/Pages/EllipsePage.xaml deleted file mode 100644 index f66cca9cdb..0000000000 --- a/samples/ControlCatalog/Pages/EllipsePage.xaml +++ /dev/null @@ -1,23 +0,0 @@ - - - Ellipse - A control which represents an ellipse with a fill and a stroke. - - - - - - - - - - - - - - diff --git a/samples/ControlCatalog/Pages/EllipsePage.xaml.cs b/samples/ControlCatalog/Pages/EllipsePage.xaml.cs deleted file mode 100644 index e450e961ed..0000000000 --- a/samples/ControlCatalog/Pages/EllipsePage.xaml.cs +++ /dev/null @@ -1,18 +0,0 @@ -using Avalonia.Controls; -using Avalonia.Markup.Xaml; - -namespace ControlCatalog.Pages -{ - public class EllipsePage : UserControl - { - public EllipsePage() - { - this.InitializeComponent(); - } - - private void InitializeComponent() - { - AvaloniaXamlLoader.Load(this); - } - } -} diff --git a/samples/ControlCatalog/Pages/LinePage.xaml b/samples/ControlCatalog/Pages/LinePage.xaml deleted file mode 100644 index 62ab917578..0000000000 --- a/samples/ControlCatalog/Pages/LinePage.xaml +++ /dev/null @@ -1,21 +0,0 @@ - - - Line - A control which represents a line. - - - - - - - - - - - - diff --git a/samples/ControlCatalog/Pages/LinePage.xaml.cs b/samples/ControlCatalog/Pages/LinePage.xaml.cs deleted file mode 100644 index 43b8049d45..0000000000 --- a/samples/ControlCatalog/Pages/LinePage.xaml.cs +++ /dev/null @@ -1,18 +0,0 @@ -using Avalonia.Controls; -using Avalonia.Markup.Xaml; - -namespace ControlCatalog.Pages -{ - public class LinePage : UserControl - { - public LinePage() - { - this.InitializeComponent(); - } - - private void InitializeComponent() - { - AvaloniaXamlLoader.Load(this); - } - } -} diff --git a/samples/ControlCatalog/Pages/RectanglePage.xaml b/samples/ControlCatalog/Pages/RectanglePage.xaml deleted file mode 100644 index 49701812c4..0000000000 --- a/samples/ControlCatalog/Pages/RectanglePage.xaml +++ /dev/null @@ -1,21 +0,0 @@ - - - Rectangle - A control which represents a rectangle with a fill and a stroke. - - - - - - - - - - - - diff --git a/samples/ControlCatalog/Pages/RectanglePage.xaml.cs b/samples/ControlCatalog/Pages/RectanglePage.xaml.cs deleted file mode 100644 index 0ee8a1a40f..0000000000 --- a/samples/ControlCatalog/Pages/RectanglePage.xaml.cs +++ /dev/null @@ -1,18 +0,0 @@ -using Avalonia.Controls; -using Avalonia.Markup.Xaml; - -namespace ControlCatalog.Pages -{ - public class RectanglePage : UserControl - { - public RectanglePage() - { - this.InitializeComponent(); - } - - private void InitializeComponent() - { - AvaloniaXamlLoader.Load(this); - } - } -} From 1b869ff27b68901d8db4b7235e199b7f00355581 Mon Sep 17 00:00:00 2001 From: Dariusz Komosinski Date: Fri, 12 Apr 2019 11:32:41 +0200 Subject: [PATCH 24/41] Get rid of not needed interfaces. --- .../Platform/IEllipseGeometryImpl.cs | 12 ------------ src/Avalonia.Visuals/Platform/ILineGeometryImpl.cs | 12 ------------ .../Platform/IPlatformRenderInterface.cs | 12 ++++++------ .../Platform/IRectangleGeometryImpl.cs | 12 ------------ src/Skia/Avalonia.Skia/EllipseGeometryImpl.cs | 3 +-- src/Skia/Avalonia.Skia/LineGeometryImpl.cs | 3 +-- src/Skia/Avalonia.Skia/PlatformRenderInterface.cs | 6 +++--- src/Skia/Avalonia.Skia/RectangleGeometryImpl.cs | 3 +-- src/Windows/Avalonia.Direct2D1/Direct2D1Platform.cs | 6 +++--- .../Avalonia.Direct2D1/Media/EllipseGeometryImpl.cs | 3 +-- .../Avalonia.Direct2D1/Media/LineGeometryImpl.cs | 3 +-- .../Media/RectangleGeometryImpl.cs | 3 +-- .../MockPlatformRenderInterface.cs | 12 ++++++------ .../VisualTree/MockRenderInterface.cs | 6 +++--- 14 files changed, 27 insertions(+), 69 deletions(-) delete mode 100644 src/Avalonia.Visuals/Platform/IEllipseGeometryImpl.cs delete mode 100644 src/Avalonia.Visuals/Platform/ILineGeometryImpl.cs delete mode 100644 src/Avalonia.Visuals/Platform/IRectangleGeometryImpl.cs diff --git a/src/Avalonia.Visuals/Platform/IEllipseGeometryImpl.cs b/src/Avalonia.Visuals/Platform/IEllipseGeometryImpl.cs deleted file mode 100644 index 982cf286a3..0000000000 --- a/src/Avalonia.Visuals/Platform/IEllipseGeometryImpl.cs +++ /dev/null @@ -1,12 +0,0 @@ -// Copyright (c) The Avalonia Project. All rights reserved. -// Licensed under the MIT license. See licence.md file in the project root for full license information. - -namespace Avalonia.Platform -{ - /// - /// Defines the platform-specific interface for a . - /// - public interface IEllipseGeometryImpl : IGeometryImpl - { - } -} diff --git a/src/Avalonia.Visuals/Platform/ILineGeometryImpl.cs b/src/Avalonia.Visuals/Platform/ILineGeometryImpl.cs deleted file mode 100644 index a8aa46fb13..0000000000 --- a/src/Avalonia.Visuals/Platform/ILineGeometryImpl.cs +++ /dev/null @@ -1,12 +0,0 @@ -// Copyright (c) The Avalonia Project. All rights reserved. -// Licensed under the MIT license. See licence.md file in the project root for full license information. - -namespace Avalonia.Platform -{ - /// - /// Defines the platform-specific interface for a . - /// - public interface ILineGeometryImpl : IGeometryImpl - { - } -} diff --git a/src/Avalonia.Visuals/Platform/IPlatformRenderInterface.cs b/src/Avalonia.Visuals/Platform/IPlatformRenderInterface.cs index 45ce8f5874..87db9251e1 100644 --- a/src/Avalonia.Visuals/Platform/IPlatformRenderInterface.cs +++ b/src/Avalonia.Visuals/Platform/IPlatformRenderInterface.cs @@ -40,23 +40,23 @@ namespace Avalonia.Platform /// Creates an ellipse geometry implementation. /// /// The bounds of the ellipse. - /// An . - IEllipseGeometryImpl CreateEllipseGeometry(Rect rect); + /// An ellipse geometry.. + IGeometryImpl CreateEllipseGeometry(Rect rect); /// /// Creates a line geometry implementation. /// /// The start of the line. /// The end of the line. - /// An . - ILineGeometryImpl CreateLineGeometry(Point p1, Point p2); + /// A line geometry. + IGeometryImpl CreateLineGeometry(Point p1, Point p2); /// /// Creates a rectangle geometry implementation. /// /// The bounds of the rectangle. - /// An . - IRectangleGeometryImpl CreateRectangleGeometry(Rect rect); + /// A rectangle. + IGeometryImpl CreateRectangleGeometry(Rect rect); /// /// Creates a stream geometry implementation. diff --git a/src/Avalonia.Visuals/Platform/IRectangleGeometryImpl.cs b/src/Avalonia.Visuals/Platform/IRectangleGeometryImpl.cs deleted file mode 100644 index 7ada2c874d..0000000000 --- a/src/Avalonia.Visuals/Platform/IRectangleGeometryImpl.cs +++ /dev/null @@ -1,12 +0,0 @@ -// Copyright (c) The Avalonia Project. All rights reserved. -// Licensed under the MIT license. See licence.md file in the project root for full license information. - -namespace Avalonia.Platform -{ - /// - /// Defines the platform-specific interface for a . - /// - public interface IRectangleGeometryImpl : IGeometryImpl - { - } -} diff --git a/src/Skia/Avalonia.Skia/EllipseGeometryImpl.cs b/src/Skia/Avalonia.Skia/EllipseGeometryImpl.cs index 92a0a5ff80..aae1dd8cef 100644 --- a/src/Skia/Avalonia.Skia/EllipseGeometryImpl.cs +++ b/src/Skia/Avalonia.Skia/EllipseGeometryImpl.cs @@ -1,7 +1,6 @@ // Copyright (c) The Avalonia Project. All rights reserved. // Licensed under the MIT license. See licence.md file in the project root for full license information. -using Avalonia.Platform; using SkiaSharp; namespace Avalonia.Skia @@ -9,7 +8,7 @@ namespace Avalonia.Skia /// /// A Skia implementation of a . /// - internal class EllipseGeometryImpl : GeometryImpl, IEllipseGeometryImpl + internal class EllipseGeometryImpl : GeometryImpl { public override Rect Bounds { get; } public override SKPath EffectivePath { get; } diff --git a/src/Skia/Avalonia.Skia/LineGeometryImpl.cs b/src/Skia/Avalonia.Skia/LineGeometryImpl.cs index a78c76d44a..e929e153d1 100644 --- a/src/Skia/Avalonia.Skia/LineGeometryImpl.cs +++ b/src/Skia/Avalonia.Skia/LineGeometryImpl.cs @@ -2,7 +2,6 @@ // Licensed under the MIT license. See licence.md file in the project root for full license information. using System; -using Avalonia.Platform; using SkiaSharp; namespace Avalonia.Skia @@ -10,7 +9,7 @@ namespace Avalonia.Skia /// /// A Skia implementation of a . /// - internal class LineGeometryImpl : GeometryImpl, ILineGeometryImpl + internal class LineGeometryImpl : GeometryImpl { public override Rect Bounds { get; } public override SKPath EffectivePath { get; } diff --git a/src/Skia/Avalonia.Skia/PlatformRenderInterface.cs b/src/Skia/Avalonia.Skia/PlatformRenderInterface.cs index f1e89bc464..6240a1cb4b 100644 --- a/src/Skia/Avalonia.Skia/PlatformRenderInterface.cs +++ b/src/Skia/Avalonia.Skia/PlatformRenderInterface.cs @@ -50,11 +50,11 @@ namespace Avalonia.Skia return new FormattedTextImpl(text, typeface, textAlignment, wrapping, constraint, spans); } - public IEllipseGeometryImpl CreateEllipseGeometry(Rect rect) => new EllipseGeometryImpl(rect); + public IGeometryImpl CreateEllipseGeometry(Rect rect) => new EllipseGeometryImpl(rect); - public ILineGeometryImpl CreateLineGeometry(Point p1, Point p2) => new LineGeometryImpl(p1, p2); + public IGeometryImpl CreateLineGeometry(Point p1, Point p2) => new LineGeometryImpl(p1, p2); - public IRectangleGeometryImpl CreateRectangleGeometry(Rect rect) => new RectangleGeometryImpl(rect); + public IGeometryImpl CreateRectangleGeometry(Rect rect) => new RectangleGeometryImpl(rect); /// public IStreamGeometryImpl CreateStreamGeometry() diff --git a/src/Skia/Avalonia.Skia/RectangleGeometryImpl.cs b/src/Skia/Avalonia.Skia/RectangleGeometryImpl.cs index 235cd37b56..a873e8e2df 100644 --- a/src/Skia/Avalonia.Skia/RectangleGeometryImpl.cs +++ b/src/Skia/Avalonia.Skia/RectangleGeometryImpl.cs @@ -1,7 +1,6 @@ // Copyright (c) The Avalonia Project. All rights reserved. // Licensed under the MIT license. See licence.md file in the project root for full license information. -using Avalonia.Platform; using SkiaSharp; namespace Avalonia.Skia @@ -9,7 +8,7 @@ namespace Avalonia.Skia /// /// A Skia implementation of a . /// - internal class RectangleGeometryImpl : GeometryImpl, IRectangleGeometryImpl + internal class RectangleGeometryImpl : GeometryImpl { public override Rect Bounds { get; } public override SKPath EffectivePath { get; } diff --git a/src/Windows/Avalonia.Direct2D1/Direct2D1Platform.cs b/src/Windows/Avalonia.Direct2D1/Direct2D1Platform.cs index cb37a93bb3..5ab9a8f74d 100644 --- a/src/Windows/Avalonia.Direct2D1/Direct2D1Platform.cs +++ b/src/Windows/Avalonia.Direct2D1/Direct2D1Platform.cs @@ -182,9 +182,9 @@ namespace Avalonia.Direct2D1 return new WriteableWicBitmapImpl(size, dpi, format); } - public IEllipseGeometryImpl CreateEllipseGeometry(Rect rect) => new EllipseGeometryImpl(rect); - public ILineGeometryImpl CreateLineGeometry(Point p1, Point p2) => new LineGeometryImpl(p1, p2); - public IRectangleGeometryImpl CreateRectangleGeometry(Rect rect) => new RectangleGeometryImpl(rect); + public IGeometryImpl CreateEllipseGeometry(Rect rect) => new EllipseGeometryImpl(rect); + public IGeometryImpl CreateLineGeometry(Point p1, Point p2) => new LineGeometryImpl(p1, p2); + public IGeometryImpl CreateRectangleGeometry(Rect rect) => new RectangleGeometryImpl(rect); public IStreamGeometryImpl CreateStreamGeometry() => new StreamGeometryImpl(); public IBitmapImpl LoadBitmap(string fileName) diff --git a/src/Windows/Avalonia.Direct2D1/Media/EllipseGeometryImpl.cs b/src/Windows/Avalonia.Direct2D1/Media/EllipseGeometryImpl.cs index c6bf475ed1..9440966406 100644 --- a/src/Windows/Avalonia.Direct2D1/Media/EllipseGeometryImpl.cs +++ b/src/Windows/Avalonia.Direct2D1/Media/EllipseGeometryImpl.cs @@ -1,7 +1,6 @@ // Copyright (c) The Avalonia Project. All rights reserved. // Licensed under the MIT license. See licence.md file in the project root for full license information. -using Avalonia.Platform; using SharpDX.Direct2D1; namespace Avalonia.Direct2D1.Media @@ -9,7 +8,7 @@ namespace Avalonia.Direct2D1.Media /// /// A Direct2D implementation of a . /// - internal class EllipseGeometryImpl : GeometryImpl, IEllipseGeometryImpl + internal class EllipseGeometryImpl : GeometryImpl { /// /// Initializes a new instance of the class. diff --git a/src/Windows/Avalonia.Direct2D1/Media/LineGeometryImpl.cs b/src/Windows/Avalonia.Direct2D1/Media/LineGeometryImpl.cs index b2d11247b9..6b73fce309 100644 --- a/src/Windows/Avalonia.Direct2D1/Media/LineGeometryImpl.cs +++ b/src/Windows/Avalonia.Direct2D1/Media/LineGeometryImpl.cs @@ -1,7 +1,6 @@ // Copyright (c) The Avalonia Project. All rights reserved. // Licensed under the MIT license. See licence.md file in the project root for full license information. -using Avalonia.Platform; using SharpDX.Direct2D1; namespace Avalonia.Direct2D1.Media @@ -9,7 +8,7 @@ namespace Avalonia.Direct2D1.Media /// /// A Direct2D implementation of a . /// - internal class LineGeometryImpl : StreamGeometryImpl, ILineGeometryImpl + internal class LineGeometryImpl : StreamGeometryImpl { /// /// Initializes a new instance of the class. diff --git a/src/Windows/Avalonia.Direct2D1/Media/RectangleGeometryImpl.cs b/src/Windows/Avalonia.Direct2D1/Media/RectangleGeometryImpl.cs index 55b2b66b3f..194de4dd14 100644 --- a/src/Windows/Avalonia.Direct2D1/Media/RectangleGeometryImpl.cs +++ b/src/Windows/Avalonia.Direct2D1/Media/RectangleGeometryImpl.cs @@ -1,7 +1,6 @@ // Copyright (c) The Avalonia Project. All rights reserved. // Licensed under the MIT license. See licence.md file in the project root for full license information. -using Avalonia.Platform; using SharpDX.Direct2D1; namespace Avalonia.Direct2D1.Media @@ -9,7 +8,7 @@ namespace Avalonia.Direct2D1.Media /// /// A Direct2D implementation of a . /// - internal class RectangleGeometryImpl : GeometryImpl, IRectangleGeometryImpl + internal class RectangleGeometryImpl : GeometryImpl { /// /// Initializes a new instance of the class. diff --git a/tests/Avalonia.UnitTests/MockPlatformRenderInterface.cs b/tests/Avalonia.UnitTests/MockPlatformRenderInterface.cs index c73c30365b..a3cc3dec17 100644 --- a/tests/Avalonia.UnitTests/MockPlatformRenderInterface.cs +++ b/tests/Avalonia.UnitTests/MockPlatformRenderInterface.cs @@ -22,19 +22,19 @@ namespace Avalonia.UnitTests return Mock.Of(); } - public IEllipseGeometryImpl CreateEllipseGeometry(Rect rect) + public IGeometryImpl CreateEllipseGeometry(Rect rect) { - return Mock.Of(); + return Mock.Of(); } - public ILineGeometryImpl CreateLineGeometry(Point p1, Point p2) + public IGeometryImpl CreateLineGeometry(Point p1, Point p2) { - return Mock.Of(); + return Mock.Of(); } - public IRectangleGeometryImpl CreateRectangleGeometry(Rect rect) + public IGeometryImpl CreateRectangleGeometry(Rect rect) { - return Mock.Of(); + return Mock.Of(); } public IRenderTarget CreateRenderTarget(IEnumerable surfaces) diff --git a/tests/Avalonia.Visuals.UnitTests/VisualTree/MockRenderInterface.cs b/tests/Avalonia.Visuals.UnitTests/VisualTree/MockRenderInterface.cs index 34be5f1dde..03470670d2 100644 --- a/tests/Avalonia.Visuals.UnitTests/VisualTree/MockRenderInterface.cs +++ b/tests/Avalonia.Visuals.UnitTests/VisualTree/MockRenderInterface.cs @@ -56,17 +56,17 @@ namespace Avalonia.Visuals.UnitTests.VisualTree throw new NotImplementedException(); } - public IEllipseGeometryImpl CreateEllipseGeometry(Rect rect) + public IGeometryImpl CreateEllipseGeometry(Rect rect) { throw new NotImplementedException(); } - public ILineGeometryImpl CreateLineGeometry(Point p1, Point p2) + public IGeometryImpl CreateLineGeometry(Point p1, Point p2) { throw new NotImplementedException(); } - public IRectangleGeometryImpl CreateRectangleGeometry(Rect rect) + public IGeometryImpl CreateRectangleGeometry(Rect rect) { throw new NotImplementedException(); } From 55e64e4c744b6836c26cc4409561b3930c441632 Mon Sep 17 00:00:00 2001 From: Benedikt Schroeder Date: Fri, 12 Apr 2019 11:32:59 +0200 Subject: [PATCH 25/41] Move Thumb style outside the control template --- src/Avalonia.Themes.Default/ScrollBar.xaml | 40 +++++++--------------- 1 file changed, 12 insertions(+), 28 deletions(-) diff --git a/src/Avalonia.Themes.Default/ScrollBar.xaml b/src/Avalonia.Themes.Default/ScrollBar.xaml index edd678ed56..ca308b33c3 100644 --- a/src/Avalonia.Themes.Default/ScrollBar.xaml +++ b/src/Avalonia.Themes.Default/ScrollBar.xaml @@ -30,20 +30,7 @@ Classes="repeattrack" Focusable="False"/> - - - - - + - - - - - + + From a39763a5f20bc00076fa52823641618f67a02e20 Mon Sep 17 00:00:00 2001 From: Nikita Tsukanov Date: Fri, 12 Apr 2019 16:58:46 +0300 Subject: [PATCH 26/41] Disable Mono tests for Linux until https://github.com/mono/mono/issues/13969 is fixed --- nukebuild/Build.cs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/nukebuild/Build.cs b/nukebuild/Build.cs index bb31034299..84092d52eb 100644 --- a/nukebuild/Build.cs +++ b/nukebuild/Build.cs @@ -122,6 +122,14 @@ partial class Build : NukeBuild foreach(var fw in frameworks) { + if (fw.StartsWith("net4") + && RuntimeInformation.IsOSPlatform(OSPlatform.Linux) + && Environment.GetEnvironmentVariable("FORCE_LINUX_TESTS") != "1") + { + Information($"Skipping {fw} tests on Linux - https://github.com/mono/mono/issues/13969"); + continue; + } + Information("Running for " + fw); DotNetTest(c => { From 1e74e8fc60b52360b57f0850298c318656e87875 Mon Sep 17 00:00:00 2001 From: Steven Kirk Date: Sat, 13 Apr 2019 16:26:08 +0200 Subject: [PATCH 27/41] Add failing tests for #2388. --- .../WindowTests.cs | 45 +++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/tests/Avalonia.Controls.UnitTests/WindowTests.cs b/tests/Avalonia.Controls.UnitTests/WindowTests.cs index 8221dadc86..ee416c4cb0 100644 --- a/tests/Avalonia.Controls.UnitTests/WindowTests.cs +++ b/tests/Avalonia.Controls.UnitTests/WindowTests.cs @@ -292,6 +292,51 @@ namespace Avalonia.Controls.UnitTests } } + [Fact] + public void Calling_Show_On_Closed_Window_Should_Throw() + { + using (UnitTestApplication.Start(TestServices.StyledWindow)) + { + var windowImpl = Mock.Of(x => x.Scaling == 1); + var target = new Window(windowImpl); + + target.Show(); + target.Close(); + + var openedRaised = false; + target.Opened += (s, e) => openedRaised = true; + + var ex = Assert.Throws(() => target.Show()); + Assert.Equal("Cannot re-show a closed window.", ex.Message); + Assert.False(openedRaised); + } + } + + [Fact] + public async Task Calling_ShowDialog_On_Closed_Window_Should_Throw() + { + using (UnitTestApplication.Start(TestServices.StyledWindow)) + { + var parent = new Mock(); + var windowImpl = new Mock(); + windowImpl.SetupProperty(x => x.Closed); + windowImpl.Setup(x => x.Scaling).Returns(1); + + var target = new Window(windowImpl.Object); + var task = target.ShowDialog(parent.Object); + + windowImpl.Object.Closed(); + await task; + + var openedRaised = false; + target.Opened += (s, e) => openedRaised = true; + + var ex = await Assert.ThrowsAsync(() => target.ShowDialog(parent.Object)); + Assert.Equal("Cannot re-show a closed window.", ex.Message); + Assert.False(openedRaised); + } + } + [Fact] public void Window_Should_Be_Centered_When_WindowStartupLocation_Is_CenterScreen() { From 30e006ac78d91b49eddd0ad9368ccff216e58c32 Mon Sep 17 00:00:00 2001 From: Steven Kirk Date: Sat, 13 Apr 2019 16:26:43 +0200 Subject: [PATCH 28/41] Throw an exception when trying to re-show closed window. --- src/Avalonia.Controls/Window.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Avalonia.Controls/Window.cs b/src/Avalonia.Controls/Window.cs index c8e09b8f9c..6c3517af62 100644 --- a/src/Avalonia.Controls/Window.cs +++ b/src/Avalonia.Controls/Window.cs @@ -373,6 +373,11 @@ namespace Avalonia.Controls /// public override void Show() { + if (PlatformImpl == null) + { + throw new InvalidOperationException("Cannot re-show a closed window."); + } + if (IsVisible) { return; From 53e666ac90f98d72d77dca160499248187c61aee Mon Sep 17 00:00:00 2001 From: Steven Kirk Date: Sat, 13 Apr 2019 16:31:33 +0200 Subject: [PATCH 29/41] Added exception details to XML docs. --- src/Avalonia.Controls/Window.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/Avalonia.Controls/Window.cs b/src/Avalonia.Controls/Window.cs index 6c3517af62..e40e114769 100644 --- a/src/Avalonia.Controls/Window.cs +++ b/src/Avalonia.Controls/Window.cs @@ -371,6 +371,9 @@ namespace Avalonia.Controls /// /// Shows the window. /// + /// + /// The window has already been closed. + /// public override void Show() { if (PlatformImpl == null) @@ -402,6 +405,9 @@ namespace Avalonia.Controls /// Shows the window as a dialog. /// /// The dialog's owner window. + /// + /// The window has already been closed. + /// /// /// A task that can be used to track the lifetime of the dialog. /// From 6f1ebdf76d5528d66cf898b9b2779b698a000170 Mon Sep 17 00:00:00 2001 From: Dariusz Komosinski Date: Tue, 16 Apr 2019 10:56:08 +0200 Subject: [PATCH 30/41] Update Numerge. --- nukebuild/Numerge | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nukebuild/Numerge b/nukebuild/Numerge index 4464343aef..aef10ae67d 160000 --- a/nukebuild/Numerge +++ b/nukebuild/Numerge @@ -1 +1 @@ -Subproject commit 4464343aef5c8ab7a42fcb20a483a6058199f8b8 +Subproject commit aef10ae67dc55c95f49b52a505a0be33bfa297a5 From 4413de463e504b9b29b925102a00aceaf96b746b Mon Sep 17 00:00:00 2001 From: Benedikt Schroeder Date: Tue, 16 Apr 2019 19:14:16 +0200 Subject: [PATCH 31/41] Remove unsupported line caps --- src/Avalonia.Controls/Shapes/Shape.cs | 72 ++++++++++-------- src/Avalonia.Visuals/Media/BrushExtensions.cs | 10 +-- src/Avalonia.Visuals/Media/Pen.cs | 72 ++++++++---------- src/Avalonia.Visuals/Media/PenLineCap.cs | 3 +- src/Skia/Avalonia.Skia/DrawingContextImpl.cs | 19 ++--- .../Avalonia.Direct2D1/PrimitiveExtensions.cs | 8 +- .../Avalonia.RenderTests/Shapes/PathTests.cs | 8 +- .../Shapes/PolylineTests.cs | 3 +- .../Path/Path_With_PenLineCap.expected.png | Bin 1155 -> 1522 bytes .../Path/Path_With_PenLineCap.expected.png | Bin 1155 -> 1522 bytes 10 files changed, 90 insertions(+), 105 deletions(-) diff --git a/src/Avalonia.Controls/Shapes/Shape.cs b/src/Avalonia.Controls/Shapes/Shape.cs index 57dbeba1cc..499dfb5320 100644 --- a/src/Avalonia.Controls/Shapes/Shape.cs +++ b/src/Avalonia.Controls/Shapes/Shape.cs @@ -21,13 +21,19 @@ namespace Avalonia.Controls.Shapes public static readonly StyledProperty> StrokeDashArrayProperty = AvaloniaProperty.Register>(nameof(StrokeDashArray)); - + public static readonly StyledProperty StrokeDashOffsetProperty = AvaloniaProperty.Register(nameof(StrokeDashOffset)); public static readonly StyledProperty StrokeThicknessProperty = AvaloniaProperty.Register(nameof(StrokeThickness)); + public static readonly StyledProperty StrokeLineCapProperty = + AvaloniaProperty.Register(nameof(StrokeLineCap), PenLineCap.Flat); + + public static readonly StyledProperty StrokeJoinProperty = + AvaloniaProperty.Register(nameof(StrokeJoin), PenLineJoin.Miter); + private Matrix _transform = Matrix.Identity; private Geometry _definingGeometry; private Geometry _renderedGeometry; @@ -36,7 +42,9 @@ namespace Avalonia.Controls.Shapes static Shape() { AffectsMeasure(StretchProperty, StrokeThicknessProperty); - AffectsRender(FillProperty, StrokeProperty, StrokeDashArrayProperty); + + AffectsRender(FillProperty, StrokeProperty, StrokeDashArrayProperty, StrokeDashOffsetProperty, + StrokeThicknessProperty, StrokeLineCapProperty, StrokeJoinProperty); } public Geometry DefiningGeometry @@ -106,7 +114,7 @@ namespace Avalonia.Controls.Shapes get { return GetValue(StrokeDashArrayProperty); } set { SetValue(StrokeDashArrayProperty, value); } } - + public double StrokeDashOffset { get { return GetValue(StrokeDashOffsetProperty); } @@ -119,13 +127,17 @@ namespace Avalonia.Controls.Shapes set { SetValue(StrokeThicknessProperty, value); } } - public PenLineCap StrokeDashCap { get; set; } = PenLineCap.Flat; - - public PenLineCap StrokeStartLineCap { get; set; } = PenLineCap.Flat; - - public PenLineCap StrokeEndLineCap { get; set; } = PenLineCap.Flat; + public PenLineCap StrokeLineCap + { + get { return GetValue(StrokeLineCapProperty); } + set { SetValue(StrokeLineCapProperty, value); } + } - public PenLineJoin StrokeJoin { get; set; } = PenLineJoin.Miter; + public PenLineJoin StrokeJoin + { + get { return GetValue(StrokeJoinProperty); } + set { SetValue(StrokeJoinProperty, value); } + } public override void Render(DrawingContext context) { @@ -133,8 +145,8 @@ namespace Avalonia.Controls.Shapes if (geometry != null) { - var pen = new Pen(Stroke, StrokeThickness, new DashStyle(StrokeDashArray, StrokeDashOffset), - StrokeDashCap, StrokeStartLineCap, StrokeEndLineCap, StrokeJoin); + var pen = new Pen(Stroke, StrokeThickness, new DashStyle(StrokeDashArray, StrokeDashOffset), + StrokeLineCap, StrokeJoin); context.DrawGeometry(Fill, pen, geometry); } } @@ -169,11 +181,11 @@ namespace Avalonia.Controls.Shapes protected void InvalidateGeometry() { - this._renderedGeometry = null; - this._definingGeometry = null; + _renderedGeometry = null; + _definingGeometry = null; InvalidateMeasure(); } - + protected override Size MeasureOverride(Size availableSize) { bool deferCalculateTransform; @@ -203,10 +215,10 @@ namespace Avalonia.Controls.Shapes return CalculateShapeSizeAndSetTransform(availableSize); } } - + protected override Size ArrangeOverride(Size finalSize) { - if(_calculateTransformOnArrange) + if (_calculateTransformOnArrange) { _calculateTransformOnArrange = false; CalculateShapeSizeAndSetTransform(finalSize); @@ -312,25 +324,25 @@ namespace Avalonia.Controls.Shapes private static void AffectsGeometryInvalidate(AvaloniaPropertyChangedEventArgs e) { - var control = e.Sender as Shape; + if (!(e.Sender is Shape control)) + { + return; + } - if (control != null) + // If the geometry is invalidated when Bounds changes, only invalidate when the Size + // portion changes. + if (e.Property == BoundsProperty) { - // If the geometry is invalidated when Bounds changes, only invalidate when the Size - // portion changes. - if (e.Property == BoundsProperty) - { - var oldBounds = (Rect)e.OldValue; - var newBounds = (Rect)e.NewValue; + var oldBounds = (Rect)e.OldValue; + var newBounds = (Rect)e.NewValue; - if (oldBounds.Size == newBounds.Size) - { - return; - } + if (oldBounds.Size == newBounds.Size) + { + return; } - - control.InvalidateGeometry(); } + + control.InvalidateGeometry(); } } } diff --git a/src/Avalonia.Visuals/Media/BrushExtensions.cs b/src/Avalonia.Visuals/Media/BrushExtensions.cs index cd351071dd..522953eb04 100644 --- a/src/Avalonia.Visuals/Media/BrushExtensions.cs +++ b/src/Avalonia.Visuals/Media/BrushExtensions.cs @@ -34,16 +34,14 @@ namespace Avalonia.Media { Contract.Requires(pen != null); - var brush = pen?.Brush?.ToImmutable(); - return pen == null || ReferenceEquals(pen?.Brush, brush) ? + var brush = pen.Brush?.ToImmutable(); + return ReferenceEquals(pen.Brush, brush) ? pen : new Pen( brush, thickness: pen.Thickness, - dashStyle: pen.DashStyle, - dashCap: pen.DashCap, - startLineCap: pen.StartLineCap, - endLineCap: pen.EndLineCap, + dashStyle: pen.DashStyle, + lineCap: pen.LineCap, lineJoin: pen.LineJoin, miterLimit: pen.MiterLimit); } diff --git a/src/Avalonia.Visuals/Media/Pen.cs b/src/Avalonia.Visuals/Media/Pen.cs index ddd8091801..ee427c913b 100644 --- a/src/Avalonia.Visuals/Media/Pen.cs +++ b/src/Avalonia.Visuals/Media/Pen.cs @@ -11,63 +11,45 @@ namespace Avalonia.Media /// /// Initializes a new instance of the class. /// - /// The brush used to draw. + /// The stroke color. /// The stroke thickness. /// The dash style. - /// The dash cap. - /// The start line cap. - /// The end line cap. + /// Specifies the type of graphic shape to use on both ends of a line. /// The line join. /// The miter limit. public Pen( - IBrush brush, + uint color, double thickness = 1.0, - DashStyle dashStyle = null, - PenLineCap dashCap = PenLineCap.Flat, - PenLineCap startLineCap = PenLineCap.Flat, - PenLineCap endLineCap = PenLineCap.Flat, - PenLineJoin lineJoin = PenLineJoin.Miter, - double miterLimit = 10.0) + DashStyle dashStyle = null, + PenLineCap lineCap = PenLineCap.Flat, + PenLineJoin lineJoin = PenLineJoin.Miter, + double miterLimit = 10.0) : this(new SolidColorBrush(color), thickness, dashStyle, lineCap, lineJoin, miterLimit) { - Brush = brush; - Thickness = thickness; - DashCap = dashCap; - StartLineCap = startLineCap; - EndLineCap = endLineCap; - LineJoin = lineJoin; - MiterLimit = miterLimit; - DashStyle = dashStyle; } /// /// Initializes a new instance of the class. /// - /// The stroke color. + /// The brush used to draw. /// The stroke thickness. /// The dash style. - /// The dash cap. - /// The start line cap. - /// The end line cap. + /// The line cap. /// The line join. /// The miter limit. public Pen( - uint color, + IBrush brush, double thickness = 1.0, - DashStyle dashStyle = null, - PenLineCap dashCap = PenLineCap.Flat, - PenLineCap startLineCap = PenLineCap.Flat, - PenLineCap endLineCap = PenLineCap.Flat, - PenLineJoin lineJoin = PenLineJoin.Miter, + DashStyle dashStyle = null, + PenLineCap lineCap = PenLineCap.Flat, + PenLineJoin lineJoin = PenLineJoin.Miter, double miterLimit = 10.0) { - Brush = new SolidColorBrush(color); + Brush = brush; Thickness = thickness; - StartLineCap = startLineCap; - EndLineCap = endLineCap; + LineCap = lineCap; LineJoin = lineJoin; MiterLimit = miterLimit; DashStyle = dashStyle; - DashCap = dashCap; } /// @@ -78,18 +60,26 @@ namespace Avalonia.Media /// /// Gets the stroke thickness. /// - public double Thickness { get; } = 1.0; + public double Thickness { get; } + /// + /// Specifies the style of dashed lines drawn with a object. + /// public DashStyle DashStyle { get; } - public PenLineCap DashCap { get; } - - public PenLineCap StartLineCap { get; } = PenLineCap.Flat; - - public PenLineCap EndLineCap { get; } = PenLineCap.Flat; + /// + /// Specifies the type of graphic shape to use on both ends of a line. + /// + public PenLineCap LineCap { get; } - public PenLineJoin LineJoin { get; } = PenLineJoin.Miter; + /// + /// Specifies how to join consecutive line or curve segments in a (subpath) contained in a object. + /// + public PenLineJoin LineJoin { get; } - public double MiterLimit { get; } = 10.0; + /// + /// The limit on the ratio of the miter length to half this pen's Thickness. + /// + public double MiterLimit { get; } } } diff --git a/src/Avalonia.Visuals/Media/PenLineCap.cs b/src/Avalonia.Visuals/Media/PenLineCap.cs index 56c5c040eb..83d8f11613 100644 --- a/src/Avalonia.Visuals/Media/PenLineCap.cs +++ b/src/Avalonia.Visuals/Media/PenLineCap.cs @@ -4,7 +4,6 @@ namespace Avalonia.Media { Flat, Round, - Square, - Triangle + Square } } diff --git a/src/Skia/Avalonia.Skia/DrawingContextImpl.cs b/src/Skia/Avalonia.Skia/DrawingContextImpl.cs index e69d155305..ef37f69f45 100644 --- a/src/Skia/Avalonia.Skia/DrawingContextImpl.cs +++ b/src/Skia/Avalonia.Skia/DrawingContextImpl.cs @@ -573,25 +573,17 @@ namespace Avalonia.Skia // Need to modify dashes due to Skia modifying their lengths // https://docs.microsoft.com/en-us/xamarin/xamarin-forms/user-interface/graphics/skiasharp/paths/dots // TODO: Still something is off, dashes are now present, but don't look the same as D2D ones. - float dashLengthModifier; - float gapLengthModifier; - switch (pen.StartLineCap) + switch (pen.LineCap) { case PenLineCap.Round: paint.StrokeCap = SKStrokeCap.Round; - dashLengthModifier = -paint.StrokeWidth; - gapLengthModifier = paint.StrokeWidth; break; case PenLineCap.Square: paint.StrokeCap = SKStrokeCap.Square; - dashLengthModifier = -paint.StrokeWidth; - gapLengthModifier = paint.StrokeWidth; break; default: paint.StrokeCap = SKStrokeCap.Butt; - dashLengthModifier = 0.0f; - gapLengthModifier = 0.0f; break; } @@ -617,13 +609,12 @@ namespace Avalonia.Skia for (var i = 0; i < srcDashes.Count; ++i) { - var lengthModifier = i % 2 == 0 ? dashLengthModifier : gapLengthModifier; - - // Avalonia dash lengths are relative, but Skia takes absolute sizes - need to scale - dashesArray[i] = (float) srcDashes[i] * paint.StrokeWidth + lengthModifier; + dashesArray[i] = (float) srcDashes[i] * paint.StrokeWidth; } - var pe = SKPathEffect.CreateDash(dashesArray, (float) pen.DashStyle.Offset); + var offset = (float)(pen.DashStyle.Offset * pen.Thickness); + + var pe = SKPathEffect.CreateDash(dashesArray, offset); paint.PathEffect = pe; rv.AddDisposable(pe); diff --git a/src/Windows/Avalonia.Direct2D1/PrimitiveExtensions.cs b/src/Windows/Avalonia.Direct2D1/PrimitiveExtensions.cs index 5209014271..6b0d30f250 100644 --- a/src/Windows/Avalonia.Direct2D1/PrimitiveExtensions.cs +++ b/src/Windows/Avalonia.Direct2D1/PrimitiveExtensions.cs @@ -122,14 +122,16 @@ namespace Avalonia.Direct2D1 /// The Direct2D brush. public static StrokeStyle ToDirect2DStrokeStyle(this Avalonia.Media.Pen pen, Factory factory) { + var d2dLineCap = pen.LineCap.ToDirect2D(); + var properties = new StrokeStyleProperties { DashStyle = DashStyle.Solid, MiterLimit = (float)pen.MiterLimit, LineJoin = pen.LineJoin.ToDirect2D(), - StartCap = pen.StartLineCap.ToDirect2D(), - EndCap = pen.EndLineCap.ToDirect2D(), - DashCap = pen.DashCap.ToDirect2D() + StartCap = d2dLineCap, + EndCap = d2dLineCap, + DashCap = d2dLineCap }; float[] dashes = null; if (pen.DashStyle?.Dashes != null && pen.DashStyle.Dashes.Count > 0) diff --git a/tests/Avalonia.RenderTests/Shapes/PathTests.cs b/tests/Avalonia.RenderTests/Shapes/PathTests.cs index 4703daca25..2fa93b49e2 100644 --- a/tests/Avalonia.RenderTests/Shapes/PathTests.cs +++ b/tests/Avalonia.RenderTests/Shapes/PathTests.cs @@ -334,11 +334,7 @@ namespace Avalonia.Direct2D1.RenderTests.Shapes CompareImages(); } -#if AVALONIA_SKIA_SKIP_FAIL - [Fact(Skip = "FIXME")] -#else [Fact] -#endif public async Task Path_With_PenLineCap() { Decorator target = new Decorator @@ -351,10 +347,8 @@ namespace Avalonia.Direct2D1.RenderTests.Shapes StrokeThickness = 10, HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center, - StrokeDashCap = PenLineCap.Triangle, StrokeDashArray = new AvaloniaList(3, 1), - StrokeStartLineCap = PenLineCap.Round, - StrokeEndLineCap = PenLineCap.Square, + StrokeLineCap = PenLineCap.Round, Data = StreamGeometry.Parse("M 20,20 L 180,180"), } }; diff --git a/tests/Avalonia.RenderTests/Shapes/PolylineTests.cs b/tests/Avalonia.RenderTests/Shapes/PolylineTests.cs index 3b586d55ea..8afaeb8838 100644 --- a/tests/Avalonia.RenderTests/Shapes/PolylineTests.cs +++ b/tests/Avalonia.RenderTests/Shapes/PolylineTests.cs @@ -61,8 +61,7 @@ namespace Avalonia.Direct2D1.RenderTests.Shapes Points = polylinePoints, Stretch = Stretch.Uniform, StrokeJoin = PenLineJoin.Round, - StrokeStartLineCap = PenLineCap.Round, - StrokeEndLineCap = PenLineCap.Round, + StrokeLineCap = PenLineCap.Round, StrokeThickness = 10 } }; diff --git a/tests/TestFiles/Direct2D1/Shapes/Path/Path_With_PenLineCap.expected.png b/tests/TestFiles/Direct2D1/Shapes/Path/Path_With_PenLineCap.expected.png index d33068d62c9deb097896fc29422ed4f765f2daf4..a61ba9f080449b976575ff2faaf7d793aac7e5f9 100644 GIT binary patch literal 1522 zcmeAS@N?(olHy`uVBq!ia0vp^CqS5k4M?tyST_$yF%}28J29*~C-V}>VM%xNb!1@J z*w6hZkrl}2EbxddW?Klsp8uxup*tayqEg>Z;J%+FI`*b<}H{$3&;5)~420g%%DmO{F7F9V!V& zIJ#e0p62U0yuJ8YT<`3=pKU&DI(Oyw<9j<_*H|(EU4RZw`yH|CjlCWF@B2!LE#Jd( ztiN49^=U7+VTSg4nZ*{Rz>ESIGr!JbM&6(T5 z!ll&MtUlV6t`f1Dt9DMh z(1yobFwX)#W}XE0*ouXJ>^Qd=s0*o|x_s)2$EV*PE}WX;aqh^1xxPv}rBB!AJ)C*t z=8Z=R))@=CRL(#CmH2dT^u`|6s1xoxe{RXLY}!*4(tb5H=7N*msk6&Ne>U3K7eC3p z`f6&j$;1mmbrj$w1w(XnUv8lm!&~lPd2T z;H$Dl5m%(ZTn~&jVEokZM9mOBS*Ej}|9ovx$#?bN@4a;Vy)CzX&NAjdUe{l{@iUjy zj4IWiHf(EsI#aaS-sVW1wB9&nd-^%XWmB~#NpCFP_bn-q@=*IA^7_Fq!)e>2fL`wUQ@_{d?xNm3 zNtuG?aQ}FA zs(Po*;@5vAwoK?R+TR07cH2WMQzegX+_Q(t(Yvx$!gZt7#0!^}-q7f{2uy^Pr%j>$ z6R(3rm*0_P^EBpLUzlhyd%EvmnbYw<#LMDx&qW^CV)Q&r`*~Tn86MBTyx6*P;+$Sb z?qa2#qQFcf_RM9{{j?UdWo|`kpvZc%^2WXob4$K?*SXv7Up?=BWW4(MKYw+;1-+Si zeZ)rENK0+T*U8~(KKMj zir!n)15A8Xwq{&Oz+`#uCp0zAEMkrHQQ0!FzZj?&lF6Pdz7xoD)x}Br=V?1o?>eZ3&F>ybmVM^c+PM3FOpd!-K)z4*}Q$iB} Dt%9q! literal 1155 zcmeAS@N?(olHy`uVBq!ia0vp^CqS5k4M?tyST_$yF%}28J29*~C-V}>VM%xNb!1@J z*w6hZkrl|*^>lFzsfc@fcVS*?s6^XCKHq>2FBQJ-H3}`=2Odm_kdbq4YOq#d;WQ6u zeaIKUa*%^XsIi&l+Wq2LCU3L$Z#AF0F(MRJMfd&p*>N!&ha? z=hHWI+IFi6Mg7dn5j#{X%$a+|edo*RUv9b_T5M$-7r*uXu{ina_n)rr;(DF)=Fuln zo8nTXGk#qr>YTY9EKCy}6ofcjm>NA41UOlg8XZ&w5P}EqdDw6?nSFElbXa1`MpL22 z3+JYJusC_Ip2*R%Elf#}W9?E8mP7U59##C^zpB6JzU`fRpNihhKKxd>bhT%4r8rp;nX#c1#@*LIshHz5UoAYAzM@Ef!yYdbzy~$*_#d4`KxR(>wfeM zX!mA?G+|ENvq?L$l@`v82*=qvRM@vPM5M&m=>;`3Jffudm8s7>Gy@t zTlY)jdoM6-^85Ez?%4bE`Ns47+b>+cp1gVT)2vb^$7sz7vph1gRY7E?DTqw>Rxq6i z^q@nQ(!yT<<7t9RI$O+MowWnGdW#~?Sc5pRT6yJuTOQpvolE}x<-`?vw^$$D+;b;H z{^>R2`t&;a)#?Av{jvP^_n}zTs^uro`%PPYm6IiRDaih{Q$gg?s~~c&E+_)EqnUvb zX!dG<^K5XGtuX(s(_}L7LL0V}gcNLVdY^O~W+eKn?C*1wj#d`rc$?D+47M#&oen_X z1H&$=>&Zptk2!I2(X~^e`I~2~OlPdG*fF=Na*vaDe(zbLT=k75sCt8kUw?Q-*FOns zY3uzpTi5N|x9>et^0&{sNXV%+9xCf)*MGQEWAyFnL$MvFr%gW6AF*YNP^U%4+kGBK v7!T_R6&^6Xt}Mvz6C&}5fuVv&UHw1P$(b*HrVM%xNb!1@J z*w6hZkrl}2EbxddW?Klsp8uxup*tayqEg>Z;J%+FI`*b<}H{$3&;5)~420g%%DmO{F7F9V!V& zIJ#e0p62U0yuJ8YT<`3=pKU&DI(Oyw<9j<_*H|(EU4RZw`yH|CjlCWF@B2!LE#Jd( ztiN49^=U7+VTSg4nZ*{Rz>ESIGr!JbM&6(T5 z!ll&MtUlV6t`f1Dt9DMh z(1yobFwX)#W}XE0*ouXJ>^Qd=s0*o|x_s)2$EV*PE}WX;aqh^1xxPv}rBB!AJ)C*t z=8Z=R))@=CRL(#CmH2dT^u`|6s1xoxe{RXLY}!*4(tb5H=7N*msk6&Ne>U3K7eC3p z`f6&j$;1mmbrj$w1w(XnUv8lm!&~lPd2T z;H$Dl5m%(ZTn~&jVEokZM9mOBS*Ej}|9ovx$#?bN@4a;Vy)CzX&NAjdUe{l{@iUjy zj4IWiHf(EsI#aaS-sVW1wB9&nd-^%XWmB~#NpCFP_bn-q@=*IA^7_Fq!)e>2fL`wUQ@_{d?xNm3 zNtuG?aQ}FA zs(Po*;@5vAwoK?R+TR07cH2WMQzegX+_Q(t(Yvx$!gZt7#0!^}-q7f{2uy^Pr%j>$ z6R(3rm*0_P^EBpLUzlhyd%EvmnbYw<#LMDx&qW^CV)Q&r`*~Tn86MBTyx6*P;+$Sb z?qa2#qQFcf_RM9{{j?UdWo|`kpvZc%^2WXob4$K?*SXv7Up?=BWW4(MKYw+;1-+Si zeZ)rENK0+T*U8~(KKMj zir!n)15A8Xwq{&Oz+`#uCp0zAEMkrHQQ0!FzZj?&lF6Pdz7xoD)x}Br=V?1o?>eZ3&F>ybmVM^c+PM3FOpd!-K)z4*}Q$iB} Dt%9q! literal 1155 zcmeAS@N?(olHy`uVBq!ia0vp^CqS5k4M?tyST_$yF%}28J29*~C-V}>VM%xNb!1@J z*w6hZkrl|*^>lFzsfc@fcVS*?s6^XCKHq>2FBQJ-H3}`=2Odm_kdbq4YOq#d;WQ6u zeaIKUa*%^XsIi&l+Wq2LCU3L$Z#AF0F(MRJMfd&p*>N!&ha? z=hHWI+IFi6Mg7dn5j#{X%$a+|edo*RUv9b_T5M$-7r*uXu{ina_n)rr;(DF)=Fuln zo8nTXGk#qr>YTY9EKCy}6ofcjm>NA41UOlg8XZ&w5P}EqdDw6?nSFElbXa1`MpL22 z3+JYJusC_Ip2*R%Elf#}W9?E8mP7U59##C^zpB6JzU`fRpNihhKKxd>bhT%4r8rp;nX#c1#@*LIshHz5UoAYAzM@Ef!yYdbzy~$*_#d4`KxR(>wfeM zX!mA?G+|ENvq?L$l@`v82*=qvRM@vPM5M&m=>;`3Jffudm8s7>Gy@t zTlY)jdoM6-^85Ez?%4bE`Ns47+b>+cp1gVT)2vb^$7sz7vph1gRY7E?DTqw>Rxq6i z^q@nQ(!yT<<7t9RI$O+MowWnGdW#~?Sc5pRT6yJuTOQpvolE}x<-`?vw^$$D+;b;H z{^>R2`t&;a)#?Av{jvP^_n}zTs^uro`%PPYm6IiRDaih{Q$gg?s~~c&E+_)EqnUvb zX!dG<^K5XGtuX(s(_}L7LL0V}gcNLVdY^O~W+eKn?C*1wj#d`rc$?D+47M#&oen_X z1H&$=>&Zptk2!I2(X~^e`I~2~OlPdG*fF=Na*vaDe(zbLT=k75sCt8kUw?Q-*FOns zY3uzpTi5N|x9>et^0&{sNXV%+9xCf)*MGQEWAyFnL$MvFr%gW6AF*YNP^U%4+kGBK v7!T_R6&^6Xt}Mvz6C&}5fuVv&UHw1P$(b*Hr Date: Thu, 18 Apr 2019 20:15:51 -0700 Subject: [PATCH 32/41] do not fire key drag event before any drag has happened --- src/Avalonia.Controls/Platform/InProcessDragSource.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Avalonia.Controls/Platform/InProcessDragSource.cs b/src/Avalonia.Controls/Platform/InProcessDragSource.cs index f8ae9f4249..0918da1a90 100644 --- a/src/Avalonia.Controls/Platform/InProcessDragSource.cs +++ b/src/Avalonia.Controls/Platform/InProcessDragSource.cs @@ -147,7 +147,10 @@ namespace Avalonia.Platform e.Handled = true; } else if (e.Key == Key.LeftCtrl || e.Key == Key.RightCtrl || e.Key == Key.LeftAlt || e.Key == Key.RightAlt) - RaiseEventAndUpdateCursor(RawDragEventType.DragOver, _lastRoot, _lastPosition, e.Modifiers); + { + if (_lastRoot != null) + RaiseEventAndUpdateCursor(RawDragEventType.DragOver, _lastRoot, _lastPosition, e.Modifiers); + } } private void ProcessMouseEvents(RawMouseEventArgs e) From 8562270c66ad5f9f21265ae2ce4230c5a4603fef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Pedro?= Date: Sat, 20 Apr 2019 23:57:29 +0100 Subject: [PATCH 33/41] Fixed type name in XML comment. --- .../Collections/DataGridCollectionView.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Avalonia.Controls.DataGrid/Collections/DataGridCollectionView.cs b/src/Avalonia.Controls.DataGrid/Collections/DataGridCollectionView.cs index 4b4203ba40..92734b128d 100644 --- a/src/Avalonia.Controls.DataGrid/Collections/DataGridCollectionView.cs +++ b/src/Avalonia.Controls.DataGrid/Collections/DataGridCollectionView.cs @@ -927,7 +927,7 @@ namespace Avalonia.Collections /// ///

/// Clear a sort criteria by assigning SortDescription.Empty to this property. - /// One or more sort criteria in form of + /// One or more sort criteria in form of /// can be used, each specifying a property and direction to sort by. ///

///
@@ -4312,4 +4312,4 @@ namespace Avalonia.Collections } } } -} \ No newline at end of file +} From dda9dd729c5274637735fdfe8fe6545049ff97a3 Mon Sep 17 00:00:00 2001 From: Dan Walmsley Date: Tue, 23 Apr 2019 20:59:45 +0100 Subject: [PATCH 34/41] [Grid] add missing static set and get methods for IsSharedSizeScope property. --- src/Avalonia.Controls/Grid.cs | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/Avalonia.Controls/Grid.cs b/src/Avalonia.Controls/Grid.cs index b51583d8b3..90a27d0b31 100644 --- a/src/Avalonia.Controls/Grid.cs +++ b/src/Avalonia.Controls/Grid.cs @@ -177,6 +177,17 @@ namespace Avalonia.Controls return element.GetValue(RowSpanProperty); } + + /// + /// Gets the value of the IsSharedSizeScope attached property for a control. + /// + /// The control. + /// The control's IsSharedSizeScope value. + public static bool GetIsSharedSizeScope(AvaloniaObject element) + { + return element.GetValue(IsSharedSizeScopeProperty); + } + /// /// Sets the value of the Column attached property for a control. /// @@ -217,6 +228,16 @@ namespace Avalonia.Controls element.SetValue(RowSpanProperty, value); } + /// + /// Sets the value of IsSharedSizeScope property for a control. + /// + /// The control. + /// The IsSharedSizeScope value. + public static void SetIsSharedSizeScope(AvaloniaObject element, bool value) + { + element.SetValue(IsSharedSizeScopeProperty, value); + } + /// /// Gets the result of the last column measurement. /// Use this result to reduce the arrange calculation. From e8cc8ec17feafed2ffecb2bf9321ea7b5ccae3f7 Mon Sep 17 00:00:00 2001 From: Dan Walmsley Date: Tue, 23 Apr 2019 21:07:25 +0100 Subject: [PATCH 35/41] fix datagrid xmlns attribute. --- src/Avalonia.Controls.DataGrid/Properties/AssemblyInfo.cs | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/Avalonia.Controls.DataGrid/Properties/AssemblyInfo.cs b/src/Avalonia.Controls.DataGrid/Properties/AssemblyInfo.cs index d5ad4c75f8..5c30a1b23e 100644 --- a/src/Avalonia.Controls.DataGrid/Properties/AssemblyInfo.cs +++ b/src/Avalonia.Controls.DataGrid/Properties/AssemblyInfo.cs @@ -8,7 +8,4 @@ using Avalonia.Metadata; [assembly: InternalsVisibleTo("Avalonia.Controls.UnitTests")] [assembly: InternalsVisibleTo("Avalonia.DesignerSupport")] -[assembly: XmlnsDefinition("https://github.com/avaloniaui", "Avalonia")] [assembly: XmlnsDefinition("https://github.com/avaloniaui", "Avalonia.Controls")] -[assembly: XmlnsDefinition("https://github.com/avaloniaui", "Avalonia.Controls.Primitives")] -[assembly: XmlnsDefinition("https://github.com/avaloniaui", "Avalonia.Controls.Collections")] From 0df770b1c46c1e0ffb86b7cee24e70cec95d1080 Mon Sep 17 00:00:00 2001 From: Dan Walmsley Date: Tue, 23 Apr 2019 21:47:29 +0100 Subject: [PATCH 36/41] fix datagrid xmlns --- src/Avalonia.Controls.DataGrid/Properties/AssemblyInfo.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Avalonia.Controls.DataGrid/Properties/AssemblyInfo.cs b/src/Avalonia.Controls.DataGrid/Properties/AssemblyInfo.cs index 5c30a1b23e..f15442addf 100644 --- a/src/Avalonia.Controls.DataGrid/Properties/AssemblyInfo.cs +++ b/src/Avalonia.Controls.DataGrid/Properties/AssemblyInfo.cs @@ -9,3 +9,5 @@ using Avalonia.Metadata; [assembly: InternalsVisibleTo("Avalonia.DesignerSupport")] [assembly: XmlnsDefinition("https://github.com/avaloniaui", "Avalonia.Controls")] +[assembly: XmlnsDefinition("https://github.com/avaloniaui", "Avalonia.Controls.Collections")] +[assembly: XmlnsDefinition("https://github.com/avaloniaui", "Avalonia.Controls.Primitives")] From 2c5956514e22313f31d4a790459ae956d6dcea36 Mon Sep 17 00:00:00 2001 From: Dan Walmsley Date: Wed, 24 Apr 2019 18:58:10 +0100 Subject: [PATCH 37/41] install xcode sdk --- azure-pipelines.yml | 5 + scripts/XcodeLegacy.sh | 1306 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 1311 insertions(+) create mode 100755 scripts/XcodeLegacy.sh diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 39333f37ba..dcf21cf30f 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -9,6 +9,11 @@ jobs: script: | sudo apt-get update sudo apt-get install castxml + - task: CmdLine@2 + displayName: 'Install OSX Sdk' + inputs: + script: | + ./scripts/XcodeLegacy.sh -osx1013 - task: CmdLine@2 displayName: 'Install Nuke' diff --git a/scripts/XcodeLegacy.sh b/scripts/XcodeLegacy.sh new file mode 100755 index 0000000000..2a67dca414 --- /dev/null +++ b/scripts/XcodeLegacy.sh @@ -0,0 +1,1306 @@ +#!/bin/bash +# XCodeLegacy.sh +# +# Original author: Frederic Devernay +# Contributors: +# - Garrett Walbridge +# - Jae Liu +# - Eric Knibbe +# - Chris Roueche +# - Kris Coppieters +# - Nick Beadman / +# +# License: Creative Commons BY-NC-SA 3.0 http://creativecommons.org/licenses/by-nc-sa/3.0/ +# +# History: +# 1.0 (08/10/2012): First public version, supports Xcode up to version 4.6.3 +# 1.1 (20/09/2013): Xcode 5 removed llvm-gcc and 10.7 SDK support, grab them from Xcode 3 and 4 +# 1.2 (03/02/2014): Xcode 5 broke PPC assembly and linking; fix assembly and grab linker from Xcode 3 +# 1.3 (07/10/2014): Xcode 6 removed 10.8 SDK, grab it from Xcode 5.1.1 +# 1.4 (21/08/2015): Xcode 7 removed 10.9 and 10.10 SDKs, grab them from Xcode 6.4 +# 1.5 (15/10/2015): Fixes for OS X 10.11 El Capitan (nothing can be installed in /usr/bin because of the sandbox) +# 1.6 (11/11/2015): Fix buildpackages, fix /usr/bin/gcc on recent OS X, fix download messages +# 1.7 (05/04/2016): Xcode 7.3 disables support for older SDKs, fix that +# 1.8 (07/04/2016): add options to install only some SDKs or compilers only +# 1.9 (16/09/2016): Xcode 8 dropped 10.11 SDK, get it from Xcode 7.3.1 +# 2.0 (02/05/2017): Xcode 8 cannot always link i386 for OS X 10.5, use the Xcode 3 linker for this arch too. Force use of legacy assembler with GCC 4.x. +# 2.1 (17/01/2017): Xcode 9 dropped 10.12 SDK, get it from https://github.com/phracker/MacOSX-SDKs; fix compiling with GNU Ada, and many other fixes +# 2.2 (12/02/2019): Added support for using macOS High Sierra 10.13 SDK from Xcode 9.4.1 for use on Xcode 10/macOS 10.14 Mojave, also changed source of OS X 10.12 SDK to Xcode 8.3.3 + +#set -e # Exit immediately if a command exits with a non-zero status +#set -u # Treat unset variables as an error when substituting. +#set -x # Print commands and their arguments as they are executed. + +compilers=0 +osx104=0 +osx105=0 +osx106=0 +osx107=0 +osx108=0 +osx109=0 +osx1010=0 +osx1011=0 +osx1012=0 +osx1013=0 +gotoption=0 +error=0 + +while [[ $error = 0 ]] && [[ $# -gt 1 ]]; do + + case $1 in + -compilers) + compilers=1 + gotoption=1 + shift + ;; + -osx104) + osx104=1 + gotoption=1 + shift + ;; + -osx105) + osx105=1 + gotoption=1 + shift + ;; + -osx106) + osx106=1 + gotoption=1 + shift + ;; + -osx107) + osx107=1 + gotoption=1 + shift + ;; + -osx108) + osx108=1 + gotoption=1 + shift + ;; + -osx109) + osx109=1 + gotoption=1 + shift + ;; + -osx1010) + osx1010=1 + gotoption=1 + shift + ;; + -osx1011) + osx1011=1 + gotoption=1 + shift + ;; + -osx1012) + osx1012=1 + gotoption=1 + shift + ;; + -osx1013) + osx1013=1 + gotoption=1 + shift + ;; + *) + # unknown option or spurious arg + error=1 + ;; + esac + +done + +if [ $gotoption = 0 ]; then + compilers=1 + osx104=1 + osx105=1 + osx106=1 + osx107=1 + osx108=1 + osx109=1 + osx1010=1 + osx1011=1 + osx1012=1 + osx1013=1 +fi + +if [ $# != 1 ]; then + # ################################################################################ 80 cols + echo "Usage: $0 [-compilers|-osx104|-osx105|-osx106|-osx107|-osx108|-osx109|-osx1010|-osx1011|-osx1012|-osx1013] buildpackages|install|installbeta|cleanpackages|uninstall|uninstallbeta" + echo "" + echo "Description: Extracts / installs / cleans / uninstalls the following components" + echo "from Xcode 3.2.6, Xcode 4.6.3, Xcode 5.1.1, Xcode 6.4, Xcode 7.3.1, Xcode 8.3.3 and Xcode 9.4.1 which" + echo "are not available in Xcode >= 4.2:" + echo " - PPC assembler and linker" + echo " - GCC 4.0 and 4.2 compilers and Xcode plugins" + echo " - LLVM-GCC 4.2 compiler and Xcode plugin (Xcode >= 5)" + echo " - Mac OS X SDK 10.4u, 10.5, 10.6, 10.7, 10.8, 10.9, 10.10, 10.11, 10.12, 10.13" + echo "" + echo "An optional first argument may be provided to limit the operation (by default" + echo "everything is done):" + echo " -compilers : only install the gcc and llvm-gcc compilers, as well as the" + echo " corresponding Xcode plugins" + echo " -osx104 : only install Mac OSX 10.4 SDK" + echo " -osx105 : only install Mac OSX 10.5 SDK" + echo " -osx106 : only install Mac OSX 10.6 SDK" + echo " -osx107 : only install Mac OSX 10.7 SDK" + echo " -osx108 : only install OSX 10.8 SDK" + echo " -osx109 : only install OSX 10.9 SDK" + echo " -osx1010 : only install OSX 10.10 SDK" + echo " -osx1011 : only install OSX 10.11 SDK" + echo " -osx1012 : only install OSX 10.12 SDK" + echo " -osx1013 : only install OSX 10.13 SDK" + echo "Note that these can be combined. For example, to build and install the 10.9" + echo "and 10.10 SDKs, one could execute:" + echo " $ $0 -osx109 -osx1010 buildpackages" + echo " $ sudo $0 -osx109 -osx1010 install" + echo "" + echo "Typically, you will want to run this script with the buildpackages argument" + echo "first, then the install argument, and lastly the cleanpackages argument, in" + echo "order to properly install the legacy Xcode files." + echo "The install and uninstall phases have to be run with administrative rights, as" + echo "in:" + echo " $ sudo $0 install" + echo "The installbeta and uninstallbeta phases work on the beta versions of Xcode." + exit +fi + +if [ "$1" = "installbeta" ] || [ "$1" = "uninstallbeta" ]; then + XCODEAPP="/Applications/Xcode-beta.app" +else + XCODEAPP="/Applications/Xcode.app" +fi +XCODE42=0 +PLUGINDIR="$XCODEAPP/Contents/PlugIns/Xcode3Core.ideplugin/Contents/SharedSupport/Developer/Library/Xcode/Plug-ins" +GCCDIR="$XCODEAPP/Contents/Developer" +SDKDIR="$GCCDIR/Platforms/MacOSX.platform/Developer" +if [ -d "$XCODEAPP" ]; then + echo "*** Info: found Xcode >= 4.3 in $XCODEAPP" +else + GCCDIR="/Developer" + XCODEAPP="$GCCDIR/Applications/Xcode.app" + PLUGINDIR="$GCCDIR/Library/Xcode/PrivatePlugIns/Xcode3Core.ideplugin/Contents/SharedSupport/Developer/Library/Xcode/Plug-ins" + SDKDIR="$GCCDIR" + if [ -d "$XCODEAPP" ]; then + XCODE42=1 + echo "*** Info: found Xcode <= 4.2.1 in $XCODEAPP" + else + echo "*** Info: could not find Xcode 4.2 in /Developer/Applications nor Xcode >= 4.3 in /Applications" + fi +fi +PLATFORMDIR="$GCCDIR/Platforms/MacOSX.platform" +GCCINSTALLDIR="$GCCDIR/Toolchains/XcodeDefault.xctoolchain" +GCCLINKDIR=/usr +RELEASENUM=$(uname -r | awk -F. '{print $1}') +if [ "$RELEASENUM" -gt 14 ]; then + # on OSX 10.11 El Capitan, nothing can be installed in /usr because of the Sandbox + # install in Xcode instead, and put links in /usr/local + GCCLINKDIR=/usr/local +elif [ "$RELEASENUM" -lt 10 ]; then + echo "*** Error: This script requires Mac OS X 10.6 Snow Leopard or newer." + exit 1 +fi + +GCCFILES="usr/share/man/man7/fsf-funding.7 usr/share/man/man7/gfdl.7 usr/share/man/man7/gpl.7 usr/share/man/man1/*-4.0.1 usr/share/man/man1/*-4.0.1.1 usr/libexec/gcc/*-apple-darwin10/4.0.1 usr/lib/gcc/*-apple-darwin10/4.0.1 usr/include/gcc/darwin/4.0 usr/bin/*-4.0 usr/bin/*-4.0.1 usr/share/man/man1/*-4.2.1 usr/share/man/man1/*-4.2.1.1 usr/libexec/gcc/*-apple-darwin10/4.2.1 usr/lib/gcc/*-apple-darwin10/4.2.1 usr/include/gcc/darwin/4.2 usr/bin/*-4.2 usr/bin/*-4.2.1" +LLVMGCCFILES="usr/llvm-gcc-4.2 usr/share/man/man1/llvm-g*.1.gz" + +xc3="$(( compilers + osx104 + osx105 + osx106 != 0 ))" +xc4="$(( compilers + osx107 != 0 ))" +xc5="$(( osx108 != 0 ))" +xc6="$(( osx109 + osx1010 != 0 ))" +xc7="$(( osx1011 != 0 ))" +xc8="$(( osx1012 != 0 ))" +xc9="$(( osx1013 != 0 ))" + +# The sole argument is the macOS version (e.g. 10.12) +installSDK() { + macos="$1" + macosnodot="${macos//./}" + if [ -d "$SDKDIR/SDKs/MacOSX${macos}.sdk" ]; then + echo "*** Not installing MacOSX${macos}.sdk (found installed in $SDKDIR/SDKs/MacOSX${macos}.sdk, uninstall first to force install)" + else + if [ -f Xcode${macosnodot}SDK.tar.gz ]; then + (gzip -dc Xcode${macosnodot}SDK.tar.gz | (cd "$SDKDIR" || exit; tar xf -)) && echo "*** installed Xcode${macosnodot}SDK.tar.gz" + elif [ -f MacOSX${macos}.sdk.tar.xz ]; then + (gzip -dc MacOSX${macos}.sdk.tar.xz | (cd "$SDKDIR/SDKs" || exit; tar xf -)) && echo "*** installed MacOSX${macos}.sdk.tar.xz" + else + echo "*** Could not install MacOSX${macos}.sdk" + echo "*** Before installing:" + echo "- execute \"$0 buildpackages\"" + exit 1 + fi + touch "$SDKDIR/SDKs/MacOSX${macos}.sdk/legacy" + fi +} + +case $1 in + buildpackages) + ####################### + # PHASE 1: PACKAGING + # + missingdmg=0 + # note: Xcode links from http://stackoverflow.com/questions/10335747/how-to-download-xcode-4-5-6-7-and-get-the-dmg-file/10335943#10335943 + if [ "$xc3" = 1 ] && [ ! -f xcode_3.2.6_and_ios_sdk_4.3.dmg ]; then + echo "*** You should download Xcode 3.2.6. Login to:" + echo " https://developer.apple.com/downloads/" + echo "then download from:" + echo " https://developer.apple.com/devcenter/download.action?path=/Developer_Tools/xcode_3.2.6_and_ios_sdk_4.3__final/xcode_3.2.6_and_ios_sdk_4.3.dmg" + echo "or" + echo " https://adcdownload.apple.com/Developer_Tools/xcode_3.2.6_and_ios_sdk_4.3__final/xcode_3.2.6_and_ios_sdk_4.3.dmg" + echo "and then run this script from within the same directory as the downloaded file" + missingdmg=1 + fi + if [ "$xc4" = 1 ] && [ ! -f xcode4630916281a.dmg ]; then + echo "*** You should download Xcode 4.6.3. Login to:" + echo " https://developer.apple.com/downloads/" + echo "then download from:" + echo " https://developer.apple.com/devcenter/download.action?path=/Developer_Tools/xcode_4.6.3/xcode4630916281a.dmg" + echo "or" + echo " https://adcdownload.apple.com/Developer_Tools/xcode_4.6.3/xcode4630916281a.dmg" + echo "and then run this script from within the same directory as the downloaded file" + missingdmg=1 + fi + if [ "$xc5" = 1 ] && [ ! -f xcode_5.1.1.dmg ]; then + echo "*** You should download Xcode 5.1.1. Login to:" + echo " https://developer.apple.com/downloads/" + echo "then download from:" + echo " https://developer.apple.com/devcenter/download.action?path=/Developer_Tools/xcode_5.1.1/xcode_5.1.1.dmg" + echo "or" + echo " https://adcdownload.apple.com/Developer_Tools/xcode_5.1.1/xcode_5.1.1.dmg" + echo "and then run this script from within the same directory as the downloaded file" + missingdmg=1 + fi + if [ "$xc6" = 1 ] && [ ! -f Xcode_6.4.dmg ]; then + echo "*** You should download Xcode 6.4. Login to:" + echo " https://developer.apple.com/downloads/" + echo "then download from:" + echo " https://developer.apple.com/devcenter/download.action?path=/Developer_Tools/Xcode_6.4/Xcode_6.4.dmg" + echo "or" + echo " https://adcdownload.apple.com/Developer_Tools/Xcode_6.4/Xcode_6.4.dmg" + echo "and then run this script from within the same directory as the downloaded file" + missingdmg=1 + fi + if [ "$xc7" = 1 ] && [ ! -f Xcode_7.3.1.dmg ]; then + echo "*** You should download Xcode 7.3.1. Login to:" + echo " https://developer.apple.com/downloads/" + echo "then download from:" + echo " https://developer.apple.com/devcenter/download.action?path=/Developer_Tools/Xcode_7.3.1/Xcode_7.3.1.dmg" + echo "or" + echo " https://adcdownload.apple.com/Developer_Tools/Xcode_7.3.1/Xcode_7.3.1.dmg" + echo "and then run this script from within the same directory as the downloaded file" + missingdmg=1 + fi + if [ "$xc8" = 1 ] && [ ! -f Xcode8.3.3.xip ]; then + echo "*** You should download Xcode 8.3.3. Login to:" + echo " https://developer.apple.com/downloads/" + echo "then download from:" + echo " https://download.developer.apple.com/Developer_Tools/Xcode_8.3.3/Xcode8.3.3.xip" + echo "and then run this script from within the same directory as the downloaded file" + missingdmg=1 + fi + if [ "$xc9" = 1 ] && [ ! -f Xcode_9.4.1.xip ]; then + echo "*** You should download Xcode 9.4.1. Login to:" + echo " https://developer.apple.com/downloads/" + echo "then download from:" + echo " https://download.developer.apple.com/Developer_Tools/Xcode_9.4.1/Xcode_9.4.1.xip" + echo "and then run this script from within the same directory as the downloaded file" + missingdmg=1 + fi + if [ "$missingdmg" = 1 ]; then + echo "*** at least one Xcode distribution is missing, cannot build packages - exiting now" + exit + fi + if [ "$xc8" = 1 ]; then + if [ -e Xcode.app ]; then + echo "*** A stray Xcode.app exists in the XcodeLegacy.sh folder. Remove it then try again." + exit + fi + fi + + MNTDIR="$(mktemp -d mount.XXX)" + ATTACH_OPTS=(-nobrowse -mountroot "$MNTDIR") + if [ "$xc3" = 1 ]; then + # you should download Xcode 3.2.6 from: + # http://connect.apple.com/cgi-bin/WebObjects/MemberSite.woa/wa/getSoftware?bundleID=20792 + hdiutil attach xcode_3.2.6_and_ios_sdk_4.3.dmg "${ATTACH_OPTS[@]}" + if [ ! -d "$MNTDIR/Xcode and iOS SDK" ]; then + echo "*** Error while trying to attach disk image xcode_3.2.6_and_ios_sdk_4.3.dmg" + echo "Aborting" + exit + fi + if [ "$compilers" = 1 ]; then + rm -rf /tmp/XC3 + pkgutil --expand "$MNTDIR/Xcode and iOS SDK/Packages/DeveloperTools.pkg" /tmp/XC3 + (cd /tmp/XC3 || exit; gzip -dc Payload | cpio -id --quiet Library/Xcode/Plug-ins) #we only need these, see https://github.com/devernay/xcodelegacy/issues/8 + ( (cd /tmp/XC3/Library/Xcode/Plug-ins || exit; tar cf - "GCC 4.0.xcplugin") | gzip -c > XcodePluginGCC40.tar.gz) && echo "*** Created XcodePluginGCC40.tar.gz in directory $(pwd)" + ( (cd /tmp/XC3/Library/Xcode/Plug-ins || exit; tar cf - "GCC 4.2.xcplugin") | gzip -c > XcodePluginGCC42.tar.gz) && echo "*** Created XcodePluginGCC42.tar.gz in directory $(pwd)" + #( (cd /tmp/XC3/Library/Xcode/Plug-ins || exit; tar cf - "LLVM GCC 4.2.xcplugin") | gzip -c > XcodePluginLLVMGCC42.tar.gz) && echo "*** Created XcodePluginLLVMGCC42.tar.gz in directory $(pwd)" + # should be untarred in /Developer/Library/Xcode/PrivatePlugIns/Xcode3Core.ideplugin/Contents/SharedSupport/Developer/Library/Xcode/Plug-ins + # gzip -dc XcodePluginGCC40.tar.gz | (cd /Developer/Library/Xcode/PrivatePlugIns/Xcode3Core.ideplugin/Contents/SharedSupport/Developer/Library/Xcode/Plug-ins || exit; sudo tar xvf -) + + rm -rf /tmp/XC3 + pkgutil --expand "$MNTDIR/Xcode and iOS SDK/Packages/DeveloperToolsCLI.pkg" /tmp/XC3 + + (cd /tmp/XC3 || exit; gzip -dc Payload | cpio -id --quiet usr/bin usr/libexec) #we only need these, see https://github.com/devernay/xcodelegacy/issues/8 + ( (cd /tmp/XC3 || exit; tar cf - usr/libexec/gcc/darwin/ppc usr/libexec/gcc/darwin/ppc64 usr/libexec/gcc/darwin/i386 usr/libexec/gcc/darwin/x86_64) | gzip -c > Xcode3as.tar.gz) && echo "*** Created Xcode3as.tar.gz in directory $(pwd)" + ( (cd /tmp/XC3 || exit; tar cf - usr/bin/ld) | gzip -c > Xcode3ld.tar.gz) && echo "*** Created Xcode3ld.tar.gz in directory $(pwd)" + + #(cp "$MNTDIR/Xcode and iOS SDK/Packages/gcc4.0.pkg" xcode_3.2.6_gcc4.0.pkg) && echo "*** Created xcode_3.2.6_gcc4.0.pkg in directory $(pwd)" + rm -rf /tmp/XC3 + pkgutil --expand "$MNTDIR/Xcode and iOS SDK/Packages/gcc4.0.pkg" /tmp/XC3 + + (cd /tmp/XC3 || exit; gzip -dc Payload | cpio -id --quiet usr) #we only need these, see https://github.com/devernay/xcodelegacy/issues/8 + ( (cd /tmp/XC3 || exit; tar cf - usr) | gzip -c > Xcode3gcc40.tar.gz) && echo "*** Created Xcode3gcc40.tar.gz in directory $(pwd)" + + #(cp "$MNTDIR/Xcode and iOS SDK/Packages/gcc4.2.pkg" xcode_3.2.6_gcc4.2.pkg) && echo "*** Created xcode_3.2.6_gcc4.2.pkg in directory $(pwd)" + rm -rf /tmp/XC3 + pkgutil --expand "$MNTDIR/Xcode and iOS SDK/Packages/gcc4.2.pkg" /tmp/XC3 + + (cd /tmp/XC3 || exit; gzip -dc Payload | cpio -id --quiet usr) #we only need these, see https://github.com/devernay/xcodelegacy/issues/8 + ( (cd /tmp/XC3 || exit; tar cf - usr) | gzip -c > Xcode3gcc42.tar.gz) && echo "*** Created Xcode3gcc42.tar.gz in directory $(pwd)" + + #(cp "$MNTDIR/Xcode and iOS SDK/Packages/llvm-gcc4.2.pkg" xcode_3.2.6_llvm-gcc4.2.pkg) && echo "*** Created xcode_3.2.6_llvm-gcc4.2.pkg in directory $(pwd)" + rm -rf /tmp/XC3 + pkgutil --expand "$MNTDIR/Xcode and iOS SDK/Packages/llvm-gcc4.2.pkg" /tmp/XC3 + + (cd /tmp/XC3 || exit; gzip -dc Payload | cpio -id --quiet usr) #we only need these, see https://github.com/devernay/xcodelegacy/issues/8 + ( (cd /tmp/XC3 || exit; tar cf - usr) | gzip -c > Xcode3llvmgcc42.tar.gz) && echo "*** Created Xcode3llvmgcc42.tar.gz in directory $(pwd)" + fi + + rm -rf /tmp/XC3 + + if [ "$osx104" = 1 ] || [ "$osx105" = 1 ]; then + # use the latest version of the hashtable include, as recommended by: + # http://wiki.inkscape.org/wiki/index.php/HashtableFixOSX + # http://permalink.gmane.org/gmane.comp.graphics.inkscape.devel/32966 + # The version from gcc 4.0.4 fixes these four bugs: + # + # GCC Bugzilla Bug 23053 + # Const-correctness issue in TR1 hashtable + # + # + # GCC Bugzilla Bug 23465 + # Assignment fails on TR1 unordered containers + # + # + # GCC Bugzilla Bug 24054 + # std::tr1::unordered_map's erase does not seem to return a value + # + # + # GCC Bugzilla Bug 24064 + # tr1::unordered_map seems to seg-fault when caching hash values + # + + # see also: + # http://wayback.archive.org/web/20100810175143/http://mohri-lt.cs.nyu.edu:80/twiki/bin/view/FST/CompilingOnMacOSX + # (only fixes GCC Bugzilla Bug 23465) + + #curl -A 'Mozilla/5.0 (Windows NT 6.2) AppleWebKit/536.6 (KHTML, like Gecko) Chrome/20.0.1090.0 Safari/536.6' 'https://gcc.gnu.org/viewcvs/gcc/branches/gcc-4_0-branch/libstdc%2B%2B-v3/include/tr1/hashtable?revision=95538&view=co' -o hashtable-gcc-4.0.0 + #curl -A 'Mozilla/5.0 (Windows NT 6.2) AppleWebKit/536.6 (KHTML, like Gecko) Chrome/20.0.1090.0 Safari/536.6' 'https://gcc.gnu.org/viewcvs/gcc/branches/gcc-4_0-branch/libstdc%2B%2B-v3/include/tr1/hashtable?revision=104939&view=co' -o hashtable-gcc-4.0.4 + if false; then + # older version of the patch, for the record (only fixes 23053 and 23465) + cat > /tmp/hashtable.patch <, iterator>::type + Insert_Return_Type; + +- node* find_node (node* p, const key_type& k, typename hashtable::hash_code_t c); ++ node* find_node (node* p, const key_type& k, typename hashtable::hash_code_t c) const; + + std::pair insert (const value_type&, std::tr1::true_type); + iterator insert (const value_type&, std::tr1::false_type); +@@ -1042,8 +1042,9 @@ + node* n = ht.m_buckets[i]; + node** tail = m_buckets + i; + while (n) { +- *tail = m_allocate_node (n); +- (*tail).copy_code_from (n); ++ // *tail = m_allocate_node (n); ++ // (*tail).copy_code_from (n); ++ *tail = m_allocate_node (n->m_v); + tail = &((*tail)->m_next); + n = n->m_next; + } +@@ -1216,7 +1217,7 @@ + bool c, bool m, bool u> + typename hashtable::node* + hashtable +-::find_node (node* p, const key_type& k, typename hashtable::hash_code_t code) ++::find_node (node* p, const key_type& k, typename hashtable::hash_code_t code) const + { + for ( ; p ; p = p->m_next) + if (this->compare (k, code, p)) +EOF + fi + fi + + if [ "$osx104" = 1 ]; then + test -d /tmp/XC3-10.4 && rm -rf /tmp/XC3-10.4 + pkgutil --expand "$MNTDIR/Xcode and iOS SDK/Packages/MacOSX10.4.Universal.pkg" /tmp/XC3-10.4 + (cd /tmp/XC3-10.4 || exit; gzip -dc Payload | cpio -id --quiet SDKs/MacOSX10.4u.sdk) + SDKROOT=/tmp/XC3-10.4/SDKs/MacOSX10.4u.sdk + # should we install more than these? (fixed includes?) + # Add links to libstdc++ so that "g++-4.0 -isysroot /Developer/SDKs/MacOSX10.4u.sdk -Wl,-syslibroot,/Developer/SDKs/MacOSX10.4u.sdk -mmacosx-version-min=10.4" works + ln -s ../../../i686-apple-darwin10/4.0.1/libstdc++.dylib $SDKROOT/usr/lib/gcc/i686-apple-darwin10/4.0.1/libstdc++.dylib + # Add links to libstdc++ so that "clang++ -stdlib=libstdc++ -isysroot /Developer/SDKs/MacOSX10.4u.sdk -Wl,-syslibroot,/Developer/SDKs/MacOSX10.4u.sdk -mmacosx-version-min=10.4" works + ln -s libstdc++.6.dylib $SDKROOT/usr/lib/libstdc++.dylib + # Fix tr1/hashtable + # see http://www.openfst.org/twiki/bin/view/FST/CompilingOnMacOSX https://gcc.gnu.org/ml/libstdc++/2005-08/msg00017.html https://gcc.gnu.org/bugzilla/show_bug.cgi?id=23053 + # in SDKs/MacOSX10.4u.sdk/usr/include/c++/4.0.0/tr1/hashtable + #(cd $SDKROOT/usr/include/c++/4.0.0/tr1 || exit; patch -p0 -d. < /tmp/hashtable.patch) + mv $SDKROOT/usr/include/c++/4.0.0/tr1/hashtable $SDKROOT/usr/include/c++/4.0.0/tr1/hashtable.orig + cp hashtable-gcc-4.0.4 $SDKROOT/usr/include/c++/4.0.0/tr1/hashtable + + # Add links for compatibility with GCC 4.2 + ln -s 4.0.1 $SDKROOT/usr/lib/gcc/i686-apple-darwin10/4.2.1 + ln -s 4.0.1 $SDKROOT/usr/lib/gcc/powerpc-apple-darwin10/4.2.1 + ln -s 4.0.1 $SDKROOT/usr/lib/i686-apple-darwin10/4.2.1 + ln -s 4.0.1 $SDKROOT/usr/lib/powerpc-apple-darwin10/4.2.1 + ln -s 4.0.0 $SDKROOT/usr/include/c++/4.2.1 + + ( (cd /tmp/XC3-10.4 || exit; tar cf - SDKs/MacOSX10.4u.sdk) | gzip -c > Xcode104SDK.tar.gz) && echo "*** Created Xcode104SDK.tar.gz in directory $(pwd)" + rm -rf /tmp/XC3-10.4 + fi + + if [ "$osx105" = 1 ]; then + test -d /tmp/XC3-10.5 && rm -rf /tmp/XC3-10.5 + pkgutil --expand "$MNTDIR/Xcode and iOS SDK/Packages/MacOSX10.5.pkg" /tmp/XC3-10.5 + (cd /tmp/XC3-10.5 || exit; gzip -dc Payload | cpio -id --quiet SDKs/MacOSX10.5.sdk) + SDKROOT=/tmp/XC3-10.5/SDKs/MacOSX10.5.sdk + # should we install more than these? (fixed includes?) + # Add links to libstdc++ so that "g++-4.0 -isysroot /Developer/SDKs/MacOSX10.5.sdk -Wl,-syslibroot,/Developer/SDKs/MacOSX10.5.sdk -mmacosx-version-min=10.5" works + ln -s ../../../i686-apple-darwin10/4.0.1/libstdc++.dylib $SDKROOT/usr/lib/gcc/i686-apple-darwin10/4.0.1/libstdc++.dylib + ln -s ../../../i686-apple-darwin10/4.2.1/libstdc++.dylib $SDKROOT/usr/lib/gcc/i686-apple-darwin10/4.2.1/libstdc++.dylib + # Add links to libstdc++ so that "clang++ -stdlib=libstdc++ -isysroot /Developer/SDKs/MacOSX10.5.sdk -Wl,-syslibroot,/Developer/SDKs/MacOSX10.5.sdk -mmacosx-version-min=10.5" works + ln -s libstdc++.6.dylib $SDKROOT/usr/lib/libstdc++.dylib + # fix AvailabilityInternal.h (see https://trac.macports.org/wiki/LeopardSDKFixes) + sed -i.orig -e 's/define __MAC_OS_X_VERSION_MAX_ALLOWED __MAC_10_6/define __MAC_OS_X_VERSION_MAX_ALLOWED 1058/' $SDKROOT/usr/include/AvailabilityInternal.h + # Fix tr1/hashtable + # see http://www.openfst.org/twiki/bin/view/FST/CompilingOnMacOSX https://gcc.gnu.org/ml/libstdc++/2005-08/msg00017.html https://gcc.gnu.org/bugzilla/show_bug.cgi?id=23053 + # in SDKs/MacOSX10.5.sdk/usr/include/c++/4.0.0/tr1/hashtable + # this also affects g++-4.2, since usr/include/c++/4.2.1 links to usr/include/c++/4.0.0 + #(cd $SDKROOT/usr/include/c++/4.0.0/tr1 || exit; patch -p0 -d. < /tmp/hashtable.patch) + mv $SDKROOT/usr/include/c++/4.0.0/tr1/hashtable $SDKROOT/usr/include/c++/4.0.0/tr1/hashtable.orig + cp hashtable-gcc-4.0.4 $SDKROOT/usr/include/c++/4.0.0/tr1/hashtable + fi + + if [ "$osx104" = 1 ] || [ "$osx105" = 1 ]; then + true + #rm /tmp/hashtable.patch + fi + + if [ $osx105 = 1 ] || [ $osx106 = 1 ]; then + test -d /tmp/XC3 && rm -rf /tmp/XC3 + pkgutil --expand "$MNTDIR/Xcode and iOS SDK/Packages/MacOSX10.6.pkg" /tmp/XC3 + (cd /tmp/XC3 || exit; gzip -dc Payload | cpio -id --quiet SDKs/MacOSX10.6.sdk) + SDKROOT=/tmp/XC3/SDKs/MacOSX10.6.sdk + # should we install more than these? (fixed includes?) + # Add links to libstdc++ so that "clang++ -stdlib=libstdc++ -isysroot /Developer/SDKs/MacOSX10.6.sdk -Wl,-syslibroot,/Developer/SDKs/MacOSX10.6.sdk -mmacosx-version-min=10.6" works + ln -s libstdc++.6.dylib $SDKROOT/usr/lib/libstdc++.dylib + + # fix buggy hashtable include (see above for explanations) + cp hashtable-gcc-4.0.4 $SDKROOT/usr/include/c++/4.0.0/tr1/hashtable + + if [ "$osx105" = 1 ]; then + # we also need to copy /usr/lib/libgcc_s.10.5.dylib from 10.6 SDK to 10.5SDK, see https://trac.macports.org/wiki/LeopardSDKFixes + # This should fix compiling the following: + # int main() { __uint128_t a = 100; __uint128_t b = 200; __uint128_t c = a / b; return 0; } + # with clang -isysroot /Developer/SDKs/MacOSX10.5.sdk -Wl,-syslibroot,/Developer/SDKs/MacOSX10.5.sdk -mmacosx-version-min=10.5 conftest1.c + cp /tmp/XC3-10.5/SDKs/MacOSX10.5.sdk/usr/lib/libgcc_s.10.5.dylib /tmp/XC3-10.5/SDKs/MacOSX10.5.sdk/usr/lib/libgcc_s.10.5.dylib.bak + cp $SDKROOT/usr/lib/libgcc_s.10.5.dylib /tmp/XC3-10.5/SDKs/MacOSX10.5.sdk/usr/lib/libgcc_s.10.5.dylib + + ( (cd /tmp/XC3-10.5 || exit; tar cf - SDKs/MacOSX10.5.sdk) | gzip -c > Xcode105SDK.tar.gz) && echo "*** Created Xcode105SDK.tar.gz in directory $(pwd)" + fi + if [ "$osx106" = 1 ]; then + ( (cd /tmp/XC3 || exit; tar cf - SDKs/MacOSX10.6.sdk) | gzip -c > Xcode106SDK.tar.gz) && echo "*** Created Xcode106SDK.tar.gz in directory $(pwd)" + fi + rm -rf /tmp/XC3-10.5 /tmp/XC3 + fi + hdiutil detach "$MNTDIR/Xcode and iOS SDK" -force + fi + + if [ "$xc4" = 1 ]; then + hdiutil attach xcode4630916281a.dmg "${ATTACH_OPTS[@]}" + if [ ! -d "$MNTDIR/Xcode" ]; then + echo "*** Error while trying to attach disk image xcode4630916281a.dmg" + echo "Aborting" + rmdir "$MNTDIR" + exit + fi + if [ "$osx107" = 1 ]; then + ( (cd "$MNTDIR/Xcode/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer" || exit; tar cf - SDKs/MacOSX10.7.sdk) | gzip -c > Xcode107SDK.tar.gz) && echo "*** Created Xcode107SDK.tar.gz in directory $(pwd)" + fi + if [ "$compilers" = 1 ]; then + ( (cd "$MNTDIR/Xcode/Xcode.app/Contents/PlugIns/Xcode3Core.ideplugin/Contents/SharedSupport/Developer/Library/Xcode/Plug-ins" || exit; tar cf - "GCC 4.2.xcplugin") | gzip -c > XcodePluginGCC42-Xcode4.tar.gz) && echo "*** Created XcodePluginGCC42-Xcode4.tar.gz in directory $(pwd)" + ( (cd "$MNTDIR/Xcode/Xcode.app/Contents/PlugIns/Xcode3Core.ideplugin/Contents/SharedSupport/Developer/Library/Xcode/Plug-ins" || exit; tar cf - "LLVM GCC 4.2.xcplugin") | gzip -c > XcodePluginLLVMGCC42.tar.gz) && echo "*** Created XcodePluginLLVMGCC42.tar.gz in directory $(pwd)" + fi + hdiutil detach "$MNTDIR/Xcode" -force + fi + + if [ "$xc5" = 1 ]; then + hdiutil attach xcode_5.1.1.dmg "${ATTACH_OPTS[@]}" + if [ ! -d "$MNTDIR/Xcode" ]; then + echo "*** Error while trying to attach disk image xcode_5.1.1.dmg" + echo "Aborting" + rmdir "$MNTDIR" + exit + fi + if [ "$osx108" = 1 ]; then + ( (cd "$MNTDIR/Xcode/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer" || exit; tar cf - SDKs/MacOSX10.8.sdk) | gzip -c > Xcode108SDK.tar.gz) && echo "*** Created Xcode108SDK.tar.gz in directory $(pwd)" + fi + hdiutil detach "$MNTDIR/Xcode" -force + fi + + if [ "$xc6" = 1 ]; then + hdiutil attach Xcode_6.4.dmg "${ATTACH_OPTS[@]}" + if [ ! -d "$MNTDIR/Xcode" ]; then + echo "*** Error while trying to attach disk image Xcode_6.4.dmg" + echo "Aborting" + rmdir "$MNTDIR" + exit + fi + if [ "$osx109" = 1 ]; then + ( (cd "$MNTDIR/Xcode/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer" || exit; tar cf - SDKs/MacOSX10.9.sdk) | gzip -c > Xcode109SDK.tar.gz) && echo "*** Created Xcode109SDK.tar.gz in directory $(pwd)" + fi + if [ "$osx1010" = 1 ]; then + ( (cd "$MNTDIR/Xcode/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer" || exit; tar cf - SDKs/MacOSX10.10.sdk) | gzip -c > Xcode1010SDK.tar.gz) && echo "*** Created Xcode1010SDK.tar.gz in directory $(pwd)" + fi + hdiutil detach "$MNTDIR/Xcode" -force + fi + if [ "$xc7" = 1 ]; then + hdiutil attach Xcode_7.3.1.dmg "${ATTACH_OPTS[@]}" + if [ ! -d "$MNTDIR/Xcode" ]; then + echo "*** Error while trying to attach disk image Xcode_7.3.1.dmg" + echo "Aborting" + rmdir "$MNTDIR" + exit + fi + if [ "$osx1011" = 1 ]; then + ( (cd "$MNTDIR/Xcode/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer" || exit; tar cf - SDKs/MacOSX10.11.sdk) | gzip -c > Xcode1011SDK.tar.gz) && echo "*** Created Xcode1011SDK.tar.gz in directory $(pwd)" + fi + hdiutil detach "$MNTDIR/Xcode" -force + fi + if [ "$xc8" = 1 ]; then + if [ "$osx1012" = 1 ]; then + echo "Extracting Mac OS X 10.12 SDK from Xcode 8.3.3. Be patient - this will take some time" + open Xcode8.3.3.xip + while [ ! -d Xcode.app ]; do + sleep 5 + done + sleep 5 + ( (cd "Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer" || exit; rm SDKs/MacOSX10.12.sdk; mv SDKs/MacOSX.sdk SDKs/MacOSX10.12.sdk; tar cf - SDKs/MacOSX10.12.sdk) | gzip -c > Xcode1012SDK.tar.gz) && echo "*** Created Xcode1012SDK.tar.gz in directory $(pwd)" + rm -rf Xcode.app + fi + fi + if [ "$xc9" = 1 ]; then + if [ "$osx1013" = 1 ]; then + echo "Extracting Mac OS X 10.13 SDK from Xcode 9.4.1. Be patient - this will take some time" + open Xcode_9.4.1.xip + while [ ! -d Xcode.app ]; do + sleep 5 + done + sleep 5 + ( (cd "Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer" || exit; rm SDKs/MacOSX10.13.sdk; mv SDKs/MacOSX.sdk SDKs/MacOSX10.13.sdk; tar cf - SDKs/MacOSX10.13.sdk) | gzip -c > Xcode1013SDK.tar.gz) && echo "*** Created Xcode1013SDK.tar.gz in directory $(pwd)" + rm -rf Xcode.app + fi + fi + rmdir "$MNTDIR" + ;; + + install|installbeta) + ####################### + # PHASE 2: INSTALLING + # + if [ $EUID -ne 0 ]; then + echo "*** Error: The install phase requires administrative rights. Please run it as:" + echo " $ sudo $0 install" + exit 1 + fi + if [ ! -d "$PLUGINDIR" ]; then + echo "*** Error: could not find Xcode 4.2 in /Developer/Applications nor Xcode >= 4.3 in /Applications, cannot install" + exit 1 + fi + if [ "$compilers" = 1 ]; then + if [ -d "$PLUGINDIR/GCC 4.0.xcplugin" ]; then + echo "*** Not installing XcodePluginGCC40.tar.gz (found installed in $PLUGINDIR/GCC 4.0.xcplugin, uninstall first to force install)" + else + (gzip -dc XcodePluginGCC40.tar.gz | (cd "$PLUGINDIR" || exit; tar xf -)) && touch "$PLUGINDIR/GCC 4.0.xcplugin/legacy" && echo "*** installed XcodePluginGCC40.tar.gz" + # Add entries expected by later xcodebuilds. + mv "$PLUGINDIR/GCC 4.0.xcplugin/Contents/Resources/GCC 4.0.xcspec" "$PLUGINDIR/GCC 4.0.xcplugin/Contents/Resources/GCC 4.0.xcspec-original" + sed '$ i\ +\ ExecDescription = \"Compile \$\(InputFile\)\"\;\ +\ ProgressDescription = \"Compiling \$\(InputFile\)\"\;\ +\ ExecDescriptionForPrecompile = \"Precompile \$\(InputFile\)\"\;\ +\ ProgressDescriptionForPrecompile = \"Precompiling \$\(InputFile\)\"\; +' < "$PLUGINDIR/GCC 4.0.xcplugin/Contents/Resources/GCC 4.0.xcspec-original" > "$PLUGINDIR/GCC 4.0.xcplugin/Contents/Resources/GCC 4.0.xcspec" + + echo "*** modified GCC 4.0.xcspec" + fi + if [ -d "$PLUGINDIR/GCC 4.2.xcplugin" ] && [ ! -f "$PLUGINDIR/GCC 4.2.xcplugin/Contents/Resources/GCC Generic.xcspec" ]; then + echo "*** Not installing XcodePluginGCC42.tar.gz (found installed in $PLUGINDIR/GCC 4.2.xcplugin, uninstall first to force install)" + else + if [ -f "$PLUGINDIR/GCC 4.2.xcplugin/Contents/Resources/GCC Generic.xcspec" ]; then + mv "$PLUGINDIR/GCC 4.2.xcplugin" "$PLUGINDIR/GCC 4.2.xcplugin-original" + fi + (gzip -dc XcodePluginGCC42.tar.gz | (cd "$PLUGINDIR" || exit; tar xf -)) && touch "$PLUGINDIR/GCC 4.2.xcplugin/legacy" && echo "*** installed XcodePluginGCC42.tar.gz" + # Add entries expected by later xcodebuilds. + mv "$PLUGINDIR/GCC 4.2.xcplugin/Contents/Resources/GCC 4.2.xcspec" "$PLUGINDIR/GCC 4.2.xcplugin/Contents/Resources/GCC 4.2.xcspec-original" + sed '$ i\ +\ ExecDescription = \"Compile \$\(InputFile\)\"\;\ +\ ProgressDescription = \"Compiling \$\(InputFile\)\"\;\ +\ ExecDescriptionForPrecompile = \"Precompile \$\(InputFile\)\"\;\ +\ ProgressDescriptionForPrecompile = \"Precompiling \$\(InputFile\)\"\; +' < "$PLUGINDIR/GCC 4.2.xcplugin/Contents/Resources/GCC 4.2.xcspec-original" > "$PLUGINDIR/GCC 4.2.xcplugin/Contents/Resources/GCC 4.2.xcspec" + echo "*** modified GCC 4.2.xcspec" + fi + if [ -d "$PLUGINDIR/LLVM GCC 4.2.xcplugin" ]; then + echo "*** Not installing XcodePluginLLVMGCC42.tar.gz (found installed in $PLUGINDIR/LLVM GCC 4.2.xcplugin, uninstall first to force install)" + else + (gzip -dc XcodePluginLLVMGCC42.tar.gz | (cd "$PLUGINDIR" || exit; tar xf -)) && touch "$PLUGINDIR/LLVM GCC 4.2.xcplugin/legacy" && echo "*** installed XcodePluginLLVMGCC42.tar.gz" + fi + + if [ -f "$GCCDIR/usr/libexec/gcc/darwin/ppc/as" ]; then + echo "*** Not installing Xcode3as.tar.gz (found installed in $GCCDIR/usr/libexec/gcc/darwin/ppc/as, uninstall first to force install)" + else + (gzip -dc Xcode3as.tar.gz | (cd "$GCCDIR" || exit; tar xf -)) + mkdir -p "$GCCINSTALLDIR/usr/bin" + mkdir -p "$GCCINSTALLDIR/usr/libexec/as/ppc" + mkdir -p "$GCCINSTALLDIR/usr/libexec/as/ppc64" + mkdir -p "$GCCINSTALLDIR/usr/libexec/as/i386" + mkdir -p "$GCCINSTALLDIR/usr/libexec/as/x86_64" + ln -sf "$GCCDIR/usr/libexec/gcc/darwin/ppc/as" "$GCCINSTALLDIR/usr/libexec/as/ppc/as" + ln -sf "$GCCDIR/usr/libexec/gcc/darwin/ppc64/as" "$GCCINSTALLDIR/usr/libexec/as/ppc64/as" + # Xcodes >= 4 already include an acceptable GNU legacy assembler + # (v1.38) for i386 and x86_64 in $GCCINSTALLDIR/usr/libexec/as. + # When they no longer do, enable these links (conditionally, + # of course). + #ln -sf "$GCCDIR/usr/libexec/gcc/darwin/i386/as" "$GCCINSTALLDIR/usr/libexec/as/i386/as" + #ln -sf "$GCCDIR/usr/libexec/gcc/darwin/x86_64/as" "$GCCINSTALLDIR/usr/libexec/as/x86_64/as" + + # Replace Xcode's modern toolchain assembler with a script + # that auto-selects the proper legacy assembler based on the + # command line's -arch parameter. Using a legacy assembler fixes + # "ld: too many personality routines for compact unwind" errors + # and "section '__textcoal_nt' is deprecated" warnings emitted + # by Xcode 7+ assemblers. + # First, though, don't overwrite the original assembler if + # XcodeLegacy is installed twice. + if [ -f "$GCCINSTALLDIR/usr/bin/as" ] && [ ! -f "$GCCINSTALLDIR/usr/bin/as-original" ]; then + mv "$GCCINSTALLDIR/usr/bin/as" "$GCCINSTALLDIR/usr/bin/as-original" + fi + # NB: While only gcc uses the assembler in our builds (it pipes the + # output of usr/libexec/gcc/*-apple-darwin10/4.*/ccobj1plus into + # usr/libexec/gcc/*-apple-darwin10/4.*/as -> usr/bin/as), we can't + # simply change the link to, say, usr/libexec/gcc/darwin/i386/as + # because the assembler seems to want the -arch parameter to match + # its containing folder. Hence, a script (like for ld, below). + # NB: To keep it simple, the script assumes that anyone invoking + # the toolchain's usr/bin/as wants to use Xcode 3's assembler. + # NB: AS_DIR resolves as the directory of the (source) link that + # invoked the script. + + # Note that we don't look for AS in $AS_DIR/../libexec/as/\$ARCH/as + # because gprbuild (from GNU Ada) calls as with both -m and -arch + # flags, and the arch-specific as doesn'b understand -m32 or -m64. + # We just look for as in a few places, and if it's not there, we + # look for as-original, starting in the current dir. + # In any case, we prune -m32 and -m64 from the as args. + # see https://github.com/devernay/xcodelegacy/issues/33 + cat <> "$GCCINSTALLDIR"/usr/bin/as +#!/bin/bash + +ARCH='' +ARCH_FOUND=0 +AS_ARGS=() +for var in "\$@" +do + if [ -z "\$ARCH" ] && [ "\$ARCH_FOUND" -eq '1' ]; then + ARCH="\$var" + AS_ARGS+=("\$var") + elif [ "\$var" = '-arch' ]; then + ARCH_FOUND=1 + AS_ARGS+=("\$var") + elif [ "\$var" = '-m32' ]; then + true + elif [ "\$var" = '-m64' ]; then + true + else + AS_ARGS+=("\$var") + fi +done + +AS_DIR=\`dirname "\$0"\` +AS_FOUND=0 +if [ "\$ARCH_FOUND" -eq '1' ]; then + if [ -x "\$AS_DIR/../../../as/\$ARCH/as" ]; then + AS="\$AS_DIR/../../../as/\$ARCH/as" + AS_FOUND=1 + elif [ -x "\$AS_DIR/../../../../../libexec/as/\$ARCH/as" ]; then + AS="\$AS_DIR/../../../../../libexec/as/\$ARCH/as" + AS_FOUND=1 + elif [ -x "\$AS_DIR/../../../../../../../usr/libexec/as/\$ARCH/as" ]; then + AS="\$AS_DIR/../../../../../../../usr/libexec/as/\$ARCH/as" + AS_FOUND=1 + fi +fi +if [ "\$AS_FOUND" -eq '1' ]; then + exec \$AS "\${AS_ARGS[@]}" +else + if [ -x "\$AS_DIR/as-original" ]; then + ASORIGINAL="\$AS_DIR/as-original" + elif [ -x "\$AS_DIR/../../../bin/as-original" ]; then + ASORIGINAL="\$AS_DIR/../../../bin/as-original" + elif [ -x "\$AS_DIR/../../../../bin/as-original" ]; then + ASORIGINAL="\$AS_DIR/../../../../bin/as-original" + elif [ -x "\$AS_DIR/../../../../../bin/as-original" ]; then + ASORIGINAL="\$AS_DIR/../../../../../bin/as-original" + else + echo "Error: cannot find as-original in \$AS_DIR/as-original or \$AS_DIR/../../../bin/as-original or \$AS_DIR/../../../../bin/as-original or \$AS_DIR/../../../../../bin/as-original" + exit 1 + fi + + exec \$ASORIGINAL "\$@" +fi +AS_EOF + chmod +x "$GCCINSTALLDIR/usr/bin/as" + echo "*** installed Xcode3as.tar.gz" + fi + + if [ -f "$GCCDIR/usr/libexec/gcc/darwin/ppc/ld" ]; then + echo "*** Not installing Xcode3ld.tar.gz (found installed in $GCCDIR/usr/libexec/gcc/darwin/ppc/ld, uninstall first to force install)" + elif [ $XCODE42 -eq 1 ]; then + echo "*** Not installing Xcode3ld.tar.gz (not required for Xcode <= 4.2.1)" + else + mkdir -p "$GCCDIR/tmp" + (gzip -dc Xcode3ld.tar.gz | (cd "$GCCDIR/tmp" || exit; tar xf -)) + cp "$GCCDIR/tmp/usr/bin/ld" "$GCCDIR/usr/libexec/gcc/darwin/ppc/" + ln "$GCCDIR/usr/libexec/gcc/darwin/ppc/ld" "$GCCDIR/usr/libexec/gcc/darwin/ppc64/ld" + rm -rf "$GCCDIR/tmp" + mkdir -p "$GCCINSTALLDIR/usr/libexec/ld/ppc" + mkdir -p "$GCCINSTALLDIR/usr/libexec/ld/ppc7400" + mkdir -p "$GCCINSTALLDIR/usr/libexec/ld/ppc970" + mkdir -p "$GCCINSTALLDIR/usr/libexec/ld/ppc64" + ln -sf "$GCCDIR/usr/libexec/gcc/darwin/ppc/ld" "$GCCINSTALLDIR/usr/libexec/ld/ppc/ld" + ln -sf "$GCCDIR/usr/libexec/gcc/darwin/ppc/ld" "$GCCINSTALLDIR/usr/libexec/ld/ppc7400/ld" + ln -sf "$GCCDIR/usr/libexec/gcc/darwin/ppc/ld" "$GCCINSTALLDIR/usr/libexec/ld/ppc970/ld" + ln -sf "$GCCDIR/usr/libexec/gcc/darwin/ppc64/ld" "$GCCINSTALLDIR/usr/libexec/ld/ppc64/ld" + # Xcode 8's ld fails to link i386 and x86_64 for OSX 10.5: https://github.com/devernay/xcodelegacy/issues/30 + # Since this ld is from Xcode 3.2.6 for OSX 10.6, this should be OK if the target OS is < 10.6 + # (which is checked by the stub ld script) + for arch in i386 x86_64; do + mkdir -p "$GCCDIR/usr/libexec/gcc/darwin/$arch" + ln "$GCCDIR/usr/libexec/gcc/darwin/ppc/ld" "$GCCDIR/usr/libexec/gcc/darwin/$arch/ld" + mkdir -p "$GCCINSTALLDIR/usr/libexec/ld/$arch" + ln -sf "$GCCDIR/usr/libexec/gcc/darwin/$arch/ld" "$GCCINSTALLDIR/usr/libexec/ld/$arch/ld" + done + # prevent overwriting the original ld if the script is run twice + if [ ! -f "$GCCINSTALLDIR/usr/bin/ld-original" ]; then + mv "$GCCINSTALLDIR/usr/bin/ld" "$GCCINSTALLDIR/usr/bin/ld-original" + fi + cat <> "$GCCINSTALLDIR"/usr/bin/ld +#!/bin/bash + +ARCH='' +ARCH_FOUND=0 +for var in "\$@" +do + if [ "\$ARCH_FOUND" -eq '1' ]; then + ARCH=\$var + ARCH_FOUND=2 + break + else + case "\$var" in + -mmacosx-version-min=10.[0-6]) + MACOSX_DEPLOYMENT_TARGET=\$( echo \$var | sed -e s/-mmacosx-version-min=// ) + ;; + -arch) + if [ "\$ARCH_FOUND" -ne '0' ]; then + echo "Warning: ld: multiple -arch flags" + fi + ARCH_FOUND=1 + ;; + esac + fi +done + +# use the old (Snow Leopard 10.6) ld only if ppc arch or the target macOS is <= 10.6 +USE_OLD_LD=0 +case "\$ARCH" in + ppc*) #ppc ppc7400 ppc970 ppc64 + USE_OLD_LD=1 + ;; +esac + +if [ -n \${MACOSX_DEPLOYMENT_TARGET+x} ]; then + # MACOSX_DEPLOYMENT_TARGET can either be set externally as an env variable, + # or as an ld option using -mmacosx-version-min=10.x + case "\${MACOSX_DEPLOYMENT_TARGET}" in + 10.[0-6]) + USE_OLD_LD=1 + ;; + esac +fi + +#echo "Running ld for \$ARCH ..." + +LD_DIR=\`dirname "\$0"\` +if [ -x "\$LD_DIR/ld-original" ]; then + LDORIGINAL="\$LD_DIR/ld-original" +elif [ -x "\$LD_DIR/../../../../bin/ld-original" ]; then + LDORIGINAL="\$LD_DIR/../../../../bin/ld-original" +elif [ -x "\$LD_DIR/../../../../../bin/ld-original" ]; then + LDORIGINAL="\$LD_DIR/../../../../../bin/ld-original" +else + echo "Error: cannot find ld-original in \$LD_DIR \$LD_DIR/../../../../bin or \$LD_DIR/../../../../../bin" + exit 1 +fi +LD_RESULT=255 +if [ "\$USE_OLD_LD" -eq '1' ]; then + ARGS=() + # strip the -dependency_info xxx, -object_path_lto xxx, -no_deduplicate, -export_dynamic flags + DEPINFO_FOUND=0 + OBJECT_PATH_LTO_FOUND=0 + for var in "\$@"; do + if [ "\$DEPINFO_FOUND" -eq '1' ]; then + DEPINFO_FOUND=0 + continue + elif [ "\$OBJECT_PATH_LTO_FOUND" -eq '1' ]; then + OBJECT_PATH_LTO_FOUND=0 + continue + elif [ "\$var" = '-dependency_info' ]; then + DEPINFO_FOUND=1 + continue + elif [ "\$var" = '-object_path_lto' ]; then + OBJECT_PATH_LTO_FOUND=1 + continue + elif [ "\$var" = '-no_deduplicate' ]; then + continue + elif [ "\$var" = '-export_dynamic' ]; then + continue + fi + + ARGS+=("\$var") + done + # the old ld is put in the ppc dir so as not to disturb more recent archs (i386, x86_64) + # works with ppc ppc7400 ppc970 ppc64 i386 x86_64 + LDARCHDIR=ppc + if [ -x "\$LD_DIR/../libexec/ld/\$LDARCHDIR/ld" ]; then + LD="\$LD_DIR/../libexec/ld/\$LDARCHDIR/ld" + elif [ -x "\$LD_DIR/../../../libexec/ld/\$LDARCHDIR/ld" ]; then + LD="\$LD_DIR/../../../libexec/ld/\$LDARCHDIR/ld" + elif [ -x "\$LD_DIR/../../../../libexec/ld/\$LDARCHDIR/ld" ]; then + LD="\$LD_DIR/../../../../libexec/ld/\$LDARCHDIR/ld" + elif [ -x "\$LD_DIR/../../../../../libexec/ld/\$LDARCHDIR/ld" ]; then + LD="\$LD_DIR/../../../../../libexec/ld/\$LDARCHDIR/ld" + else + echo "Error: cannot find ld for \$ARCH in \$LD_DIR/../libexec/ld/\$LDARCHDIR \$LD_DIR/../../../libexec/ld/\$LDARCHDIR \$LD_DIR/../../../../libexec/ld/\$LDARCHDIR or \$LD_DIR/../../../../../libexec/ld/\$LDARCHDIR" + exit 1 + fi + + \`\$LD "\${ARGS[@]}"\` + LD_RESULT=\$? +else + \`\$LDORIGINAL "\$@"\` + LD_RESULT=\$? +fi + +exit \$LD_RESULT +LD_EOF + chmod +x "$GCCINSTALLDIR/usr/bin/ld" + echo "*** installed Xcode3ld.tar.gz" + fi + + if [ -f "$PLATFORMDIR/Developer/Library/Xcode/Specifications/MacOSX Architectures.xcspec-original" ]; then + echo "*** Not modifying MacOSX Architectures.xcspec (found original at $PLATFORMDIR/Developer/Library/Xcode/Specifications/MacOSX Architectures.xcspec-original, uninstall first to force install)" + else + mv "$PLATFORMDIR/Developer/Library/Xcode/Specifications/MacOSX Architectures.xcspec" "$PLATFORMDIR/Developer/Library/Xcode/Specifications/MacOSX Architectures.xcspec-original" + { awk 'NR>1{print l}{l=$0}' "$PLATFORMDIR/Developer/Library/Xcode/Specifications/MacOSX Architectures.xcspec-original"; cat - < "$PLATFORMDIR/Developer/Library/Xcode/Specifications/MacOSX Architectures.xcspec" + { + Type = Architecture; + Identifier = ppc; + Name = "Minimal (32-bit PowerPC only)"; + Description = "32-bit PowerPC"; + "PerArchBuildSettingName" = PowerPC; + ByteOrder = big; + ListInEnum = YES; + SortNumber = 201; + }, + { + Type = Architecture; + Identifier = ppc7400; + Name = "PowerPC G4"; + Description = "32-bit PowerPC for G4 processor"; + ByteOrder = big; + ListInEnum = YES; + SortNumber = 202; + }, + { + Type = Architecture; + Identifier = ppc970; + Name = "PowerPC G5 32-bit"; + Description = "32-bit PowerPC for G5 processor"; + ByteOrder = big; + ListInEnum = YES; + SortNumber = 203; + }, + { + Type = Architecture; + Identifier = ppc64; + Name = "PowerPC 64-bit"; + Description = "64-bit PowerPC"; + "PerArchBuildSettingName" = "PowerPC 64-bit"; + ByteOrder = big; + ListInEnum = YES; + SortNumber = 204; + }, +) +SPEC_EOF + echo "*** modified MacOSX Architectures.xcspec" + fi + fi + + if [ "$osx104" = 1 ]; then + if [ -d "$SDKDIR/SDKs/MacOSX10.4u.sdk" ]; then + echo "*** Not installing Xcode104SDK.tar.gz (found installed in $SDKDIR/SDKs/MacOSX10.4u.sdk, uninstall first to force install)" + else + (gzip -dc Xcode104SDK.tar.gz | (cd "$SDKDIR" || exit; tar xf -)) && echo "*** installed Xcode104SDK.tar.gz" + touch "$SDKDIR/SDKs/MacOSX10.4u.sdk/legacy" + fi + fi + + if [ "$osx105" = 1 ]; then + if [ -d "$SDKDIR/SDKs/MacOSX10.5.sdk" ]; then + echo "*** Not installing Xcode105SDK.tar.gz (found installed in $SDKDIR/SDKs/MacOSX10.5.sdk, uninstall first to force install)" + else + (gzip -dc Xcode105SDK.tar.gz | (cd "$SDKDIR" || exit; tar xf -)) && echo "*** installed Xcode105SDK.tar.gz" + touch "$SDKDIR/SDKs/MacOSX10.5.sdk/legacy" + fi + fi + + if [ "$osx106" = 1 ]; then + if [ -d "$SDKDIR/SDKs/MacOSX10.6.sdk" ]; then + echo "*** Not installing Xcode106SDK.tar.gz (found installed in $SDKDIR/SDKs/MacOSX10.6.sdk, uninstall first to force install)" + else + (gzip -dc Xcode106SDK.tar.gz | (cd "$SDKDIR" || exit; tar xf -)) && echo "*** installed Xcode106SDK.tar.gz" + touch "$SDKDIR/SDKs/MacOSX10.6.sdk/legacy" + fi + fi + + if [ "$osx107" = 1 ]; then + installSDK 10.7 + fi + + if [ "$osx108" = 1 ]; then + installSDK 10.8 + fi + + if [ "$osx109" = 1 ]; then + installSDK 10.9 + fi + + if [ "$osx1010" = 1 ]; then + installSDK 10.10 + fi + + if [ "$osx1011" = 1 ]; then + installSDK 10.11 + fi + + if [ "$osx1012" = 1 ]; then + installSDK 10.12 + fi + + if [ "$osx1013" = 1 ]; then + installSDK 10.13 + fi + + if [ "$compilers" = 1 ]; then + if [ -f /usr/bin/gcc-4.0 ]; then + #echo "*** Not installing xcode_3.2.6_gcc4.0.pkg (found installed in /usr/bin/gcc-4.0, uninstall first to force install)" + echo "*** Not installing Xcode3gcc40.tar.gz (found installed in /usr/bin/gcc-4.0, uninstall first to force install)" + elif [ -f "$GCCINSTALLDIR/usr/bin/gcc-4.0" ]; then + echo "*** Not installing Xcode3gcc40.tar.gz (found installed in $GCCINSTALLDIR/usr/bin/gcc-4.0, uninstall first to force install)" + else + echo "*** Installing GCC 4.0" + #installer -pkg xcode_3.2.6_gcc4.0.pkg -target / + (gzip -dc Xcode3gcc40.tar.gz | (cd "$GCCINSTALLDIR" || exit; tar xf -)) && echo "*** installed Xcode3gcc40.tar.gz" + fi + if [ -f /usr/bin/gcc-4.2 ]; then + #echo "*** Not installing xcode_3.2.6_gcc4.2.pkg (found installed in /usr/bin/gcc-4.2, uninstall first to force install)" + echo "*** Not installing Xcode3gcc42.tar.gz (found installed in /usr/bin/gcc-4.2, uninstall first to force install)" + elif [ -f "$GCCINSTALLDIR/usr/bin/gcc-4.2" ]; then + echo "*** Not installing Xcode3gcc42.tar.gz (found installed in $GCCINSTALLDIR/usr/bin/gcc-4.2, uninstall first to force install)" + else + echo "*** Installing GCC 4.2" + #installer -pkg xcode_3.2.6_gcc4.2.pkg -target / + (gzip -dc Xcode3gcc42.tar.gz | (cd "$GCCINSTALLDIR" || exit; tar xf -)) && echo "*** installed Xcode3gcc42.tar.gz" + fi + if [ -f "$GCCINSTALLDIR/usr/bin/llvm-gcc-4.2" ]; then + echo "*** Not installing Xcode3llvmgcc42.tar.gz (found installed in $GCCINSTALLDIR/usr/bin/llvm-gcc-4.2, uninstall first to force install)" + else + echo "*** Installing LLVM GCC 4.2" + #installer -pkg xcode_3.2.6_llvm-gcc4.2.pkg -target / + (gzip -dc Xcode3llvmgcc42.tar.gz | (cd "$GCCINSTALLDIR" || exit; tar xf -)) && echo "*** installed Xcode3llvmgcc42.tar.gz" + if [ -f "$GCCDIR/usr/llvm-gcc-4.2/bin/llvm-gcc-4.2" ]; then + for i in g++ gcc; do + ln -sf "$GCCINSTALLDIR"/usr/bin/powerpc-apple-darwin10-llvm-${i}-4.2 "$GCCDIR"/usr/bin/powerpc-apple-darwin"$RELEASENUM"-llvm-${i}-4.2 + ln -sf "$GCCINSTALLDIR"/usr/llvm-gcc-4.2/bin/powerpc-apple-darwin10-llvm-${i}-4.2 "$GCCDIR"/usr/llvm-gcc-4.2/bin/powerpc-apple-darwin"$RELEASENUM"-llvm-${i}-4.2 + ln -sf "$GCCINSTALLDIR"/usr/llvm-gcc-4.2/share/man/man1/powerpc-apple-darwin10-llvm-${i}.1.gz "$GCCDIR"/usr/llvm-gcc-4.2/share/man/man1/powerpc-apple-darwin"$RELEASENUM"-llvm-${i}.1.gz + done + ln -sf "$GCCINSTALLDIR"/usr/llvm-gcc-4.2/lib/gcc/powerpc-apple-darwin10 "$GCCDIR"/usr/llvm-gcc-4.2/lib/gcc/powerpc-apple-darwin10 + ln -sf "$GCCINSTALLDIR"/usr/llvm-gcc-4.2/libexec/gcc/powerpc-apple-darwin10 "$GCCDIR"/usr/llvm-gcc-4.2/libexec/gcc/powerpc-apple-darwin10 + fi + fi + + echo "*** Creating symbolic links to compliers in $GCCDIR and $GCCLINKDIR:" + if [ ! -d "$GCCDIR"/usr/bin ]; then + mkdir -p "$GCCDIR"/usr/bin + fi + if [ ! -d "$GCCLINKDIR"/bin ]; then + mkdir -p "$GCCLINKDIR"/bin + fi + for v in 4.0 4.2 4.0.1 4.2.1; do + for i in c++ cpp g++ gcc gcov llvm-cpp llvm-g++ llvm-gcc; do + for p in i686-apple-darwin10- powerpc-apple-darwin10- ""; do + if [ -f "$GCCINSTALLDIR"/usr/bin/${p}${i}-${v} ]; then + echo "$GCCINSTALLDIR"/usr/bin/${p}${i}-${v} exists + if [ ! -f "$GCCLINKDIR"/bin/${p}${i}-${v} ]; then + echo "* creating link $GCCLINKDIR/bin/${p}${i}-${v}" + ln -sf "$GCCINSTALLDIR"/usr/bin/${p}${i}-${v} "$GCCLINKDIR"/bin/${p}${i}-${v} + fi + if [ ! -f "$GCCDIR"/usr/bin/${p}${i}-${v} ]; then + echo "* creating link $GCCDIR/usr/bin/${p}${i}-${v}" + ln -sf "$GCCINSTALLDIR"/usr/bin/${p}${i}-${v} "$GCCDIR"/usr/bin/${p}${i}-${v} + fi + fi + done + done + done + # fix /usr/bin/gcc, see https://github.com/devernay/xcodelegacy/issues/19 + if [ -x /usr/bin/gcc ] && [ ! -x "$GCCINSTALLDIR/usr/bin/gcc" ] && [ -x "$GCCINSTALLDIR/usr/bin/clang" ]; then + # "xcode-select -r" sets /usr/bin/gcc to be the first gcc found in $GCCINSTALLDIR, which happens to be + # the directory $GCCINSTALLDIR/usr/libexec/gcc, and results in the following error: + # $ gcc + # gcc: error: can't exec '/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/libexec/gcc' (errno=Permission denied) + # by putting a link to clang (which is the default Xcode behavior), we fix this + ln -s clang "$GCCINSTALLDIR/usr/bin/gcc" + # run gcc once so that xcode-select finds the right file for gcc + gcc 1>/dev/null 2>/dev/null + fi + fi + + # Xcode >= 7.3 disables support for older SDKs in /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Info.plist + # see https://github.com/devernay/xcodelegacy/issues/23 + if [ -f "$PLATFORMDIR/Info.plist-original" ]; then + echo "*** Not modifying MacOSX Info.plist (found original at $PLATFORMDIR/Info.plist-original, uninstall first to force install)" + elif [ -f "$PLATFORMDIR/Info.plist" ]; then + mv "$PLATFORMDIR/Info.plist" "$PLATFORMDIR/Info.plist-original" + plutil -remove MinimumSDKVersion -o "$PLATFORMDIR/Info.plist" "$PLATFORMDIR/Info.plist-original" + echo "*** modified MacOSX Info.plist" + fi + + if [ ! -L /Developer/SDKs ] && [ $XCODE42 -ne 1 ]; then + echo "*** Warning: /Developer/SDKs should be a symlink to $SDKDIR/SDKs" + echo "Check that /Developer exists, and fix /Developer/SDKs with:" + echo " $ sudo ln -sf '$SDKDIR/SDKs' /Developer/SDKs" + fi + ;; + + cleanpackages) + ####################### + # PHASE 3: CLEANING + # + + if [ "$compilers" = 1 ]; then + rm XcodePluginGCC40.tar.gz Xcode3as.tar.gz Xcode3ld.tar.gz xcode_3.2.6_gcc4.0.pkg xcode_3.2.6_gcc4.2.pkg xcode_3.2.6_llvm-gcc4.2.pkg XcodePluginGCC42-Xcode4.tar.gz XcodePluginGCC42.tar.gz XcodePluginLLVMGCC42.tar.gz Xcode3gcc40.tar.gz Xcode3gcc42.tar.gz Xcode3llvmgcc42.tar.gz 2>/dev/null + fi + #for i in 10.4u 10.5 10.6 10.7 10.8 10.9 10.10; do + if [ "$osx104" = 1 ]; then + rm Xcode104SDK.tar.gz 2>/dev/null + fi + if [ "$osx105" = 1 ]; then + rm Xcode105SDK.tar.gz 2>/dev/null + fi + if [ "$osx106" = 1 ]; then + rm Xcode106SDK.tar.gz 2>/dev/null + fi + if [ "$osx107" = 1 ]; then + rm Xcode107SDK.tar.gz 2>/dev/null + fi + if [ "$osx108" = 1 ]; then + rm Xcode108SDK.tar.gz 2>/dev/null + fi + if [ "$osx109" = 1 ]; then + rm Xcode109SDK.tar.gz 2>/dev/null + fi + if [ "$osx1010" = 1 ]; then + rm Xcode1010SDK.tar.gz 2>/dev/null + fi + if [ "$osx1011" = 1 ]; then + rm Xcode1011SDK.tar.gz 2>/dev/null + fi + if [ "$osx1012" = 1 ]; then + rm Xcode1012SDK.tar.gz 2>/dev/null + fi + if [ "$osx1012" = 1 ]; then + rm Xcode1013SDK.tar.gz 2>/dev/null + fi + + ;; + + uninstall|uninstallbeta) + ####################### + # PHASE 4: UNINSTALLING + # + if [ $EUID -ne 0 ]; then + echo "*** Error: The uninstall phase requires administrative rights. Please run it as:" + echo " $ sudo $0 uninstall" + exit 1 + fi + + if [ "$compilers" = 1 ]; then + if [ -f "$PLUGINDIR/GCC 4.0.xcplugin/legacy" ]; then + rm -rf "$PLUGINDIR/GCC 4.0.xcplugin" + fi + if [ -f "$PLUGINDIR/GCC 4.2.xcplugin/legacy" ]; then + rm -rf "$PLUGINDIR/GCC 4.2.xcplugin" + fi + if [ -d "$PLUGINDIR/GCC 4.2.xcplugin-original" ]; then + mv "$PLUGINDIR/GCC 4.2.xcplugin-original" "$PLUGINDIR/GCC 4.2.xcplugin" + fi + if [ -f "$PLUGINDIR/LLVM GCC 4.2.xcplugin/legacy" ]; then + rm -rf "$PLUGINDIR/LLVM GCC 4.2.xcplugin" + fi + for f in "$GCCDIR/usr/libexec/gcc/darwin/ppc" \ + "$GCCDIR/usr/libexec/gcc/darwin/ppc64" \ + "$GCCDIR/usr/libexec/gcc/darwin/i386" \ + "$GCCDIR/usr/libexec/gcc/darwin/x86_64" \ + "$GCCINSTALLDIR/usr/libexec/as/ppc" \ + "$GCCINSTALLDIR/usr/libexec/as/ppc64" \ + "$GCCINSTALLDIR/usr/libexec/ld/ppc" \ + "$GCCINSTALLDIR/usr/libexec/ld/ppc7400" \ + "$GCCINSTALLDIR/usr/libexec/ld/ppc970" \ + "$GCCINSTALLDIR/usr/libexec/ld/ppc64" \ + "$GCCINSTALLDIR/usr/libexec/ld/i386" \ + "$GCCINSTALLDIR/usr/libexec/ld/x86_64"; do + if [ -e "$f" ]; then + rm -rf "$f" + fi + done + if [ -f "$GCCINSTALLDIR/usr/bin/as-original" ]; then + rm "$GCCINSTALLDIR/usr/bin/as" + mv -f "$GCCINSTALLDIR/usr/bin/as-original" "$GCCINSTALLDIR/usr/bin/as" + fi + if [ -f "$GCCINSTALLDIR/usr/bin/ld-original" ]; then + rm "$GCCINSTALLDIR/usr/bin/ld" + mv -f "$GCCINSTALLDIR/usr/bin/ld-original" "$GCCINSTALLDIR/usr/bin/ld" + fi + # preserve original LLVM-GCC on Xcode 4 and earlier + if [ ! -d "$GCCDIR/Library/Perl" ] || [ -d "$GCCDIR/Library/Perl/5.10" ]; then + mv "$GCCDIR"/usr/bin/{gcov,i686-apple-darwin"$RELEASENUM"-llvm-g{++,cc},llvm-{cpp,g++,gcc}}-4.2 "$GCCDIR" + (cd "$GCCDIR" || exit; rm -rf $GCCFILES ) + mv "$GCCDIR"/*-4.2 "$GCCDIR"/usr/bin + (cd "$GCCDIR/usr/llvm-gcc-4.2" || exit; rm -f {bin,lib/gcc,libexec/gcc,share/man/man1}/powerpc*) + else + [ -f "$GCCDIR/usr/bin/gcov-4.2" ] && [ ! -L "$GCCDIR/usr/bin/gcov-4.2" ] && mv "$GCCDIR/usr/bin/gcov-4.2" "$GCCDIR" + (cd "$GCCDIR" || exit; rm -rf $GCCFILES $LLVMGCCFILES) + [ -f "$GCCDIR/gcov-4.2" ] && mv "$GCCDIR/gcov-4.2" "$GCCDIR/usr/bin" + fi + (cd "$GCCINSTALLDIR" || exit; rm -rf $GCCFILES $LLVMGCCFILES) + rmdir "$GCCINSTALLDIR/usr/include/gcc/darwin" "$GCCINSTALLDIR/usr/include/gcc" || : + rmdir "$GCCINSTALLDIR/usr/lib/"{i686-apple-darwin10,powerpc-apple-darwin10}"/4.2.1" "$GCCINSTALLDIR/usr/lib/"{gcc/,}{i686-apple-darwin10,powerpc-apple-darwin10} "$GCCINSTALLDIR/usr/lib/gcc" || : + rmdir "$GCCINSTALLDIR/usr/libexec/gcc/"{i686-apple-darwin10,powerpc-apple-darwin10} "$GCCINSTALLDIR/usr/libexec/gcc" "$GCCINSTALLDIR/usr/libexec/ld" "$GCCDIR/usr/libexec/gcc/darwin" "$GCCDIR/usr/libexec/gcc" || : + rmdir "$GCCINSTALLDIR/usr/share/man/man7" || : + if [ -f "$PLATFORMDIR/Developer/Library/Xcode/Specifications/MacOSX Architectures.xcspec-original" ]; then + rm "$PLATFORMDIR/Developer/Library/Xcode/Specifications/MacOSX Architectures.xcspec" + mv -f "$PLATFORMDIR/Developer/Library/Xcode/Specifications/MacOSX Architectures.xcspec-original" "$PLATFORMDIR/Developer/Library/Xcode/Specifications/MacOSX Architectures.xcspec" + fi + fi + #for i in 10.4u 10.5 10.6 10.7 10.8 10.9 10.10; do + if [ "$osx104" = 1 ]; then + i=10.4u + [ -f "$SDKDIR/SDKs/MacOSX${i}.sdk/legacy" ] && rm -rf "$SDKDIR/SDKs/MacOSX${i}.sdk" + fi + if [ "$osx105" = 1 ]; then + i=10.5 + [ -f "$SDKDIR/SDKs/MacOSX${i}.sdk/legacy" ] && rm -rf "$SDKDIR/SDKs/MacOSX${i}.sdk" + fi + if [ "$osx106" = 1 ]; then + i=10.6 + [ -f "$SDKDIR/SDKs/MacOSX${i}.sdk/legacy" ] && rm -rf "$SDKDIR/SDKs/MacOSX${i}.sdk" + fi + if [ "$osx107" = 1 ]; then + i=10.7 + [ -f "$SDKDIR/SDKs/MacOSX${i}.sdk/legacy" ] && rm -rf "$SDKDIR/SDKs/MacOSX${i}.sdk" + fi + if [ "$osx108" = 1 ]; then + i=10.8 + [ -f "$SDKDIR/SDKs/MacOSX${i}.sdk/legacy" ] && rm -rf "$SDKDIR/SDKs/MacOSX${i}.sdk" + fi + if [ "$osx109" = 1 ]; then + i=10.9 + [ -f "$SDKDIR/SDKs/MacOSX${i}.sdk/legacy" ] && rm -rf "$SDKDIR/SDKs/MacOSX${i}.sdk" + fi + if [ "$osx1010" = 1 ]; then + i=10.10 + [ -f "$SDKDIR/SDKs/MacOSX${i}.sdk/legacy" ] && rm -rf "$SDKDIR/SDKs/MacOSX${i}.sdk" + fi + if [ "$osx1011" = 1 ]; then + i=10.11 + [ -f "$SDKDIR/SDKs/MacOSX${i}.sdk/legacy" ] && rm -rf "$SDKDIR/SDKs/MacOSX${i}.sdk" + fi + if [ "$osx1012" = 1 ]; then + i=10.12 + [ -f "$SDKDIR/SDKs/MacOSX${i}.sdk/legacy" ] && rm -rf "$SDKDIR/SDKs/MacOSX${i}.sdk" + fi + if [ "$osx1013" = 1 ]; then + i=10.13 + [ -f "$SDKDIR/SDKs/MacOSX${i}.sdk/legacy" ] && rm -rf "$SDKDIR/SDKs/MacOSX${i}.sdk" + fi + + if [ "$compilers" = 1 ]; then + if [ "$GCCINSTALLDIR/usr/bin/gcc" -ef "$GCCINSTALLDIR/usr/bin/clang" ]; then + rm "$GCCINSTALLDIR/usr/bin/gcc" + fi + for b in llvm-g++ llvm-gcc; do + if [ -L $GCCINSTALLDIR/usr/bin/$b ] && [ ! -e $GCCINSTALLDIR/usr/bin/$b ]; then + rm $GCCINSTALLDIR/usr/bin/$b + fi + done + for b in c++-4.0 cpp-4.0 c++-4.2 cpp-4.2 gcc-4.0 g++-4.0 gcov-4.0 gcc-4.2 g++-4.2 gcov-4.2 llvm-cpp-4.2 llvm-g++-4.2 llvm-gcc-4.2; do + if [ -L $GCCLINKDIR/bin/$b ] && [ ! -e $GCCLINKDIR/bin/$b ]; then + rm $GCCLINKDIR/bin/$b + fi + done + for b in cpp-4.2.1 gcc-4.0.1 g++-4.0.1 gcc-4.2.1 g++-4.2.1 llvm-g++-4.2 llvm-gcc-4.2; do + if [ -L $GCCLINKDIR/bin/i686-apple-darwin10-$b ] && [ ! -e $GCCLINKDIR/bin/i686-apple-darwin10-$b ]; then + rm $GCCLINKDIR/bin/i686-apple-darwin10-$b + fi + done + for b in cpp-4.2.1 gcc-4.0.1 g++-4.0.1 gcc-4.2.1 g++-4.2.1 llvm-g++-4.2 llvm-gcc-4.2; do + if [ -L $GCCLINKDIR/bin/powerpc-apple-darwin10-$b ] && [ ! -e $GCCLINKDIR/bin/powerpc-apple-darwin10-$b ]; then + rm $GCCLINKDIR/bin/powerpc-apple-darwin10-$b + fi + done + fi + if [ -f "$PLATFORMDIR/Info.plist-original" ] && [ $(ls -1 "$SDKDIR"/SDKs/MacOSX*.sdk/legacy 2>/dev/null | wc -l) -eq 0 ]; then + rm "$PLATFORMDIR/Info.plist" + mv -f "$PLATFORMDIR/Info.plist-original" "$PLATFORMDIR/Info.plist" + fi + + ;; + +esac + + + +# Local variables: +# mode: shell-script +# sh-basic-offset: 4 +# sh-indent-comment: t +# indent-tabs-mode: nil +# End: +# ex: ts=4 sw=4 et filetype=sh From 72c0513c576383a3acd574e809cb5aa8eb420fd0 Mon Sep 17 00:00:00 2001 From: Dan Walmsley Date: Wed, 24 Apr 2019 19:02:10 +0100 Subject: [PATCH 38/41] install xcode sdk on osx not linux --- azure-pipelines.yml | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index dcf21cf30f..1bf6b94092 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -9,11 +9,6 @@ jobs: script: | sudo apt-get update sudo apt-get install castxml - - task: CmdLine@2 - displayName: 'Install OSX Sdk' - inputs: - script: | - ./scripts/XcodeLegacy.sh -osx1013 - task: CmdLine@2 displayName: 'Install Nuke' @@ -50,6 +45,12 @@ jobs: curl -o ./mono.pkg https://download.mono-project.com/archive/5.18.0/macos-10-universal/MonoFramework-MDK-5.18.0.225.macos10.xamarin.universal.pkg sudo installer -verbose -pkg ./mono.pkg -target / + - task: CmdLine@2 + displayName: 'Install OSX Sdk' + inputs: + script: | + ./scripts/XcodeLegacy.sh -osx1013 + - task: Xcode@5 inputs: actions: 'build' From 46711423362eeb601634170230805591eeb859f4 Mon Sep 17 00:00:00 2001 From: Dan Walmsley Date: Wed, 24 Apr 2019 20:15:54 +0100 Subject: [PATCH 39/41] attempt to fix osx builds --- azure-pipelines.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 1bf6b94092..576dd09715 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -32,7 +32,7 @@ jobs: - job: macOS pool: - vmImage: 'xcode9-macos10.13' + vmImage: 'macOS-10.14' steps: - task: DotNetCoreInstaller@0 inputs: From 7a03f3836ac39e0d4007598c8ca5f1e0aa39eba1 Mon Sep 17 00:00:00 2001 From: Dan Walmsley Date: Wed, 24 Apr 2019 20:16:58 +0100 Subject: [PATCH 40/41] dont install osx sdk manually --- azure-pipelines.yml | 6 - scripts/XcodeLegacy.sh | 1306 ---------------------------------------- 2 files changed, 1312 deletions(-) delete mode 100755 scripts/XcodeLegacy.sh diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 576dd09715..36377acea3 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -45,12 +45,6 @@ jobs: curl -o ./mono.pkg https://download.mono-project.com/archive/5.18.0/macos-10-universal/MonoFramework-MDK-5.18.0.225.macos10.xamarin.universal.pkg sudo installer -verbose -pkg ./mono.pkg -target / - - task: CmdLine@2 - displayName: 'Install OSX Sdk' - inputs: - script: | - ./scripts/XcodeLegacy.sh -osx1013 - - task: Xcode@5 inputs: actions: 'build' diff --git a/scripts/XcodeLegacy.sh b/scripts/XcodeLegacy.sh deleted file mode 100755 index 2a67dca414..0000000000 --- a/scripts/XcodeLegacy.sh +++ /dev/null @@ -1,1306 +0,0 @@ -#!/bin/bash -# XCodeLegacy.sh -# -# Original author: Frederic Devernay -# Contributors: -# - Garrett Walbridge -# - Jae Liu -# - Eric Knibbe -# - Chris Roueche -# - Kris Coppieters -# - Nick Beadman / -# -# License: Creative Commons BY-NC-SA 3.0 http://creativecommons.org/licenses/by-nc-sa/3.0/ -# -# History: -# 1.0 (08/10/2012): First public version, supports Xcode up to version 4.6.3 -# 1.1 (20/09/2013): Xcode 5 removed llvm-gcc and 10.7 SDK support, grab them from Xcode 3 and 4 -# 1.2 (03/02/2014): Xcode 5 broke PPC assembly and linking; fix assembly and grab linker from Xcode 3 -# 1.3 (07/10/2014): Xcode 6 removed 10.8 SDK, grab it from Xcode 5.1.1 -# 1.4 (21/08/2015): Xcode 7 removed 10.9 and 10.10 SDKs, grab them from Xcode 6.4 -# 1.5 (15/10/2015): Fixes for OS X 10.11 El Capitan (nothing can be installed in /usr/bin because of the sandbox) -# 1.6 (11/11/2015): Fix buildpackages, fix /usr/bin/gcc on recent OS X, fix download messages -# 1.7 (05/04/2016): Xcode 7.3 disables support for older SDKs, fix that -# 1.8 (07/04/2016): add options to install only some SDKs or compilers only -# 1.9 (16/09/2016): Xcode 8 dropped 10.11 SDK, get it from Xcode 7.3.1 -# 2.0 (02/05/2017): Xcode 8 cannot always link i386 for OS X 10.5, use the Xcode 3 linker for this arch too. Force use of legacy assembler with GCC 4.x. -# 2.1 (17/01/2017): Xcode 9 dropped 10.12 SDK, get it from https://github.com/phracker/MacOSX-SDKs; fix compiling with GNU Ada, and many other fixes -# 2.2 (12/02/2019): Added support for using macOS High Sierra 10.13 SDK from Xcode 9.4.1 for use on Xcode 10/macOS 10.14 Mojave, also changed source of OS X 10.12 SDK to Xcode 8.3.3 - -#set -e # Exit immediately if a command exits with a non-zero status -#set -u # Treat unset variables as an error when substituting. -#set -x # Print commands and their arguments as they are executed. - -compilers=0 -osx104=0 -osx105=0 -osx106=0 -osx107=0 -osx108=0 -osx109=0 -osx1010=0 -osx1011=0 -osx1012=0 -osx1013=0 -gotoption=0 -error=0 - -while [[ $error = 0 ]] && [[ $# -gt 1 ]]; do - - case $1 in - -compilers) - compilers=1 - gotoption=1 - shift - ;; - -osx104) - osx104=1 - gotoption=1 - shift - ;; - -osx105) - osx105=1 - gotoption=1 - shift - ;; - -osx106) - osx106=1 - gotoption=1 - shift - ;; - -osx107) - osx107=1 - gotoption=1 - shift - ;; - -osx108) - osx108=1 - gotoption=1 - shift - ;; - -osx109) - osx109=1 - gotoption=1 - shift - ;; - -osx1010) - osx1010=1 - gotoption=1 - shift - ;; - -osx1011) - osx1011=1 - gotoption=1 - shift - ;; - -osx1012) - osx1012=1 - gotoption=1 - shift - ;; - -osx1013) - osx1013=1 - gotoption=1 - shift - ;; - *) - # unknown option or spurious arg - error=1 - ;; - esac - -done - -if [ $gotoption = 0 ]; then - compilers=1 - osx104=1 - osx105=1 - osx106=1 - osx107=1 - osx108=1 - osx109=1 - osx1010=1 - osx1011=1 - osx1012=1 - osx1013=1 -fi - -if [ $# != 1 ]; then - # ################################################################################ 80 cols - echo "Usage: $0 [-compilers|-osx104|-osx105|-osx106|-osx107|-osx108|-osx109|-osx1010|-osx1011|-osx1012|-osx1013] buildpackages|install|installbeta|cleanpackages|uninstall|uninstallbeta" - echo "" - echo "Description: Extracts / installs / cleans / uninstalls the following components" - echo "from Xcode 3.2.6, Xcode 4.6.3, Xcode 5.1.1, Xcode 6.4, Xcode 7.3.1, Xcode 8.3.3 and Xcode 9.4.1 which" - echo "are not available in Xcode >= 4.2:" - echo " - PPC assembler and linker" - echo " - GCC 4.0 and 4.2 compilers and Xcode plugins" - echo " - LLVM-GCC 4.2 compiler and Xcode plugin (Xcode >= 5)" - echo " - Mac OS X SDK 10.4u, 10.5, 10.6, 10.7, 10.8, 10.9, 10.10, 10.11, 10.12, 10.13" - echo "" - echo "An optional first argument may be provided to limit the operation (by default" - echo "everything is done):" - echo " -compilers : only install the gcc and llvm-gcc compilers, as well as the" - echo " corresponding Xcode plugins" - echo " -osx104 : only install Mac OSX 10.4 SDK" - echo " -osx105 : only install Mac OSX 10.5 SDK" - echo " -osx106 : only install Mac OSX 10.6 SDK" - echo " -osx107 : only install Mac OSX 10.7 SDK" - echo " -osx108 : only install OSX 10.8 SDK" - echo " -osx109 : only install OSX 10.9 SDK" - echo " -osx1010 : only install OSX 10.10 SDK" - echo " -osx1011 : only install OSX 10.11 SDK" - echo " -osx1012 : only install OSX 10.12 SDK" - echo " -osx1013 : only install OSX 10.13 SDK" - echo "Note that these can be combined. For example, to build and install the 10.9" - echo "and 10.10 SDKs, one could execute:" - echo " $ $0 -osx109 -osx1010 buildpackages" - echo " $ sudo $0 -osx109 -osx1010 install" - echo "" - echo "Typically, you will want to run this script with the buildpackages argument" - echo "first, then the install argument, and lastly the cleanpackages argument, in" - echo "order to properly install the legacy Xcode files." - echo "The install and uninstall phases have to be run with administrative rights, as" - echo "in:" - echo " $ sudo $0 install" - echo "The installbeta and uninstallbeta phases work on the beta versions of Xcode." - exit -fi - -if [ "$1" = "installbeta" ] || [ "$1" = "uninstallbeta" ]; then - XCODEAPP="/Applications/Xcode-beta.app" -else - XCODEAPP="/Applications/Xcode.app" -fi -XCODE42=0 -PLUGINDIR="$XCODEAPP/Contents/PlugIns/Xcode3Core.ideplugin/Contents/SharedSupport/Developer/Library/Xcode/Plug-ins" -GCCDIR="$XCODEAPP/Contents/Developer" -SDKDIR="$GCCDIR/Platforms/MacOSX.platform/Developer" -if [ -d "$XCODEAPP" ]; then - echo "*** Info: found Xcode >= 4.3 in $XCODEAPP" -else - GCCDIR="/Developer" - XCODEAPP="$GCCDIR/Applications/Xcode.app" - PLUGINDIR="$GCCDIR/Library/Xcode/PrivatePlugIns/Xcode3Core.ideplugin/Contents/SharedSupport/Developer/Library/Xcode/Plug-ins" - SDKDIR="$GCCDIR" - if [ -d "$XCODEAPP" ]; then - XCODE42=1 - echo "*** Info: found Xcode <= 4.2.1 in $XCODEAPP" - else - echo "*** Info: could not find Xcode 4.2 in /Developer/Applications nor Xcode >= 4.3 in /Applications" - fi -fi -PLATFORMDIR="$GCCDIR/Platforms/MacOSX.platform" -GCCINSTALLDIR="$GCCDIR/Toolchains/XcodeDefault.xctoolchain" -GCCLINKDIR=/usr -RELEASENUM=$(uname -r | awk -F. '{print $1}') -if [ "$RELEASENUM" -gt 14 ]; then - # on OSX 10.11 El Capitan, nothing can be installed in /usr because of the Sandbox - # install in Xcode instead, and put links in /usr/local - GCCLINKDIR=/usr/local -elif [ "$RELEASENUM" -lt 10 ]; then - echo "*** Error: This script requires Mac OS X 10.6 Snow Leopard or newer." - exit 1 -fi - -GCCFILES="usr/share/man/man7/fsf-funding.7 usr/share/man/man7/gfdl.7 usr/share/man/man7/gpl.7 usr/share/man/man1/*-4.0.1 usr/share/man/man1/*-4.0.1.1 usr/libexec/gcc/*-apple-darwin10/4.0.1 usr/lib/gcc/*-apple-darwin10/4.0.1 usr/include/gcc/darwin/4.0 usr/bin/*-4.0 usr/bin/*-4.0.1 usr/share/man/man1/*-4.2.1 usr/share/man/man1/*-4.2.1.1 usr/libexec/gcc/*-apple-darwin10/4.2.1 usr/lib/gcc/*-apple-darwin10/4.2.1 usr/include/gcc/darwin/4.2 usr/bin/*-4.2 usr/bin/*-4.2.1" -LLVMGCCFILES="usr/llvm-gcc-4.2 usr/share/man/man1/llvm-g*.1.gz" - -xc3="$(( compilers + osx104 + osx105 + osx106 != 0 ))" -xc4="$(( compilers + osx107 != 0 ))" -xc5="$(( osx108 != 0 ))" -xc6="$(( osx109 + osx1010 != 0 ))" -xc7="$(( osx1011 != 0 ))" -xc8="$(( osx1012 != 0 ))" -xc9="$(( osx1013 != 0 ))" - -# The sole argument is the macOS version (e.g. 10.12) -installSDK() { - macos="$1" - macosnodot="${macos//./}" - if [ -d "$SDKDIR/SDKs/MacOSX${macos}.sdk" ]; then - echo "*** Not installing MacOSX${macos}.sdk (found installed in $SDKDIR/SDKs/MacOSX${macos}.sdk, uninstall first to force install)" - else - if [ -f Xcode${macosnodot}SDK.tar.gz ]; then - (gzip -dc Xcode${macosnodot}SDK.tar.gz | (cd "$SDKDIR" || exit; tar xf -)) && echo "*** installed Xcode${macosnodot}SDK.tar.gz" - elif [ -f MacOSX${macos}.sdk.tar.xz ]; then - (gzip -dc MacOSX${macos}.sdk.tar.xz | (cd "$SDKDIR/SDKs" || exit; tar xf -)) && echo "*** installed MacOSX${macos}.sdk.tar.xz" - else - echo "*** Could not install MacOSX${macos}.sdk" - echo "*** Before installing:" - echo "- execute \"$0 buildpackages\"" - exit 1 - fi - touch "$SDKDIR/SDKs/MacOSX${macos}.sdk/legacy" - fi -} - -case $1 in - buildpackages) - ####################### - # PHASE 1: PACKAGING - # - missingdmg=0 - # note: Xcode links from http://stackoverflow.com/questions/10335747/how-to-download-xcode-4-5-6-7-and-get-the-dmg-file/10335943#10335943 - if [ "$xc3" = 1 ] && [ ! -f xcode_3.2.6_and_ios_sdk_4.3.dmg ]; then - echo "*** You should download Xcode 3.2.6. Login to:" - echo " https://developer.apple.com/downloads/" - echo "then download from:" - echo " https://developer.apple.com/devcenter/download.action?path=/Developer_Tools/xcode_3.2.6_and_ios_sdk_4.3__final/xcode_3.2.6_and_ios_sdk_4.3.dmg" - echo "or" - echo " https://adcdownload.apple.com/Developer_Tools/xcode_3.2.6_and_ios_sdk_4.3__final/xcode_3.2.6_and_ios_sdk_4.3.dmg" - echo "and then run this script from within the same directory as the downloaded file" - missingdmg=1 - fi - if [ "$xc4" = 1 ] && [ ! -f xcode4630916281a.dmg ]; then - echo "*** You should download Xcode 4.6.3. Login to:" - echo " https://developer.apple.com/downloads/" - echo "then download from:" - echo " https://developer.apple.com/devcenter/download.action?path=/Developer_Tools/xcode_4.6.3/xcode4630916281a.dmg" - echo "or" - echo " https://adcdownload.apple.com/Developer_Tools/xcode_4.6.3/xcode4630916281a.dmg" - echo "and then run this script from within the same directory as the downloaded file" - missingdmg=1 - fi - if [ "$xc5" = 1 ] && [ ! -f xcode_5.1.1.dmg ]; then - echo "*** You should download Xcode 5.1.1. Login to:" - echo " https://developer.apple.com/downloads/" - echo "then download from:" - echo " https://developer.apple.com/devcenter/download.action?path=/Developer_Tools/xcode_5.1.1/xcode_5.1.1.dmg" - echo "or" - echo " https://adcdownload.apple.com/Developer_Tools/xcode_5.1.1/xcode_5.1.1.dmg" - echo "and then run this script from within the same directory as the downloaded file" - missingdmg=1 - fi - if [ "$xc6" = 1 ] && [ ! -f Xcode_6.4.dmg ]; then - echo "*** You should download Xcode 6.4. Login to:" - echo " https://developer.apple.com/downloads/" - echo "then download from:" - echo " https://developer.apple.com/devcenter/download.action?path=/Developer_Tools/Xcode_6.4/Xcode_6.4.dmg" - echo "or" - echo " https://adcdownload.apple.com/Developer_Tools/Xcode_6.4/Xcode_6.4.dmg" - echo "and then run this script from within the same directory as the downloaded file" - missingdmg=1 - fi - if [ "$xc7" = 1 ] && [ ! -f Xcode_7.3.1.dmg ]; then - echo "*** You should download Xcode 7.3.1. Login to:" - echo " https://developer.apple.com/downloads/" - echo "then download from:" - echo " https://developer.apple.com/devcenter/download.action?path=/Developer_Tools/Xcode_7.3.1/Xcode_7.3.1.dmg" - echo "or" - echo " https://adcdownload.apple.com/Developer_Tools/Xcode_7.3.1/Xcode_7.3.1.dmg" - echo "and then run this script from within the same directory as the downloaded file" - missingdmg=1 - fi - if [ "$xc8" = 1 ] && [ ! -f Xcode8.3.3.xip ]; then - echo "*** You should download Xcode 8.3.3. Login to:" - echo " https://developer.apple.com/downloads/" - echo "then download from:" - echo " https://download.developer.apple.com/Developer_Tools/Xcode_8.3.3/Xcode8.3.3.xip" - echo "and then run this script from within the same directory as the downloaded file" - missingdmg=1 - fi - if [ "$xc9" = 1 ] && [ ! -f Xcode_9.4.1.xip ]; then - echo "*** You should download Xcode 9.4.1. Login to:" - echo " https://developer.apple.com/downloads/" - echo "then download from:" - echo " https://download.developer.apple.com/Developer_Tools/Xcode_9.4.1/Xcode_9.4.1.xip" - echo "and then run this script from within the same directory as the downloaded file" - missingdmg=1 - fi - if [ "$missingdmg" = 1 ]; then - echo "*** at least one Xcode distribution is missing, cannot build packages - exiting now" - exit - fi - if [ "$xc8" = 1 ]; then - if [ -e Xcode.app ]; then - echo "*** A stray Xcode.app exists in the XcodeLegacy.sh folder. Remove it then try again." - exit - fi - fi - - MNTDIR="$(mktemp -d mount.XXX)" - ATTACH_OPTS=(-nobrowse -mountroot "$MNTDIR") - if [ "$xc3" = 1 ]; then - # you should download Xcode 3.2.6 from: - # http://connect.apple.com/cgi-bin/WebObjects/MemberSite.woa/wa/getSoftware?bundleID=20792 - hdiutil attach xcode_3.2.6_and_ios_sdk_4.3.dmg "${ATTACH_OPTS[@]}" - if [ ! -d "$MNTDIR/Xcode and iOS SDK" ]; then - echo "*** Error while trying to attach disk image xcode_3.2.6_and_ios_sdk_4.3.dmg" - echo "Aborting" - exit - fi - if [ "$compilers" = 1 ]; then - rm -rf /tmp/XC3 - pkgutil --expand "$MNTDIR/Xcode and iOS SDK/Packages/DeveloperTools.pkg" /tmp/XC3 - (cd /tmp/XC3 || exit; gzip -dc Payload | cpio -id --quiet Library/Xcode/Plug-ins) #we only need these, see https://github.com/devernay/xcodelegacy/issues/8 - ( (cd /tmp/XC3/Library/Xcode/Plug-ins || exit; tar cf - "GCC 4.0.xcplugin") | gzip -c > XcodePluginGCC40.tar.gz) && echo "*** Created XcodePluginGCC40.tar.gz in directory $(pwd)" - ( (cd /tmp/XC3/Library/Xcode/Plug-ins || exit; tar cf - "GCC 4.2.xcplugin") | gzip -c > XcodePluginGCC42.tar.gz) && echo "*** Created XcodePluginGCC42.tar.gz in directory $(pwd)" - #( (cd /tmp/XC3/Library/Xcode/Plug-ins || exit; tar cf - "LLVM GCC 4.2.xcplugin") | gzip -c > XcodePluginLLVMGCC42.tar.gz) && echo "*** Created XcodePluginLLVMGCC42.tar.gz in directory $(pwd)" - # should be untarred in /Developer/Library/Xcode/PrivatePlugIns/Xcode3Core.ideplugin/Contents/SharedSupport/Developer/Library/Xcode/Plug-ins - # gzip -dc XcodePluginGCC40.tar.gz | (cd /Developer/Library/Xcode/PrivatePlugIns/Xcode3Core.ideplugin/Contents/SharedSupport/Developer/Library/Xcode/Plug-ins || exit; sudo tar xvf -) - - rm -rf /tmp/XC3 - pkgutil --expand "$MNTDIR/Xcode and iOS SDK/Packages/DeveloperToolsCLI.pkg" /tmp/XC3 - - (cd /tmp/XC3 || exit; gzip -dc Payload | cpio -id --quiet usr/bin usr/libexec) #we only need these, see https://github.com/devernay/xcodelegacy/issues/8 - ( (cd /tmp/XC3 || exit; tar cf - usr/libexec/gcc/darwin/ppc usr/libexec/gcc/darwin/ppc64 usr/libexec/gcc/darwin/i386 usr/libexec/gcc/darwin/x86_64) | gzip -c > Xcode3as.tar.gz) && echo "*** Created Xcode3as.tar.gz in directory $(pwd)" - ( (cd /tmp/XC3 || exit; tar cf - usr/bin/ld) | gzip -c > Xcode3ld.tar.gz) && echo "*** Created Xcode3ld.tar.gz in directory $(pwd)" - - #(cp "$MNTDIR/Xcode and iOS SDK/Packages/gcc4.0.pkg" xcode_3.2.6_gcc4.0.pkg) && echo "*** Created xcode_3.2.6_gcc4.0.pkg in directory $(pwd)" - rm -rf /tmp/XC3 - pkgutil --expand "$MNTDIR/Xcode and iOS SDK/Packages/gcc4.0.pkg" /tmp/XC3 - - (cd /tmp/XC3 || exit; gzip -dc Payload | cpio -id --quiet usr) #we only need these, see https://github.com/devernay/xcodelegacy/issues/8 - ( (cd /tmp/XC3 || exit; tar cf - usr) | gzip -c > Xcode3gcc40.tar.gz) && echo "*** Created Xcode3gcc40.tar.gz in directory $(pwd)" - - #(cp "$MNTDIR/Xcode and iOS SDK/Packages/gcc4.2.pkg" xcode_3.2.6_gcc4.2.pkg) && echo "*** Created xcode_3.2.6_gcc4.2.pkg in directory $(pwd)" - rm -rf /tmp/XC3 - pkgutil --expand "$MNTDIR/Xcode and iOS SDK/Packages/gcc4.2.pkg" /tmp/XC3 - - (cd /tmp/XC3 || exit; gzip -dc Payload | cpio -id --quiet usr) #we only need these, see https://github.com/devernay/xcodelegacy/issues/8 - ( (cd /tmp/XC3 || exit; tar cf - usr) | gzip -c > Xcode3gcc42.tar.gz) && echo "*** Created Xcode3gcc42.tar.gz in directory $(pwd)" - - #(cp "$MNTDIR/Xcode and iOS SDK/Packages/llvm-gcc4.2.pkg" xcode_3.2.6_llvm-gcc4.2.pkg) && echo "*** Created xcode_3.2.6_llvm-gcc4.2.pkg in directory $(pwd)" - rm -rf /tmp/XC3 - pkgutil --expand "$MNTDIR/Xcode and iOS SDK/Packages/llvm-gcc4.2.pkg" /tmp/XC3 - - (cd /tmp/XC3 || exit; gzip -dc Payload | cpio -id --quiet usr) #we only need these, see https://github.com/devernay/xcodelegacy/issues/8 - ( (cd /tmp/XC3 || exit; tar cf - usr) | gzip -c > Xcode3llvmgcc42.tar.gz) && echo "*** Created Xcode3llvmgcc42.tar.gz in directory $(pwd)" - fi - - rm -rf /tmp/XC3 - - if [ "$osx104" = 1 ] || [ "$osx105" = 1 ]; then - # use the latest version of the hashtable include, as recommended by: - # http://wiki.inkscape.org/wiki/index.php/HashtableFixOSX - # http://permalink.gmane.org/gmane.comp.graphics.inkscape.devel/32966 - # The version from gcc 4.0.4 fixes these four bugs: - # - # GCC Bugzilla Bug 23053 - # Const-correctness issue in TR1 hashtable - # - # - # GCC Bugzilla Bug 23465 - # Assignment fails on TR1 unordered containers - # - # - # GCC Bugzilla Bug 24054 - # std::tr1::unordered_map's erase does not seem to return a value - # - # - # GCC Bugzilla Bug 24064 - # tr1::unordered_map seems to seg-fault when caching hash values - # - - # see also: - # http://wayback.archive.org/web/20100810175143/http://mohri-lt.cs.nyu.edu:80/twiki/bin/view/FST/CompilingOnMacOSX - # (only fixes GCC Bugzilla Bug 23465) - - #curl -A 'Mozilla/5.0 (Windows NT 6.2) AppleWebKit/536.6 (KHTML, like Gecko) Chrome/20.0.1090.0 Safari/536.6' 'https://gcc.gnu.org/viewcvs/gcc/branches/gcc-4_0-branch/libstdc%2B%2B-v3/include/tr1/hashtable?revision=95538&view=co' -o hashtable-gcc-4.0.0 - #curl -A 'Mozilla/5.0 (Windows NT 6.2) AppleWebKit/536.6 (KHTML, like Gecko) Chrome/20.0.1090.0 Safari/536.6' 'https://gcc.gnu.org/viewcvs/gcc/branches/gcc-4_0-branch/libstdc%2B%2B-v3/include/tr1/hashtable?revision=104939&view=co' -o hashtable-gcc-4.0.4 - if false; then - # older version of the patch, for the record (only fixes 23053 and 23465) - cat > /tmp/hashtable.patch <, iterator>::type - Insert_Return_Type; - -- node* find_node (node* p, const key_type& k, typename hashtable::hash_code_t c); -+ node* find_node (node* p, const key_type& k, typename hashtable::hash_code_t c) const; - - std::pair insert (const value_type&, std::tr1::true_type); - iterator insert (const value_type&, std::tr1::false_type); -@@ -1042,8 +1042,9 @@ - node* n = ht.m_buckets[i]; - node** tail = m_buckets + i; - while (n) { -- *tail = m_allocate_node (n); -- (*tail).copy_code_from (n); -+ // *tail = m_allocate_node (n); -+ // (*tail).copy_code_from (n); -+ *tail = m_allocate_node (n->m_v); - tail = &((*tail)->m_next); - n = n->m_next; - } -@@ -1216,7 +1217,7 @@ - bool c, bool m, bool u> - typename hashtable::node* - hashtable --::find_node (node* p, const key_type& k, typename hashtable::hash_code_t code) -+::find_node (node* p, const key_type& k, typename hashtable::hash_code_t code) const - { - for ( ; p ; p = p->m_next) - if (this->compare (k, code, p)) -EOF - fi - fi - - if [ "$osx104" = 1 ]; then - test -d /tmp/XC3-10.4 && rm -rf /tmp/XC3-10.4 - pkgutil --expand "$MNTDIR/Xcode and iOS SDK/Packages/MacOSX10.4.Universal.pkg" /tmp/XC3-10.4 - (cd /tmp/XC3-10.4 || exit; gzip -dc Payload | cpio -id --quiet SDKs/MacOSX10.4u.sdk) - SDKROOT=/tmp/XC3-10.4/SDKs/MacOSX10.4u.sdk - # should we install more than these? (fixed includes?) - # Add links to libstdc++ so that "g++-4.0 -isysroot /Developer/SDKs/MacOSX10.4u.sdk -Wl,-syslibroot,/Developer/SDKs/MacOSX10.4u.sdk -mmacosx-version-min=10.4" works - ln -s ../../../i686-apple-darwin10/4.0.1/libstdc++.dylib $SDKROOT/usr/lib/gcc/i686-apple-darwin10/4.0.1/libstdc++.dylib - # Add links to libstdc++ so that "clang++ -stdlib=libstdc++ -isysroot /Developer/SDKs/MacOSX10.4u.sdk -Wl,-syslibroot,/Developer/SDKs/MacOSX10.4u.sdk -mmacosx-version-min=10.4" works - ln -s libstdc++.6.dylib $SDKROOT/usr/lib/libstdc++.dylib - # Fix tr1/hashtable - # see http://www.openfst.org/twiki/bin/view/FST/CompilingOnMacOSX https://gcc.gnu.org/ml/libstdc++/2005-08/msg00017.html https://gcc.gnu.org/bugzilla/show_bug.cgi?id=23053 - # in SDKs/MacOSX10.4u.sdk/usr/include/c++/4.0.0/tr1/hashtable - #(cd $SDKROOT/usr/include/c++/4.0.0/tr1 || exit; patch -p0 -d. < /tmp/hashtable.patch) - mv $SDKROOT/usr/include/c++/4.0.0/tr1/hashtable $SDKROOT/usr/include/c++/4.0.0/tr1/hashtable.orig - cp hashtable-gcc-4.0.4 $SDKROOT/usr/include/c++/4.0.0/tr1/hashtable - - # Add links for compatibility with GCC 4.2 - ln -s 4.0.1 $SDKROOT/usr/lib/gcc/i686-apple-darwin10/4.2.1 - ln -s 4.0.1 $SDKROOT/usr/lib/gcc/powerpc-apple-darwin10/4.2.1 - ln -s 4.0.1 $SDKROOT/usr/lib/i686-apple-darwin10/4.2.1 - ln -s 4.0.1 $SDKROOT/usr/lib/powerpc-apple-darwin10/4.2.1 - ln -s 4.0.0 $SDKROOT/usr/include/c++/4.2.1 - - ( (cd /tmp/XC3-10.4 || exit; tar cf - SDKs/MacOSX10.4u.sdk) | gzip -c > Xcode104SDK.tar.gz) && echo "*** Created Xcode104SDK.tar.gz in directory $(pwd)" - rm -rf /tmp/XC3-10.4 - fi - - if [ "$osx105" = 1 ]; then - test -d /tmp/XC3-10.5 && rm -rf /tmp/XC3-10.5 - pkgutil --expand "$MNTDIR/Xcode and iOS SDK/Packages/MacOSX10.5.pkg" /tmp/XC3-10.5 - (cd /tmp/XC3-10.5 || exit; gzip -dc Payload | cpio -id --quiet SDKs/MacOSX10.5.sdk) - SDKROOT=/tmp/XC3-10.5/SDKs/MacOSX10.5.sdk - # should we install more than these? (fixed includes?) - # Add links to libstdc++ so that "g++-4.0 -isysroot /Developer/SDKs/MacOSX10.5.sdk -Wl,-syslibroot,/Developer/SDKs/MacOSX10.5.sdk -mmacosx-version-min=10.5" works - ln -s ../../../i686-apple-darwin10/4.0.1/libstdc++.dylib $SDKROOT/usr/lib/gcc/i686-apple-darwin10/4.0.1/libstdc++.dylib - ln -s ../../../i686-apple-darwin10/4.2.1/libstdc++.dylib $SDKROOT/usr/lib/gcc/i686-apple-darwin10/4.2.1/libstdc++.dylib - # Add links to libstdc++ so that "clang++ -stdlib=libstdc++ -isysroot /Developer/SDKs/MacOSX10.5.sdk -Wl,-syslibroot,/Developer/SDKs/MacOSX10.5.sdk -mmacosx-version-min=10.5" works - ln -s libstdc++.6.dylib $SDKROOT/usr/lib/libstdc++.dylib - # fix AvailabilityInternal.h (see https://trac.macports.org/wiki/LeopardSDKFixes) - sed -i.orig -e 's/define __MAC_OS_X_VERSION_MAX_ALLOWED __MAC_10_6/define __MAC_OS_X_VERSION_MAX_ALLOWED 1058/' $SDKROOT/usr/include/AvailabilityInternal.h - # Fix tr1/hashtable - # see http://www.openfst.org/twiki/bin/view/FST/CompilingOnMacOSX https://gcc.gnu.org/ml/libstdc++/2005-08/msg00017.html https://gcc.gnu.org/bugzilla/show_bug.cgi?id=23053 - # in SDKs/MacOSX10.5.sdk/usr/include/c++/4.0.0/tr1/hashtable - # this also affects g++-4.2, since usr/include/c++/4.2.1 links to usr/include/c++/4.0.0 - #(cd $SDKROOT/usr/include/c++/4.0.0/tr1 || exit; patch -p0 -d. < /tmp/hashtable.patch) - mv $SDKROOT/usr/include/c++/4.0.0/tr1/hashtable $SDKROOT/usr/include/c++/4.0.0/tr1/hashtable.orig - cp hashtable-gcc-4.0.4 $SDKROOT/usr/include/c++/4.0.0/tr1/hashtable - fi - - if [ "$osx104" = 1 ] || [ "$osx105" = 1 ]; then - true - #rm /tmp/hashtable.patch - fi - - if [ $osx105 = 1 ] || [ $osx106 = 1 ]; then - test -d /tmp/XC3 && rm -rf /tmp/XC3 - pkgutil --expand "$MNTDIR/Xcode and iOS SDK/Packages/MacOSX10.6.pkg" /tmp/XC3 - (cd /tmp/XC3 || exit; gzip -dc Payload | cpio -id --quiet SDKs/MacOSX10.6.sdk) - SDKROOT=/tmp/XC3/SDKs/MacOSX10.6.sdk - # should we install more than these? (fixed includes?) - # Add links to libstdc++ so that "clang++ -stdlib=libstdc++ -isysroot /Developer/SDKs/MacOSX10.6.sdk -Wl,-syslibroot,/Developer/SDKs/MacOSX10.6.sdk -mmacosx-version-min=10.6" works - ln -s libstdc++.6.dylib $SDKROOT/usr/lib/libstdc++.dylib - - # fix buggy hashtable include (see above for explanations) - cp hashtable-gcc-4.0.4 $SDKROOT/usr/include/c++/4.0.0/tr1/hashtable - - if [ "$osx105" = 1 ]; then - # we also need to copy /usr/lib/libgcc_s.10.5.dylib from 10.6 SDK to 10.5SDK, see https://trac.macports.org/wiki/LeopardSDKFixes - # This should fix compiling the following: - # int main() { __uint128_t a = 100; __uint128_t b = 200; __uint128_t c = a / b; return 0; } - # with clang -isysroot /Developer/SDKs/MacOSX10.5.sdk -Wl,-syslibroot,/Developer/SDKs/MacOSX10.5.sdk -mmacosx-version-min=10.5 conftest1.c - cp /tmp/XC3-10.5/SDKs/MacOSX10.5.sdk/usr/lib/libgcc_s.10.5.dylib /tmp/XC3-10.5/SDKs/MacOSX10.5.sdk/usr/lib/libgcc_s.10.5.dylib.bak - cp $SDKROOT/usr/lib/libgcc_s.10.5.dylib /tmp/XC3-10.5/SDKs/MacOSX10.5.sdk/usr/lib/libgcc_s.10.5.dylib - - ( (cd /tmp/XC3-10.5 || exit; tar cf - SDKs/MacOSX10.5.sdk) | gzip -c > Xcode105SDK.tar.gz) && echo "*** Created Xcode105SDK.tar.gz in directory $(pwd)" - fi - if [ "$osx106" = 1 ]; then - ( (cd /tmp/XC3 || exit; tar cf - SDKs/MacOSX10.6.sdk) | gzip -c > Xcode106SDK.tar.gz) && echo "*** Created Xcode106SDK.tar.gz in directory $(pwd)" - fi - rm -rf /tmp/XC3-10.5 /tmp/XC3 - fi - hdiutil detach "$MNTDIR/Xcode and iOS SDK" -force - fi - - if [ "$xc4" = 1 ]; then - hdiutil attach xcode4630916281a.dmg "${ATTACH_OPTS[@]}" - if [ ! -d "$MNTDIR/Xcode" ]; then - echo "*** Error while trying to attach disk image xcode4630916281a.dmg" - echo "Aborting" - rmdir "$MNTDIR" - exit - fi - if [ "$osx107" = 1 ]; then - ( (cd "$MNTDIR/Xcode/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer" || exit; tar cf - SDKs/MacOSX10.7.sdk) | gzip -c > Xcode107SDK.tar.gz) && echo "*** Created Xcode107SDK.tar.gz in directory $(pwd)" - fi - if [ "$compilers" = 1 ]; then - ( (cd "$MNTDIR/Xcode/Xcode.app/Contents/PlugIns/Xcode3Core.ideplugin/Contents/SharedSupport/Developer/Library/Xcode/Plug-ins" || exit; tar cf - "GCC 4.2.xcplugin") | gzip -c > XcodePluginGCC42-Xcode4.tar.gz) && echo "*** Created XcodePluginGCC42-Xcode4.tar.gz in directory $(pwd)" - ( (cd "$MNTDIR/Xcode/Xcode.app/Contents/PlugIns/Xcode3Core.ideplugin/Contents/SharedSupport/Developer/Library/Xcode/Plug-ins" || exit; tar cf - "LLVM GCC 4.2.xcplugin") | gzip -c > XcodePluginLLVMGCC42.tar.gz) && echo "*** Created XcodePluginLLVMGCC42.tar.gz in directory $(pwd)" - fi - hdiutil detach "$MNTDIR/Xcode" -force - fi - - if [ "$xc5" = 1 ]; then - hdiutil attach xcode_5.1.1.dmg "${ATTACH_OPTS[@]}" - if [ ! -d "$MNTDIR/Xcode" ]; then - echo "*** Error while trying to attach disk image xcode_5.1.1.dmg" - echo "Aborting" - rmdir "$MNTDIR" - exit - fi - if [ "$osx108" = 1 ]; then - ( (cd "$MNTDIR/Xcode/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer" || exit; tar cf - SDKs/MacOSX10.8.sdk) | gzip -c > Xcode108SDK.tar.gz) && echo "*** Created Xcode108SDK.tar.gz in directory $(pwd)" - fi - hdiutil detach "$MNTDIR/Xcode" -force - fi - - if [ "$xc6" = 1 ]; then - hdiutil attach Xcode_6.4.dmg "${ATTACH_OPTS[@]}" - if [ ! -d "$MNTDIR/Xcode" ]; then - echo "*** Error while trying to attach disk image Xcode_6.4.dmg" - echo "Aborting" - rmdir "$MNTDIR" - exit - fi - if [ "$osx109" = 1 ]; then - ( (cd "$MNTDIR/Xcode/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer" || exit; tar cf - SDKs/MacOSX10.9.sdk) | gzip -c > Xcode109SDK.tar.gz) && echo "*** Created Xcode109SDK.tar.gz in directory $(pwd)" - fi - if [ "$osx1010" = 1 ]; then - ( (cd "$MNTDIR/Xcode/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer" || exit; tar cf - SDKs/MacOSX10.10.sdk) | gzip -c > Xcode1010SDK.tar.gz) && echo "*** Created Xcode1010SDK.tar.gz in directory $(pwd)" - fi - hdiutil detach "$MNTDIR/Xcode" -force - fi - if [ "$xc7" = 1 ]; then - hdiutil attach Xcode_7.3.1.dmg "${ATTACH_OPTS[@]}" - if [ ! -d "$MNTDIR/Xcode" ]; then - echo "*** Error while trying to attach disk image Xcode_7.3.1.dmg" - echo "Aborting" - rmdir "$MNTDIR" - exit - fi - if [ "$osx1011" = 1 ]; then - ( (cd "$MNTDIR/Xcode/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer" || exit; tar cf - SDKs/MacOSX10.11.sdk) | gzip -c > Xcode1011SDK.tar.gz) && echo "*** Created Xcode1011SDK.tar.gz in directory $(pwd)" - fi - hdiutil detach "$MNTDIR/Xcode" -force - fi - if [ "$xc8" = 1 ]; then - if [ "$osx1012" = 1 ]; then - echo "Extracting Mac OS X 10.12 SDK from Xcode 8.3.3. Be patient - this will take some time" - open Xcode8.3.3.xip - while [ ! -d Xcode.app ]; do - sleep 5 - done - sleep 5 - ( (cd "Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer" || exit; rm SDKs/MacOSX10.12.sdk; mv SDKs/MacOSX.sdk SDKs/MacOSX10.12.sdk; tar cf - SDKs/MacOSX10.12.sdk) | gzip -c > Xcode1012SDK.tar.gz) && echo "*** Created Xcode1012SDK.tar.gz in directory $(pwd)" - rm -rf Xcode.app - fi - fi - if [ "$xc9" = 1 ]; then - if [ "$osx1013" = 1 ]; then - echo "Extracting Mac OS X 10.13 SDK from Xcode 9.4.1. Be patient - this will take some time" - open Xcode_9.4.1.xip - while [ ! -d Xcode.app ]; do - sleep 5 - done - sleep 5 - ( (cd "Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer" || exit; rm SDKs/MacOSX10.13.sdk; mv SDKs/MacOSX.sdk SDKs/MacOSX10.13.sdk; tar cf - SDKs/MacOSX10.13.sdk) | gzip -c > Xcode1013SDK.tar.gz) && echo "*** Created Xcode1013SDK.tar.gz in directory $(pwd)" - rm -rf Xcode.app - fi - fi - rmdir "$MNTDIR" - ;; - - install|installbeta) - ####################### - # PHASE 2: INSTALLING - # - if [ $EUID -ne 0 ]; then - echo "*** Error: The install phase requires administrative rights. Please run it as:" - echo " $ sudo $0 install" - exit 1 - fi - if [ ! -d "$PLUGINDIR" ]; then - echo "*** Error: could not find Xcode 4.2 in /Developer/Applications nor Xcode >= 4.3 in /Applications, cannot install" - exit 1 - fi - if [ "$compilers" = 1 ]; then - if [ -d "$PLUGINDIR/GCC 4.0.xcplugin" ]; then - echo "*** Not installing XcodePluginGCC40.tar.gz (found installed in $PLUGINDIR/GCC 4.0.xcplugin, uninstall first to force install)" - else - (gzip -dc XcodePluginGCC40.tar.gz | (cd "$PLUGINDIR" || exit; tar xf -)) && touch "$PLUGINDIR/GCC 4.0.xcplugin/legacy" && echo "*** installed XcodePluginGCC40.tar.gz" - # Add entries expected by later xcodebuilds. - mv "$PLUGINDIR/GCC 4.0.xcplugin/Contents/Resources/GCC 4.0.xcspec" "$PLUGINDIR/GCC 4.0.xcplugin/Contents/Resources/GCC 4.0.xcspec-original" - sed '$ i\ -\ ExecDescription = \"Compile \$\(InputFile\)\"\;\ -\ ProgressDescription = \"Compiling \$\(InputFile\)\"\;\ -\ ExecDescriptionForPrecompile = \"Precompile \$\(InputFile\)\"\;\ -\ ProgressDescriptionForPrecompile = \"Precompiling \$\(InputFile\)\"\; -' < "$PLUGINDIR/GCC 4.0.xcplugin/Contents/Resources/GCC 4.0.xcspec-original" > "$PLUGINDIR/GCC 4.0.xcplugin/Contents/Resources/GCC 4.0.xcspec" - - echo "*** modified GCC 4.0.xcspec" - fi - if [ -d "$PLUGINDIR/GCC 4.2.xcplugin" ] && [ ! -f "$PLUGINDIR/GCC 4.2.xcplugin/Contents/Resources/GCC Generic.xcspec" ]; then - echo "*** Not installing XcodePluginGCC42.tar.gz (found installed in $PLUGINDIR/GCC 4.2.xcplugin, uninstall first to force install)" - else - if [ -f "$PLUGINDIR/GCC 4.2.xcplugin/Contents/Resources/GCC Generic.xcspec" ]; then - mv "$PLUGINDIR/GCC 4.2.xcplugin" "$PLUGINDIR/GCC 4.2.xcplugin-original" - fi - (gzip -dc XcodePluginGCC42.tar.gz | (cd "$PLUGINDIR" || exit; tar xf -)) && touch "$PLUGINDIR/GCC 4.2.xcplugin/legacy" && echo "*** installed XcodePluginGCC42.tar.gz" - # Add entries expected by later xcodebuilds. - mv "$PLUGINDIR/GCC 4.2.xcplugin/Contents/Resources/GCC 4.2.xcspec" "$PLUGINDIR/GCC 4.2.xcplugin/Contents/Resources/GCC 4.2.xcspec-original" - sed '$ i\ -\ ExecDescription = \"Compile \$\(InputFile\)\"\;\ -\ ProgressDescription = \"Compiling \$\(InputFile\)\"\;\ -\ ExecDescriptionForPrecompile = \"Precompile \$\(InputFile\)\"\;\ -\ ProgressDescriptionForPrecompile = \"Precompiling \$\(InputFile\)\"\; -' < "$PLUGINDIR/GCC 4.2.xcplugin/Contents/Resources/GCC 4.2.xcspec-original" > "$PLUGINDIR/GCC 4.2.xcplugin/Contents/Resources/GCC 4.2.xcspec" - echo "*** modified GCC 4.2.xcspec" - fi - if [ -d "$PLUGINDIR/LLVM GCC 4.2.xcplugin" ]; then - echo "*** Not installing XcodePluginLLVMGCC42.tar.gz (found installed in $PLUGINDIR/LLVM GCC 4.2.xcplugin, uninstall first to force install)" - else - (gzip -dc XcodePluginLLVMGCC42.tar.gz | (cd "$PLUGINDIR" || exit; tar xf -)) && touch "$PLUGINDIR/LLVM GCC 4.2.xcplugin/legacy" && echo "*** installed XcodePluginLLVMGCC42.tar.gz" - fi - - if [ -f "$GCCDIR/usr/libexec/gcc/darwin/ppc/as" ]; then - echo "*** Not installing Xcode3as.tar.gz (found installed in $GCCDIR/usr/libexec/gcc/darwin/ppc/as, uninstall first to force install)" - else - (gzip -dc Xcode3as.tar.gz | (cd "$GCCDIR" || exit; tar xf -)) - mkdir -p "$GCCINSTALLDIR/usr/bin" - mkdir -p "$GCCINSTALLDIR/usr/libexec/as/ppc" - mkdir -p "$GCCINSTALLDIR/usr/libexec/as/ppc64" - mkdir -p "$GCCINSTALLDIR/usr/libexec/as/i386" - mkdir -p "$GCCINSTALLDIR/usr/libexec/as/x86_64" - ln -sf "$GCCDIR/usr/libexec/gcc/darwin/ppc/as" "$GCCINSTALLDIR/usr/libexec/as/ppc/as" - ln -sf "$GCCDIR/usr/libexec/gcc/darwin/ppc64/as" "$GCCINSTALLDIR/usr/libexec/as/ppc64/as" - # Xcodes >= 4 already include an acceptable GNU legacy assembler - # (v1.38) for i386 and x86_64 in $GCCINSTALLDIR/usr/libexec/as. - # When they no longer do, enable these links (conditionally, - # of course). - #ln -sf "$GCCDIR/usr/libexec/gcc/darwin/i386/as" "$GCCINSTALLDIR/usr/libexec/as/i386/as" - #ln -sf "$GCCDIR/usr/libexec/gcc/darwin/x86_64/as" "$GCCINSTALLDIR/usr/libexec/as/x86_64/as" - - # Replace Xcode's modern toolchain assembler with a script - # that auto-selects the proper legacy assembler based on the - # command line's -arch parameter. Using a legacy assembler fixes - # "ld: too many personality routines for compact unwind" errors - # and "section '__textcoal_nt' is deprecated" warnings emitted - # by Xcode 7+ assemblers. - # First, though, don't overwrite the original assembler if - # XcodeLegacy is installed twice. - if [ -f "$GCCINSTALLDIR/usr/bin/as" ] && [ ! -f "$GCCINSTALLDIR/usr/bin/as-original" ]; then - mv "$GCCINSTALLDIR/usr/bin/as" "$GCCINSTALLDIR/usr/bin/as-original" - fi - # NB: While only gcc uses the assembler in our builds (it pipes the - # output of usr/libexec/gcc/*-apple-darwin10/4.*/ccobj1plus into - # usr/libexec/gcc/*-apple-darwin10/4.*/as -> usr/bin/as), we can't - # simply change the link to, say, usr/libexec/gcc/darwin/i386/as - # because the assembler seems to want the -arch parameter to match - # its containing folder. Hence, a script (like for ld, below). - # NB: To keep it simple, the script assumes that anyone invoking - # the toolchain's usr/bin/as wants to use Xcode 3's assembler. - # NB: AS_DIR resolves as the directory of the (source) link that - # invoked the script. - - # Note that we don't look for AS in $AS_DIR/../libexec/as/\$ARCH/as - # because gprbuild (from GNU Ada) calls as with both -m and -arch - # flags, and the arch-specific as doesn'b understand -m32 or -m64. - # We just look for as in a few places, and if it's not there, we - # look for as-original, starting in the current dir. - # In any case, we prune -m32 and -m64 from the as args. - # see https://github.com/devernay/xcodelegacy/issues/33 - cat <> "$GCCINSTALLDIR"/usr/bin/as -#!/bin/bash - -ARCH='' -ARCH_FOUND=0 -AS_ARGS=() -for var in "\$@" -do - if [ -z "\$ARCH" ] && [ "\$ARCH_FOUND" -eq '1' ]; then - ARCH="\$var" - AS_ARGS+=("\$var") - elif [ "\$var" = '-arch' ]; then - ARCH_FOUND=1 - AS_ARGS+=("\$var") - elif [ "\$var" = '-m32' ]; then - true - elif [ "\$var" = '-m64' ]; then - true - else - AS_ARGS+=("\$var") - fi -done - -AS_DIR=\`dirname "\$0"\` -AS_FOUND=0 -if [ "\$ARCH_FOUND" -eq '1' ]; then - if [ -x "\$AS_DIR/../../../as/\$ARCH/as" ]; then - AS="\$AS_DIR/../../../as/\$ARCH/as" - AS_FOUND=1 - elif [ -x "\$AS_DIR/../../../../../libexec/as/\$ARCH/as" ]; then - AS="\$AS_DIR/../../../../../libexec/as/\$ARCH/as" - AS_FOUND=1 - elif [ -x "\$AS_DIR/../../../../../../../usr/libexec/as/\$ARCH/as" ]; then - AS="\$AS_DIR/../../../../../../../usr/libexec/as/\$ARCH/as" - AS_FOUND=1 - fi -fi -if [ "\$AS_FOUND" -eq '1' ]; then - exec \$AS "\${AS_ARGS[@]}" -else - if [ -x "\$AS_DIR/as-original" ]; then - ASORIGINAL="\$AS_DIR/as-original" - elif [ -x "\$AS_DIR/../../../bin/as-original" ]; then - ASORIGINAL="\$AS_DIR/../../../bin/as-original" - elif [ -x "\$AS_DIR/../../../../bin/as-original" ]; then - ASORIGINAL="\$AS_DIR/../../../../bin/as-original" - elif [ -x "\$AS_DIR/../../../../../bin/as-original" ]; then - ASORIGINAL="\$AS_DIR/../../../../../bin/as-original" - else - echo "Error: cannot find as-original in \$AS_DIR/as-original or \$AS_DIR/../../../bin/as-original or \$AS_DIR/../../../../bin/as-original or \$AS_DIR/../../../../../bin/as-original" - exit 1 - fi - - exec \$ASORIGINAL "\$@" -fi -AS_EOF - chmod +x "$GCCINSTALLDIR/usr/bin/as" - echo "*** installed Xcode3as.tar.gz" - fi - - if [ -f "$GCCDIR/usr/libexec/gcc/darwin/ppc/ld" ]; then - echo "*** Not installing Xcode3ld.tar.gz (found installed in $GCCDIR/usr/libexec/gcc/darwin/ppc/ld, uninstall first to force install)" - elif [ $XCODE42 -eq 1 ]; then - echo "*** Not installing Xcode3ld.tar.gz (not required for Xcode <= 4.2.1)" - else - mkdir -p "$GCCDIR/tmp" - (gzip -dc Xcode3ld.tar.gz | (cd "$GCCDIR/tmp" || exit; tar xf -)) - cp "$GCCDIR/tmp/usr/bin/ld" "$GCCDIR/usr/libexec/gcc/darwin/ppc/" - ln "$GCCDIR/usr/libexec/gcc/darwin/ppc/ld" "$GCCDIR/usr/libexec/gcc/darwin/ppc64/ld" - rm -rf "$GCCDIR/tmp" - mkdir -p "$GCCINSTALLDIR/usr/libexec/ld/ppc" - mkdir -p "$GCCINSTALLDIR/usr/libexec/ld/ppc7400" - mkdir -p "$GCCINSTALLDIR/usr/libexec/ld/ppc970" - mkdir -p "$GCCINSTALLDIR/usr/libexec/ld/ppc64" - ln -sf "$GCCDIR/usr/libexec/gcc/darwin/ppc/ld" "$GCCINSTALLDIR/usr/libexec/ld/ppc/ld" - ln -sf "$GCCDIR/usr/libexec/gcc/darwin/ppc/ld" "$GCCINSTALLDIR/usr/libexec/ld/ppc7400/ld" - ln -sf "$GCCDIR/usr/libexec/gcc/darwin/ppc/ld" "$GCCINSTALLDIR/usr/libexec/ld/ppc970/ld" - ln -sf "$GCCDIR/usr/libexec/gcc/darwin/ppc64/ld" "$GCCINSTALLDIR/usr/libexec/ld/ppc64/ld" - # Xcode 8's ld fails to link i386 and x86_64 for OSX 10.5: https://github.com/devernay/xcodelegacy/issues/30 - # Since this ld is from Xcode 3.2.6 for OSX 10.6, this should be OK if the target OS is < 10.6 - # (which is checked by the stub ld script) - for arch in i386 x86_64; do - mkdir -p "$GCCDIR/usr/libexec/gcc/darwin/$arch" - ln "$GCCDIR/usr/libexec/gcc/darwin/ppc/ld" "$GCCDIR/usr/libexec/gcc/darwin/$arch/ld" - mkdir -p "$GCCINSTALLDIR/usr/libexec/ld/$arch" - ln -sf "$GCCDIR/usr/libexec/gcc/darwin/$arch/ld" "$GCCINSTALLDIR/usr/libexec/ld/$arch/ld" - done - # prevent overwriting the original ld if the script is run twice - if [ ! -f "$GCCINSTALLDIR/usr/bin/ld-original" ]; then - mv "$GCCINSTALLDIR/usr/bin/ld" "$GCCINSTALLDIR/usr/bin/ld-original" - fi - cat <> "$GCCINSTALLDIR"/usr/bin/ld -#!/bin/bash - -ARCH='' -ARCH_FOUND=0 -for var in "\$@" -do - if [ "\$ARCH_FOUND" -eq '1' ]; then - ARCH=\$var - ARCH_FOUND=2 - break - else - case "\$var" in - -mmacosx-version-min=10.[0-6]) - MACOSX_DEPLOYMENT_TARGET=\$( echo \$var | sed -e s/-mmacosx-version-min=// ) - ;; - -arch) - if [ "\$ARCH_FOUND" -ne '0' ]; then - echo "Warning: ld: multiple -arch flags" - fi - ARCH_FOUND=1 - ;; - esac - fi -done - -# use the old (Snow Leopard 10.6) ld only if ppc arch or the target macOS is <= 10.6 -USE_OLD_LD=0 -case "\$ARCH" in - ppc*) #ppc ppc7400 ppc970 ppc64 - USE_OLD_LD=1 - ;; -esac - -if [ -n \${MACOSX_DEPLOYMENT_TARGET+x} ]; then - # MACOSX_DEPLOYMENT_TARGET can either be set externally as an env variable, - # or as an ld option using -mmacosx-version-min=10.x - case "\${MACOSX_DEPLOYMENT_TARGET}" in - 10.[0-6]) - USE_OLD_LD=1 - ;; - esac -fi - -#echo "Running ld for \$ARCH ..." - -LD_DIR=\`dirname "\$0"\` -if [ -x "\$LD_DIR/ld-original" ]; then - LDORIGINAL="\$LD_DIR/ld-original" -elif [ -x "\$LD_DIR/../../../../bin/ld-original" ]; then - LDORIGINAL="\$LD_DIR/../../../../bin/ld-original" -elif [ -x "\$LD_DIR/../../../../../bin/ld-original" ]; then - LDORIGINAL="\$LD_DIR/../../../../../bin/ld-original" -else - echo "Error: cannot find ld-original in \$LD_DIR \$LD_DIR/../../../../bin or \$LD_DIR/../../../../../bin" - exit 1 -fi -LD_RESULT=255 -if [ "\$USE_OLD_LD" -eq '1' ]; then - ARGS=() - # strip the -dependency_info xxx, -object_path_lto xxx, -no_deduplicate, -export_dynamic flags - DEPINFO_FOUND=0 - OBJECT_PATH_LTO_FOUND=0 - for var in "\$@"; do - if [ "\$DEPINFO_FOUND" -eq '1' ]; then - DEPINFO_FOUND=0 - continue - elif [ "\$OBJECT_PATH_LTO_FOUND" -eq '1' ]; then - OBJECT_PATH_LTO_FOUND=0 - continue - elif [ "\$var" = '-dependency_info' ]; then - DEPINFO_FOUND=1 - continue - elif [ "\$var" = '-object_path_lto' ]; then - OBJECT_PATH_LTO_FOUND=1 - continue - elif [ "\$var" = '-no_deduplicate' ]; then - continue - elif [ "\$var" = '-export_dynamic' ]; then - continue - fi - - ARGS+=("\$var") - done - # the old ld is put in the ppc dir so as not to disturb more recent archs (i386, x86_64) - # works with ppc ppc7400 ppc970 ppc64 i386 x86_64 - LDARCHDIR=ppc - if [ -x "\$LD_DIR/../libexec/ld/\$LDARCHDIR/ld" ]; then - LD="\$LD_DIR/../libexec/ld/\$LDARCHDIR/ld" - elif [ -x "\$LD_DIR/../../../libexec/ld/\$LDARCHDIR/ld" ]; then - LD="\$LD_DIR/../../../libexec/ld/\$LDARCHDIR/ld" - elif [ -x "\$LD_DIR/../../../../libexec/ld/\$LDARCHDIR/ld" ]; then - LD="\$LD_DIR/../../../../libexec/ld/\$LDARCHDIR/ld" - elif [ -x "\$LD_DIR/../../../../../libexec/ld/\$LDARCHDIR/ld" ]; then - LD="\$LD_DIR/../../../../../libexec/ld/\$LDARCHDIR/ld" - else - echo "Error: cannot find ld for \$ARCH in \$LD_DIR/../libexec/ld/\$LDARCHDIR \$LD_DIR/../../../libexec/ld/\$LDARCHDIR \$LD_DIR/../../../../libexec/ld/\$LDARCHDIR or \$LD_DIR/../../../../../libexec/ld/\$LDARCHDIR" - exit 1 - fi - - \`\$LD "\${ARGS[@]}"\` - LD_RESULT=\$? -else - \`\$LDORIGINAL "\$@"\` - LD_RESULT=\$? -fi - -exit \$LD_RESULT -LD_EOF - chmod +x "$GCCINSTALLDIR/usr/bin/ld" - echo "*** installed Xcode3ld.tar.gz" - fi - - if [ -f "$PLATFORMDIR/Developer/Library/Xcode/Specifications/MacOSX Architectures.xcspec-original" ]; then - echo "*** Not modifying MacOSX Architectures.xcspec (found original at $PLATFORMDIR/Developer/Library/Xcode/Specifications/MacOSX Architectures.xcspec-original, uninstall first to force install)" - else - mv "$PLATFORMDIR/Developer/Library/Xcode/Specifications/MacOSX Architectures.xcspec" "$PLATFORMDIR/Developer/Library/Xcode/Specifications/MacOSX Architectures.xcspec-original" - { awk 'NR>1{print l}{l=$0}' "$PLATFORMDIR/Developer/Library/Xcode/Specifications/MacOSX Architectures.xcspec-original"; cat - < "$PLATFORMDIR/Developer/Library/Xcode/Specifications/MacOSX Architectures.xcspec" - { - Type = Architecture; - Identifier = ppc; - Name = "Minimal (32-bit PowerPC only)"; - Description = "32-bit PowerPC"; - "PerArchBuildSettingName" = PowerPC; - ByteOrder = big; - ListInEnum = YES; - SortNumber = 201; - }, - { - Type = Architecture; - Identifier = ppc7400; - Name = "PowerPC G4"; - Description = "32-bit PowerPC for G4 processor"; - ByteOrder = big; - ListInEnum = YES; - SortNumber = 202; - }, - { - Type = Architecture; - Identifier = ppc970; - Name = "PowerPC G5 32-bit"; - Description = "32-bit PowerPC for G5 processor"; - ByteOrder = big; - ListInEnum = YES; - SortNumber = 203; - }, - { - Type = Architecture; - Identifier = ppc64; - Name = "PowerPC 64-bit"; - Description = "64-bit PowerPC"; - "PerArchBuildSettingName" = "PowerPC 64-bit"; - ByteOrder = big; - ListInEnum = YES; - SortNumber = 204; - }, -) -SPEC_EOF - echo "*** modified MacOSX Architectures.xcspec" - fi - fi - - if [ "$osx104" = 1 ]; then - if [ -d "$SDKDIR/SDKs/MacOSX10.4u.sdk" ]; then - echo "*** Not installing Xcode104SDK.tar.gz (found installed in $SDKDIR/SDKs/MacOSX10.4u.sdk, uninstall first to force install)" - else - (gzip -dc Xcode104SDK.tar.gz | (cd "$SDKDIR" || exit; tar xf -)) && echo "*** installed Xcode104SDK.tar.gz" - touch "$SDKDIR/SDKs/MacOSX10.4u.sdk/legacy" - fi - fi - - if [ "$osx105" = 1 ]; then - if [ -d "$SDKDIR/SDKs/MacOSX10.5.sdk" ]; then - echo "*** Not installing Xcode105SDK.tar.gz (found installed in $SDKDIR/SDKs/MacOSX10.5.sdk, uninstall first to force install)" - else - (gzip -dc Xcode105SDK.tar.gz | (cd "$SDKDIR" || exit; tar xf -)) && echo "*** installed Xcode105SDK.tar.gz" - touch "$SDKDIR/SDKs/MacOSX10.5.sdk/legacy" - fi - fi - - if [ "$osx106" = 1 ]; then - if [ -d "$SDKDIR/SDKs/MacOSX10.6.sdk" ]; then - echo "*** Not installing Xcode106SDK.tar.gz (found installed in $SDKDIR/SDKs/MacOSX10.6.sdk, uninstall first to force install)" - else - (gzip -dc Xcode106SDK.tar.gz | (cd "$SDKDIR" || exit; tar xf -)) && echo "*** installed Xcode106SDK.tar.gz" - touch "$SDKDIR/SDKs/MacOSX10.6.sdk/legacy" - fi - fi - - if [ "$osx107" = 1 ]; then - installSDK 10.7 - fi - - if [ "$osx108" = 1 ]; then - installSDK 10.8 - fi - - if [ "$osx109" = 1 ]; then - installSDK 10.9 - fi - - if [ "$osx1010" = 1 ]; then - installSDK 10.10 - fi - - if [ "$osx1011" = 1 ]; then - installSDK 10.11 - fi - - if [ "$osx1012" = 1 ]; then - installSDK 10.12 - fi - - if [ "$osx1013" = 1 ]; then - installSDK 10.13 - fi - - if [ "$compilers" = 1 ]; then - if [ -f /usr/bin/gcc-4.0 ]; then - #echo "*** Not installing xcode_3.2.6_gcc4.0.pkg (found installed in /usr/bin/gcc-4.0, uninstall first to force install)" - echo "*** Not installing Xcode3gcc40.tar.gz (found installed in /usr/bin/gcc-4.0, uninstall first to force install)" - elif [ -f "$GCCINSTALLDIR/usr/bin/gcc-4.0" ]; then - echo "*** Not installing Xcode3gcc40.tar.gz (found installed in $GCCINSTALLDIR/usr/bin/gcc-4.0, uninstall first to force install)" - else - echo "*** Installing GCC 4.0" - #installer -pkg xcode_3.2.6_gcc4.0.pkg -target / - (gzip -dc Xcode3gcc40.tar.gz | (cd "$GCCINSTALLDIR" || exit; tar xf -)) && echo "*** installed Xcode3gcc40.tar.gz" - fi - if [ -f /usr/bin/gcc-4.2 ]; then - #echo "*** Not installing xcode_3.2.6_gcc4.2.pkg (found installed in /usr/bin/gcc-4.2, uninstall first to force install)" - echo "*** Not installing Xcode3gcc42.tar.gz (found installed in /usr/bin/gcc-4.2, uninstall first to force install)" - elif [ -f "$GCCINSTALLDIR/usr/bin/gcc-4.2" ]; then - echo "*** Not installing Xcode3gcc42.tar.gz (found installed in $GCCINSTALLDIR/usr/bin/gcc-4.2, uninstall first to force install)" - else - echo "*** Installing GCC 4.2" - #installer -pkg xcode_3.2.6_gcc4.2.pkg -target / - (gzip -dc Xcode3gcc42.tar.gz | (cd "$GCCINSTALLDIR" || exit; tar xf -)) && echo "*** installed Xcode3gcc42.tar.gz" - fi - if [ -f "$GCCINSTALLDIR/usr/bin/llvm-gcc-4.2" ]; then - echo "*** Not installing Xcode3llvmgcc42.tar.gz (found installed in $GCCINSTALLDIR/usr/bin/llvm-gcc-4.2, uninstall first to force install)" - else - echo "*** Installing LLVM GCC 4.2" - #installer -pkg xcode_3.2.6_llvm-gcc4.2.pkg -target / - (gzip -dc Xcode3llvmgcc42.tar.gz | (cd "$GCCINSTALLDIR" || exit; tar xf -)) && echo "*** installed Xcode3llvmgcc42.tar.gz" - if [ -f "$GCCDIR/usr/llvm-gcc-4.2/bin/llvm-gcc-4.2" ]; then - for i in g++ gcc; do - ln -sf "$GCCINSTALLDIR"/usr/bin/powerpc-apple-darwin10-llvm-${i}-4.2 "$GCCDIR"/usr/bin/powerpc-apple-darwin"$RELEASENUM"-llvm-${i}-4.2 - ln -sf "$GCCINSTALLDIR"/usr/llvm-gcc-4.2/bin/powerpc-apple-darwin10-llvm-${i}-4.2 "$GCCDIR"/usr/llvm-gcc-4.2/bin/powerpc-apple-darwin"$RELEASENUM"-llvm-${i}-4.2 - ln -sf "$GCCINSTALLDIR"/usr/llvm-gcc-4.2/share/man/man1/powerpc-apple-darwin10-llvm-${i}.1.gz "$GCCDIR"/usr/llvm-gcc-4.2/share/man/man1/powerpc-apple-darwin"$RELEASENUM"-llvm-${i}.1.gz - done - ln -sf "$GCCINSTALLDIR"/usr/llvm-gcc-4.2/lib/gcc/powerpc-apple-darwin10 "$GCCDIR"/usr/llvm-gcc-4.2/lib/gcc/powerpc-apple-darwin10 - ln -sf "$GCCINSTALLDIR"/usr/llvm-gcc-4.2/libexec/gcc/powerpc-apple-darwin10 "$GCCDIR"/usr/llvm-gcc-4.2/libexec/gcc/powerpc-apple-darwin10 - fi - fi - - echo "*** Creating symbolic links to compliers in $GCCDIR and $GCCLINKDIR:" - if [ ! -d "$GCCDIR"/usr/bin ]; then - mkdir -p "$GCCDIR"/usr/bin - fi - if [ ! -d "$GCCLINKDIR"/bin ]; then - mkdir -p "$GCCLINKDIR"/bin - fi - for v in 4.0 4.2 4.0.1 4.2.1; do - for i in c++ cpp g++ gcc gcov llvm-cpp llvm-g++ llvm-gcc; do - for p in i686-apple-darwin10- powerpc-apple-darwin10- ""; do - if [ -f "$GCCINSTALLDIR"/usr/bin/${p}${i}-${v} ]; then - echo "$GCCINSTALLDIR"/usr/bin/${p}${i}-${v} exists - if [ ! -f "$GCCLINKDIR"/bin/${p}${i}-${v} ]; then - echo "* creating link $GCCLINKDIR/bin/${p}${i}-${v}" - ln -sf "$GCCINSTALLDIR"/usr/bin/${p}${i}-${v} "$GCCLINKDIR"/bin/${p}${i}-${v} - fi - if [ ! -f "$GCCDIR"/usr/bin/${p}${i}-${v} ]; then - echo "* creating link $GCCDIR/usr/bin/${p}${i}-${v}" - ln -sf "$GCCINSTALLDIR"/usr/bin/${p}${i}-${v} "$GCCDIR"/usr/bin/${p}${i}-${v} - fi - fi - done - done - done - # fix /usr/bin/gcc, see https://github.com/devernay/xcodelegacy/issues/19 - if [ -x /usr/bin/gcc ] && [ ! -x "$GCCINSTALLDIR/usr/bin/gcc" ] && [ -x "$GCCINSTALLDIR/usr/bin/clang" ]; then - # "xcode-select -r" sets /usr/bin/gcc to be the first gcc found in $GCCINSTALLDIR, which happens to be - # the directory $GCCINSTALLDIR/usr/libexec/gcc, and results in the following error: - # $ gcc - # gcc: error: can't exec '/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/libexec/gcc' (errno=Permission denied) - # by putting a link to clang (which is the default Xcode behavior), we fix this - ln -s clang "$GCCINSTALLDIR/usr/bin/gcc" - # run gcc once so that xcode-select finds the right file for gcc - gcc 1>/dev/null 2>/dev/null - fi - fi - - # Xcode >= 7.3 disables support for older SDKs in /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Info.plist - # see https://github.com/devernay/xcodelegacy/issues/23 - if [ -f "$PLATFORMDIR/Info.plist-original" ]; then - echo "*** Not modifying MacOSX Info.plist (found original at $PLATFORMDIR/Info.plist-original, uninstall first to force install)" - elif [ -f "$PLATFORMDIR/Info.plist" ]; then - mv "$PLATFORMDIR/Info.plist" "$PLATFORMDIR/Info.plist-original" - plutil -remove MinimumSDKVersion -o "$PLATFORMDIR/Info.plist" "$PLATFORMDIR/Info.plist-original" - echo "*** modified MacOSX Info.plist" - fi - - if [ ! -L /Developer/SDKs ] && [ $XCODE42 -ne 1 ]; then - echo "*** Warning: /Developer/SDKs should be a symlink to $SDKDIR/SDKs" - echo "Check that /Developer exists, and fix /Developer/SDKs with:" - echo " $ sudo ln -sf '$SDKDIR/SDKs' /Developer/SDKs" - fi - ;; - - cleanpackages) - ####################### - # PHASE 3: CLEANING - # - - if [ "$compilers" = 1 ]; then - rm XcodePluginGCC40.tar.gz Xcode3as.tar.gz Xcode3ld.tar.gz xcode_3.2.6_gcc4.0.pkg xcode_3.2.6_gcc4.2.pkg xcode_3.2.6_llvm-gcc4.2.pkg XcodePluginGCC42-Xcode4.tar.gz XcodePluginGCC42.tar.gz XcodePluginLLVMGCC42.tar.gz Xcode3gcc40.tar.gz Xcode3gcc42.tar.gz Xcode3llvmgcc42.tar.gz 2>/dev/null - fi - #for i in 10.4u 10.5 10.6 10.7 10.8 10.9 10.10; do - if [ "$osx104" = 1 ]; then - rm Xcode104SDK.tar.gz 2>/dev/null - fi - if [ "$osx105" = 1 ]; then - rm Xcode105SDK.tar.gz 2>/dev/null - fi - if [ "$osx106" = 1 ]; then - rm Xcode106SDK.tar.gz 2>/dev/null - fi - if [ "$osx107" = 1 ]; then - rm Xcode107SDK.tar.gz 2>/dev/null - fi - if [ "$osx108" = 1 ]; then - rm Xcode108SDK.tar.gz 2>/dev/null - fi - if [ "$osx109" = 1 ]; then - rm Xcode109SDK.tar.gz 2>/dev/null - fi - if [ "$osx1010" = 1 ]; then - rm Xcode1010SDK.tar.gz 2>/dev/null - fi - if [ "$osx1011" = 1 ]; then - rm Xcode1011SDK.tar.gz 2>/dev/null - fi - if [ "$osx1012" = 1 ]; then - rm Xcode1012SDK.tar.gz 2>/dev/null - fi - if [ "$osx1012" = 1 ]; then - rm Xcode1013SDK.tar.gz 2>/dev/null - fi - - ;; - - uninstall|uninstallbeta) - ####################### - # PHASE 4: UNINSTALLING - # - if [ $EUID -ne 0 ]; then - echo "*** Error: The uninstall phase requires administrative rights. Please run it as:" - echo " $ sudo $0 uninstall" - exit 1 - fi - - if [ "$compilers" = 1 ]; then - if [ -f "$PLUGINDIR/GCC 4.0.xcplugin/legacy" ]; then - rm -rf "$PLUGINDIR/GCC 4.0.xcplugin" - fi - if [ -f "$PLUGINDIR/GCC 4.2.xcplugin/legacy" ]; then - rm -rf "$PLUGINDIR/GCC 4.2.xcplugin" - fi - if [ -d "$PLUGINDIR/GCC 4.2.xcplugin-original" ]; then - mv "$PLUGINDIR/GCC 4.2.xcplugin-original" "$PLUGINDIR/GCC 4.2.xcplugin" - fi - if [ -f "$PLUGINDIR/LLVM GCC 4.2.xcplugin/legacy" ]; then - rm -rf "$PLUGINDIR/LLVM GCC 4.2.xcplugin" - fi - for f in "$GCCDIR/usr/libexec/gcc/darwin/ppc" \ - "$GCCDIR/usr/libexec/gcc/darwin/ppc64" \ - "$GCCDIR/usr/libexec/gcc/darwin/i386" \ - "$GCCDIR/usr/libexec/gcc/darwin/x86_64" \ - "$GCCINSTALLDIR/usr/libexec/as/ppc" \ - "$GCCINSTALLDIR/usr/libexec/as/ppc64" \ - "$GCCINSTALLDIR/usr/libexec/ld/ppc" \ - "$GCCINSTALLDIR/usr/libexec/ld/ppc7400" \ - "$GCCINSTALLDIR/usr/libexec/ld/ppc970" \ - "$GCCINSTALLDIR/usr/libexec/ld/ppc64" \ - "$GCCINSTALLDIR/usr/libexec/ld/i386" \ - "$GCCINSTALLDIR/usr/libexec/ld/x86_64"; do - if [ -e "$f" ]; then - rm -rf "$f" - fi - done - if [ -f "$GCCINSTALLDIR/usr/bin/as-original" ]; then - rm "$GCCINSTALLDIR/usr/bin/as" - mv -f "$GCCINSTALLDIR/usr/bin/as-original" "$GCCINSTALLDIR/usr/bin/as" - fi - if [ -f "$GCCINSTALLDIR/usr/bin/ld-original" ]; then - rm "$GCCINSTALLDIR/usr/bin/ld" - mv -f "$GCCINSTALLDIR/usr/bin/ld-original" "$GCCINSTALLDIR/usr/bin/ld" - fi - # preserve original LLVM-GCC on Xcode 4 and earlier - if [ ! -d "$GCCDIR/Library/Perl" ] || [ -d "$GCCDIR/Library/Perl/5.10" ]; then - mv "$GCCDIR"/usr/bin/{gcov,i686-apple-darwin"$RELEASENUM"-llvm-g{++,cc},llvm-{cpp,g++,gcc}}-4.2 "$GCCDIR" - (cd "$GCCDIR" || exit; rm -rf $GCCFILES ) - mv "$GCCDIR"/*-4.2 "$GCCDIR"/usr/bin - (cd "$GCCDIR/usr/llvm-gcc-4.2" || exit; rm -f {bin,lib/gcc,libexec/gcc,share/man/man1}/powerpc*) - else - [ -f "$GCCDIR/usr/bin/gcov-4.2" ] && [ ! -L "$GCCDIR/usr/bin/gcov-4.2" ] && mv "$GCCDIR/usr/bin/gcov-4.2" "$GCCDIR" - (cd "$GCCDIR" || exit; rm -rf $GCCFILES $LLVMGCCFILES) - [ -f "$GCCDIR/gcov-4.2" ] && mv "$GCCDIR/gcov-4.2" "$GCCDIR/usr/bin" - fi - (cd "$GCCINSTALLDIR" || exit; rm -rf $GCCFILES $LLVMGCCFILES) - rmdir "$GCCINSTALLDIR/usr/include/gcc/darwin" "$GCCINSTALLDIR/usr/include/gcc" || : - rmdir "$GCCINSTALLDIR/usr/lib/"{i686-apple-darwin10,powerpc-apple-darwin10}"/4.2.1" "$GCCINSTALLDIR/usr/lib/"{gcc/,}{i686-apple-darwin10,powerpc-apple-darwin10} "$GCCINSTALLDIR/usr/lib/gcc" || : - rmdir "$GCCINSTALLDIR/usr/libexec/gcc/"{i686-apple-darwin10,powerpc-apple-darwin10} "$GCCINSTALLDIR/usr/libexec/gcc" "$GCCINSTALLDIR/usr/libexec/ld" "$GCCDIR/usr/libexec/gcc/darwin" "$GCCDIR/usr/libexec/gcc" || : - rmdir "$GCCINSTALLDIR/usr/share/man/man7" || : - if [ -f "$PLATFORMDIR/Developer/Library/Xcode/Specifications/MacOSX Architectures.xcspec-original" ]; then - rm "$PLATFORMDIR/Developer/Library/Xcode/Specifications/MacOSX Architectures.xcspec" - mv -f "$PLATFORMDIR/Developer/Library/Xcode/Specifications/MacOSX Architectures.xcspec-original" "$PLATFORMDIR/Developer/Library/Xcode/Specifications/MacOSX Architectures.xcspec" - fi - fi - #for i in 10.4u 10.5 10.6 10.7 10.8 10.9 10.10; do - if [ "$osx104" = 1 ]; then - i=10.4u - [ -f "$SDKDIR/SDKs/MacOSX${i}.sdk/legacy" ] && rm -rf "$SDKDIR/SDKs/MacOSX${i}.sdk" - fi - if [ "$osx105" = 1 ]; then - i=10.5 - [ -f "$SDKDIR/SDKs/MacOSX${i}.sdk/legacy" ] && rm -rf "$SDKDIR/SDKs/MacOSX${i}.sdk" - fi - if [ "$osx106" = 1 ]; then - i=10.6 - [ -f "$SDKDIR/SDKs/MacOSX${i}.sdk/legacy" ] && rm -rf "$SDKDIR/SDKs/MacOSX${i}.sdk" - fi - if [ "$osx107" = 1 ]; then - i=10.7 - [ -f "$SDKDIR/SDKs/MacOSX${i}.sdk/legacy" ] && rm -rf "$SDKDIR/SDKs/MacOSX${i}.sdk" - fi - if [ "$osx108" = 1 ]; then - i=10.8 - [ -f "$SDKDIR/SDKs/MacOSX${i}.sdk/legacy" ] && rm -rf "$SDKDIR/SDKs/MacOSX${i}.sdk" - fi - if [ "$osx109" = 1 ]; then - i=10.9 - [ -f "$SDKDIR/SDKs/MacOSX${i}.sdk/legacy" ] && rm -rf "$SDKDIR/SDKs/MacOSX${i}.sdk" - fi - if [ "$osx1010" = 1 ]; then - i=10.10 - [ -f "$SDKDIR/SDKs/MacOSX${i}.sdk/legacy" ] && rm -rf "$SDKDIR/SDKs/MacOSX${i}.sdk" - fi - if [ "$osx1011" = 1 ]; then - i=10.11 - [ -f "$SDKDIR/SDKs/MacOSX${i}.sdk/legacy" ] && rm -rf "$SDKDIR/SDKs/MacOSX${i}.sdk" - fi - if [ "$osx1012" = 1 ]; then - i=10.12 - [ -f "$SDKDIR/SDKs/MacOSX${i}.sdk/legacy" ] && rm -rf "$SDKDIR/SDKs/MacOSX${i}.sdk" - fi - if [ "$osx1013" = 1 ]; then - i=10.13 - [ -f "$SDKDIR/SDKs/MacOSX${i}.sdk/legacy" ] && rm -rf "$SDKDIR/SDKs/MacOSX${i}.sdk" - fi - - if [ "$compilers" = 1 ]; then - if [ "$GCCINSTALLDIR/usr/bin/gcc" -ef "$GCCINSTALLDIR/usr/bin/clang" ]; then - rm "$GCCINSTALLDIR/usr/bin/gcc" - fi - for b in llvm-g++ llvm-gcc; do - if [ -L $GCCINSTALLDIR/usr/bin/$b ] && [ ! -e $GCCINSTALLDIR/usr/bin/$b ]; then - rm $GCCINSTALLDIR/usr/bin/$b - fi - done - for b in c++-4.0 cpp-4.0 c++-4.2 cpp-4.2 gcc-4.0 g++-4.0 gcov-4.0 gcc-4.2 g++-4.2 gcov-4.2 llvm-cpp-4.2 llvm-g++-4.2 llvm-gcc-4.2; do - if [ -L $GCCLINKDIR/bin/$b ] && [ ! -e $GCCLINKDIR/bin/$b ]; then - rm $GCCLINKDIR/bin/$b - fi - done - for b in cpp-4.2.1 gcc-4.0.1 g++-4.0.1 gcc-4.2.1 g++-4.2.1 llvm-g++-4.2 llvm-gcc-4.2; do - if [ -L $GCCLINKDIR/bin/i686-apple-darwin10-$b ] && [ ! -e $GCCLINKDIR/bin/i686-apple-darwin10-$b ]; then - rm $GCCLINKDIR/bin/i686-apple-darwin10-$b - fi - done - for b in cpp-4.2.1 gcc-4.0.1 g++-4.0.1 gcc-4.2.1 g++-4.2.1 llvm-g++-4.2 llvm-gcc-4.2; do - if [ -L $GCCLINKDIR/bin/powerpc-apple-darwin10-$b ] && [ ! -e $GCCLINKDIR/bin/powerpc-apple-darwin10-$b ]; then - rm $GCCLINKDIR/bin/powerpc-apple-darwin10-$b - fi - done - fi - if [ -f "$PLATFORMDIR/Info.plist-original" ] && [ $(ls -1 "$SDKDIR"/SDKs/MacOSX*.sdk/legacy 2>/dev/null | wc -l) -eq 0 ]; then - rm "$PLATFORMDIR/Info.plist" - mv -f "$PLATFORMDIR/Info.plist-original" "$PLATFORMDIR/Info.plist" - fi - - ;; - -esac - - - -# Local variables: -# mode: shell-script -# sh-basic-offset: 4 -# sh-indent-comment: t -# indent-tabs-mode: nil -# End: -# ex: ts=4 sw=4 et filetype=sh From 62b5efbe951bd7e4517f981eb18a6053afe3cc96 Mon Sep 17 00:00:00 2001 From: Dan Walmsley Date: Wed, 24 Apr 2019 20:19:30 +0100 Subject: [PATCH 41/41] use newer sdk --- azure-pipelines.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 36377acea3..3f4fbb0d50 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -49,7 +49,7 @@ jobs: inputs: actions: 'build' scheme: '' - sdk: 'macosx10.13' + sdk: 'macosx10.14' configuration: 'Release' xcWorkspacePath: '**/*.xcodeproj/project.xcworkspace' xcodeVersion: 'default' # Options: 8, 9, default, specifyPath