Eli Schwartz
680b5ff819
treewide: add future annotations import
2 years ago
Dylan Baker
2d349eae8c
pylint: enable the set_membership plugin
...
Which adds the `use-set-for-membership` check. It's generally faster in
python to use a set with the `in` keyword, because it's a hash check
instead of a linear walk, this is especially true with strings, where
it's actually O(n^2), one loop over the container, and an inner loop of
the strings (as string comparison works by checking that `a[n] == b[n]`,
in a loop).
Also, I'm tired of complaining about this in reviews, let the tools do
it for me :)
2 years ago
Dylan Baker
f5283dd63f
pylint: enable global-statement
...
This does force a number of uses of `# pylint: disable` comments, but it
also finds a couple of useless global uses and one place (in the
previous commit) that an easy refactor removes the use of global. Global
is a code smell, so forcing adding a comment to disable helps force
developers to really consider if what they're doing is a good idea.
2 years ago
Dylan Baker
3ef332e89a
pylint: enable global-variable-not-assigned
...
The `global` statement is only needed to assign to global variables, not
read or mutate them. So calling `global.mutate()` is fine, but not
`var = foo`, which would otherwise shadow `var`.
2 years ago
Thomas Klausner
1c23281653
Add NetBSD support in symbolextractor.
...
Choose FreeBSD backend (OpenBSD backend would also work).
3 years ago
Dylan Baker
4d7031437c
pylint: turn on superflous-parens
...
We have a lot of these. Some of them are harmless, if unidiomatic, such
as `if (condition)`, others are potentially dangerous `assert(...)`, as
`assert(condtion)` works as expected, but `assert(condition, message)`
will result in an assertion that never triggers, as what you're actually
asserting is `bool(tuple[2])`, which will always be true.
3 years ago
Daniel Mensinger
3e396b3782
fix: Always explicitly set encoding for text files ( fixes #8263 )
4 years ago
Eli Schwartz
6a0fabc647
mass rewrite of string formatting to use f-strings everywhere
...
performed by running "pyupgrade --py36-plus" and committing the results
4 years ago
Eli Schwartz
4340bf34fa
various python neatness cleanups
...
All changes were created by running
"pyupgrade --py3-only --keep-percent-format"
and committing the results. I have not touched string formatting for
now.
- use set literals
- simplify .format() parameter naming
- remove __future__
- remove default "r" mode for open()
- use OSError rather than compatibility aliases
- remove stray parentheses in function(generator) scopes
4 years ago
Thibault Payet
eec5bb11ba
symbolextractor: Add FreeBSD support
4 years ago
Daniel Mensinger
a4f4379c44
typing: fully annotate scripts
4 years ago
Nirbheek Chauhan
104b80a75c
symbolextractor: Handle PermissionError when running tool
...
I can't reproduce this, but it is definitely possible. In this case
what we should do is the same as when the tool is not found.
Fixes https://github.com/mesonbuild/meson/issues/7605
4 years ago
Alan Coopersmith
e801e0435e
symbolextractor: use try/finally in solaris_syms when wrapping gnu_syms
...
As suggested by dcbaker in
https://github.com/mesonbuild/meson/pull/7370#pullrequestreview-436872661
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
4 years ago
Alan Coopersmith
45793b6ee2
symbolextractor: Add support for Solaris
...
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
5 years ago
Dylan Baker
29ef4478df
compilers/d: Add b_ndebug support
...
D lang compilers have an option -release (or similar) which turns off
asserts, contracts, and other runtime type checking. This patch wires
that up to the b_ndebug flag.
Fixes #7082
5 years ago
Pino Toscano
626522965f
symbolextractor: add support for hurd
...
Use the GNU toolchain for that.
5 years ago
Pino Toscano
a2b8ed1446
symbolextractor: rename linux_syms to gnu_syms
...
It is not specific to Linux but works with the GNU toolchain, so
give it a better name.
No functional changes.
5 years ago
Nirbheek Chauhan
04e89d0867
symbolextractor: Add support for Cygwin
5 years ago
Nirbheek Chauhan
cbd143844d
symbolextractor: Add support for clang-cl
...
Requires the latest LLVm 9.0 release which implements the `-list`
argument to `llvm-lib` and ships with an implementation of `nm` called
`llvm-nm`.
5 years ago
Nirbheek Chauhan
cace70c64e
symbolextractor: Add a Windows implementation
...
Supports both MSVC and MinGW toolchains. Checks for MSVC first, then
falls back to MinGW.
5 years ago
Nirbheek Chauhan
5dcbf10a1b
ninjabackend: Pass the import library to SHSYM
...
We actually use this while linking on Windows, and hence we need to
extract symbols from this file, and not the DLL.
However, we cannot pass it instead of the DLL because it's an optional
output of the compiler. It will not be written out at all if there are
no symbols in the DLL, and we cannot know that at configure time. This
means we cannot describe it as an output of any ninja target, or the
input of any ninja target. We must pass it as an argument without
semantic meaning.
5 years ago
Nirbheek Chauhan
feb82e0f0f
symbolextractor: Add typing hints
5 years ago
Nirbheek Chauhan
901bbc36d9
symbolextractor: Support passing arguments to tools
...
This is how we parse all env vars for tools in Meson. Do the same here
too for consistency.
5 years ago
Nirbheek Chauhan
6fe7af5809
symbolextractor: Print a warning if required tools not found
...
Also write out a dummy symbols file if the tool wasn't found or didn't
work instead of just spewing an exception.
5 years ago
Nirbheek Chauhan
431283b35d
symbolextractor: Correctly filter undefined symbols on macOS
...
-g is --extern-only and -P is --format=posix. We were missing
--defined-only for some reason, which we pass to `nm` on Linux.
This avoids having to manually filter later.
5 years ago
Nirbheek Chauhan
77d163a0e9
symbolextractor: Print one warning when no implementation found
...
So people know why all their binaries are getting relinked. Do this
only once per build-dir by writing a file to meson-private.
5 years ago
Dylan Baker
5678468c2c
Don't use len() to test for container emptiness
...
I ran the numbers once before (it's in the meson history) but it's
*much* faster to *not* use len for testing if a container is empty or
not.
6 years ago
Arkadiusz Hiler
690dd723f4
Add symbol sizes to .symbols files
...
If we change a symbol size (e.g. array) in a .c file that is a part of
.so, executables that use it are not re-linked resulting in a runtime
error:
"Symbol xyz has different size in shared object, consider re-linking"
Adding symbol sizes to .symbol files fixes this issue.
6 years ago
Igor Gnatenko
2017d8578a
style: fix E226 violations
...
E226: missing whitespace around arithmetic operator
Signed-off-by: Igor Gnatenko <i.gnatenko.brain@gmail.com>
8 years ago
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>
8 years ago
Igor Gnatenko
4fbaf295f6
remove shebangs from scripts
...
meson.noarch: E: non-executable-script /usr/lib/python3.5/site-packages/mesonbuild/scripts/regen_checker.py 644 /usr/bin/python3
meson.noarch: E: non-executable-script /usr/lib/python3.5/site-packages/mesonbuild/scripts/meson_test.py 644 /usr/bin/python3
meson.noarch: E: non-executable-script /usr/lib/python3.5/site-packages/mesonbuild/scripts/meson_benchmark.py 644 /usr/bin/python3
meson.noarch: E: non-executable-script /usr/lib/python3.5/site-packages/mesonbuild/scripts/meson_exe.py 644 /usr/bin/python3
meson.noarch: E: non-executable-script /usr/lib/python3.5/site-packages/mesonbuild/scripts/symbolextractor.py 644 /usr/bin/python3
meson.noarch: E: non-executable-script /usr/lib/python3.5/site-packages/mesonbuild/scripts/commandrunner.py 644 /usr/bin/python3
meson.noarch: E: non-executable-script /usr/lib/python3.5/site-packages/mesonbuild/scripts/gtkdochelper.py 644 /usr/bin/python3
meson.noarch: E: non-executable-script /usr/lib/python3.5/site-packages/mesonbuild/scripts/meson_install.py 644 /usr/bin/python3
meson.noarch: E: non-executable-script /usr/lib/python3.5/site-packages/mesonbuild/scripts/depfixer.py 644 /usr/bin/python3
meson.noarch: E: non-executable-script /usr/lib/python3.5/site-packages/mesonbuild/scripts/dirchanger.py 644 /usr/bin/python3
meson.noarch: E: non-executable-script /usr/lib/python3.5/site-packages/mesonbuild/scripts/delwithsuffix.py 644 /usr/bin/python3
meson.noarch: E: non-executable-script /usr/lib/python3.5/site-packages/mesonbuild/scripts/vcstagger.py 644 /usr/bin/python3
Signed-off-by: Igor Gnatenko <i.gnatenko.brain@gmail.com>
8 years ago
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
8 years ago
Marc-Antoine Perennou
a70f39f815
allow overriding nm with NM
...
Signed-off-by: Marc-Antoine Perennou <Marc-Antoine@Perennou.com>
8 years ago
Marc-Antoine Perennou
4d3cce1532
allow overriding readelf with READELF
...
Signed-off-by: Marc-Antoine Perennou <Marc-Antoine@Perennou.com>
8 years ago
Jussi Pakkanen
1f4cce86ad
Remove shebangs on files that are not runnable and add execute bits to those that are.
8 years ago
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.
8 years ago
Jussi Pakkanen
23b98cd6e6
Renamed meson package to mesonbuild so that we can have a script named meson in the same toplevel dir.
9 years ago
Jussi Pakkanen
66c01401de
Moved scripts in the module and started work to run them via the main meson command.
9 years ago
Jussi Pakkanen
61cb4ae9ca
Can compile full test suite.
9 years ago
Jussi Pakkanen
a5508d3fd3
Can run most of test suite (with hacks).
9 years ago
Jussi Pakkanen
8b1039fa30
Organise files into a module structure.
9 years ago
Jussi Pakkanen
9d559b2b39
More robust windows detection and more logs.
9 years ago
Igor Gnatenko
25c71c4d52
symbolextractor: fix bad-continuation
...
Signed-off-by: Igor Gnatenko <i.gnatenko.brain@gmail.com>
10 years ago
Jussi Pakkanen
f2de23982e
User optparse in symbolextractor.
10 years ago
Jussi Pakkanen
525f0ae6d2
Harmonised copyright declarations.
10 years ago
Jussi Pakkanen
6536354cc3
Updated symbolextractor to work with cross builds.
11 years ago
Jussi Pakkanen
7d17ecc1f7
If should have been elif.
12 years ago
Jussi Pakkanen
9323aa3ae3
Made symbol extractor work on OSX.
12 years ago
Jussi Pakkanen
d4cfc5d2cc
Only relink if exported symbols of dependencies change.
12 years ago
Jussi Pakkanen
f67e826d8a
Check return code.
12 years ago