From ce23c67994eb43eaa8f68d3b65214913fcf2e0bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marian=20=C5=A0ime=C4=8Dek?= Date: Fri, 14 Jun 2024 19:18:33 +0200 Subject: [PATCH] support zig 0.13.0 --- .gitignore | 1 + build.zig | 78 +++++++++++++++++++++++++++--------------------------- 2 files changed, 40 insertions(+), 39 deletions(-) diff --git a/.gitignore b/.gitignore index 4a0641e..9125dc9 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ zig-cache/ +.zig-cache/ zig-out/ \ No newline at end of file diff --git a/build.zig b/build.zig index e629c58..468ce41 100644 --- a/build.zig +++ b/build.zig @@ -2,8 +2,8 @@ const std = @import("std"); pub fn build(b: *std.Build) void { _ = b.addModule("webview", .{ - .root_source_file = .{ .path = "src/webview.zig" }, - //.dependencies = &[_]std.Build.ModuleDependency{}, + .root_source_file = b.path("src/webview.zig"), + //.dependencies = &[_]std.Build.ModuleDependency{}, }); const target = b.standardTargetOptions(.{}); @@ -18,7 +18,7 @@ pub fn build(b: *std.Build) void { // objectFile.linkLibCpp(); // switch(target.os_tag orelse @import("builtin").os.tag) { // .windows => { - // objectFile.addCSourceFile(.{ .file = .{ .path = "external/webview/webview.cc"}, .flags = &.{"-std=c++14"}}); + // objectFile.addCSourceFile(.{ .file = b.path("external/webview/webview.cc") .flags = &.{"-std=c++14"}}); // objectFile.addIncludePath(std.build.LazyPath.relative("external/WebView2/")); // objectFile.linkSystemLibrary("ole32"); // objectFile.linkSystemLibrary("shlwapi"); @@ -28,11 +28,11 @@ pub fn build(b: *std.Build) void { // objectFile.linkSystemLibrary("user32"); // }, // .macos => { - // objectFile.addCSourceFile(.{ .file = .{ .path = "external/webview/webview.cc"}, .flags = &.{"-std=c++11"}}); + // objectFile.addCSourceFile(.{ .file = b.path("external/webview/webview.cc") .flags = &.{"-std=c++11"}}); // objectFile.linkFramework("WebKit"); // }, // else => { - // objectFile.addCSourceFile(.{ .file = .{ .path = "external/webview/webview.cc"}, .flags = &.{"-std=c++11"}}); + // objectFile.addCSourceFile(.{ .file = b.path("external/webview/webview.cc") .flags = &.{"-std=c++11"}}); // objectFile.linkSystemLibrary("gtk+-3.0"); // objectFile.linkSystemLibrary("webkit2gtk-4.0"); // } @@ -45,10 +45,10 @@ pub fn build(b: *std.Build) void { }); staticLib.defineCMacro("WEBVIEW_STATIC", null); staticLib.linkLibCpp(); - switch(target.query.os_tag orelse @import("builtin").os.tag) { + switch (target.query.os_tag orelse @import("builtin").os.tag) { .windows => { - staticLib.addCSourceFile(.{ .file = .{ .path = "external/webview/webview.cc"}, .flags = &.{"-std=c++14"}}); - staticLib.addIncludePath(std.Build.LazyPath.relative("external/WebView2/")); + staticLib.addCSourceFile(.{ .file = b.path("external/webview/webview.cc"), .flags = &.{"-std=c++14"} }); + staticLib.addIncludePath(b.path("external/WebView2/")); staticLib.linkSystemLibrary("ole32"); staticLib.linkSystemLibrary("shlwapi"); staticLib.linkSystemLibrary("version"); @@ -57,29 +57,29 @@ pub fn build(b: *std.Build) void { staticLib.linkSystemLibrary("user32"); }, .macos => { - staticLib.addCSourceFile(.{ .file = .{ .path = "external/webview/webview.cc"}, .flags = &.{"-std=c++11"}}); + staticLib.addCSourceFile(.{ .file = b.path("external/webview/webview.cc"), .flags = &.{"-std=c++11"} }); staticLib.linkFramework("WebKit"); }, .freebsd => { - staticLib.addCSourceFile(.{ .file = .{ .path = "external/webview/webview.cc"}, .flags = &.{"-std=c++11"}}); - staticLib.addIncludePath(.{ .path = "/usr/local/include/cairo/"}); - staticLib.addIncludePath(.{ .path = "/usr/local/include/gtk-3.0/"}); - staticLib.addIncludePath(.{ .path = "/usr/local/include/glib-2.0/"}); - staticLib.addIncludePath(.{ .path = "/usr/local/lib/glib-2.0/include/"}); - staticLib.addIncludePath(.{ .path = "/usr/local/include/webkitgtk-4.0/"}); - staticLib.addIncludePath(.{ .path = "/usr/local/include/pango-1.0/"}); - staticLib.addIncludePath(.{ .path = "/usr/local/include/harfbuzz/"}); - staticLib.addIncludePath(.{ .path = "/usr/local/include/gdk-pixbuf-2.0/"}); - staticLib.addIncludePath(.{ .path = "/usr/local/include/atk-1.0/"}); - staticLib.addIncludePath(.{ .path = "/usr/local/include/libsoup-3.0/"}); + staticLib.addCSourceFile(.{ .file = b.path("external/webview/webview.cc"), .flags = &.{"-std=c++11"} }); + staticLib.addIncludePath(.{ .cwd_relative = "/usr/local/include/cairo/" }); + staticLib.addIncludePath(.{ .cwd_relative = "/usr/local/include/gtk-3.0/" }); + staticLib.addIncludePath(.{ .cwd_relative = "/usr/local/include/glib-2.0/" }); + staticLib.addIncludePath(.{ .cwd_relative = "/usr/local/lib/glib-2.0/include/" }); + staticLib.addIncludePath(.{ .cwd_relative = "/usr/local/include/webkitgtk-4.0/" }); + staticLib.addIncludePath(.{ .cwd_relative = "/usr/local/include/pango-1.0/" }); + staticLib.addIncludePath(.{ .cwd_relative = "/usr/local/include/harfbuzz/" }); + staticLib.addIncludePath(.{ .cwd_relative = "/usr/local/include/gdk-pixbuf-2.0/" }); + staticLib.addIncludePath(.{ .cwd_relative = "/usr/local/include/atk-1.0/" }); + staticLib.addIncludePath(.{ .cwd_relative = "/usr/local/include/libsoup-3.0/" }); staticLib.linkSystemLibrary("gtk-3"); staticLib.linkSystemLibrary("webkit2gtk-4.0"); }, else => { - staticLib.addCSourceFile(.{ .file = .{ .path = "external/webview/webview.cc"}, .flags = &.{"-std=c++11"}}); + staticLib.addCSourceFile(.{ .file = b.path("external/webview/webview.cc"), .flags = &.{"-std=c++11"} }); staticLib.linkSystemLibrary("gtk+-3.0"); staticLib.linkSystemLibrary("webkit2gtk-4.0"); - } + }, } b.installArtifact(staticLib); @@ -90,10 +90,10 @@ pub fn build(b: *std.Build) void { }); sharedLib.defineCMacro("WEBVIEW_BUILD_SHARED", null); sharedLib.linkLibCpp(); - switch(target.query.os_tag orelse @import("builtin").os.tag) { + switch (target.query.os_tag orelse @import("builtin").os.tag) { .windows => { - sharedLib.addCSourceFile(.{ .file = .{ .path = "external/webview/webview.cc"}, .flags = &.{"-std=c++14"}}); - sharedLib.addIncludePath(std.Build.LazyPath.relative("external/WebView2/")); + sharedLib.addCSourceFile(.{ .file = b.path("external/webview/webview.cc"), .flags = &.{"-std=c++14"} }); + sharedLib.addIncludePath(b.path("external/WebView2/")); sharedLib.linkSystemLibrary("ole32"); sharedLib.linkSystemLibrary("shlwapi"); sharedLib.linkSystemLibrary("version"); @@ -102,29 +102,29 @@ pub fn build(b: *std.Build) void { sharedLib.linkSystemLibrary("user32"); }, .macos => { - sharedLib.addCSourceFile(.{ .file = .{ .path = "external/webview/webview.cc"}, .flags = &.{"-std=c++11"}}); + sharedLib.addCSourceFile(.{ .file = b.path("external/webview/webview.cc"), .flags = &.{"-std=c++11"} }); sharedLib.linkFramework("WebKit"); }, .freebsd => { - sharedLib.addCSourceFile(.{ .file = .{ .path = "external/webview/webview.cc"}, .flags = &.{"-std=c++11"}}); - sharedLib.addIncludePath(.{ .path = "/usr/local/include/cairo/"}); - sharedLib.addIncludePath(.{ .path = "/usr/local/include/gtk-3.0/"}); - sharedLib.addIncludePath(.{ .path = "/usr/local/include/glib-2.0/"}); - sharedLib.addIncludePath(.{ .path = "/usr/local/lib/glib-2.0/include/"}); - sharedLib.addIncludePath(.{ .path = "/usr/local/include/webkitgtk-4.0/"}); - sharedLib.addIncludePath(.{ .path = "/usr/local/include/pango-1.0/"}); - sharedLib.addIncludePath(.{ .path = "/usr/local/include/harfbuzz/"}); - sharedLib.addIncludePath(.{ .path = "/usr/local/include/gdk-pixbuf-2.0/"}); - sharedLib.addIncludePath(.{ .path = "/usr/local/include/atk-1.0/"}); - sharedLib.addIncludePath(.{ .path = "/usr/local/include/libsoup-3.0/"}); + sharedLib.addCSourceFile(.{ .file = b.path("external/webview/webview.cc"), .flags = &.{"-std=c++11"} }); + sharedLib.addIncludePath(.{ .cwd_relative = "/usr/local/include/cairo/" }); + sharedLib.addIncludePath(.{ .cwd_relative = "/usr/local/include/gtk-3.0/" }); + sharedLib.addIncludePath(.{ .cwd_relative = "/usr/local/include/glib-2.0/" }); + sharedLib.addIncludePath(.{ .cwd_relative = "/usr/local/lib/glib-2.0/include/" }); + sharedLib.addIncludePath(.{ .cwd_relative = "/usr/local/include/webkitgtk-4.0/" }); + sharedLib.addIncludePath(.{ .cwd_relative = "/usr/local/include/pango-1.0/" }); + sharedLib.addIncludePath(.{ .cwd_relative = "/usr/local/include/harfbuzz/" }); + sharedLib.addIncludePath(.{ .cwd_relative = "/usr/local/include/gdk-pixbuf-2.0/" }); + sharedLib.addIncludePath(.{ .cwd_relative = "/usr/local/include/atk-1.0/" }); + sharedLib.addIncludePath(.{ .cwd_relative = "/usr/local/include/libsoup-3.0/" }); sharedLib.linkSystemLibrary("gtk-3"); sharedLib.linkSystemLibrary("webkit2gtk-4.0"); }, else => { - sharedLib.addCSourceFile(.{ .file = .{ .path = "external/webview/webview.cc"}, .flags = &.{"-std=c++11"}}); + sharedLib.addCSourceFile(.{ .file = b.path("external/webview/webview.cc"), .flags = &.{"-std=c++11"} }); sharedLib.linkSystemLibrary("gtk+-3.0"); sharedLib.linkSystemLibrary("webkit2gtk-4.0"); - } + }, } b.installArtifact(sharedLib); }