Skip to content

Commit 85e22fc

Browse files
LeonScrogginsSkia Commit-Bot
authored andcommitted
Build Android Framework host library on Mac
Based on ag/5616352, patch set 5. Bug: b/118742766 Test: lunch sdk && mmma external/skia on Mac Similar to the linux build, use a new set of GN arguments to create a json object to fill in the updated template. Add the new include/config/mac folder for the newly generated mac- specific SkUserConfig.h. Include stdarg.h in SkTraceEventCommon, which is necessary for the mac build. Add a new GN arg (skia_use_fonthost_mac) to allow framework build to manually not build SkFontHost_mac.cpp, and use the same font host as the other builds. Change-Id: I654ba496306a3f3591c3937ad5524cd45e49dd65 Reviewed-on: https://skia-review.googlesource.com/c/173183 Reviewed-by: Derek Sollenberger <djsollen@google.com> Reviewed-by: Ben Wagner <bungeman@google.com> Commit-Queue: Leon Scroggins <scroggo@google.com>
1 parent d3c92d9 commit 85e22fc

File tree

3 files changed

+64
-9
lines changed

3 files changed

+64
-9
lines changed

BUILD.gn

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ declare_args() {
2525
skia_use_egl = false
2626
skia_use_expat = true
2727
skia_use_fontconfig = is_linux
28+
skia_use_fonthost_mac = is_mac
2829
skia_use_freetype = is_android || is_fuchsia || is_linux
2930
skia_use_fixed_gamma_text = is_android
3031
skia_use_icu = !is_fuchsia && !is_ios && !is_win # TODO: Windows
@@ -982,10 +983,15 @@ component("skia") {
982983
}
983984
}
984985

986+
if (skia_use_fonthost_mac) {
987+
sources += [
988+
"src/ports/SkFontHost_mac.cpp",
989+
]
990+
}
991+
985992
if (is_mac) {
986993
sources += [
987994
"src/ports/SkDebug_stdio.cpp",
988-
"src/ports/SkFontHost_mac.cpp",
989995
"src/ports/SkImageEncoder_CG.cpp",
990996
"src/ports/SkImageGeneratorCG.cpp",
991997
]

gn/gn_to_bp.py

Lines changed: 55 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,20 @@
114114
"include/config/linux",
115115
],
116116
},
117+
darwin: {
118+
cflags: [
119+
"-mssse3",
120+
],
121+
srcs: [
122+
$mac_srcs
123+
],
124+
local_include_dirs: [
125+
"include/config/mac",
126+
],
127+
export_include_dirs: [
128+
"include/config/mac",
129+
],
130+
},
117131
},
118132
119133
defaults: ["skia_deps",
@@ -179,6 +193,11 @@
179193
"libnativewindow",
180194
],
181195
},
196+
darwin: {
197+
host_ldlibs: [
198+
"-framework AppKit",
199+
],
200+
},
182201
},
183202
}
184203
@@ -268,6 +287,21 @@
268287
'skia_use_fixed_gamma_text': 'true',
269288
}
270289

290+
gn_args_mac = {
291+
'is_official_build': 'true',
292+
'skia_enable_tools': 'true',
293+
'skia_enable_gpu' : 'false',
294+
'skia_use_libheif': 'false',
295+
'skia_use_vulkan': 'false',
296+
'target_cpu': '"none"',
297+
'target_os': '"mac"',
298+
'skia_use_fixed_gamma_text': 'true',
299+
'skia_enable_fontmgr_custom_empty': 'true',
300+
'skia_use_fonthost_mac': 'false',
301+
'skia_use_freetype': 'true',
302+
'skia_enable_fontmgr_android': 'false',
303+
}
304+
271305
js = gn_to_bp_utils.GenerateJSONFromGN(gn_args)
272306

273307
def strip_slashes(lst):
@@ -307,9 +341,16 @@ def strip_headers(sources):
307341
None)
308342
linux_srcs = strip_headers(linux_srcs)
309343

310-
srcs = android_srcs.intersection(linux_srcs)
344+
js_mac = gn_to_bp_utils.GenerateJSONFromGN(gn_args_mac)
345+
mac_srcs = strip_slashes(js_mac['targets']['//:skia']['sources'])
346+
gn_to_bp_utils.GrabDependentValues(js_mac, '//:skia', 'sources', mac_srcs,
347+
None)
348+
mac_srcs = strip_headers(mac_srcs)
349+
350+
srcs = android_srcs.intersection(linux_srcs).intersection(mac_srcs)
311351
android_srcs = android_srcs.difference(srcs)
312352
linux_srcs = linux_srcs.difference(srcs)
353+
mac_srcs = mac_srcs.difference(srcs)
313354
dm_srcs = strip_headers(dm_srcs)
314355
nanobench_srcs = strip_headers(nanobench_srcs)
315356

@@ -323,12 +364,14 @@ def get_defines(json):
323364
return {str(d) for d in json['targets']['//:skia']['defines']}
324365
android_defines = get_defines(js)
325366
linux_defines = get_defines(js_linux)
367+
mac_defines = get_defines(js_mac)
326368

327369
def mkdir_if_not_exists(path):
328370
if not os.path.exists(path):
329371
os.mkdir(path)
330372
mkdir_if_not_exists('include/config/android/')
331373
mkdir_if_not_exists('include/config/linux/')
374+
mkdir_if_not_exists('include/config/mac/')
332375

333376
platforms = { 'IOS', 'MAC', 'WIN', 'ANDROID', 'UNIX' }
334377

@@ -358,18 +401,21 @@ def append_to_file(config, s):
358401
#endif''')
359402
disallow_platforms(android_config, 'ANDROID')
360403

361-
linux_config = 'include/config/linux/SkUserConfig.h'
362-
gn_to_bp_utils.WriteUserConfig(linux_config, linux_defines)
363-
append_to_file(linux_config, '''
404+
def write_config(config_path, defines, platform):
405+
gn_to_bp_utils.WriteUserConfig(config_path, defines)
406+
append_to_file(config_path, '''
364407
// Correct SK_BUILD_FOR flags that may have been set by
365408
// SkPreConfig.h/Android.bp
366-
#ifndef SK_BUILD_FOR_UNIX
367-
#define SK_BUILD_FOR_UNIX
409+
#ifndef SK_BUILD_FOR_%s
410+
#define SK_BUILD_FOR_%s
368411
#endif
369412
#ifdef SK_BUILD_FOR_ANDROID
370413
#undef SK_BUILD_FOR_ANDROID
371-
#endif''')
372-
disallow_platforms(linux_config, 'UNIX')
414+
#endif''' % (platform, platform))
415+
disallow_platforms(config_path, platform)
416+
417+
write_config('include/config/linux/SkUserConfig.h', linux_defines, 'UNIX')
418+
write_config('include/config/mac/SkUserConfig.h', mac_defines, 'MAC')
373419

374420
# Turn a list of strings into the style bpfmt outputs.
375421
def bpfmt(indent, lst, sort=True):
@@ -406,4 +452,5 @@ def bpfmt(indent, lst, sort=True):
406452

407453
'android_srcs': bpfmt(10, android_srcs),
408454
'linux_srcs': bpfmt(10, linux_srcs),
455+
'mac_srcs': bpfmt(10, mac_srcs),
409456
})

src/core/SkTraceEventCommon.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@
6262
#ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK
6363

6464
#include <cutils/trace.h>
65+
#include <stdarg.h>
66+
6567
class SkAndroidFrameworkTraceUtil {
6668
public:
6769
SkAndroidFrameworkTraceUtil(const char* name) {

0 commit comments

Comments
 (0)