-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathbuild.zig
130 lines (125 loc) · 6.54 KB
/
build.zig
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
const std = @import("std");
pub fn build(b: *std.Build) void {
_ = b.addModule("webview", .{
.root_source_file = b.path("src/webview.zig"),
//.dependencies = &[_]std.Build.ModuleDependency{},
});
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
// const objectFile = b.addObject(.{
// .name = "webviewObject",
// .optimize = optimize,
// .target = target,
// });
// objectFile.defineCMacro("WEBVIEW_STATIC", null);
// objectFile.linkLibCpp();
// switch(target.os_tag orelse @import("builtin").os.tag) {
// .windows => {
// 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");
// objectFile.linkSystemLibrary("version");
// objectFile.linkSystemLibrary("advapi32");
// objectFile.linkSystemLibrary("shell32");
// objectFile.linkSystemLibrary("user32");
// },
// .macos => {
// objectFile.addCSourceFile(.{ .file = b.path("external/webview/webview.cc") .flags = &.{"-std=c++11"}});
// objectFile.linkFramework("WebKit");
// },
// else => {
// objectFile.addCSourceFile(.{ .file = b.path("external/webview/webview.cc") .flags = &.{"-std=c++11"}});
// objectFile.linkSystemLibrary("gtk+-3.0");
// objectFile.linkSystemLibrary("webkit2gtk-4.0");
// }
// }
const staticLib = b.addStaticLibrary(.{
.name = "webviewStatic",
.optimize = optimize,
.target = target,
});
staticLib.defineCMacro("WEBVIEW_STATIC", null);
staticLib.linkLibCpp();
switch (target.query.os_tag orelse @import("builtin").os.tag) {
.windows => {
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");
staticLib.linkSystemLibrary("advapi32");
staticLib.linkSystemLibrary("shell32");
staticLib.linkSystemLibrary("user32");
},
.macos => {
staticLib.addCSourceFile(.{ .file = b.path("external/webview/webview.cc"), .flags = &.{"-std=c++11"} });
staticLib.linkFramework("WebKit");
},
.freebsd => {
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 = b.path("external/webview/webview.cc"), .flags = &.{"-std=c++11"} });
staticLib.linkSystemLibrary("gtk+-3.0");
staticLib.linkSystemLibrary("webkit2gtk-4.0");
},
}
b.installArtifact(staticLib);
const sharedLib = b.addSharedLibrary(.{
.name = "webviewShared",
.optimize = optimize,
.target = target,
});
sharedLib.defineCMacro("WEBVIEW_BUILD_SHARED", null);
sharedLib.linkLibCpp();
switch (target.query.os_tag orelse @import("builtin").os.tag) {
.windows => {
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");
sharedLib.linkSystemLibrary("advapi32");
sharedLib.linkSystemLibrary("shell32");
sharedLib.linkSystemLibrary("user32");
},
.macos => {
sharedLib.addCSourceFile(.{ .file = b.path("external/webview/webview.cc"), .flags = &.{"-std=c++11"} });
sharedLib.linkFramework("WebKit");
},
.freebsd => {
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 = b.path("external/webview/webview.cc"), .flags = &.{"-std=c++11"} });
sharedLib.linkSystemLibrary("gtk+-3.0");
sharedLib.linkSystemLibrary("webkit2gtk-4.0");
},
}
b.installArtifact(sharedLib);
}