Skip to content

Commit 3258ba9

Browse files
authored
Merge pull request #64 from Alovchin91/alovchin/clang-cl
Build Skia with Clang-CL
2 parents a489b44 + 8772c12 commit 3258ba9

File tree

4 files changed

+31
-2
lines changed

4 files changed

+31
-2
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ permissions:
1616
contents: write
1717

1818
env:
19-
version: m132-9b3c42e2f9-1
19+
version: m132-9b3c42e2f9-2
2020

2121
jobs:
2222
macos:

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,7 @@ python3 script/checkout.py --version m126-6fd3120c1b
2828
python3 script/build.py --build-type Debug
2929
python3 script/archive.py --version m126-6fd3120c1b --build-type Debug
3030
```
31+
32+
### Windows-specific
33+
34+
On Windows, skia-pack requires Clang-cl to be installed. Clang-cl is a part of LLVM and can be downloaded from the [LLVM project's website](https://releases.llvm.org/). Please also make sure that Clang-cl.exe is available on %PATH%.

script/build.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#! /usr/bin/env python3
22

3-
import common, os, subprocess, sys
3+
import common, os, shutil, subprocess, sys
44

55
def main():
66
os.chdir(os.path.join(os.path.dirname(__file__), os.pardir, 'skia'))
@@ -86,6 +86,14 @@ def main():
8686
'skia_use_direct3d=true',
8787
'extra_cflags=["-DSK_FONT_HOST_USE_SYSTEM_SETTINGS"]',
8888
]
89+
if 'windows' == host:
90+
clang_path = shutil.which('clang-cl.exe')
91+
if not clang_path:
92+
raise Exception("Please install LLVM from https://releases.llvm.org/, and make sure that clang-cl.exe is available in PATH")
93+
args += [
94+
'clang_win="' + os.path.dirname(os.path.dirname(clang_path)) + '"',
95+
'is_trivial_abi=false',
96+
]
8997
elif 'android' == target:
9098
args += [
9199
'ndk="'+ ndk + '"'

script/checkout.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,23 @@ def main():
5151
print("> Fetching ninja")
5252
subprocess.check_call(["python3", "bin/fetch-ninja"])
5353

54+
# Patch an issue in Windows toolchain:
55+
# Enable delayed environment variable expansion for CMD to make GitHub Actions happy
56+
# https://issues.skia.org/issues/393402169
57+
with open("gn/toolchain/BUILD.gn", "r") as toolchain_file:
58+
toolchain_file_contents = toolchain_file.read()
59+
60+
toolchain_file_contents = toolchain_file_contents.replace(
61+
'shell = "cmd.exe /c',
62+
'shell = "cmd.exe /v:on /c',
63+
).replace(
64+
r'env_setup = "$shell set \"PATH=%PATH%',
65+
r'env_setup = "$shell set \"PATH=!PATH!',
66+
)
67+
68+
with open("gn/toolchain/BUILD.gn", "w") as toolchain_file:
69+
toolchain_file.write(toolchain_file_contents)
70+
5471
return 0
5572

5673
if __name__ == '__main__':

0 commit comments

Comments
 (0)