Skip to content

Commit

Permalink
Add base macOS and Linux instructions
Browse files Browse the repository at this point in the history
  • Loading branch information
harry-cpp committed Nov 2, 2023
1 parent c4e557f commit 33cea89
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 2 deletions.
22 changes: 21 additions & 1 deletion build/BuildLinuxTask.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,32 @@
namespace BuildScripts;

[TaskName("Build Linux")]
[IsDependentOn(typeof(PrepTask))]
public sealed class BuildLinuxTask : FrostingTask<BuildContext>
{
public override bool ShouldRun(BuildContext context) => context.IsRunningOnLinux();

public override void Run(BuildContext context)
{

// Make sure it statically links the dpeendencies
context.ReplaceTextInFiles("freetype/CMakeLists.txt", "# Find dependencies", "set(CMAKE_FIND_LIBRARY_SUFFIXES \".a\")");

// Build
var buildDir = "freetype/build";
context.CreateDirectory(buildDir);
context.StartProcess("cmake", new ProcessSettings { WorkingDirectory = buildDir, Arguments = "../ -DBUILD_SHARED_LIBS=true -DFT_DISABLE_HARFBUZZ=TRUE -DCMAKE_BUILD_TYPE=Release" });
context.StartProcess("make", new ProcessSettings { WorkingDirectory = buildDir });

foreach (var filePath in Directory.GetFiles("freetype/build"))
{
if (!filePath.Contains(".so") ||
File.GetAttributes(filePath).HasFlag(FileAttributes.ReparsePoint))
continue;

context.CopyFile(filePath, $"{context.ArtifactsDir}/libfreetype.so");
return;
}

throw new Exception("No built library found :(");
}
}
25 changes: 24 additions & 1 deletion build/BuildMacOSTask.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,36 @@

using Cake.Cli;
using Cake.Common.Diagnostics;

namespace BuildScripts;

[TaskName("Build macOS")]
[IsDependentOn(typeof(PrepTask))]
public sealed class BuildMacOSTask : FrostingTask<BuildContext>
{
public override bool ShouldRun(BuildContext context) => context.IsRunningOnMacOs();

public override void Run(BuildContext context)
{

// Make sure it statically links the dpeendencies
context.ReplaceTextInFiles("freetype/CMakeLists.txt", "# Find dependencies", "set(CMAKE_FIND_LIBRARY_SUFFIXES \".a\")");

// Build
var buildDir = "freetype/build";
context.CreateDirectory(buildDir);
context.StartProcess("cmake", new ProcessSettings { WorkingDirectory = buildDir, Arguments = "../ -DBUILD_SHARED_LIBS=true -DCMAKE_OSX_DEPLOYMENT_TARGET=13.0 -DFT_DISABLE_HARFBUZZ=TRUE -DCMAKE_BUILD_TYPE=Release" });
context.StartProcess("make", new ProcessSettings { WorkingDirectory = buildDir });

foreach (var filePath in Directory.GetFiles("freetype/build"))
{
if (!filePath.EndsWith(".dylib") ||
File.GetAttributes(filePath).HasFlag(FileAttributes.ReparsePoint))
continue;

context.CopyFile(filePath, $"{context.ArtifactsDir}/libfreetype.dylib");
return;
}

throw new Exception("No built library found :(");
}
}

0 comments on commit 33cea89

Please sign in to comment.