Commit Graph

58 Commits

Author SHA1 Message Date
Mike Sinkovsky 84902cb93a style: [E301] expected 1 blank line, found 0 2017-01-11 12:33:27 -05:00
Mike Sinkovsky e9a891fe25 style: [E502] the backslash is redundant between brackets 2017-01-11 12:33:27 -05:00
Igor Gnatenko 969dc7e995 style: fix E124 violations
E124: closing bracket does not match visual indentation

Signed-off-by: Igor Gnatenko <i.gnatenko.brain@gmail.com>
2017-01-01 12:02:05 -05:00
Igor Gnatenko ef608f217d style: fix E222 violations
E222: multiple spaces after operator

Signed-off-by: Igor Gnatenko <i.gnatenko.brain@gmail.com>
2017-01-01 12:02:05 -05:00
Jussi Pakkanen b55235dfbd Fix space before :. 2016-12-31 16:28:15 +02:00
Nirbheek Chauhan a97291dc6d Add get_version() method to all dependencies
We unconditionally check the version of all dependencies, so without
this regen will fail if you use that dependency.
2016-12-23 19:07:45 +02:00
Nirbheek Chauhan de0b02ee2d Store pkg-config path on the instance too
We were storing the pkg-config path on the class as a static variable --
PkgConfigDependency.pkgbin. When we regenerate via Ninja, the found-deps
are all cached in a pickled coredata, so if you have a statement that
does dep.get_pkgconfig_variable(), it will raise the following exception
because the static class variables are per-meson-invocation.

To fix this, we store the pkg-config binary as both a class variable and
an instance variable.

Traceback (most recent call last):
  File "/home/nirbheek/projects/repositories/github/meson.git/mesonbuild/mesonmain.py", line 289, in run
    app.generate()
  File "/home/nirbheek/projects/repositories/github/meson.git/mesonbuild/mesonmain.py", line 177, in generate
    intr.run()
  File "/home/nirbheek/projects/repositories/github/meson.git/mesonbuild/interpreter.py", line 2215, in run
    super().run()
  File "/home/nirbheek/projects/repositories/github/meson.git/mesonbuild/interpreterbase.py", line 124, in run
    self.evaluate_codeblock(self.ast, start=1)
  File "/home/nirbheek/projects/repositories/github/meson.git/mesonbuild/interpreterbase.py", line 145, in evaluate_codeblock
    raise e
  File "/home/nirbheek/projects/repositories/github/meson.git/mesonbuild/interpreterbase.py", line 139, in evaluate_codeblock
    self.evaluate_statement(cur)
  File "/home/nirbheek/projects/repositories/github/meson.git/mesonbuild/interpreterbase.py", line 150, in evaluate_statement
    return self.function_call(cur)
  File "/home/nirbheek/projects/repositories/github/meson.git/mesonbuild/interpreterbase.py", line 371, in function_call
    return self.funcs[func_name](node, self.flatten(posargs), kwargs)
  File "/home/nirbheek/projects/repositories/github/meson.git/mesonbuild/interpreterbase.py", line 47, in wrapped
    return f(self, node, args, kwargs)
  File "/home/nirbheek/projects/repositories/github/meson.git/mesonbuild/interpreter.py", line 2035, in func_subdir
    self.evaluate_codeblock(codeblock)
  File "/home/nirbheek/projects/repositories/github/meson.git/mesonbuild/interpreterbase.py", line 145, in evaluate_codeblock
    raise e
  File "/home/nirbheek/projects/repositories/github/meson.git/mesonbuild/interpreterbase.py", line 139, in evaluate_codeblock
    self.evaluate_statement(cur)
  File "/home/nirbheek/projects/repositories/github/meson.git/mesonbuild/interpreterbase.py", line 160, in evaluate_statement
    return self.evaluate_if(cur)
  File "/home/nirbheek/projects/repositories/github/meson.git/mesonbuild/interpreterbase.py", line 213, in evaluate_if
    self.evaluate_codeblock(i.block)
  File "/home/nirbheek/projects/repositories/github/meson.git/mesonbuild/interpreterbase.py", line 145, in evaluate_codeblock
    raise e
  File "/home/nirbheek/projects/repositories/github/meson.git/mesonbuild/interpreterbase.py", line 139, in evaluate_codeblock
    self.evaluate_statement(cur)
  File "/home/nirbheek/projects/repositories/github/meson.git/mesonbuild/interpreterbase.py", line 160, in evaluate_statement
    return self.evaluate_if(cur)
  File "/home/nirbheek/projects/repositories/github/meson.git/mesonbuild/interpreterbase.py", line 213, in evaluate_if
    self.evaluate_codeblock(i.block)
  File "/home/nirbheek/projects/repositories/github/meson.git/mesonbuild/interpreterbase.py", line 145, in evaluate_codeblock
    raise e
  File "/home/nirbheek/projects/repositories/github/meson.git/mesonbuild/interpreterbase.py", line 139, in evaluate_codeblock
    self.evaluate_statement(cur)
  File "/home/nirbheek/projects/repositories/github/meson.git/mesonbuild/interpreterbase.py", line 182, in evaluate_statement
    return self.evaluate_plusassign(cur)
  File "/home/nirbheek/projects/repositories/github/meson.git/mesonbuild/interpreterbase.py", line 333, in evaluate_plusassign
    addition = self.evaluate_statement(node.value)
  File "/home/nirbheek/projects/repositories/github/meson.git/mesonbuild/interpreterbase.py", line 166, in evaluate_statement
    return self.evaluate_arraystatement(cur)
  File "/home/nirbheek/projects/repositories/github/meson.git/mesonbuild/interpreterbase.py", line 193, in evaluate_arraystatement
    (arguments, kwargs) = self.reduce_arguments(cur.args)
  File "/home/nirbheek/projects/repositories/github/meson.git/mesonbuild/interpreterbase.py", line 515, in reduce_arguments
    reduced_pos = [self.evaluate_statement(arg) for arg in args.arguments]
  File "/home/nirbheek/projects/repositories/github/meson.git/mesonbuild/interpreterbase.py", line 515, in <listcomp>
    reduced_pos = [self.evaluate_statement(arg) for arg in args.arguments]
  File "/home/nirbheek/projects/repositories/github/meson.git/mesonbuild/interpreterbase.py", line 154, in evaluate_statement
    return self.method_call(cur)
  File "/home/nirbheek/projects/repositories/github/meson.git/mesonbuild/interpreterbase.py", line 399, in method_call
    return obj.method_call(method_name, self.flatten(args), kwargs)
  File "/home/nirbheek/projects/repositories/github/meson.git/mesonbuild/interpreter.py", line 982, in method_call
    value = fn(state, args, kwargs)
  File "/home/nirbheek/projects/repositories/github/meson.git/mesonbuild/modules/gnome.py", line 499, in generate_gir
    girdir = dep.get_pkgconfig_variable("girdir")
  File "/home/nirbheek/projects/repositories/github/meson.git/mesonbuild/dependencies.py", line 219, in get_pkgconfig_variable
    ret, out = self._call_pkgbin(['--variable=' + variable_name, self.name])
  File "/home/nirbheek/projects/repositories/github/meson.git/mesonbuild/dependencies.py", line 184, in _call_pkgbin
    p, out = Popen_safe([PkgConfigDependency.pkgbin] + args, env=os.environ)[0:2]
  File "/home/nirbheek/projects/repositories/github/meson.git/mesonbuild/mesonlib.py", line 392, in Popen_safe
    stderr=stderr, **kwargs)
  File "/usr/lib64/python3.5/subprocess.py", line 947, in __init__
    restore_signals, start_new_session)
  File "/usr/lib64/python3.5/subprocess.py", line 1474, in _execute_child
    executable = os.fsencode(executable)
  File "/usr/lib64/python3.5/os.py", line 862, in fsencode
    raise TypeError("expect bytes or str, not %s" % type(filename).__name__)
TypeError: expect bytes or str, not NoneType
FAILED: build.ninja
'/usr/bin/python3' '/home/nirbheek/projects/repositories/github/meson.git/meson.py' --internal regenerate '/home/nirbheek/projects/repositories/gst/gstreamer' '/home/nirbheek/projects/repositories/gst/gstreamer/build' --backend ninja
ninja: error: rebuilding 'build.ninja': subcommand failed
2016-12-21 21:14:45 +02:00
Jussi Pakkanen a2528a8816 Merge pull request #1233 from mesonbuild/wip/ignatenko/code-style
Trivial cleanups in code
2016-12-21 00:09:44 +02:00
Nirbheek Chauhan 9bc07a0941 Fix several more lint errors
Found by Igor Gnatenko

************* Module mesonbuild.interpreter
E:1232,33: No value for argument 'interp' in constructor call (no-value-for-parameter)
************* Module mesonbuild.dependencies
E: 68, 4: An attribute defined in mesonbuild.dependencies line 39 hides this method (method-hidden)
************* Module mesonbuild.environment
E: 26, 0: class already defined line 19 (function-redefined)
E: 68,18: Undefined variable 'InterpreterException' (undefined-variable)
E:641,39: Undefined variable 'want_cross' (undefined-variable)
E:850,94: Undefined variable 'varname' (undefined-variable)
E:854,94: Undefined variable 'varname' (undefined-variable)
E:860,102: Undefined variable 'varname' (undefined-variable)
E:863,94: Undefined variable 'varname' (undefined-variable)
************* Module mesonbuild.modules.gnome
E:438,26: Undefined variable 'compilers' (undefined-variable)
2016-12-20 00:07:00 +02:00
Igor Gnatenko 139e020ede tree-wide: use proper 'not in' notation
Let's be more pythonic and 'not is' seems really weird.

Signed-off-by: Igor Gnatenko <i.gnatenko.brain@gmail.com>
2016-12-19 21:48:35 +01:00
Nirbheek Chauhan b4cead2763 find_program: Don't leak mutable array in get_command()
In several places in the gnome module, we are getting an array from this
and directly appending to it which changes the original command array
ever since we started caching the find_program results.

We urgently need to move to immutable types for all object properties.

Reported by Alexandor Larsson on IRC.
2016-12-19 21:37:27 +02:00
Igor Gnatenko 8268eb4959 tree-wide: remove unused imports
./setup.py:17:1: F401 'os' imported but unused
import os
^
./setup.py:37:1: F401 'stat.ST_MODE' imported but unused
from stat import ST_MODE
^
./run_tests.py:17:1: F401 'os' imported but unused
import subprocess, sys, os
^
./run_tests.py:18:1: F401 'shutil' imported but unused
import shutil
^
./run_unittests.py:23:1: F401 'mesonbuild.dependencies.Qt5Dependency' imported but unused
from mesonbuild.dependencies import PkgConfigDependency, Qt5Dependency
^
./mesonbuild/build.py:15:1: F401 '.coredata' imported but unused
from . import coredata
^
./mesonbuild/interpreter.py:32:1: F401 'subprocess' imported but unused
import os, sys, subprocess, shutil, uuid, re
^
./mesonbuild/interpreter.py:32:1: F401 're' imported but unused
import os, sys, subprocess, shutil, uuid, re
^
./mesonbuild/dependencies.py:23:1: F401 'subprocess' imported but unused
import os, stat, glob, subprocess, shutil
^
./mesonbuild/mesonlib.py:17:1: F401 'sys' imported but unused
import platform, subprocess, operator, os, shutil, re, sys
^
./mesonbuild/modules/qt5.py:15:1: F401 'subprocess' imported but unused
import os, subprocess
^
./mesonbuild/modules/pkgconfig.py:15:1: F401 '..coredata' imported but unused
from .. import coredata, build
^
./mesonbuild/scripts/scanbuild.py:15:1: F401 'sys' imported but unused
import sys, os
^
./mesonbuild/scripts/meson_exe.py:20:1: F401 'subprocess' imported but unused
import subprocess
^
./mesonbuild/scripts/meson_exe.py:22:1: F401 '..mesonlib.MesonException' imported but unused
from ..mesonlib import MesonException, Popen_safe
^
./mesonbuild/scripts/symbolextractor.py:23:1: F401 'subprocess' imported but unused
import os, sys, subprocess
^
./mesonbuild/scripts/symbolextractor.py:25:1: F401 '..mesonlib.MesonException' imported but unused
from ..mesonlib import MesonException, Popen_safe
^
./mesonbuild/scripts/meson_install.py:19:1: F401 '..mesonlib.MesonException' imported but unused
from ..mesonlib import MesonException, Popen_safe
^
./mesonbuild/scripts/yelphelper.py:15:1: F401 'sys' imported but unused
import sys, os
^
./mesonbuild/scripts/yelphelper.py:20:1: F401 '..mesonlib.MesonException' imported but unused
from ..mesonlib import MesonException
^
./mesonbuild/backend/vs2010backend.py:17:1: F401 're' imported but unused
import re
^
./test cases/vala/8 generated sources/src/copy_file.py:3:1: F401 'os' imported but unused
import os
^
./test cases/common/107 postconf/postconf.py:3:1: F401 'sys' imported but unused
import sys, os
^
./test cases/common/129 object only target/obj_generator.py:5:1: F401 'shutil' imported but unused
import sys, shutil, subprocess
^
./test cases/common/57 custom target chain/usetarget/subcomp.py:3:1: F401 'os' imported but unused
import sys, os
^
./test cases/common/95 dep fallback/subprojects/boblib/genbob.py:3:1: F401 'os' imported but unused
import os
^
./test cases/common/98 gen extra/srcgen.py:4:1: F401 'os' imported but unused
import os
^
./test cases/common/113 generatorcustom/gen.py:3:1: F401 'os' imported but unused
import sys, os
^
./test cases/common/113 generatorcustom/catter.py:3:1: F401 'os' imported but unused
import sys, os
^
./test cases/common/59 object generator/obj_generator.py:5:1: F401 'shutil' imported but unused
import sys, shutil, subprocess
^

Signed-off-by: Igor Gnatenko <i.gnatenko.brain@gmail.com>
2016-12-19 18:19:35 +01:00
Elliott Sales de Andrade f9c1cc9d93 Fix pkg-config during cross-compile. 2016-12-19 14:07:25 +02:00
Nirbheek Chauhan ade1f695a6 Fix detection of pkg-config on all platforms
a) Don't search for pkg-config if we're only cross-compiling
b) Don't unconditionally error out while cross-compiling if the
   specified pkg-config is not found and the dependency is optional
c) Use the pkg-config binary that was found in check_pkgconfig for the
   actual testing
d) Use shutil.which on the found pkg-config only if it finds it.
   Sometimes shutil.which fails to find it, for instance on Windows
   with absolute paths.
2016-12-18 13:41:56 +05:30
Nirbheek Chauhan ef2c2eeed1 QtDependency: Only use -fPIC on Linux
It is enabled by default on OS X and on it doesn't make sense on
Windows.
2016-12-18 13:40:50 +05:30
Nirbheek Chauhan 361ae8d22b qt: Fix detection of tools on Windows
When you pass an absolute path to shutil.which, it will not implicitly
append any extensions. This is problematic on Windows, so we need to
account for that.

This fixes detection of Qt tools on Windows which are searched with the
full path to the Qt bindir.
2016-12-18 13:38:39 +05:30
Nirbheek Chauhan 807a53c6fc PkgConfigDependency.version_reqs must be a list
If it isn't, the --target-glib check in generate_vala_compile will
iterate over the version_reqs as a string and fail to add the
--target-glib argument.
2016-12-15 04:12:23 +05:30
Nirbheek Chauhan 60716fcd6d Use universal_newlines=True for all Popen calls
Instead of adding it everywhere manually, create a wrapper called
mesonlib.Popen_safe and use that everywhere that we call an executable
and extract its output.

This will also allow us to tweak it to do more/different things if
needed for some locales and/or systems.

Closes #1079
2016-12-11 01:59:58 +02:00
Nirbheek Chauhan 2c5680d721 python3 dep: Check arch of libraries before using
On Windows, we can build with both 32-bit and 64-bit compilers, but the
Python is either 32-bit or 64-bit. Check the architecture of the found
Python libraries and don't use them if they don't match our
build_machine.

Also skip the tests if the Python 3 dependency is not found.
2016-12-10 00:58:50 +02:00
Marc-Antoine Perennou 6d1b6de6b0 dependencies: allow overriding pkg-config with PKG_CONFIG when setting pkgbin
Signed-off-by: Marc-Antoine Perennou <Marc-Antoine@Perennou.com>
2016-12-05 10:57:10 +01:00
Marc-Antoine Perennou e9b2084592 dependencies: allow overriding pkg-config with PKG_CONFIG in check_pkgconfig
Signed-off-by: Marc-Antoine Perennou <Marc-Antoine@Perennou.com>
2016-12-05 10:57:10 +01:00
Nirbheek Chauhan e1c9d94708 Allow many version conditions for pkg-config deps
Sometimes we want to restrict the acceptable versions to a list of
versions, or a smallest-version + largest-version, or both. For
instance, GStreamer's opencv plugin is only compatible with
3.1.0 >= opencv >= 2.3.0
2016-12-03 21:46:20 +02:00
Nirbheek Chauhan 09fd24ea78 Always catch PermissionError while looking for Ninja
Also convert a few other generic `except Exception`s to be more specific

Closes #1088
2016-11-26 12:56:08 -05:00
Jussi Pakkanen c23c822196 Only add src_include_dir if it has been defined. 2016-11-14 11:43:37 -05:00
Jussi Pakkanen 08c82fd17c Merge pull request #1042 from centricular/fix-qt4-testcase-qtwidgets
qt: Fix qmake detection on Linux and Windows
2016-11-13 12:38:17 -05:00
Jussi Pakkanen 918b8d098d GTest and GMock changed their entire project layout on 1.8.0. Again. Fix it. 2016-11-13 11:00:04 -05:00
Nirbheek Chauhan 69aafd141e qt: Fix qmake detection on Linux and Windows
qmake for both Qt4 and Qt5 detection was assuming that it was only used
on Windows, which is incorrect. It can also be used on Linux for
cross-compilation or in general when pkg-config is not available.

It was also not failing properly for both Qt5 and Qt4 when no libraries
were found, and was assuming that the .dll was always available.

Qt4 detection with qmake was also completely broken.

Also prevents unwanted injection of partially-found qt dependencies in
targets by unsetting self.cargs and self.largs
2016-11-13 16:50:09 +05:30
Nirbheek Chauhan 085650a1e3 vala: Implement valac.find_library
Move CCompiler.compile to Compiler.compile so that ValaCompiler can use
it. Also rewrite ValaCompiler.sanity_check to use it since it does
a simple compile check.

At the same time, it enhances ExternalLibrary to support arguments for
languages other than C-like.

Includes a test for this that links against zlib through Vala.

Closes #983
2016-11-12 13:56:17 -05:00
Nirbheek Chauhan a72740a0d1 qt deps: New abstract impl and several fixes
* Simpler picking of pkg-config vs qmake detection
* qmake-based detection now allows specifying qmake via cross-info
* bindir is now stored from qmake/pkg-config detection and can be used
  to detect qt tools such as moc, uic, rcc with self.compilers_detect()
* Qt4 dependencies got some love; now they share the implementation with
  Qt5 since the two are very similar; basically identical
* Don't ask about Qt3
2016-11-11 01:51:02 +05:30
Nirbheek Chauhan f79c4396f8 Add repr() implementation for Dependency()
Easier to debug
2016-10-23 18:02:02 +05:30
Jussi Pakkanen e908910187 Can query pkg-config variables from the system. Closes #726. 2016-10-19 22:36:34 +03:00
Thibault Saunier 7e2390f355 interpreter: Add a type_name method to DependencyHolder
And remove the InternalDependencyHolder class.

In some cases we need to know the type of dependency we are
dealing with. For example in GStreamer if the dependency
is not an internal one, then we need to get some env var
from pkg-config to know where to find some plugins necessary
to run some tests.
2016-10-14 11:25:15 +02:00
Nirbheek Chauhan 6ffae922cc Add a unittest for pkg-config file generation
This also tests that -lfoo is correctly added to libfoo.pc when the
library name is 'libfoo' and name_prefix is ''
2016-10-13 02:19:02 +05:30
Nirbheek Chauhan 5e384b8396 dependencies: Use a wrapper for calling pkg-config
Reduces duplicated code, and also use universal_newlines=True which
avoids having to decode the bytes output to string.

We mostly need this so we can pass the *current* process environment to
pkg-config which might've changed since the module was imported. Without
this, subprocess.Popen invokes pkg-config with a stale environment (used
in the unittest added later)
2016-10-13 02:18:24 +05:30
Thibault Saunier 6eacca2024 dependencies: Fix traceback always setting 'variable'
if pkg-config return != 0 and the dep is not required, it will not be set
2016-10-10 19:41:43 +03:00
Nirbheek Chauhan a0551d7d6e dependencies/boost: Fix 32-bit vs 64-bit on Windows
Fixes https://github.com/mesonbuild/meson/issues/526

Also removes useless and incorrect mesonlib.is_32bit() function. We
cannot trust that the architecture that Python is built for is the same
as the one we're targetting.
2016-09-27 00:27:38 +05:30
Nirbheek Chauhan c9a7422cc1 dependencies/boost: Require BOOST_ROOT while cross-compiling
Our fallback to the system-provided directories is never going to work
while cross-compiling
2016-09-27 00:27:38 +05:30
Jussi Pakkanen ba0456748e Prefer pkg-config to sdl2-config. 2016-09-04 20:22:20 +03:00
Elliott Sales de Andrade 4c71695e41 Use context manager for file I/O.
There are a few cases where a context manager cannot be used, such as
the logger.
2016-08-27 18:29:55 -04:00
ippytraxx 9aef099bc7 'name' needs to be 'self.name' in DependencyException 2016-08-23 23:15:46 +02:00
Nirbheek Chauhan 577b6dfdf6 find_program: Find scripts without extensions on Windows
Because of how files and executables work on Windows, scripts that use
an interpreter must have an extension, and that extension must be
associated with an interpreter. The full list of executable extensions
is available in the PATHEXT environment variable.

However, UNIX-like OSes use an executable bit and read the shebang to
figure out what interpreter to use, and the scripts don't need to have
extensions. We can now detect these scripts using find_program by
manually searching in PATH and reading the shebang.
2016-07-30 15:20:01 +05:30
Nirbheek Chauhan baf8481c4f pkg-config: Print 'NO' when version is too old
This gives a clearer output when the dependency is not required or has a
fallback subproject otherwise the user is left wondering why the optional
dependency wasn't used or why the fallback subproject is being used.
2016-07-28 21:11:45 +05:30
Nirbheek Chauhan 48b4defa37 pkg-config: Move setting of cargs and libs to functions
Much cleaner this way. It's completely clear what each block of code does.
2016-07-28 21:06:00 +05:30
Nirbheek Chauhan bc63103ae0 pkg-config: Short-circuit when there's no pkg-config file found
Just exit immediately when there's no pkg-config file found instead of putting
everything else in a huge 'else:'. Much clearer and avoids one level of
indentation.

No code changes accompany this.
2016-07-28 21:02:02 +05:30
Thibault Saunier a23f577415 dependencies: Add a get_version method to Python3Dependency
Otherwise ninja files regeneration fails with:

  AttributeError: 'Python3Dependency' object has no attribute 'get_version'
2016-07-04 13:01:23 -04:00
Jussi Pakkanen 35eb8c7b9a Added version info to sdl2dep. Closes #616. 2016-06-24 15:45:25 +03:00
Nirbheek Chauhan cd509043e0 wxwidgets: Don't error out if dependency is not required (#606) 2016-06-21 00:16:11 +03:00
Jussi Pakkanen f9910d2c11 Ensure cargs and libs variables always exist. Closes #581. 2016-06-09 21:48:27 +03:00
Nirbheek Chauhan c33e7a68a1 Also reuse subproject-based fallback dependencies
This allows a project to use the same fallbacks dependency from the same
subproject multiple times in the same way that external dependencies can be.

Also change the format of the dependency identifier to ensure that fallback
checks with different dirname/varname aren't mistakenly reused. We now use
a tuple for this because the format is simpler to construct and it gives us the
same immutability guarantees as a string which is needed for using it as
a dictionary key.
2016-05-30 03:35:02 +05:30
Jussi Pakkanen cff4e7d299 Can query version strings of dependencies. 2016-05-29 03:15:16 +03:00