deno.land / x / skia_canvas@0.5.8 / scripts / build_skia.ts

نووسراو ببینە
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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
const _CURRENT_HASH = "2290b0b75a8abb80e23d9cb9aced5b5cebbf702d";const CURRENT_HASH_SHORT = "2290b0b";
Deno.chdir(new URL("../skia", import.meta.url));
const SLICE_WIN = Deno.build.os === "windows" ? 1 : 0;
const $ = (cmd: string | URL, ...args: string[]) => { console.log(`%c$ ${cmd.toString()} ${args.join(" ")}`, "color: #888"); const c = typeof cmd === "string" ? cmd : cmd.pathname.slice(SLICE_WIN); new Deno.Command(c, { args, cwd: new URL("../skia", import.meta.url), stdin: "null", stdout: "inherit", stderr: "inherit", }).outputSync();};
if (Deno.env.get("SKIA_FROM_SOURCE") !== "1") { const relName = `skia-${CURRENT_HASH_SHORT}`; let os = ""; switch (Deno.build.os) { case "windows": os = "Windows"; break; case "darwin": os = "macOS"; break; case "linux": os = "Linux"; break; } if ((Deno.env.get("TARGET_ARCH") || Deno.build.arch) === "aarch64") { os += "-aarch64"; } try { Deno.mkdirSync("./out/Release", { recursive: true }); // deno-lint-ignore no-empty } catch (_) {} console.log("Downloading zip"); const data = await fetch( `https://github.com/DjDeveloperr/skia_builds/releases/download/${relName}/skia-${os}.zip`, ) .then((res) => res.arrayBuffer()) .then((buffer) => new Uint8Array(buffer)); await Deno.writeFile( new URL(`../skia/out/Release/prebuilt.zip`, import.meta.url), data, ); $( "unzip", "-o", "-d", Deno.build.os === "windows" ? "./out/Release" : "../", new URL(`../skia/out/Release/prebuilt.zip`, import.meta.url).pathname.slice( Deno.build.os === "windows" ? 1 : 0, ), ); console.log(`Downloaded prebuilt binaries (${relName}, ${os})`); Deno.exit(0);}
// deno-lint-ignore no-explicit-anyconst BUILD_ARGS: Record<string, any> = { cc: Deno.build.os === "windows" ? '"clang-cl"' : '"clang"', cxx: Deno.build.os === "windows" ? '"clang-cl"' : '"clang++"', is_official_build: false, skia_use_system_harfbuzz: false, werror: false, skia_use_system_libpng: false, skia_use_system_libwebp: false, skia_use_system_zlib: false, skia_use_system_icu: false, skia_use_system_expat: false, skia_use_system_libjpeg_turbo: false, skia_use_lua: false, skia_use_piex: false, is_debug: false, is_component_build: false, skia_enable_gpu: true, skia_use_gl: true, // skia_use_harfbuzz: true, skia_use_icu: true, skia_use_libjpeg_turbo_decode: true, skia_use_libjpeg_turbo_encode: true, skia_use_libheif: true, skia_use_libwebp_decode: true, skia_use_libwebp_encode: true, skia_use_freetype: true, skia_use_freetype_woff2: true, skia_use_fontconfig: false, skia_use_x11: Deno.build.os === "linux", skia_enable_skottie: false, skia_enable_tools: false, skia_use_sfntly: false, skia_use_system_freetype2: false, paragraph_gms_enabled: false, paragraph_tests_enabled: false, skia_enable_android_utils: false, skia_enable_discrete_gpu: true, skia_enable_particles: true, skia_enable_pdf: true, skia_enable_skshaper: true, skia_enable_svg: true, skia_enable_skparagraph: true, skia_enable_sktext: true, skia_pdf_subset_harfbuzz: true, skia_use_expat: true, skia_use_wuffs: true,};
BUILD_ARGS["extra_cflags_cc"] = "[";
if (Deno.build.os === "windows") { BUILD_ARGS["clang_win"] = '"C:\\\\Program Files\\\\LLVM"';
BUILD_ARGS["extra_cflags_cc"] += '"/std:c++17",' + '"/MT",' + '"-DSK_FORCE_RASTER_PIPELINE_BLITTER",' + '"-DSK_ENABLE_SVG",' + '"-DSK_RELEASE",' + '"-DSK_DISABLE_TRACING",' + '"-DSK_ENCODE_WEBP",' + '"-DSK_CODEC_DECODES_WEBP",' + '"-DSK_ENCODE_PNG",' + '"-DSK_CODEC_DECODES_PNG",' + '"-DSK_ENCODE_JPEG",' + '"-DSK_CODEC_DECODES_JPEG",' + '"-DSK_HAS_HEIF_LIBRARY",' + '"-DSK_SHAPER_HARFBUZZ_AVAILABLE"';} else { BUILD_ARGS["extra_cflags_cc"] += '"-std=c++17",' + '"-fno-exceptions",' + '"-DSK_FORCE_RASTER_PIPELINE_BLITTER",' + '"-DSK_ENABLE_SVG",' + '"-DSK_RELEASE",' + '"-DSK_DISABLE_TRACING",' + '"-DSK_ENCODE_WEBP",' + '"-DSK_CODEC_DECODES_WEBP",' + '"-DSK_ENCODE_PNG",' + '"-DSK_CODEC_DECODES_PNG",' + '"-DSK_ENCODE_JPEG",' + '"-DSK_CODEC_DECODES_JPEG",' + '"-DSK_HAS_HEIF_LIBRARY",' + '"-DSK_SHAPER_HARFBUZZ_AVAILABLE"';
const targetArm64 = Deno.env.get("TARGET_ARM64") === "1"; const m1 = Deno.build.os === "darwin" && Deno.build.arch === "aarch64"; if (m1 || targetArm64) { BUILD_ARGS["target_cpu"] = `"arm64"`; BUILD_ARGS["target_os"] = `"mac"`; BUILD_ARGS["extra_cflags_cc"] += ', "--target=arm64-apple-macos"'; BUILD_ARGS["extra_ldflags"] = '["--target=arm64-apple-macos"]'; BUILD_ARGS["extra_asmflags"] = '["--target=arm64-apple-macos"]'; BUILD_ARGS["extra_cflags"] = '["--target=arm64-apple-macos"]'; BUILD_ARGS["extra_cflags_c"] = '["--target=arm64-apple-macos"]'; }}
BUILD_ARGS["extra_cflags_cc"] += "]";
if (!Deno.args.includes("skip-sync-deps")) { $( Deno.build.os === "windows" ? "python" : "python3", "./tools/git-sync-deps", );}
if (Deno.build.os === "windows") { const SkLoadICU = new URL( "../skia/third_party/icu/SkLoadICU.cpp", import.meta.url, ); const original = Deno.readTextFileSync(SkLoadICU); Deno.writeTextFileSync( SkLoadICU, original.replace( `load_from(executable_directory()) || load_from(library_directory());`, `load_from(library_directory()) || load_from(executable_directory());`, ), ); window.onunload = () => { Deno.writeTextFileSync(SkLoadICU, original); };}
$( new URL("../skia/bin/gn", import.meta.url), "gen", "out/Release", "--args=" + Object.entries(BUILD_ARGS).map(([k, v]) => `${k}=${v}`).join(" "),);
$("ninja", "-j 24", "-C", "out/Release");
skia_canvas

Version Info

Tagged at
8 months ago