Commit Graph

115 Commits

Author SHA1 Message Date
Jussi Pakkanen d668bea11d Merge pull request #1496 from centricular/fix-internal-dep-order
Preserve internal-dep include order in build target dependencies
2017-03-25 18:55:47 +02:00
Jussi Pakkanen 60034e87b2 Merge pull request #1491 from nioncode/vs2017
VS2017 backend
2017-03-24 19:10:31 +02:00
Nirbheek Chauhan 53795d89df vs: Always use a wrapper for custom target commands
Besides fixing output capture, it also fixes a strange bug in MSBuild
where if the command list is too long, it will remove random
characters from the command list before passing it to the command.

Closes https://github.com/mesonbuild/meson/issues/1417
2017-03-23 16:38:03 -04:00
Nicolas Schneider 92ed607290 add 'vs' backend that automatically chooses between the vs backends
For newer VS versions, we can simply rely on 'VisualStudioVersion' being
set in the environment.
For VS2010, we fall back to check 'VSINSTALLDIR' for the version string.
If the backend can not be auto detected, we raise an exception to make the
user choose an explicit backend.
We also print the detected backend to the meson log.
2017-03-23 10:34:32 +01:00
Nirbheek Chauhan 7f80f81ac9 Preserve the order of internal deps in a target
We were adding them to the CompilerArgs instance in the order in which
they are specified, which is wrong because later dependencies would
override previous ones. Add them in the reverse order instead.

Closes https://github.com/mesonbuild/meson/issues/1495
2017-03-23 10:26:29 +05:30
Nicolas Schneider 994696e0ad add vs2017 backend
VS2017 requires the 'WindowsTargetPlatformVersion' property to be set.
We gather the version to use from the environment variable
'WindowsSDKVersion' that will be set by the VS developer command prompt.
2017-03-22 11:05:28 +01:00
Nicolas Schneider baa6df2ce7 vs: do not add generated objects to project
VS2015 automatically picks up outputs from CustomBuild commands, which we
now use instead of CustomBuildStep commands, which do not get picked up
automatically.
2017-03-20 14:33:44 +01:00
Nicolas Schneider b3073aa1ca vs: use regular quotes instead of '"' in Generator commands
Seems like CustomBuild does not like '"', but works just fine with
regular quotes.
2017-03-20 14:33:44 +01:00
Nicolas Schneider b434fcd12b vs: support Generator outputs as CustomTarget inputs
This changes how generated files are added to the VS project.
Previously, they were all added as a single CustomBuildStep with all
generator commands, inputs and outputs merged together.
Now, each input file is added separately to the project and is given a
CustomBuild command. This adds all generator input files to the files list
in the VS gui and allows to run only some of the generator commands if
only some of the input files have changed.
2017-03-20 14:33:44 +01:00
Nirbheek Chauhan 7e805a019a find_program: Fix implementation of .path()
And actually test that prog.path() works. The earlier test was just
running the command without checking if it succeeded.

Also make everything use prog.get_command() or get_path() instead of
accessing the internal member prog.fullpath directly.
2017-02-19 03:49:31 +05:30
Jussi Pakkanen 4a08841331 Merge pull request #1335 from tp-m/test-custom-target-used-in-test-cmd
tests: check custom target output is created before being used in a t…
2017-01-28 19:05:54 +02:00
Nirbheek Chauhan 471904f0c5 vs: Add support for the 'werror' builtin option 2017-01-28 05:14:13 +05:30
Nirbheek Chauhan 57ec097b5f vs: Use CompilerArgs() for compile and link args
At the same time also fix the order in which they are added. They now
match the order used in the Ninja backend.
2017-01-28 05:14:12 +05:30
Nirbheek Chauhan 2e30912447 vs: Fix running of tests to use mesontest.py
Back in November when this broke, we didn't notice because our tests
are run in-process, so we don't check that `msbuild RUN_TESTS.vcxproj`
and `ninja test` actually work.

Now we do.
2017-01-28 01:05:21 +05:30
Nirbheek Chauhan fc4e332601 backends: Add support for build_by_default to vs2010 backend
Always generate the vcxproj file, but only add it to the build
configuration if it's either supposed to be built by default, or is
a dependency of another target that is built by default.
2017-01-28 01:05:20 +05:30
Nirbheek Chauhan dbcbf19ece compilers: New class CompilerArgs derived from list()
The purpose of this class is to make it possible to sanely generate
compiler command-lines by ensuring that new arguments appended or added
to a list of arguments properly override previous arguments.
For instance:

>>> a = CompilerArgs(['-Lfoo', '-DBAR'])
>>> a += ['-Lgah', '-DTAZ']
>>> print(a)
['-Lgah', '-Lfoo', '-DBAR', '-DTAZ']

Arguments will be de-duped if it is safe to do so. Currently, this is
only done for -I and -L arguments (previous occurances are removed when
a new one is added) and arguments that once added cannot be overriden
such as -pipe are removed completely.
2017-01-27 23:42:22 +05:30
Mike Sinkovsky dac8351ff1 cleanup: Unbound local variable 2017-01-18 21:22:47 +02:00
Mike Sinkovsky 969be1f679 cleanup: Remove redundant parentheses 2017-01-18 21:22:47 +02:00
Mike Sinkovsky 1d177fb127 cleanup: Unused local variables 2017-01-18 21:22:47 +02:00
Elliott Sales de Andrade 78b030cf19 Add support for Files passed to generators.
I need this for windows.compile_resources to be able to use
configure_file results, but it may have other benefits.
2017-01-12 03:25:08 -05:00
Mike Sinkovsky e9a891fe25 style: [E502] the backslash is redundant between brackets 2017-01-11 12:33:27 -05:00
Igor Gnatenko 116da33cdd style: fix E128 violations
E128: continuation line under-indented for visual indent

Signed-off-by: Igor Gnatenko <i.gnatenko.brain@gmail.com>
2017-01-01 12:02:05 -05:00
Igor Gnatenko ea570bcb67 style: fix E265 violations
E265: block comment should start with '# '

Signed-off-by: Igor Gnatenko <i.gnatenko.brain@gmail.com>
2017-01-01 12:02:05 -05:00
Igor Gnatenko 5693758e46 style: fix E231 violations
E231: missing whitespace after ','

Signed-off-by: Igor Gnatenko <i.gnatenko.brain@gmail.com>
2017-01-01 12:02:05 -05:00
Igor Gnatenko 2017d8578a style: fix E226 violations
E226: missing whitespace around arithmetic operator

Signed-off-by: Igor Gnatenko <i.gnatenko.brain@gmail.com>
2017-01-01 12:02:05 -05:00
Igor Gnatenko f0b30baa39 style: fix E225 violations
E225: missing whitespace around 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
Igor Gnatenko 971a3a3cd9 tree-wide: remove trailing whitespaces
Signed-off-by: Igor Gnatenko <i.gnatenko.brain@gmail.com>
2016-12-19 18:34:02 +01:00
Igor Gnatenko e611b6748b tree-wide: remove unused variables
./mesonbuild/scripts/regen_checker.py:35:5: F841 local variable 'scriptdir' is assigned to but never used
    scriptdir = os.path.split(__file__)[0]
    ^
./mesonbuild/scripts/yelphelper.py:84:13: F841 local variable 'symfile' is assigned to but never used
            symfile = os.path.join(install_dir, m)
            ^
./mesonbuild/backend/backends.py:164:13: F841 local variable 'lang' is assigned to but never used
            lang = comp.get_language()
            ^
./mesonbuild/backend/ninjabackend.py:1286:9: F841 local variable 'scriptdir' is assigned to but never used
        scriptdir = self.environment.get_script_dir()
        ^
./mesonbuild/backend/vs2010backend.py:736:9: F841 local variable 'additional_options_set' is assigned to but never used
        additional_options_set = True
        ^

Signed-off-by: Igor Gnatenko <i.gnatenko.brain@gmail.com>
2016-12-19 18:22:20 +01: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
Nirbheek Chauhan d5f7ba862b gnome.mkenums: Use absolute paths for all commandline args
Closes #973

test cases/vala/8 generated sources/ tests this.
2016-12-15 14:58:43 +05:30
Jussi Pakkanen f62f730821 Merge pull request #1126 from mesonbuild/sharedmodule
Support for shared modules
2016-12-07 21:49:16 +02:00
Jussi Pakkanen dc1f537fb3 Skip shared module test on VS because it fails for some reason nobody understands. 2016-12-07 00:30:28 +02:00
Jussi Pakkanen 59fdb1b9ff Add unresolved symbol arg to link line in VS backends. For some
reason VS does not pick it up even though it is visible in the linker
option box.
2016-12-06 21:35:31 +02:00
Nirbheek Chauhan b9a7c0cf39 misc: Use relative imports everywhere
Using 'mesonbuild' as the module can cause it to use the
system-installed module and can also break if we rename the directory,
so avoid that by always using relative imports.
2016-12-07 00:24:17 +05:30
Thibault Saunier 85a0cd7635 Add new add_project_[link]_args functions
Fixes 979
2016-11-12 17:34:06 -05:00
Nirbheek Chauhan 00dc929b62 vs: Properly split per-compiler args into per-file options
Previously we were just dumping all defines and include directories into
the target-wide list of defines and include directories. Now we have
separate per-target and per-file (actually per-language) arguments,
defines, and include directories.
2016-11-10 00:40:16 +05:30
Nirbheek Chauhan 419b84784f CustomTarget: Use get_outputs() instead of get_filename()
get_filename() made no sense for CustomTarget since it can have multiple
outputs. Also use get_outputs() for GeneratedList since it has the same
meaning and remove unused set_generated().

As a side-effect, we now install all the outputs of a CustomTarget.
2016-10-19 20:42:11 +05:30
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
Nirbheek Chauhan 2d05008956 vs: Fix quoting and escaping of compiler options
Target-specific compiler options should be split into pre-processor
defines, include directories, and additional options, then
escaped/quoted and added to the appropriate portions of the project
file.

The "115 spaces backslash" test now checks that backslashes and spaces
now work properly in all three places.
2016-07-29 19:51:10 +05:30
Nirbheek Chauhan 129ce6800c vs: Fix visual studio version in solution file (#648) 2016-07-18 23:59:09 +03:00
Nirbheek Chauhan 6660837953 vs: Target platform is not always Win32
It depends on the target machine. Without this building for 64-bit fails
when using external dependencies.
2016-07-11 17:11:49 +05:30
Nirbheek Chauhan 6bb9805749 vs: Don't re-add pre-existing include dirs
Reduces noise in the vcxproj files
2016-07-01 20:50:47 +05:30
Nirbheek Chauhan afca987e94 vs: Fix usage of mesonlib.File.rel_to_builddir with generated files
It should always be passed build_to_src otherwise the path for generated
files will always be wrong. Passing the vcxproj path as the build_to_src
only works for files in the source tree.
2016-07-01 20:50:47 +05:30
Nirbheek Chauhan 2535364751 vs: Explain path-conversion variables
It's not easy to understand what these variables mean and what they're
used for without some comments
2016-07-01 20:50:47 +05:30
Nirbheek Chauhan 761ac8d8c4 vs: Add support for the 'vs_module_defs' shared_library kwarg 2016-07-01 20:50:47 +05:30
Nirbheek Chauhan f54e07bcd8 vs: Fix the path of customtarget generated sources
The path is relative to the vcxproj file, not relative to the build root
2016-07-01 20:50:47 +05:30
Nirbheek Chauhan 23d29ffb14 vs: Set all compiler/linker options correctly
These need to be set via XML tags and not passed directly as
AdditionalOptions. Otherwise the project will end up with inconsistent
compiler options and the build will fail.

Since Meson internals assume that these will be set via a command-line
invocation, we need to detect the presence of various flags in
buildtype_args and buildtype_link_args and set the correct options in
the vcxproj file.

Note that this means different configurations (debug/release/etc) cannot
be enumerated in the vcxproj/sln files and chosen by the user at build
time because arbitrary build characteristics can depend on that. The
only way to support that is by doing a full parse and conversion of
Meson build files (for all build options) to vcxproj files.
2016-07-01 20:50:47 +05:30
Nirbheek Chauhan 2f8eaa6ed4 vs: Fix paths of internal library dependencies
They are relative to the path of the vcxproj file, not relative to build root
2016-07-01 20:50:47 +05:30
Nirbheek Chauhan 1481715618 vs: Add libraries, library paths, and link args needed by dependencies
The link arguments for each dependency are split into these three and
added to the vcxproj file. Without this targets cannot find the external
dependencies.
2016-07-01 20:50:47 +05:30