diff --git a/.gitignore b/.gitignore index 2695f2a71e..9caef6f3fd 100644 --- a/.gitignore +++ b/.gitignore @@ -6,6 +6,7 @@ [Bb]in/ packages/ TestResults/ +artifacts/ # globs Makefile.in @@ -39,7 +40,7 @@ Thumbs.db # dotCover *.dotCover - -src/Avalonia\.Native\.OSX/Avalonia\.Native\.OSX\.xcodeproj/project\.xcworkspace/xcshareddata/IDEWorkspaceChecks\.plist - -src/Avalonia\.Native\.OSX/Avalonia\.Native\.OSX\.xcodeproj/project\.xcworkspace/xcshareddata/WorkspaceSettings\.xcsettings + +src/Avalonia\.Native\.OSX/Avalonia\.Native\.OSX\.xcodeproj/project\.xcworkspace/xcshareddata/IDEWorkspaceChecks\.plist + +src/Avalonia\.Native\.OSX/Avalonia\.Native\.OSX\.xcodeproj/project\.xcworkspace/xcshareddata/WorkspaceSettings\.xcsettings diff --git a/azure-pipelines.yml b/azure-pipelines.yml new file mode 100644 index 0000000000..cf31ff2a8d --- /dev/null +++ b/azure-pipelines.yml @@ -0,0 +1,28 @@ + +pool: + vmImage: 'macOS 10.13' + +steps: +- bash: 'xcodebuild -showsdks' +- task: Xcode@5 + inputs: + actions: 'archive' + scheme: '' + sdk: 'macosx10.13' + configuration: 'Release' + xcWorkspacePath: '**/*.xcodeproj/project.xcworkspace' + xcodeVersion: 'default' # Options: 8, 9, default, specifyPath + args: '-derivedDataPath ./build' +- task: DotNetCoreInstaller@0 + inputs: + version: '2.1.401' +- script: | + brew install castxml + export COREHOST_TRACE=0 + export DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1 + export DOTNET_CLI_TELEMETRY_OPTOUT=1 + which dotnet + dotnet --info + dotnet tool install -g Cake.Tool --version 0.30.0 + export PATH="$PATH:$HOME/.dotnet/tools" + dotnet cake build.cake -Target="Azure" -Platform="Any CPU" -Configuration="Release" diff --git a/build.cake b/build.cake new file mode 100644 index 0000000000..0b356ec9bd --- /dev/null +++ b/build.cake @@ -0,0 +1,148 @@ +#load "./parameters.cake" + +Setup(context => +{ + Information("Running tasks..."); + return new Parameters(context); +}); + +Teardown((context, parameters) => +{ + Information("Finished running tasks."); +}); + +Task("Clean") + .Does(parameters => +{ + foreach(var project in parameters.BuildProjects) + { + (string path, string name) = project; + Information($"Clean: {name}"); + DotNetCoreClean($"{path}/{name}/{name}.csproj", new DotNetCoreCleanSettings { + Configuration = parameters.Configuration, + Verbosity = DotNetCoreVerbosity.Minimal + }); + } +}); + +Task("Build") + .Does(parameters => +{ + foreach(var project in parameters.BuildProjects) + { + (string path, string name) = project; + Information($"Build: {name}"); + DotNetCoreBuild($"{path}/{name}/{name}.csproj", new DotNetCoreBuildSettings { + Configuration = parameters.Configuration, + VersionSuffix = parameters.VersionSuffix + }); + } +}); + +Task("Test") + .Does(parameters => +{ + foreach(var project in parameters.TestProjects) + { + (string path, string name) = project; + Information($"Test: {name}"); + DotNetCoreTest($"{path}/{name}/{name}.csproj", new DotNetCoreTestSettings { + Configuration = parameters.Configuration + }); + } +}); + +Task("Publish") + .Does(parameters => +{ + CleanDirectory($"{parameters.Artifacts}/zip"); + var redistVersion = "14.15.26706"; + var redistPath = $"C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\Community\\VC\\Redist\\MSVC\\{redistVersion}\\x64\\Microsoft.VC141.CRT\\"; + var redistRuntime = "win7-x64"; + foreach(var project in parameters.PublishProjects) + { + (string path, string name, string framework, string runtime) = project; + var output = $"./{parameters.Artifacts}/publish/{name}-{framework}-{runtime}"; + Information($"Publish: {name}, {framework}, {runtime}"); + DotNetCorePublish($"{path}/{name}/{name}.csproj", new DotNetCorePublishSettings { + Configuration = parameters.Configuration, + VersionSuffix = parameters.VersionSuffix, + Framework = framework, + Runtime = runtime, + OutputDirectory = output + }); + if (string.Compare(runtime, redistRuntime, StringComparison.OrdinalIgnoreCase) == 0) + { + CopyFileToDirectory($"{redistPath}msvcp140.dll", output); + CopyFileToDirectory($"{redistPath}vcruntime140.dll", output); + } + Zip($"{parameters.Artifacts}/publish/{name}-{framework}-{runtime}", $"{parameters.Artifacts}/zip/{name}-{framework}-{runtime}.zip"); + } +}); + +Task("Pack") + .Does(parameters => +{ + CleanDirectory($"{parameters.Artifacts}/nuget"); + foreach(var project in parameters.PackProjects) + { + (string path, string name) = project; + Information($"Pack: {name}"); + DotNetCorePack($"{path}/{name}/{name}.csproj", new DotNetCorePackSettings { + Configuration = parameters.Configuration, + VersionSuffix = "parameters.VersionSuffix", + OutputDirectory = $"{parameters.Artifacts}/nuget", + EnvironmentVariables = new Dictionary + { + { "VERSION", parameters.Version } + } + }); + } +}); + +Task("Push") + .WithCriteria((context, parameters) => parameters.PushNuGet) + .Does(parameters => +{ + var apiKey = EnvironmentVariable(parameters.IsNugetRelease ? "NUGET_API_KEY" : "MYGET_API_KEY"); + var apiUrl = EnvironmentVariable(parameters.IsNugetRelease ? "NUGET_API_URL" : "MYGET_API_URL"); + var packages = GetFiles($"{parameters.Artifacts}/nuget/*.nupkg"); + foreach (var package in packages) + { + DotNetCoreNuGetPush(package.FullPath, new DotNetCoreNuGetPushSettings { + Source = apiUrl, + ApiKey = apiKey + }); + } +}); + +Task("Default") + .IsDependentOn("Build"); + +Task("AppVeyor") + .IsDependentOn("Clean") + .IsDependentOn("Build") + .IsDependentOn("Test") + .IsDependentOn("Publish") + .IsDependentOn("Pack") + .IsDependentOn("Push"); + +Task("Travis") + .IsDependentOn("Test"); + +Task("CircleCI") + .IsDependentOn("Test"); + +Task("Azure") + .IsDependentOn("Clean") + .IsDependentOn("Build") + .IsDependentOn("Pack") + .IsDependentOn("Push"); + +Task("Azure-macOS") + .IsDependentOn("Test"); + +Task("Azure-Linux") + .IsDependentOn("Test"); + +RunTarget(Context.Argument("target", "Default")); \ No newline at end of file diff --git a/parameters.cake b/parameters.cake new file mode 100644 index 0000000000..191620aa70 --- /dev/null +++ b/parameters.cake @@ -0,0 +1,74 @@ + +public class Parameters +{ + public string Configuration { get; private set; } + public string Artifacts { get; private set; } + public string VersionSuffix { get; private set; } + public string Version { get; private set; } = "0.7.0"; + public string NuGetPushBranch { get; private set; } + public string NuGetPushRepoName { get; private set; } + public bool PushNuGet { get; private set; } + public bool IsNugetRelease { get; private set; } + public (string path, string name)[] BuildProjects { get; private set; } + public (string path, string name)[] TestProjects { get; private set; } + public (string path, string name, string framework, string runtime)[] PublishProjects { get; private set; } + public (string path, string name)[] PackProjects { get; private set; } + + public Parameters(ICakeContext context) + { + Configuration = context.Argument("configuration", "Release"); + Artifacts = context.Argument("artifacts", "./artifacts"); + + VersionSuffix = context.Argument("suffix", default(string)); + if (VersionSuffix == null) + { + var build = context.EnvironmentVariable("BUILD_BUILDNUMBER"); + VersionSuffix = build != null ? $"-build{build}" : ""; + } + + Version += "-build" + context.EnvironmentVariable("BUILD_BUILDNUMBER").Replace(".",""); + + NuGetPushBranch = "master"; + NuGetPushRepoName = "https://github.com/AvaloniaUI/Avalonia.Native"; + + var repoName = context.EnvironmentVariable("BUILD_REPOSITORY_URI"); + var repoBranch = context.EnvironmentVariable("BUILD_SOURCEBRANCHNAME"); + var repoTag = context.EnvironmentVariable("APPVEYOR_REPO_TAG"); + var repoTagName = context.EnvironmentVariable("APPVEYOR_REPO_TAG_NAME"); + var pullRequestTitle = context.EnvironmentVariable("SYSTEM_PULLREQUEST_SOURCEBRANCH"); + + System.Console.WriteLine($"RepoName: {repoName}, RepoBranch: {repoBranch}, PR Title: {pullRequestTitle}/."); + + if (pullRequestTitle == null + && string.Compare(repoName, NuGetPushRepoName, StringComparison.OrdinalIgnoreCase) == 0 + && string.Compare(repoBranch, NuGetPushBranch, StringComparison.OrdinalIgnoreCase) == 0) + { + PushNuGet = true; + } + + if (pullRequestTitle == null + && string.Compare(repoTag, "True", StringComparison.OrdinalIgnoreCase) == 0 + && repoTagName != null) + { + IsNugetRelease = true; + } + + BuildProjects = new [] + { + ( "./src", "Avalonia.Native" ) + }; + + TestProjects = new (string path, string name) [] + { + }; + + PublishProjects = new (string path, string name, string framework, string runtime) [] + { + }; + + PackProjects = new [] + { + ( "./src", "Avalonia.Native" ) + }; + } +} \ No newline at end of file diff --git a/src/Avalonia.Native.OSX/window.mm b/src/Avalonia.Native.OSX/window.mm index d39ff1ce10..2c07518a64 100644 --- a/src/Avalonia.Native.OSX/window.mm +++ b/src/Avalonia.Native.OSX/window.mm @@ -594,7 +594,7 @@ NSArray* AllLoopModes = [NSArray arrayWithObjects: NSDefaultRunLoopMode, NSEvent } -- (NSArray *)validAttributesForMarkedText +- (NSArray *)validAttributesForMarkedText { return [NSArray new]; } diff --git a/src/Avalonia.Native/.AvaloniaNativePlatform.cs.swp b/src/Avalonia.Native/.AvaloniaNativePlatform.cs.swp new file mode 100644 index 0000000000..a27cc44268 Binary files /dev/null and b/src/Avalonia.Native/.AvaloniaNativePlatform.cs.swp differ diff --git a/src/Avalonia.Native/Avalonia.Native.csproj b/src/Avalonia.Native/Avalonia.Native.csproj index 7b0eef0a92..b3051bf550 100644 --- a/src/Avalonia.Native/Avalonia.Native.csproj +++ b/src/Avalonia.Native/Avalonia.Native.csproj @@ -20,4 +20,12 @@ + + + + runtimes/osx-x64/libAvalonia.Native.OSX.dylib + true + PreserveNewest + + diff --git a/src/Avalonia.Native/AvaloniaNativePlatform.cs b/src/Avalonia.Native/AvaloniaNativePlatform.cs index f59d8e3dcb..ead102d3d9 100644 --- a/src/Avalonia.Native/AvaloniaNativePlatform.cs +++ b/src/Avalonia.Native/AvaloniaNativePlatform.cs @@ -63,7 +63,8 @@ namespace Avalonia.Native _factory.Initialize(); AvaloniaLocator.CurrentMutable - .Bind().ToConstant(new CursorFactory(_factory.CreateCursor())) + .Bind().ToConstant(new PlatformThreadingInterface(_factory.CreatePlatformThreadingInterface())) + .Bind().ToTransient() .Bind().ToSingleton() .Bind().ToConstant(KeyboardDevice) .Bind().ToConstant(MouseDevice) @@ -72,8 +73,8 @@ namespace Avalonia.Native .Bind().ToConstant(new ClipboardImpl(_factory.CreateClipboard())) .Bind().ToConstant(new RenderLoop()) .Bind().ToConstant(new DefaultRenderTimer(60)) - .Bind().ToConstant(new SystemDialogs(_factory.CreateSystemDialogs())) - .Bind().ToConstant(new PlatformThreadingInterface(_factory.CreatePlatformThreadingInterface())); + .Bind().ToConstant(new SystemDialogs(_factory.CreateSystemDialogs())); + } public IWindowImpl CreateWindow()