Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 40 additions & 18 deletions build.cake
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ Task ("tests-android")
// package the app
FilePath csproj = "./tests/SkiaSharp.Android.Tests/SkiaSharp.Android.Tests.csproj";
RunMSBuild (csproj,
targets: new [] { "SignAndroidPackage" },
targets: new [] { "SignAndroidPackage" },
properties: new Dictionary<string, string> {
{ "BuildTestOnly", "true" },
},
Expand Down Expand Up @@ -463,7 +463,7 @@ Task ("samples")
{ "xamarin.forms.windows", "x86" },
};

void BuildSample (FilePath sln, bool dryrun)
void BuildSample (FilePath sln, bool useNetCore, bool dryrun)
{
var platform = sln.GetDirectory ().GetDirectoryName ().ToLower ();
var name = sln.GetFilenameWithoutExtension ();
Expand All @@ -484,11 +484,18 @@ Task ("samples")
}

if (dryrun) {
Information ($" BUILD {sln}");
if (useNetCore)
Information ($" BUILD (DN) {sln}");
else
Information ($" BUILD (FX) {sln}");
} else {
Information ($"Building sample {sln} ({platform})...");
RunNuGetRestorePackagesConfig (sln);
RunMSBuild (sln, platform: buildPlatform);
if (useNetCore) {
RunNetCoreBuild (sln);
} else {
RunNuGetRestorePackagesConfig (sln);
RunMSBuild (sln, platform: buildPlatform);
}
}
} else {
if (dryrun) {
Expand Down Expand Up @@ -524,7 +531,11 @@ Task ("samples")
var actualSamples = PREVIEW_ONLY_NUGETS.Count > 0
? "samples-preview"
: "samples";
var solutions = GetFiles ($"./output/{actualSamples}/**/*.sln");
var solutions =
GetFiles ($"./output/{actualSamples}/**/*.sln").Union (
GetFiles ($"./output/{actualSamples}/**/*.slnf"))
.OrderBy (x => x.FullPath)
.ToArray ();

Information ("Solutions found:");
foreach (var sln in solutions) {
Expand All @@ -541,17 +552,24 @@ Task ("samples")
continue;

var name = sln.GetFilenameWithoutExtension ();

// this is a IDE only solution
if (name.ToString ().EndsWith ("-vsmac"))
continue;

var slnPlatform = name.GetExtension ();

if (string.IsNullOrEmpty (slnPlatform)) {
// this is the main solution
var variants = GetFiles (sln.GetDirectory ().CombineWithFilePath (name) + ".*.sln");
var variants =
GetFiles (sln.GetDirectory ().CombineWithFilePath (name) + ".*.sln").Union (
GetFiles (sln.GetDirectory ().CombineWithFilePath (name) + ".*.slnf"));
if (!variants.Any ()) {
// there is no platform variant
BuildSample (sln, dryrun);
BuildSample (sln, false, dryrun);
// delete the built sample
if (!dryrun)
CleanDirectories (sln.GetDirectory ().FullPath);
CleanDir (sln.GetDirectory ().FullPath);
} else {
// skip as there is a platform variant
if (dryrun)
Expand All @@ -560,15 +578,20 @@ Task ("samples")
} else {
// this is a platform variant
slnPlatform = slnPlatform.ToLower ();
var useNetCore = slnPlatform.EndsWith ("-net");
if (useNetCore)
slnPlatform = slnPlatform.Substring (0, slnPlatform.Length - 4);

var shouldBuild =
(isLinux && slnPlatform == ".linux") ||
(isMac && slnPlatform == ".mac") ||
(isWin && slnPlatform == ".windows");
if (shouldBuild) {
BuildSample (sln, dryrun);
BuildSample (sln, useNetCore, dryrun);
// delete the built sample
if (!dryrun)
CleanDirectories (sln.GetDirectory ().FullPath);
if (!dryrun) {
CleanDir (sln.GetDirectory ().FullPath);
}
} else {
// skip this as this is not the correct platform
if (dryrun)
Expand All @@ -578,10 +601,10 @@ Task ("samples")
}
}

CleanDirectory ("./output/samples/");
DeleteDirectory ("./output/samples/", new DeleteDirectorySettings { Recursive = true, Force = true });
CleanDirectory ("./output/samples-preview/");
DeleteDirectory ("./output/samples-preview/", new DeleteDirectorySettings { Recursive = true, Force = true });
CleanDir ("./output/samples/");
DeleteDir ("./output/samples/");
CleanDir ("./output/samples-preview/");
DeleteDir ("./output/samples-preview/");
});

////////////////////////////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -930,8 +953,7 @@ Task ("clean-managed")

DeleteFiles ("./nuget/*.prerelease.nuspec");

if (DirectoryExists ("./output"))
DeleteDirectory ("./output", new DeleteDirectorySettings { Recursive = true, Force = true });
DeleteDir ("./output");
});

////////////////////////////////////////////////////////////////////////////////////////////////////
Expand Down
46 changes: 46 additions & 0 deletions cake/msbuild.cake
Original file line number Diff line number Diff line change
Expand Up @@ -113,3 +113,49 @@ void RunMSBuild(
c.ArgumentCustomization = args => args.Append($"/p:RestoreSources=\"{string.Join(sep, GetNuGetSources())}\"");
});
}

void RunNetCoreBuild(
FilePath solution,
bool bl = true,
string[] targets = null,
string configuration = null,
Dictionary<string, string> properties = null)
{
EnsureDirectoryExists(OUTPUT_NUGETS_PATH);

var c = new DotNetCoreBuildSettings();
var msb = new DotNetCoreMSBuildSettings();
c.MSBuildSettings = msb;

c.Configuration = configuration ?? CONFIGURATION;
c.Verbosity = (DotNetVerbosity)VERBOSITY;

var relativeSolution = MakeAbsolute(ROOT_PATH).GetRelativePath(MakeAbsolute(solution));
var blPath = ROOT_PATH.Combine("output/logs/binlogs").CombineWithFilePath(relativeSolution + ".binlog");
msb.BinaryLogger = new MSBuildBinaryLoggerSettings {
Enabled = true,
FileName = blPath.FullPath,
};

c.NoLogo = VERBOSITY == Verbosity.Minimal;

if (targets?.Length > 0) {
msb.Targets.Clear();
foreach (var target in targets) {
msb.Targets.Add(target);
}
}

msb.Properties ["BuildingForDotNet"] = new [] { "true" };
msb.Properties ["RestoreNoCache"] = new [] { "true" };
msb.Properties ["RestorePackagesPath"] = new [] { PACKAGE_CACHE_PATH.FullPath };

if (properties != null) {
foreach (var prop in properties) {
msb.Properties [prop.Key] = new [] { prop.Value };
}
}
c.Sources = GetNuGetSources();

DotNetCoreBuild(solution.FullPath, c);
}
29 changes: 27 additions & 2 deletions cake/samples.cake
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ void CreateSamplesDirectory(DirectoryPath samplesDirPath, DirectoryPath outputDi
outputDirPath = MakeAbsolute(outputDirPath);

var solutionProjectRegex = new Regex(@",\s*""(.*?\.\w{2}proj)"", ""(\{.*?\})""");
var solutionFilterProjectRegex = new Regex(@"\s*""(.+)\.csproj"",?");

EnsureDirectoryExists(outputDirPath);
CleanDirectory(outputDirPath);
CleanDir (outputDirPath);

var ignoreBinObj = new GlobberSettings {
Predicate = fileSystemInfo => {
Expand Down Expand Up @@ -64,6 +64,31 @@ void CreateSamplesDirectory(DirectoryPath samplesDirPath, DirectoryPath outputDi
}
}

// save the solution
EnsureDirectoryExists(dest.GetDirectory());
FileWriteLines(dest, lines.ToArray());
} else if (ext.Equals(".slnf", StringComparison.OrdinalIgnoreCase)) {
var lines = FileReadLines(file.FullPath).ToList();

// remove projects that aren't samples
for(var i = 0; i < lines.Count; i++) {
var line = lines [i];
var m = solutionFilterProjectRegex.Match(line);
if (!m.Success)
continue;

// get the path of the project relative to the samples directory
var relProjectPath = (FilePath) m.Groups [1].Value.Replace("\\\\", "\\");
var absProjectPath = GetFullPath(file, relProjectPath);
var relSamplesPath = samplesDirPath.GetRelativePath(absProjectPath);
if (!relSamplesPath.FullPath.StartsWith(".."))
continue;

Debug($"Removing the project '{relProjectPath}' for solution '{rel}'.");

lines.RemoveAt(i--);
}

// save the solution
EnsureDirectoryExists(dest.GetDirectory());
FileWriteLines(dest, lines.ToArray());
Expand Down
18 changes: 18 additions & 0 deletions cake/shared.cake
Original file line number Diff line number Diff line change
Expand Up @@ -95,3 +95,21 @@ string GetRegexValue(string regex, FilePath file)
return "";
}
}

void DeleteDir(DirectoryPath dir)
{
if (DirectoryExists(dir))
DeleteDirectory(dir, new DeleteDirectorySettings { Recursive = true, Force = true });
}

void CleanDir(DirectoryPath dir)
{
if (DirectoryExists(dir)) {
foreach (var d in GetSubDirectories(dir)) {
DeleteDir(d);
}
CleanDirectory(dir);
}

EnsureDirectoryExists(dir);
}
2 changes: 1 addition & 1 deletion cake/xcode.cake
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ void CreateFatVersionedFramework(DirectoryPath archives)
void SafeCopy(DirectoryPath src, DirectoryPath dst)
{
EnsureDirectoryExists(dst);
DeleteDirectory(dst, new DeleteDirectorySettings { Recursive = true, Force = true });
DeleteDir(dst);
RunProcess("cp", $"-R {src} {dst}");
}

Expand Down
14 changes: 14 additions & 0 deletions samples/Basic/Maui/SkiaSharpSample.Mac-net.slnf
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"solution": {
"path": "SkiaSharpSample.sln",
"projects": [
"..\\..\\..\\binding\\SkiaSharp\\SkiaSharp.csproj",
"..\\..\\..\\source\\SkiaSharp.Views.Maui\\SkiaSharp.Views.Maui.Controls.Compatibility\\SkiaSharp.Views.Maui.Controls.Compatibility.csproj",
"..\\..\\..\\source\\SkiaSharp.Views.Maui\\SkiaSharp.Views.Maui.Controls\\SkiaSharp.Views.Maui.Controls.csproj",
"..\\..\\..\\source\\SkiaSharp.Views.Maui\\SkiaSharp.Views.Maui.Core\\SkiaSharp.Views.Maui.Core.csproj",
"..\\..\\..\\source\\SkiaSharp.Views.WinUI\\SkiaSharp.Views.WinUI\\SkiaSharp.Views.WinUI.csproj",
"..\\..\\..\\source\\SkiaSharp.Views\\SkiaSharp.Views\\SkiaSharp.Views.csproj",
"SkiaSharpSample\\SkiaSharpSample.csproj"
]
}
}
14 changes: 14 additions & 0 deletions samples/Basic/Maui/SkiaSharpSample.Windows-net.slnf
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"solution": {
"path": "SkiaSharpSample.sln",
"projects": [
"..\\..\\..\\binding\\SkiaSharp\\SkiaSharp.csproj",
"..\\..\\..\\source\\SkiaSharp.Views.Maui\\SkiaSharp.Views.Maui.Controls.Compatibility\\SkiaSharp.Views.Maui.Controls.Compatibility.csproj",
"..\\..\\..\\source\\SkiaSharp.Views.Maui\\SkiaSharp.Views.Maui.Controls\\SkiaSharp.Views.Maui.Controls.csproj",
"..\\..\\..\\source\\SkiaSharp.Views.Maui\\SkiaSharp.Views.Maui.Core\\SkiaSharp.Views.Maui.Core.csproj",
"..\\..\\..\\source\\SkiaSharp.Views.WinUI\\SkiaSharp.Views.WinUI\\SkiaSharp.Views.WinUI.csproj",
"..\\..\\..\\source\\SkiaSharp.Views\\SkiaSharp.Views\\SkiaSharp.Views.csproj",
"SkiaSharpSample\\SkiaSharpSample.csproj"
]
}
}
63 changes: 0 additions & 63 deletions samples/Basic/Maui/SkiaSharpSample.Windows.sln

This file was deleted.

10 changes: 10 additions & 0 deletions samples/Basic/NetCore/MacCatalyst/SkiaSharpSample.Mac-net.slnf
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"solution": {
"path": "SkiaSharpSample.sln",
"projects": [
"..\\..\\..\\..\\binding\\SkiaSharp\\SkiaSharp.csproj",
"..\\..\\..\\..\\source\\SkiaSharp.Views\\SkiaSharp.Views\\SkiaSharp.Views.csproj",
"SkiaSharpSample\\SkiaSharpSample.csproj"
]
}
}
36 changes: 36 additions & 0 deletions samples/Basic/NetCore/MacCatalyst/SkiaSharpSample.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.27130.2010
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SkiaSharpSample", "SkiaSharpSample\SkiaSharpSample.csproj", "{B6D1B569-6ED2-4C9D-9CD3-64ACB89303EA}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SkiaSharp", "..\..\..\..\binding\SkiaSharp\SkiaSharp.csproj", "{ADEB6908-D553-4ED3-94CD-CEC4CF0B34E2}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SkiaSharp.Views", "..\..\..\..\source\SkiaSharp.Views\SkiaSharp.Views\SkiaSharp.Views.csproj", "{294EA76C-241E-4C20-9D1C-1AEADA007B21}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{B6D1B569-6ED2-4C9D-9CD3-64ACB89303EA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B6D1B569-6ED2-4C9D-9CD3-64ACB89303EA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B6D1B569-6ED2-4C9D-9CD3-64ACB89303EA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B6D1B569-6ED2-4C9D-9CD3-64ACB89303EA}.Release|Any CPU.Build.0 = Release|Any CPU
{ADEB6908-D553-4ED3-94CD-CEC4CF0B34E2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{ADEB6908-D553-4ED3-94CD-CEC4CF0B34E2}.Debug|Any CPU.Build.0 = Debug|Any CPU
{ADEB6908-D553-4ED3-94CD-CEC4CF0B34E2}.Release|Any CPU.ActiveCfg = Release|Any CPU
{ADEB6908-D553-4ED3-94CD-CEC4CF0B34E2}.Release|Any CPU.Build.0 = Release|Any CPU
{294EA76C-241E-4C20-9D1C-1AEADA007B21}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{294EA76C-241E-4C20-9D1C-1AEADA007B21}.Debug|Any CPU.Build.0 = Debug|Any CPU
{294EA76C-241E-4C20-9D1C-1AEADA007B21}.Release|Any CPU.ActiveCfg = Release|Any CPU
{294EA76C-241E-4C20-9D1C-1AEADA007B21}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {D802D896-3C98-498F-86AF-075791CFF220}
EndGlobalSection
EndGlobal
Loading