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
14 changes: 11 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,20 @@ jobs:
- name: Build (linux)
if: matrix.os == 'ubuntu-latest'
run: |
zig build -Doptimize=ReleaseFast -Dno-fileselector -fno-sys=libxkbcommon -Dxkb-config-root="" -Dx-locale-root=""
zig build -Doptimize=ReleaseFast -Dno-fileselector -Dlegacy
zig build -Dtarget=x86_64-linux-musl -Dno-fileselector -fno-sys=libxkbcommon -Dxkb-config-root="" -Dx-locale-root=""
zig build -Dtarget=x86_64-linux-musl -Dno-fileselector -Dlegacy
zig build -Dtarget=x86_64-linux-gnu -Dlinkage=dynamic -Dno-fileselector -fno-sys=libxkbcommon -Dxkb-config-root="" -Dx-locale-root=""
zig build -Dtarget=x86_64-linux-gnu -Dlinkage=dynamic -Dno-fileselector -Dlegacy

- name: Build (macOS)
if: matrix.os == 'macos-latest'
run: zig build -Doptimize=ReleaseFast -Dno-fileselector
run: zig build -Dno-fileselector

- name: Build (cross-compile freebsd)
if: matrix.os == 'ubuntu-latest'
run: |
zig build -Dtarget=native-freebsd -Dno-fileselector -fno-sys=libxkbcommon -Dxkb-config-root=/usr/local/share/X11/xkb -Dx-locale-root=/usr/local/lib/X11/locale
zig build -Dtarget=native-freebsd -Dno-fileselector -Dlegacy

- name: Build (windows)
if: matrix.os == 'windows-latest'
Expand Down
18 changes: 14 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,12 @@ zig build run

When building for Windows or macOS, no system dependencies are required.

The graphical profiler has the following dependencies on linux:
The graphical profiler has the following dependencies on Linux and FreeBSD:

- `libGL`: runtime dependency
- `libGL`, `libGLX`: runtime dependency
- `libEGL`: runtime dependency, not required when using `-Dlegacy`
- `libwayland-*` runtime dependencies to run a native wayland session
- `libX*` runtime dependencies to run a X11 session, only required when using `-Dlegacy`
- `libxkbcommon`: not required when using `-Dlegacy`
- `libdbus-1`: can be disabled with `-Dno-fileselector` or `-Dportal=false`
- `libgtk+-3.0`: only required when using `-Dportal=false`
Expand All @@ -48,8 +50,16 @@ zig build run -Dtarget=x86_64-windows -fwine # run the tracy profiler with Wine

#### Linux

Cross compiling to macOS can successfully produce a binary. The binary has a runtime dependency on `libGL` and will fail if it can't be found with `dlopen`.
This will produce a dynamically linked executable that will try to `dlopen` various runtime libraries. This is not guaranteed to work as all distros like NixOS.

```bash
zig build -Dtarget=x86_64-linux -Dno-fileselector -Dlegacy
zig build -Dtarget=x86_64-linux-gnu -Dlinkage=dynamic -Dno-fileselector -fno-sys=libxkbcommon -Dxkb-config-root=/usr/share/X11/xkb -Dx-locale-root=/usr/share/X11/locale
zig build -Dtarget=x86_64-linux-gnu -Dlinkage=dynamic -Dno-fileselector -Dlegacy
```

#### FreeBSD

```bash
zig build -Dtarget=x86_64-freebsd -Dno-fileselector -fno-sys=libxkbcommon -Dxkb-config-root=/usr/local/share/X11/xkb -Dx-locale-root=/usr/local/lib/X11/locale
zig build -Dtarget=x86_64-freebsd -Dno-fileselector -Dlegacy
```
50 changes: 24 additions & 26 deletions build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -125,19 +125,22 @@ pub fn build(b: *std.Build) !void {
// Profiler / Server Options
const no_fileselector = b.option(bool, "no-fileselector", "Disable the file selector") orelse false;
const portal = b.option(bool, "portal", "Use xdg-desktop-portal instead of GTK") orelse true; // upstream uses gtk as the default
const legacy = b.option(bool, "legacy", "Instead of Wayland, use the legacy X11 backend on Linux") orelse false;
const legacy = b.option(bool, "legacy", "Instead of Wayland, use the legacy X11 backend on Linux or FreeBSD") orelse false;
const no_statistics = b.option(bool, "no-statistics", "Disable calculation of statistics") orelse false;
const self_profile = b.option(bool, "self-profile", "Enable self-profiling") orelse false;
const no_parallel_stl = b.option(bool, "no-parallel-stl", "Disable parallel STL") orelse true;

const use_wayland = target.result.os.tag == .linux and !legacy;
const use_wayland = !legacy and switch (target.result.os.tag) {
.linux, .freebsd => true,
else => false,
};

const ini = createIni(b, common_module_options);
const base64 = createBase64(b, common_module_options);
const md4c = createMd4c(b, common_module_options);
const pugixml = createPugixml(b, common_module_options);
const tidy = createTidyHtml5(b, common_module_options);
const imgui = createImgui(b, common_module_options, legacy, link_system_glfw, link_system_freetype);
const imgui = createImgui(b, common_module_options, use_wayland, link_system_glfw, link_system_freetype);
const zstd = if (link_system_zstd) null else if (b.lazyDependency("zstd", .{
.target = target,
.optimize = optimize,
Expand Down Expand Up @@ -168,7 +171,7 @@ pub fn build(b: *std.Build) !void {
})) |dependency| dependency.artifact("nfd") else null;

const tracy_server = b.addLibrary(.{
.linkage = linkage,
.linkage = .static,
.name = "tracy-server",
.root_module = b.createModule(.{
.target = target,
Expand Down Expand Up @@ -452,8 +455,8 @@ pub fn build(b: *std.Build) !void {
.optimize = optimize,
.@"xkb-config-root" = xkb_config_root,
.@"x-locale-root" = x_locale_root,
})) |wayland| {
tracy_profiler.root_module.linkLibrary(wayland.artifact("xkbcommon"));
})) |libxkbcommon| {
tracy_profiler.root_module.linkLibrary(libxkbcommon.artifact("xkbcommon"));
}
}

Expand Down Expand Up @@ -554,8 +557,7 @@ pub fn build(b: *std.Build) !void {
if (b.lazyDependency("glfw", .{
.target = target,
.optimize = optimize,
.x11 = if (target.result.os.tag == .linux) legacy else true,
.wayland = true,
.wayland = false,
})) |glfw_dependency| {
tracy_profiler.root_module.linkLibrary(glfw_dependency.artifact("glfw"));
}
Expand Down Expand Up @@ -901,7 +903,7 @@ fn createRpcmalloc(b: *std.Build, options: std.Build.Module.CreateOptions) *std.
fn createImgui(
b: *std.Build,
options: std.Build.Module.CreateOptions,
legacy: bool,
use_wayland: bool,
link_system_glfw: bool,
link_system_freetype: bool,
) *std.Build.Step.Compile {
Expand Down Expand Up @@ -931,26 +933,22 @@ fn createImgui(
"imgui_widgets.cpp",
},
});
if (link_system_glfw) {
imgui.root_module.linkSystemLibrary("glfw3", .{});
} else {
if (b.lazyDependency("glfw", .{
.target = options.target.?,
.optimize = options.optimize.?,
.x11 = if (options.target.?.result.os.tag == .linux) legacy else true,
.wayland = true,
})) |glfw_dependency| {
imgui.root_module.linkLibrary(glfw_dependency.artifact("glfw"));
if (!use_wayland) {
imgui.root_module.addCSourceFile(.{ .file = upstream.path("backends/imgui_impl_glfw.cpp") });
if (link_system_glfw) {
imgui.root_module.linkSystemLibrary("glfw3", .{});
} else {
if (b.lazyDependency("glfw", .{
.target = options.target.?,
.optimize = options.optimize.?,
.wayland = false,
})) |glfw_dependency| {
imgui.root_module.linkLibrary(glfw_dependency.artifact("glfw"));
}
}
}

imgui.root_module.addCSourceFiles(.{
.root = upstream.path("backends"),
.files = &.{
"imgui_impl_glfw.cpp",
"imgui_impl_opengl3.cpp",
},
});
imgui.root_module.addCSourceFile(.{ .file = upstream.path("backends/imgui_impl_opengl3.cpp") });
imgui.installHeadersDirectory(upstream.path("backends"), "imgui", .{});
imgui.root_module.addCMacro("GLFW_INCLUDE_NONE", "1");
if (imgui.root_module.optimize != .Debug) {
Expand Down
14 changes: 7 additions & 7 deletions build.zig.zon
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
.fingerprint = 0x255a89eecd27f4ce, // Changing this has security and trust implications.
.minimum_zig_version = "0.15.1",
.dependencies = .{
.glfw = .{ // A fork of GLFW packaged for the Zig build system
.url = "git+https://github.com/terraquad/glfw.git#00a723504e6451d8210031ec7940f2a6841cc0a6",
.hash = "glfw_c-3.4.0-_9LYGLaqGQAI0baWDUTJHNdld2y6gKrsbLvOwUse4Q6x",
.glfw = .{ // glfw ported to the zig build system
.url = "git+https://github.com/Techatrix/glfw.git#5ab24844c4982f1665985bd2a808a62c8cbeb97b",
.hash = "glfw-3.4.0-yvF4PIFDMwBvlU52tuJU9_ijSCazcLeWvYsdaBJm7HQ6",
.lazy = true,
},
.capstone = .{ // Availability for capstone as Zig dependency
Expand All @@ -15,8 +15,8 @@
.lazy = true,
},
.curl = .{ // curl ported to the zig build system
.url = "git+https://github.com/allyourcodebase/curl.git#0180cf1de923f479633b0d7a13aee4ad482b3ead",
.hash = "curl-8.15.0-mFDAWPDvAACDblXwmIxaAM-mCWYYk8JgfWpuKFQ9pKAT",
.url = "git+https://github.com/allyourcodebase/curl.git#fc863d6cbc4a694ff5bb11fc59470142c8682e2b",
.hash = "curl-8.18.0-mFDAWK_0AABsv8MPtSIjAPCVElXbt1vbzgBOs7plIlUJ",
.lazy = true,
},
.zstd = .{ // zstd ported to the zig build system
Expand All @@ -40,8 +40,8 @@
// .lazy = true,
// },
.wayland = .{
.url = "git+https://github.com/allyourcodebase/wayland.git?ref=1.24.0-2#209cdc0d604facd02f67a93a145188d10a54f1ce",
.hash = "wayland-1.24.0-2-dxEBa4RlAAABLcAFSA_vUHi0KqowweDZzkcOQ8KNG4N7",
.url = "git+https://github.com/allyourcodebase/wayland.git?ref=1.24.0-3#c3e9e7b92a135badb24643da7be8a441a060af9d",
.hash = "wayland-1.24.0-3-dxEBa6N9AAD5fW7Hq-V8ngPRpUTky6PmnHxVFRPvn1aI",
.lazy = true,
},
.wayland_protocols = .{
Expand Down
2 changes: 1 addition & 1 deletion import/src/import-chrome.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#ifdef _MSC_VER
# define stat64 _stat64
#endif
#if defined __APPLE__
#if defined __APPLE__ || defined __FreeBSD__ || (defined __linux__ && !defined __GLIBC__)
# define stat64 stat
#endif

Expand Down
2 changes: 1 addition & 1 deletion import/src/import-fuchsia.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#ifdef _MSC_VER
#define stat64 _stat64
#endif
#if defined __APPLE__
#if defined __APPLE__ || defined __FreeBSD__ || (defined __linux__ && !defined __GLIBC__)
#define stat64 stat
#endif

Expand Down
9 changes: 8 additions & 1 deletion profiler/src/BackendWayland.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
#include "imgui/imgui_impl_opengl3.h"

#include <chrono>
#include <linux/input-event-codes.h>
#include <memory>
#include <stdio.h>
#include <stdlib.h>
Expand Down Expand Up @@ -38,6 +37,14 @@
#include "RunQueue.hpp"
#include "profiler/TracyConfig.hpp"

#ifdef __linux__
#include <linux/input-event-codes.h>
#endif

#ifdef __FreeBSD__
#include <dev/evdev/input-event-codes.h>
#endif

constexpr ImGuiKey s_keyTable[] = {
/* 0 */ ImGuiKey_None,
/* 1 */ ImGuiKey_Escape,
Expand Down
4 changes: 4 additions & 0 deletions profiler/src/winmain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
# include <intrin.h>
# include <stdint.h>

#if defined(__x86_64__) || defined(__i386__)
static inline void CpuId( uint32_t* regs, uint32_t leaf )
{
memset(regs, 0, sizeof(uint32_t) * 4);
Expand All @@ -13,6 +14,7 @@ static inline void CpuId( uint32_t* regs, uint32_t leaf )
__get_cpuid( leaf, regs, regs+1, regs+2, regs+3 );
#endif
}
#endif

namespace tracy
{
Expand All @@ -24,6 +26,7 @@ int main( int argc, char** argv );

int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpszCmd, int nCmd )
{
#if defined(__x86_64__) || defined(__i386__)
{
uint32_t regs[4];
CpuId( regs, 0 );
Expand Down Expand Up @@ -52,6 +55,7 @@ int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpszCmd,
return 0;
}
}
#endif

return main( __argc, __argv );
}
Expand Down