Reduce an indent level in the install for loop

if not t.should_install(): continue

No logic changes at all.

Also improve the message when erroring out about insufficient
install_dir: list elements.
pull/1469/head
Nirbheek Chauhan 8 years ago
parent a4255d74f5
commit aa3480daba
  1. 156
      mesonbuild/backend/ninjabackend.py

@ -628,85 +628,87 @@ int dummy;
def generate_target_install(self, d): def generate_target_install(self, d):
for t in self.build.get_targets().values(): for t in self.build.get_targets().values():
if t.should_install(): if not t.should_install():
continue
# Find the installation directory.
outdirs = t.get_custom_install_dir()
custom_install_dir = False
if outdirs[0] is not None and outdirs[0] is not True:
# Either the value is set, or is set to False which means
# we want this specific output out of many outputs to not
# be installed.
custom_install_dir = True
elif isinstance(t, build.SharedLibrary):
outdirs[0] = self.environment.get_shared_lib_dir()
elif isinstance(t, build.StaticLibrary):
outdirs[0] = self.environment.get_static_lib_dir()
elif isinstance(t, build.Executable):
outdirs[0] = self.environment.get_bindir()
else:
assert(isinstance(t, build.BuildTarget))
# XXX: Add BuildTarget-specific install dir cases here
outdirs[0] = self.environment.get_libdir()
# Sanity-check the outputs and install_dirs
num_outdirs, num_out = len(outdirs), len(t.get_outputs())
if num_outdirs != 1 and num_outdirs != num_out:
m = 'Target {!r} has {} outputs: {!r}, but only {} "install_dir"s were found.\n' \
"Pass 'false' for outputs that should not be installed and 'true' for\n" \
'using the default installation directory for an output.'
raise MesonException(m.format(t.name, num_out, t.get_outputs(), num_outdirs))
# Install the target output(s)
if isinstance(t, build.BuildTarget):
should_strip = self.get_option_for_target('strip', t) should_strip = self.get_option_for_target('strip', t)
# Find the installation directory. # Install primary build output (library/executable/jar, etc)
outdirs = t.get_custom_install_dir() # Done separately because of strip/aliases/rpath
custom_install_dir = False if outdirs[0] is not False:
if outdirs[0] is not None and outdirs[0] is not True: i = [self.get_target_filename(t), outdirs[0],
# Either the value is set, or is set to False which means t.get_aliases(), should_strip, t.install_rpath]
# we want this specific output out of many outputs to not d.targets.append(i)
# be installed. # On toolchains/platforms that use an import library for
custom_install_dir = True # linking (separate from the shared library with all the
elif isinstance(t, build.SharedLibrary): # code), we need to install that too (dll.a/.lib).
outdirs[0] = self.environment.get_shared_lib_dir() if isinstance(t, build.SharedLibrary) and t.get_import_filename():
elif isinstance(t, build.StaticLibrary): if custom_install_dir:
outdirs[0] = self.environment.get_static_lib_dir() # If the DLL is installed into a custom directory,
elif isinstance(t, build.Executable): # install the import library into the same place so
outdirs[0] = self.environment.get_bindir() # it doesn't go into a surprising place
else: implib_install_dir = outdirs[0]
assert(isinstance(t, build.BuildTarget)) else:
# XXX: Add BuildTarget-specific install dir cases here implib_install_dir = self.environment.get_import_lib_dir()
outdirs[0] = self.environment.get_libdir() # Install the import library.
# Sanity-check the outputs and install_dirs i = [self.get_target_filename_for_linking(t),
num_outdirs, num_out = len(outdirs), len(t.get_outputs()) implib_install_dir,
if num_outdirs != 1 and num_outdirs != num_out: # It has no aliases, should not be stripped, and
raise MesonException('Target {!r} has {} outputs, but only ' # doesn't have an install_rpath
'{} "install_dir"s were specified' {}, False, '']
''.format(t.name, num_out, num_outdirs))
# Install the target output(s)
if isinstance(t, build.BuildTarget):
# Install primary build output (library/executable/jar, etc)
# Done separately because of strip/aliases/rpath
if outdirs[0] is not False:
i = [self.get_target_filename(t), outdirs[0],
t.get_aliases(), should_strip, t.install_rpath]
d.targets.append(i) d.targets.append(i)
# On toolchains/platforms that use an import library for # Install secondary outputs. Only used for Vala right now.
# linking (separate from the shared library with all the if num_outdirs > 1:
# code), we need to install that too (dll.a/.lib). for output, outdir in zip(t.get_outputs()[1:], outdirs[1:]):
if isinstance(t, build.SharedLibrary) and t.get_import_filename(): # User requested that we not install this output
if custom_install_dir: if outdir is False:
# If the DLL is installed into a custom directory, continue
# install the import library into the same place so f = os.path.join(self.get_target_dir(t), output)
# it doesn't go into a surprising place d.targets.append([f, outdir, {}, False, None])
implib_install_dir = outdirs[0] elif isinstance(t, build.CustomTarget):
else: # If only one install_dir is specified, assume that all
implib_install_dir = self.environment.get_import_lib_dir() # outputs will be installed into it. This is for
# Install the import library. # backwards-compatibility and because it makes sense to
i = [self.get_target_filename_for_linking(t), # avoid repetition since this is a common use-case.
implib_install_dir, #
# It has no aliases, should not be stripped, and # To selectively install only some outputs, pass `false` as
# doesn't have an install_rpath # the install_dir for the corresponding output by index
{}, False, ''] if num_outdirs == 1 and num_out > 1:
d.targets.append(i) for output in t.get_outputs():
# Install secondary outputs. Only used for Vala right now. f = os.path.join(self.get_target_dir(t), output)
if num_outdirs > 1: d.targets.append([f, outdirs[0], {}, False, None])
for output, outdir in zip(t.get_outputs()[1:], outdirs[1:]): else:
# User requested that we not install this output for output, outdir in zip(t.get_outputs(), outdirs):
if outdir is False: # User requested that we not install this output
continue if outdir is False:
f = os.path.join(self.get_target_dir(t), output) continue
d.targets.append([f, outdir, {}, False, None]) f = os.path.join(self.get_target_dir(t), output)
elif isinstance(t, build.CustomTarget): d.targets.append([f, outdir, {}, False, None])
# If only one install_dir is specified, assume that all
# outputs will be installed into it. This is for
# backwards-compatibility and because it makes sense to
# avoid repetition since this is a common use-case.
#
# To selectively install only some outputs, pass `false` as
# the install_dir for the corresponding output by index
if num_outdirs == 1 and num_out > 1:
for output in t.get_outputs():
f = os.path.join(self.get_target_dir(t), output)
d.targets.append([f, outdirs[0], {}, False, None])
else:
for output, outdir in zip(t.get_outputs(), outdirs):
# User requested that we not install this output
if outdir is False:
continue
f = os.path.join(self.get_target_dir(t), output)
d.targets.append([f, outdir, {}, False, None])
def generate_custom_install_script(self, d): def generate_custom_install_script(self, d):
d.install_scripts = self.build.install_scripts d.install_scripts = self.build.install_scripts

Loading…
Cancel
Save