mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-17 17:26:09 +03:00
support dynamic linking (not default) test in GH actions
This commit is contained in:
12
.github/workflows/test.yml
vendored
12
.github/workflows/test.yml
vendored
@ -35,10 +35,10 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
nix_path: nixpkgs=channel:nixos-unstable
|
nix_path: nixpkgs=channel:nixos-unstable
|
||||||
|
|
||||||
# Run our go tests within the context of the dev shell from the flake. This
|
# Cross-compile the binary. We always use static building for this
|
||||||
# will ensure we have all our dependencies.
|
# because its the only way to access the headers.
|
||||||
- name: Test Build
|
- name: Test Build
|
||||||
run: nix develop -c zig build -Dtarget=${{ matrix.target }}
|
run: nix develop -c zig build -Dstatic=true -Dtarget=${{ matrix.target }}
|
||||||
|
|
||||||
test:
|
test:
|
||||||
strategy:
|
strategy:
|
||||||
@ -57,7 +57,9 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
nix_path: nixpkgs=channel:nixos-unstable
|
nix_path: nixpkgs=channel:nixos-unstable
|
||||||
|
|
||||||
# Run our go tests within the context of the dev shell from the flake. This
|
|
||||||
# will ensure we have all our dependencies.
|
|
||||||
- name: test
|
- name: test
|
||||||
run: nix develop -c zig build test
|
run: nix develop -c zig build test
|
||||||
|
|
||||||
|
- name: Test Dynamic Build
|
||||||
|
run: nix develop -c zig build -Dstatic=false
|
||||||
|
|
||||||
|
70
build.zig
70
build.zig
@ -11,7 +11,7 @@ const zlib = @import("pkg/zlib/build.zig");
|
|||||||
const tracylib = @import("pkg/tracy/build.zig");
|
const tracylib = @import("pkg/tracy/build.zig");
|
||||||
const system_sdk = @import("vendor/mach/glfw/system_sdk.zig");
|
const system_sdk = @import("vendor/mach/glfw/system_sdk.zig");
|
||||||
|
|
||||||
/// A build that is set to true if Tracy integration should be built.
|
// Build options, see the build options help for more info.
|
||||||
var tracy: bool = false;
|
var tracy: bool = false;
|
||||||
|
|
||||||
pub fn build(b: *std.build.Builder) !void {
|
pub fn build(b: *std.build.Builder) !void {
|
||||||
@ -33,6 +33,12 @@ pub fn build(b: *std.build.Builder) !void {
|
|||||||
"Enable Tracy integration (default true in Debug on Linux)",
|
"Enable Tracy integration (default true in Debug on Linux)",
|
||||||
) orelse (mode == .Debug and target.isLinux());
|
) orelse (mode == .Debug and target.isLinux());
|
||||||
|
|
||||||
|
const static = b.option(
|
||||||
|
bool,
|
||||||
|
"static",
|
||||||
|
"Statically build as much as possible for the exe",
|
||||||
|
) orelse true;
|
||||||
|
|
||||||
const conformance = b.option(
|
const conformance = b.option(
|
||||||
[]const u8,
|
[]const u8,
|
||||||
"conformance",
|
"conformance",
|
||||||
@ -52,7 +58,7 @@ pub fn build(b: *std.build.Builder) !void {
|
|||||||
exe.install();
|
exe.install();
|
||||||
|
|
||||||
// Add the shared dependencies
|
// Add the shared dependencies
|
||||||
try addDeps(b, exe);
|
try addDeps(b, exe, static);
|
||||||
}
|
}
|
||||||
|
|
||||||
// term.wasm
|
// term.wasm
|
||||||
@ -105,7 +111,7 @@ pub fn build(b: *std.build.Builder) !void {
|
|||||||
}
|
}
|
||||||
|
|
||||||
main_test.setTarget(target);
|
main_test.setTarget(target);
|
||||||
try addDeps(b, main_test);
|
try addDeps(b, main_test, true);
|
||||||
|
|
||||||
var before = b.addLog("\x1b[" ++ color_map.get("cyan").? ++ "\x1b[" ++ color_map.get("b").? ++ "[{s} tests]" ++ "\x1b[" ++ color_map.get("d").? ++ " ----" ++ "\x1b[0m", .{"ghostty"});
|
var before = b.addLog("\x1b[" ++ color_map.get("cyan").? ++ "\x1b[" ++ color_map.get("b").? ++ "[{s} tests]" ++ "\x1b[" ++ color_map.get("d").? ++ " ----" ++ "\x1b[0m", .{"ghostty"});
|
||||||
var after = b.addLog("\x1b[" ++ color_map.get("d").? ++ "–––---\n\n" ++ "\x1b[0m", .{});
|
var after = b.addLog("\x1b[" ++ color_map.get("d").? ++ "–––---\n\n" ++ "\x1b[0m", .{});
|
||||||
@ -123,7 +129,7 @@ pub fn build(b: *std.build.Builder) !void {
|
|||||||
var test_ = b.addTestSource(pkg.source);
|
var test_ = b.addTestSource(pkg.source);
|
||||||
|
|
||||||
test_.setTarget(target);
|
test_.setTarget(target);
|
||||||
try addDeps(b, test_);
|
try addDeps(b, test_, true);
|
||||||
if (pkg.dependencies) |children| {
|
if (pkg.dependencies) |children| {
|
||||||
test_.packages = std.ArrayList(std.build.Pkg).init(b.allocator);
|
test_.packages = std.ArrayList(std.build.Pkg).init(b.allocator);
|
||||||
try test_.packages.appendSlice(children);
|
try test_.packages.appendSlice(children);
|
||||||
@ -142,11 +148,46 @@ pub fn build(b: *std.build.Builder) !void {
|
|||||||
fn addDeps(
|
fn addDeps(
|
||||||
b: *std.build.Builder,
|
b: *std.build.Builder,
|
||||||
step: *std.build.LibExeObjStep,
|
step: *std.build.LibExeObjStep,
|
||||||
|
static: bool,
|
||||||
) !void {
|
) !void {
|
||||||
|
// We always need the Zig packages
|
||||||
|
step.addPackage(freetype.pkg);
|
||||||
|
step.addPackage(glfw.pkg);
|
||||||
|
step.addPackage(libuv.pkg);
|
||||||
|
step.addPackage(utf8proc.pkg);
|
||||||
|
|
||||||
|
// We always statically compile glad
|
||||||
step.addIncludeDir("vendor/glad/include/");
|
step.addIncludeDir("vendor/glad/include/");
|
||||||
step.addCSourceFile("vendor/glad/src/gl.c", &.{});
|
step.addCSourceFile("vendor/glad/src/gl.c", &.{});
|
||||||
|
|
||||||
// Dependencies of other dependencies
|
// Tracy
|
||||||
|
step.addPackage(tracylib.pkg);
|
||||||
|
if (tracy) {
|
||||||
|
var tracy_step = try tracylib.link(b, step);
|
||||||
|
system_sdk.include(b, tracy_step, .{});
|
||||||
|
}
|
||||||
|
|
||||||
|
// utf8proc
|
||||||
|
_ = try utf8proc.link(b, step);
|
||||||
|
|
||||||
|
// Glfw
|
||||||
|
glfw.link(b, step, .{
|
||||||
|
.metal = false,
|
||||||
|
.opengl = false, // Found at runtime
|
||||||
|
});
|
||||||
|
|
||||||
|
// Dynamic link
|
||||||
|
if (!static) {
|
||||||
|
step.addIncludePath(freetype.include_path_self);
|
||||||
|
step.linkSystemLibrary("bzip2");
|
||||||
|
step.linkSystemLibrary("freetype2");
|
||||||
|
step.linkSystemLibrary("libpng");
|
||||||
|
step.linkSystemLibrary("libuv");
|
||||||
|
step.linkSystemLibrary("zlib");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Other dependencies, we may dynamically link
|
||||||
|
if (static) {
|
||||||
const zlib_step = try zlib.link(b, step);
|
const zlib_step = try zlib.link(b, step);
|
||||||
const libpng_step = try libpng.link(b, step, .{
|
const libpng_step = try libpng.link(b, step, .{
|
||||||
.zlib = .{
|
.zlib = .{
|
||||||
@ -156,7 +197,6 @@ fn addDeps(
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Freetype
|
// Freetype
|
||||||
step.addPackage(freetype.pkg);
|
|
||||||
_ = try freetype.link(b, step, .{
|
_ = try freetype.link(b, step, .{
|
||||||
.libpng = freetype.Options.Libpng{
|
.libpng = freetype.Options.Libpng{
|
||||||
.enabled = true,
|
.enabled = true,
|
||||||
@ -171,27 +211,9 @@ fn addDeps(
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
// Glfw
|
|
||||||
step.addPackage(glfw.pkg);
|
|
||||||
glfw.link(b, step, .{
|
|
||||||
.metal = false,
|
|
||||||
.opengl = false, // Found at runtime
|
|
||||||
});
|
|
||||||
|
|
||||||
// Libuv
|
// Libuv
|
||||||
step.addPackage(libuv.pkg);
|
|
||||||
var libuv_step = try libuv.link(b, step);
|
var libuv_step = try libuv.link(b, step);
|
||||||
system_sdk.include(b, libuv_step, .{});
|
system_sdk.include(b, libuv_step, .{});
|
||||||
|
|
||||||
// utf8proc
|
|
||||||
step.addPackage(utf8proc.pkg);
|
|
||||||
_ = try utf8proc.link(b, step);
|
|
||||||
|
|
||||||
// Tracy
|
|
||||||
step.addPackage(tracylib.pkg);
|
|
||||||
if (tracy) {
|
|
||||||
var tracy_step = try tracylib.link(b, step);
|
|
||||||
system_sdk.include(b, tracy_step, .{});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,18 +19,26 @@
|
|||||||
, freetype
|
, freetype
|
||||||
, libpng
|
, libpng
|
||||||
, libGL
|
, libGL
|
||||||
|
, libuv
|
||||||
, libX11
|
, libX11
|
||||||
, libXcursor
|
, libXcursor
|
||||||
, libXext
|
, libXext
|
||||||
, libXi
|
, libXi
|
||||||
, libXinerama
|
, libXinerama
|
||||||
, libXrandr
|
, libXrandr
|
||||||
|
, zlib
|
||||||
}:
|
}:
|
||||||
let
|
let
|
||||||
# See package.nix. Keep in sync.
|
# See package.nix. Keep in sync.
|
||||||
rpathLibs = [
|
rpathLibs = [
|
||||||
libGL
|
libGL
|
||||||
] ++ lib.optionals stdenv.isLinux [
|
] ++ lib.optionals stdenv.isLinux [
|
||||||
|
bzip2
|
||||||
|
freetype
|
||||||
|
libpng
|
||||||
|
libuv
|
||||||
|
zlib
|
||||||
|
|
||||||
libX11
|
libX11
|
||||||
libXcursor
|
libXcursor
|
||||||
libXi
|
libXi
|
||||||
@ -61,6 +69,12 @@ in mkShell rec {
|
|||||||
buildInputs = [
|
buildInputs = [
|
||||||
# TODO: non-linux
|
# TODO: non-linux
|
||||||
] ++ lib.optionals stdenv.isLinux [
|
] ++ lib.optionals stdenv.isLinux [
|
||||||
|
bzip2
|
||||||
|
freetype
|
||||||
|
libpng
|
||||||
|
libuv
|
||||||
|
zlib
|
||||||
|
|
||||||
libX11
|
libX11
|
||||||
libXcursor
|
libXcursor
|
||||||
libXext
|
libXext
|
||||||
|
@ -3,7 +3,7 @@ const std = @import("std");
|
|||||||
/// Directories with our includes.
|
/// Directories with our includes.
|
||||||
const root = thisDir() ++ "../../../vendor/freetype/";
|
const root = thisDir() ++ "../../../vendor/freetype/";
|
||||||
const include_path = root ++ "include";
|
const include_path = root ++ "include";
|
||||||
const include_path_self = thisDir();
|
pub const include_path_self = thisDir();
|
||||||
|
|
||||||
pub const pkg = std.build.Pkg{
|
pub const pkg = std.build.Pkg{
|
||||||
.name = "freetype",
|
.name = "freetype",
|
||||||
|
Reference in New Issue
Block a user