flake8: Perform suggested whitespace/formatting changes

This only touches newlines, spaces, and (occaisionally) commas.  Anything
else is left for another commit.
pull/2357/head
Luke Shumaker 8 years ago
parent 751d59d952
commit bb25260f00
  1. 31
      mesonbuild/backend/ninjabackend.py
  2. 6
      mesonbuild/backend/vs2010backend.py
  3. 2
      mesonbuild/compilers/c.py
  4. 2
      mesonbuild/compilers/compilers.py
  5. 79
      mesonbuild/interpreter.py
  6. 10
      mesonbuild/mesonmain.py
  7. 22
      mesonbuild/modules/gnome.py
  8. 6
      mesonbuild/modules/i18n.py
  9. 1
      mesonrewriter.py
  10. 34
      msi/createmsi.py
  11. 2
      run_unittests.py
  12. 4
      test cases/common/147 mesonintrospect from scripts/check_env.py

@ -83,10 +83,9 @@ class NinjaBuildElement:
def write(self, outfile): def write(self, outfile):
self.check_outputs() self.check_outputs()
line = 'build %s: %s %s' % ( line = 'build %s: %s %s' % (' '.join([ninja_quote(i) for i in self.outfilenames]),
' '.join([ninja_quote(i) for i in self.outfilenames]), self.rule,
self.rule, ' '.join([ninja_quote(i) for i in self.infilenames]))
' '.join([ninja_quote(i) for i in self.infilenames]))
if len(self.deps) > 0: if len(self.deps) > 0:
line += ' | ' + ' '.join([ninja_quote(x) for x in self.deps]) line += ' | ' + ' '.join([ninja_quote(x) for x in self.deps])
if len(self.orderdeps) > 0: if len(self.orderdeps) > 0:
@ -721,8 +720,7 @@ int dummy;
# On toolchains/platforms that use an import library for # On toolchains/platforms that use an import library for
# linking (separate from the shared library with all the # linking (separate from the shared library with all the
# code), we need to install that too (dll.a/.lib). # code), we need to install that too (dll.a/.lib).
if (isinstance(t, build.SharedLibrary) or if (isinstance(t, build.SharedLibrary) or isinstance(t, build.Executable)) and t.get_import_filename():
isinstance(t, build.Executable)) and t.get_import_filename():
if custom_install_dir: if custom_install_dir:
# If the DLL is installed into a custom directory, # If the DLL is installed into a custom directory,
# install the import library into the same place so # install the import library into the same place so
@ -856,8 +854,9 @@ int dummy;
self.create_target_alias('meson-test', outfile) self.create_target_alias('meson-test', outfile)
# And then benchmarks. # And then benchmarks.
cmd = self.environment.get_build_command(True) + ['test', '--benchmark', '--logbase', cmd = self.environment.get_build_command(True) + [
'benchmarklog', '--num-processes=1', '--no-rebuild'] 'test', '--benchmark', '--logbase',
'benchmarklog', '--num-processes=1', '--no-rebuild']
elem = NinjaBuildElement(self.all_outputs, 'meson-benchmark', 'CUSTOM_COMMAND', ['all', 'PHONY']) elem = NinjaBuildElement(self.all_outputs, 'meson-benchmark', 'CUSTOM_COMMAND', ['all', 'PHONY'])
elem.add_item('COMMAND', cmd) elem.add_item('COMMAND', cmd)
elem.add_item('DESC', 'Running benchmark suite.') elem.add_item('DESC', 'Running benchmark suite.')
@ -1576,9 +1575,10 @@ int dummy;
def generate_swift_compile_rules(self, compiler, outfile): def generate_swift_compile_rules(self, compiler, outfile):
rule = 'rule %s_COMPILER\n' % compiler.get_language() rule = 'rule %s_COMPILER\n' % compiler.get_language()
full_exe = [ninja_quote(x) for x in self.environment.get_build_command()] + [ full_exe = [ninja_quote(x) for x in self.environment.get_build_command()] + [
'--internal', '--internal',
'dirchanger', 'dirchanger',
'$RUNDIR'] '$RUNDIR',
]
invoc = (' '.join(full_exe) + ' ' + invoc = (' '.join(full_exe) + ' ' +
' '.join(ninja_quote(i) for i in compiler.get_exelist())) ' '.join(ninja_quote(i) for i in compiler.get_exelist()))
command = ' command = %s $ARGS $in\n' % invoc command = ' command = %s $ARGS $in\n' % invoc
@ -2527,10 +2527,11 @@ rule FORTRAN_DEP_HACK
def generate_dist(self, outfile): def generate_dist(self, outfile):
elem = NinjaBuildElement(self.all_outputs, 'meson-dist', 'CUSTOM_COMMAND', 'PHONY') elem = NinjaBuildElement(self.all_outputs, 'meson-dist', 'CUSTOM_COMMAND', 'PHONY')
elem.add_item('DESC', 'Creating source packages') elem.add_item('DESC', 'Creating source packages')
elem.add_item('COMMAND', self.environment.get_build_command() + elem.add_item('COMMAND', self.environment.get_build_command() + [
['--internal', 'dist', '--internal', 'dist',
self.environment.source_dir, self.environment.source_dir,
self.environment.build_dir] + self.environment.get_build_command()) self.environment.build_dir,
] + self.environment.get_build_command())
elem.add_item('pool', 'console') elem.add_item('pool', 'console')
elem.write(outfile) elem.write(outfile)
# Alias that runs the target defined above # Alias that runs the target defined above

@ -383,8 +383,7 @@ class Vs2010Backend(backends.Backend):
cmd = [sys.executable, os.path.join(self.environment.get_script_dir(), 'commandrunner.py'), cmd = [sys.executable, os.path.join(self.environment.get_script_dir(), 'commandrunner.py'),
self.environment.get_build_dir(), self.environment.get_build_dir(),
self.environment.get_source_dir(), self.environment.get_source_dir(),
self.get_target_dir(target)] + \ self.get_target_dir(target)] + self.environment.get_build_command()
self.environment.get_build_command()
for i in cmd_raw: for i in cmd_raw:
if isinstance(i, build.BuildTarget): if isinstance(i, build.BuildTarget):
cmd.append(os.path.join(self.environment.get_build_dir(), self.get_target_filename(i))) cmd.append(os.path.join(self.environment.get_build_dir(), self.get_target_filename(i)))
@ -926,8 +925,7 @@ class Vs2010Backend(backends.Backend):
ofile.text = '$(OutDir)%s' % target.get_filename() ofile.text = '$(OutDir)%s' % target.get_filename()
subsys = ET.SubElement(link, 'SubSystem') subsys = ET.SubElement(link, 'SubSystem')
subsys.text = subsystem subsys.text = subsystem
if (isinstance(target, build.SharedLibrary) or if (isinstance(target, build.SharedLibrary) or isinstance(target, build.Executable)) and target.get_import_filename():
isinstance(target, build.Executable)) and target.get_import_filename():
# DLLs built with MSVC always have an import library except when # DLLs built with MSVC always have an import library except when
# they're data-only DLLs, but we don't support those yet. # they're data-only DLLs, but we don't support those yet.
ET.SubElement(link, 'ImportLibrary').text = target.get_import_filename() ET.SubElement(link, 'ImportLibrary').text = target.get_import_filename()

@ -1025,5 +1025,3 @@ class VisualStudioCCompiler(CCompiler):
# and the can not be called. # and the can not be called.
return None return None
return vs32_instruction_set_args.get(instruction_set, None) return vs32_instruction_set_args.get(instruction_set, None)

@ -252,7 +252,7 @@ vs32_instruction_set_args = {'mmx': ['/arch:SSE'], # There does not seem to be a
'avx': ['/arch:AVX'], 'avx': ['/arch:AVX'],
'avx2': ['/arch:AVX2'], 'avx2': ['/arch:AVX2'],
'neon': None, 'neon': None,
} }
# The 64 bit compiler defaults to /arch:avx. # The 64 bit compiler defaults to /arch:avx.
vs64_instruction_set_args = {'mmx': ['/arch:AVX'], vs64_instruction_set_args = {'mmx': ['/arch:AVX'],

@ -1028,7 +1028,6 @@ class CompilerHolder(InterpreterObject):
h) h)
return result return result
def first_supported_argument_method(self, args, kwargs): def first_supported_argument_method(self, args, kwargs):
for i in mesonlib.stringlistify(args): for i in mesonlib.stringlistify(args):
if self.compiler.has_argument(i, self.environment): if self.compiler.has_argument(i, self.environment):
@ -1245,48 +1244,50 @@ class MesonMain(InterpreterObject):
pch_kwargs = set(['c_pch', 'cpp_pch']) pch_kwargs = set(['c_pch', 'cpp_pch'])
lang_arg_kwargs = set(['c_args', lang_arg_kwargs = set([
'cpp_args', 'c_args',
'd_args', 'cpp_args',
'd_import_dirs', 'd_args',
'd_unittest', 'd_import_dirs',
'd_module_versions', 'd_unittest',
'fortran_args', 'd_module_versions',
'java_args', 'fortran_args',
'objc_args', 'java_args',
'objcpp_args', 'objc_args',
'rust_args', 'objcpp_args',
'vala_args', 'rust_args',
'cs_args', 'vala_args',
]) 'cs_args',
])
vala_kwargs = set(['vala_header', 'vala_gir', 'vala_vapi']) vala_kwargs = set(['vala_header', 'vala_gir', 'vala_vapi'])
rust_kwargs = set(['rust_crate_type']) rust_kwargs = set(['rust_crate_type'])
cs_kwargs = set(['resources', 'cs_args']) cs_kwargs = set(['resources', 'cs_args'])
buildtarget_kwargs = set(['build_by_default', buildtarget_kwargs = set([
'build_rpath', 'build_by_default',
'dependencies', 'build_rpath',
'extra_files', 'dependencies',
'gui_app', 'extra_files',
'link_with', 'gui_app',
'link_whole', 'link_with',
'link_args', 'link_whole',
'link_depends', 'link_args',
'implicit_include_directories', 'link_depends',
'include_directories', 'implicit_include_directories',
'install', 'include_directories',
'install_rpath', 'install',
'install_dir', 'install_rpath',
'name_prefix', 'install_dir',
'name_suffix', 'name_prefix',
'native', 'name_suffix',
'objects', 'native',
'override_options', 'objects',
'pic', 'override_options',
'sources', 'pic',
'vs_module_defs', 'sources',
]) 'vs_module_defs',
])
build_target_common_kwargs = ( build_target_common_kwargs = (
buildtarget_kwargs | buildtarget_kwargs |
@ -2013,7 +2014,7 @@ class Interpreter(InterpreterBase):
if not isinstance(use_native, bool): if not isinstance(use_native, bool):
raise InvalidArguments('Argument to "native" must be a boolean.') raise InvalidArguments('Argument to "native" must be a boolean.')
if not use_native: if not use_native:
progobj = self.program_from_cross_file(args) progobj = self.program_from_cross_file(args)
if progobj is None: if progobj is None:
progobj = self.program_from_system(args) progobj = self.program_from_system(args)
if required and (progobj is None or not progobj.found()): if required and (progobj is None or not progobj.found()):

@ -122,11 +122,11 @@ class MesonApp:
if os.path.exists(priv_dir): if os.path.exists(priv_dir):
if not handshake: if not handshake:
print('Directory already configured, exiting Meson. Just run your build command\n' print('Directory already configured, exiting Meson. Just run your build command\n'
'(e.g. ninja) and Meson will regenerate as necessary. If ninja fails, run ninja\n' '(e.g. ninja) and Meson will regenerate as necessary. If ninja fails, run ninja\n'
'reconfigure to force Meson to regenerate.\n' 'reconfigure to force Meson to regenerate.\n'
'\nIf build failures persist, manually wipe your build directory to clear any\n' '\nIf build failures persist, manually wipe your build directory to clear any\n'
'stored system data.\n' 'stored system data.\n'
'\nTo change option values, run meson configure instead.') '\nTo change option values, run meson configure instead.')
sys.exit(0) sys.exit(0)
else: else:
if handshake: if handshake:

@ -697,18 +697,22 @@ This will become a hard error in the future.''')
args.append('--langs=' + '@@'.join(langs)) args.append('--langs=' + '@@'.join(langs))
inscript = build.RunScript(script, args) inscript = build.RunScript(script, args)
potargs = state.environment.get_build_command() + ['--internal', 'yelphelper', 'pot', potargs = state.environment.get_build_command() + [
'--subdir=' + state.subdir, '--internal', 'yelphelper', 'pot',
'--id=' + project_id, '--subdir=' + state.subdir,
'--sources=' + source_str] '--id=' + project_id,
'--sources=' + source_str,
]
pottarget = build.RunTarget('help-' + project_id + '-pot', potargs[0], pottarget = build.RunTarget('help-' + project_id + '-pot', potargs[0],
potargs[1:], [], state.subdir) potargs[1:], [], state.subdir)
poargs = state.environment.get_build_command() + ['--internal', 'yelphelper', 'update-po', poargs = state.environment.get_build_command() + [
'--subdir=' + state.subdir, '--internal', 'yelphelper', 'update-po',
'--id=' + project_id, '--subdir=' + state.subdir,
'--sources=' + source_str, '--id=' + project_id,
'--langs=' + '@@'.join(langs)] '--sources=' + source_str,
'--langs=' + '@@'.join(langs),
]
potarget = build.RunTarget('help-' + project_id + '-update-po', poargs[0], potarget = build.RunTarget('help-' + project_id + '-update-po', poargs[0],
poargs[1:], [], state.subdir) poargs[1:], [], state.subdir)

@ -72,8 +72,10 @@ class I18nModule(ExtensionModule):
datadirs = self._get_data_dirs(state, mesonlib.stringlistify(kwargs.pop('data_dirs', []))) datadirs = self._get_data_dirs(state, mesonlib.stringlistify(kwargs.pop('data_dirs', [])))
datadirs = '--datadirs=' + ':'.join(datadirs) if datadirs else None datadirs = '--datadirs=' + ':'.join(datadirs) if datadirs else None
command = state.environment.get_build_command() + ['--internal', 'msgfmthelper', command = state.environment.get_build_command() + [
'@INPUT@', '@OUTPUT@', file_type, podir] '--internal', 'msgfmthelper',
'@INPUT@', '@OUTPUT@', file_type, podir
]
if datadirs: if datadirs:
command.append(datadirs) command.append(datadirs)

@ -30,4 +30,3 @@ if __name__ == '__main__':
print('Warning: This executable is deprecated. Use "meson rewrite" instead.', print('Warning: This executable is deprecated. Use "meson rewrite" instead.',
file=sys.stderr) file=sys.stderr)
sys.exit(mesonmain.run(['rewrite'] + sys.argv[1:])) sys.exit(mesonmain.run(['rewrite'] + sys.argv[1:]))

@ -56,7 +56,7 @@ class PackageGenerator:
'Title': 'Meson', 'Title': 'Meson',
'Description': 'Meson executables', 'Description': 'Meson executables',
'Level': '1', 'Level': '1',
'Absent': 'disallow', 'Absent': 'disallow',
}, },
self.staging_dirs[1]: { self.staging_dirs[1]: {
'Id': 'NinjaProgram', 'Id': 'NinjaProgram',
@ -109,7 +109,7 @@ class PackageGenerator:
'Language': '1033', 'Language': '1033',
'Codepage': '1252', 'Codepage': '1252',
'Version': self.version, 'Version': self.version,
}) })
package = ET.SubElement(product, 'Package', { package = ET.SubElement(product, 'Package', {
'Id': '*', 'Id': '*',
@ -121,7 +121,7 @@ class PackageGenerator:
'Languages': '1033', 'Languages': '1033',
'Compressed': 'yes', 'Compressed': 'yes',
'SummaryCodepage': '1252', 'SummaryCodepage': '1252',
}) })
if self.bytesize == 64: if self.bytesize == 64:
package.set('Platform', 'x64') package.set('Platform', 'x64')
@ -129,25 +129,26 @@ class PackageGenerator:
'Id': '1', 'Id': '1',
'Cabinet': 'meson.cab', 'Cabinet': 'meson.cab',
'EmbedCab': 'yes', 'EmbedCab': 'yes',
}) })
targetdir = ET.SubElement(product, 'Directory', { targetdir = ET.SubElement(product, 'Directory', {
'Id': 'TARGETDIR', 'Id': 'TARGETDIR',
'Name': 'SourceDir', 'Name': 'SourceDir',
}) })
progfiledir = ET.SubElement(targetdir, 'Directory', { progfiledir = ET.SubElement(targetdir, 'Directory', {
'Id' : self.progfile_dir, 'Id': self.progfile_dir,
}) })
installdir = ET.SubElement(progfiledir, 'Directory', { installdir = ET.SubElement(progfiledir, 'Directory', {
'Id': 'INSTALLDIR', 'Id': 'INSTALLDIR',
'Name': 'Meson'}) 'Name': 'Meson',
})
ET.SubElement(product, 'Property', { ET.SubElement(product, 'Property', {
'Id': 'WIXUI_INSTALLDIR', 'Id': 'WIXUI_INSTALLDIR',
'Value': 'INSTALLDIR', 'Value': 'INSTALLDIR',
}) })
ET.SubElement(product, 'UIRef', { ET.SubElement(product, 'UIRef', {
'Id': 'WixUI_FeatureTree', 'Id': 'WixUI_FeatureTree',
}) })
for sd in self.staging_dirs: for sd in self.staging_dirs:
assert(os.path.isdir(sd)) assert(os.path.isdir(sd))
top_feature = ET.SubElement(product, 'Feature', { top_feature = ET.SubElement(product, 'Feature', {
@ -157,7 +158,7 @@ class PackageGenerator:
'Display': 'expand', 'Display': 'expand',
'Level': '1', 'Level': '1',
'ConfigurableDirectory': 'INSTALLDIR', 'ConfigurableDirectory': 'INSTALLDIR',
}) })
for sd in self.staging_dirs: for sd in self.staging_dirs:
nodes = {} nodes = {}
for root, dirs, files in os.walk(sd): for root, dirs, files in os.walk(sd):
@ -165,7 +166,7 @@ class PackageGenerator:
nodes[root] = cur_node nodes[root] = cur_node
self.create_xml(nodes, sd, installdir, sd) self.create_xml(nodes, sd, installdir, sd)
self.build_features(nodes, top_feature, sd) self.build_features(nodes, top_feature, sd)
ET.ElementTree(self.root).write(self.main_xml, encoding='utf-8',xml_declaration=True) ET.ElementTree(self.root).write(self.main_xml, encoding='utf-8', xml_declaration=True)
# ElementTree can not do prettyprinting so do it manually # ElementTree can not do prettyprinting so do it manually
import xml.dom.minidom import xml.dom.minidom
doc = xml.dom.minidom.parse(self.main_xml) doc = xml.dom.minidom.parse(self.main_xml)
@ -177,8 +178,7 @@ class PackageGenerator:
for component_id in self.feature_components[staging_dir]: for component_id in self.feature_components[staging_dir]:
ET.SubElement(feature, 'ComponentRef', { ET.SubElement(feature, 'ComponentRef', {
'Id': component_id, 'Id': component_id,
}) })
def create_xml(self, nodes, current_dir, parent_xml_node, staging_dir): def create_xml(self, nodes, current_dir, parent_xml_node, staging_dir):
cur_node = nodes[current_dir] cur_node = nodes[current_dir]
@ -187,7 +187,7 @@ class PackageGenerator:
comp_xml_node = ET.SubElement(parent_xml_node, 'Component', { comp_xml_node = ET.SubElement(parent_xml_node, 'Component', {
'Id': component_id, 'Id': component_id,
'Guid': gen_guid(), 'Guid': gen_guid(),
}) })
self.feature_components[staging_dir].append(component_id) self.feature_components[staging_dir].append(component_id)
if self.bytesize == 64: if self.bytesize == 64:
comp_xml_node.set('Win64', 'yes') comp_xml_node.set('Win64', 'yes')
@ -208,14 +208,14 @@ class PackageGenerator:
'Id': file_id, 'Id': file_id,
'Name': f, 'Name': f,
'Source': os.path.join(current_dir, f), 'Source': os.path.join(current_dir, f),
}) })
for dirname in cur_node.dirs: for dirname in cur_node.dirs:
dir_id = os.path.join(current_dir, dirname).replace('\\', '_').replace('/', '_') dir_id = os.path.join(current_dir, dirname).replace('\\', '_').replace('/', '_')
dir_node = ET.SubElement(parent_xml_node, 'Directory', { dir_node = ET.SubElement(parent_xml_node, 'Directory', {
'Id': dir_id, 'Id': dir_id,
'Name': dirname, 'Name': dirname,
}) })
self.create_xml(nodes, os.path.join(current_dir, dirname), dir_node, staging_dir) self.create_xml(nodes, os.path.join(current_dir, dirname), dir_node, staging_dir)
def build_package(self): def build_package(self):

@ -1946,7 +1946,7 @@ cpu = 'armv7' # Not sure if correct.
endian = 'little' endian = 'little'
''' % os.path.join(testdir, 'some_cross_tool.py')) ''' % os.path.join(testdir, 'some_cross_tool.py'))
crossfile.flush() crossfile.flush()
self.init(testdir, ['--cross-file='+crossfile.name]) self.init(testdir, ['--cross-file=' + crossfile.name])
def test_reconfigure(self): def test_reconfigure(self):
testdir = os.path.join(self.unit_test_dir, '13 reconfigure') testdir = os.path.join(self.unit_test_dir, '13 reconfigure')

@ -16,8 +16,8 @@ mesonintrospect = os.environ['MESONINTROSPECT']
introspect_arr = shlex.split(mesonintrospect) introspect_arr = shlex.split(mesonintrospect)
#print(mesonintrospect) # print(mesonintrospect)
#print(introspect_arr) # print(introspect_arr)
some_executable = introspect_arr[0] some_executable = introspect_arr[0]

Loading…
Cancel
Save