Flutter Engine
The Flutter Engine
gen.py
Go to the documentation of this file.
1import subprocess
2import os
3
4gn_in = open("BUILD.input.gn", "rb")
5gn_file = gn_in.read()
6gn_in.close()
7
8
9def get_files(path, exclude=[]):
10 cmd = ["git", "ls-files", "--"]
11 for ex in exclude:
12 cmd.append(":!%s" % ex)
13 cmd.append(path)
14 git_ls = subprocess.Popen(
15 cmd,
16 stdout=subprocess.PIPE,
17 cwd=os.path.join(os.environ["FUCHSIA_DIR"], "third_party", "protobuf"))
18 sed1 = subprocess.Popen(
19 ["sed", "s/^/\"/"], stdin=git_ls.stdout, stdout=subprocess.PIPE)
20 return subprocess.check_output(["sed", "s/$/\",/"], stdin=sed1.stdout)
21
22
23gn_file = gn_file.replace(
24 b"PROTOBUF_LITE_PUBLIC",
26 "src/google/protobuf/*.h",
27 exclude=["*/compiler/*", "*/testing/*", "*/util/*"]))
28gn_file = gn_file.replace(
29 b"PROTOBUF_FULL_PUBLIC",
31 "src/google/protobuf/*.h", exclude=["*/compiler/*", "*/testing/*"]))
32gn_file = gn_file.replace(
33 b"PROTOC_LIB_SOURCES",
35 "src/google/protobuf/compiler/*.cc",
36 exclude=["*/main.cc", "*test*", "*mock*"]))
37
38gn_file = subprocess.check_output(["gn", "format", "--stdin"], input=gn_file)
39
40gn_out = open("BUILD.gn", "wb")
41gn_out.write(
42 b"# THIS FILE IS GENERATED FROM BUILD.input.gn BY gen.py\n# EDIT BUILD.input.gn FIRST AND THEN RUN gen.py\n#\n#\n"
43)
44gn_out.write(gn_file)
def get_files(path, exclude=[])
Definition: gen.py:9