Skip to content

Commit

Permalink
More pythons to be formatted
Browse files Browse the repository at this point in the history
  • Loading branch information
veblush committed Jan 4, 2020
1 parent 40d8986 commit e52081f
Show file tree
Hide file tree
Showing 34 changed files with 2,059 additions and 1,682 deletions.
30 changes: 30 additions & 0 deletions .yapfignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,33 @@

# no need to format protoc generated files
*_pb2*.py

# no need to format build-yaml generated files
*.gen.py

# generated files from a template
*test/cpp/naming/resolver_component_tests_runner.py

# No BUILD, .bzl files
*BUILD
*.bzl
*.bazelrc

# No other languages
*.bat
*.c
*.c++
*.cc
*.css
*.go
*.h
*.html
*.json
*.md
*.objc
*.php
*.proto
*.rb
*.sh
*.xml
*.yaml
6 changes: 3 additions & 3 deletions src/abseil-cpp/gen_build_yaml.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@
import os
import yaml

BUILDS_YAML_PATH = os.path.join(
os.path.dirname(os.path.abspath(__file__)), 'preprocessed_builds.yaml')
BUILDS_YAML_PATH = os.path.join(os.path.dirname(os.path.abspath(__file__)),
'preprocessed_builds.yaml')
with open(BUILDS_YAML_PATH) as f:
builds = yaml.load(f)
builds = yaml.load(f)

for build in builds:
build['build'] = 'private'
Expand Down
27 changes: 17 additions & 10 deletions src/benchmark/gen_build_yaml.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,27 @@
import glob
import yaml

os.chdir(os.path.dirname(sys.argv[0])+'/../..')
os.chdir(os.path.dirname(sys.argv[0]) + '/../..')

out = {}

out['libs'] = [{
'name': 'benchmark',
'build': 'private',
'language': 'c++',
'secure': False,
'defaults': 'benchmark',
'src': sorted(glob.glob('third_party/benchmark/src/*.cc')),
'headers': sorted(
glob.glob('third_party/benchmark/src/*.h') +
glob.glob('third_party/benchmark/include/benchmark/*.h')),
'name':
'benchmark',
'build':
'private',
'language':
'c++',
'secure':
False,
'defaults':
'benchmark',
'src':
sorted(glob.glob('third_party/benchmark/src/*.cc')),
'headers':
sorted(
glob.glob('third_party/benchmark/src/*.h') +
glob.glob('third_party/benchmark/include/benchmark/*.h')),
}]

print(yaml.dump(out))
198 changes: 100 additions & 98 deletions src/boringssl/gen_build_yaml.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,122 +21,124 @@

sys.dont_write_bytecode = True

boring_ssl_root = os.path.abspath(os.path.join(
os.path.dirname(sys.argv[0]),
'../../third_party/boringssl'))
boring_ssl_root = os.path.abspath(
os.path.join(os.path.dirname(sys.argv[0]), '../../third_party/boringssl'))
sys.path.append(os.path.join(boring_ssl_root, 'util'))

try:
import generate_build_files
import generate_build_files
except ImportError:
print(yaml.dump({}))
sys.exit()
print(yaml.dump({}))
sys.exit()


def map_dir(filename):
if filename[0:4] == 'src/':
return 'third_party/boringssl/' + filename[4:]
else:
return 'src/boringssl/' + filename
if filename[0:4] == 'src/':
return 'third_party/boringssl/' + filename[4:]
else:
return 'src/boringssl/' + filename


def map_testarg(arg):
if '/' in arg:
return 'third_party/boringssl/' + arg
else:
return arg
if '/' in arg:
return 'third_party/boringssl/' + arg
else:
return arg


class Grpc(object):

yaml = None

def WriteFiles(self, files, asm_outputs):
test_binaries = ['ssl_test', 'crypto_test']

self.yaml = {
'#': 'generated with tools/buildgen/gen_boring_ssl_build_yaml.py',
'raw_boringssl_build_output_for_debugging': {
'files': files,
'asm_outputs': asm_outputs,
},
'libs': [
{
'name': 'boringssl',
'build': 'private',
'language': 'c',
'secure': False,
'src': sorted(
map_dir(f)
for f in files['ssl'] + files['crypto']
),
'headers': sorted(
map_dir(f)
# We want to include files['fips_fragments'], but not build them as objects.
# See https://boringssl-review.googlesource.com/c/boringssl/+/16946
for f in files['ssl_headers'] + files['ssl_internal_headers'] + files['crypto_headers'] + files['crypto_internal_headers'] + files['fips_fragments']
),
'boringssl': True,
'defaults': 'boringssl',
},
{
'name': 'boringssl_test_util',
'build': 'private',
'language': 'c++',
'secure': False,
'boringssl': True,
'defaults': 'boringssl',
'src': [
map_dir(f)
for f in sorted(files['test_support'])
yaml = None

def WriteFiles(self, files, asm_outputs):
test_binaries = ['ssl_test', 'crypto_test']

self.yaml = {
'#':
'generated with tools/buildgen/gen_boring_ssl_build_yaml.py',
'raw_boringssl_build_output_for_debugging': {
'files': files,
'asm_outputs': asm_outputs,
},
'libs': [
{
'name':
'boringssl',
'build':
'private',
'language':
'c',
'secure':
False,
'src':
sorted(
map_dir(f) for f in files['ssl'] + files['crypto']),
'headers':
sorted(
map_dir(f)
# We want to include files['fips_fragments'], but not build them as objects.
# See https://boringssl-review.googlesource.com/c/boringssl/+/16946
for f in files['ssl_headers'] +
files['ssl_internal_headers'] +
files['crypto_headers'] +
files['crypto_internal_headers'] +
files['fips_fragments']),
'boringssl':
True,
'defaults':
'boringssl',
},
{
'name': 'boringssl_test_util',
'build': 'private',
'language': 'c++',
'secure': False,
'boringssl': True,
'defaults': 'boringssl',
'src': [map_dir(f) for f in sorted(files['test_support'])],
}
],
}
],
'targets': [
{
'name': 'boringssl_%s' % test,
'build': 'test',
'run': False,
'secure': False,
'language': 'c++',
'src': sorted(map_dir(f) for f in files[test]),
'vs_proj_dir': 'test/boringssl',
'boringssl': True,
'defaults': 'boringssl',
'deps': [
'boringssl_test_util',
'boringssl',
]
}
for test in test_binaries
],
'tests': [
{
'name': 'boringssl_%s' % test,
'args': [],
'exclude_configs': ['asan', 'ubsan'],
'ci_platforms': ['linux', 'mac', 'posix', 'windows'],
'platforms': ['linux', 'mac', 'posix', 'windows'],
'flaky': False,
'gtest': True,
'language': 'c++',
'boringssl': True,
'defaults': 'boringssl',
'cpu_cost': 1.0
}
for test in test_binaries
]
}
'targets': [{
'name': 'boringssl_%s' % test,
'build': 'test',
'run': False,
'secure': False,
'language': 'c++',
'src': sorted(map_dir(f) for f in files[test]),
'vs_proj_dir': 'test/boringssl',
'boringssl': True,
'defaults': 'boringssl',
'deps': [
'boringssl_test_util',
'boringssl',
]
} for test in test_binaries],
'tests': [{
'name': 'boringssl_%s' % test,
'args': [],
'exclude_configs': ['asan', 'ubsan'],
'ci_platforms': ['linux', 'mac', 'posix', 'windows'],
'platforms': ['linux', 'mac', 'posix', 'windows'],
'flaky': False,
'gtest': True,
'language': 'c++',
'boringssl': True,
'defaults': 'boringssl',
'cpu_cost': 1.0
} for test in test_binaries]
}


os.chdir(os.path.dirname(sys.argv[0]))
os.mkdir('src')
try:
for f in os.listdir(boring_ssl_root):
os.symlink(os.path.join(boring_ssl_root, f),
os.path.join('src', f))
for f in os.listdir(boring_ssl_root):
os.symlink(os.path.join(boring_ssl_root, f), os.path.join('src', f))

g = Grpc()
generate_build_files.main([g])
g = Grpc()
generate_build_files.main([g])

print(yaml.dump(g.yaml))
print(yaml.dump(g.yaml))

finally:
shutil.rmtree('src')
shutil.rmtree('src')
Loading

0 comments on commit e52081f

Please sign in to comment.