10from __future__
import print_function
20parser = argparse.ArgumentParser(description=
'Process some cmdline flags.')
21parser.add_argument(
'--gn', dest=
'gn_cmd', default=
'gn')
22args = parser.parse_args()
25 gn_args =
' '.
join(sorted(
'%s=%s' % (k,v)
for (k,v)
in iter(gn_args.items())))
26 tmp = tempfile.mkdtemp()
27 subprocess.check_call([args.gn_cmd,
'gen', tmp,
'--args=%s' % gn_args,
29 return json.load(open(os.path.join(tmp,
'project.json')))
32 return {str(p.lstrip(
'/'))
for p
in lst}
37 for dep
in js[
'targets'][name][
'deps']:
38 if 'third_party' in dep:
42 if exclude
and isinstance(exclude, str)
and exclude == dep:
44 if exclude
and isinstance(exclude, list)
and dep
in exclude:
47 list_to_extend.update(_strip_slash(js[
'targets'][dep].
get(value_type, [])))
52 cflags = {s
for s
in cflags
if s.startswith(
'-W')}
56 cflags = cflags.union([
57 "-Wno-implicit-fallthrough",
58 "-Wno-missing-field-initializers",
59 "-Wno-sign-conversion",
60 "-Wno-thread-safety-analysis",
61 "-Wno-unknown-warning-option",
62 "-Wno-unused-parameter",
63 "-Wno-unused-variable",
66 cflags = cflags.union([
67 "-fvisibility=hidden",
68 "-D_FORTIFY_SOURCE=1",
70 "-DSKIA_IMPLEMENTATION=1",
71 "-DATRACE_TAG=ATRACE_TAG_VIEW",
75 if "-Weverything" in cflags:
76 cflags.remove(
"-Weverything")
80 cflags = sorted(cflags)
81 cflags.insert(0,
"-U_FORTIFY_SOURCE")
86 if "-Weverything" in cflags_cc:
87 cflags_cc.remove(
"-Weverything")
90 return {s
for s
in cflags_cc
if s.startswith(
'-W')}
92def _get_path_info(path, kind):
93 assert path ==
"../src"
94 assert kind ==
"abspath"
104 builtins = {
'get_path_info': _get_path_info }
106 with open(opts_file)
as f:
107 code =
compile(f.read(), opts_file,
'exec')
108 exec(code, builtins, defs)
112 defs[arch] = [ p.replace(
'$_src',
'src')
for p
in defs[arch]]
118 defines.remove(
'NDEBUG')
119 defines.remove(
'SKIA_IMPLEMENTATION=1')
120 if 'WIN32_LEAN_AND_MEAN' in defines:
121 defines.remove(
'WIN32_LEAN_AND_MEAN')
122 if '_HAS_EXCEPTIONS=0' in defines:
123 defines.remove(
'_HAS_EXCEPTIONS=0')
126 with open(userConfigPath,
'w')
as f:
127 print(
'// DO NOT MODIFY! This file is autogenerated by gn_to_bp.py.', file=f)
128 print(
'// If need to change a define, modify SkUserConfigManual.h', file=f)
129 print(
'#pragma once', file=f)
130 print(
'#include "SkUserConfigManual.h"', file=f)
132 for define
in sorted(defines):
134 print(
'#ifndef', define.split(
'=')[0], file=f)
135 print(
'#define', define.replace(
'=',
' ', 1), file=f)
136 print(
'#endif', file=f)
def GrabDependentValues(js, name, value_type, list_to_extend, exclude)
def CleanupCCFlags(cflags_cc)
def GenerateJSONFromGN(gn_args)
def WriteUserConfig(userConfigPath, defines)
def CleanupCFlags(cflags)
def GetArchSources(opts_file)
const myers::Point & get(const myers::Segment &)
def print(*args, **kwargs)
static SkString join(const CommandLineFlags::StringArray &)