summaryrefslogtreecommitdiff
path: root/mesonbuild/interpreter.py
Commit message (Collapse)AuthorAgeFilesLines
...
* Store extra_files as file objects. Helps with #1686.Jussi Pakkanen2017-05-041-0/+5
|
* Don't use len() to test emptiness vs not emptinessDylan Baker2017-05-021-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Meson has a common pattern of using 'if len(foo) == 0:' or 'if len(foo) != 0:', however, this is a common anti-pattern in python. Instead tests for emptiness/non-emptiness should be done with a simple 'if foo:' or 'if not foo:' Consider the following: >>> import timeit >>> timeit.timeit('if len([]) == 0: pass') 0.10730923599840025 >>> timeit.timeit('if not []: pass') 0.030033907998586074 >>> timeit.timeit('if len(['a', 'b', 'c', 'd']) == 0: pass') 0.1154778649979562 >>> timeit.timeit("if not ['a', 'b', 'c', 'd']: pass") 0.08259823200205574 >>> timeit.timeit('if len("") == 0: pass') 0.089759664999292 >>> timeit.timeit('if not "": pass') 0.02340641999762738 >>> timeit.timeit('if len("foo") == 0: pass') 0.08848102600313723 >>> timeit.timeit('if not "foo": pass') 0.04032287199879647 And for the one additional case of 'if len(foo.strip()) == 0', which can be replaced with 'if not foo.isspace()' >>> timeit.timeit('if len(" ".strip()) == 0: pass') 0.15294511600222904 >>> timeit.timeit('if " ".isspace(): pass') 0.09413968399894657 >>> timeit.timeit('if len(" abc".strip()) == 0: pass') 0.2023209120015963 >>> timeit.timeit('if " abc".isspace(): pass') 0.09571301700270851 In other words, it's always a win to not use len(), when you don't actually want to check the length.
* configure_file: Accept output of configure_file as inputNirbheek Chauhan2017-04-221-1/+3
|
* Expose the implementation language for external librariesNirbheek Chauhan2017-04-211-8/+1
| | | | | | Ideally, all dependency objects should support this, but it's a lot of work and isn't supported by all dependency types (like frameworks and pkg-config), so for now just enable it for external libraries.
* Don't fail include_directories if the dir is only in the build pathMatthias Klumpp2017-04-201-3/+7
|
* Raise clear error if module name doesn't exist.Elliott Sales de Andrade2017-04-171-2/+5
| | | | Don't raise a full backtrace.
* Make it possible to only do unity builds on subprojects.Jussi Pakkanen2017-04-151-1/+4
|
* install scripts: Actually check if it was foundNirbheek Chauhan2017-04-111-1/+1
| | | | Closes https://github.com/mesonbuild/meson/issues/1600
* Merge pull request #1469 from centricular/install-secondary-outputsJussi Pakkanen2017-04-091-1/+1
|\ | | | | Support multiple install dirs for built/custom targets
| * Support multiple install dirs for built/custom targetsNirbheek Chauhan2017-04-041-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | You can now pass a list of strings to the install_dir: kwarg to build_target and custom_target. Custom Targets: =============== Allows you to specify the installation directory for each corresponding output. For example: custom_target('different-install-dirs', output : ['first.file', 'second.file'], ... install : true, install_dir : ['somedir', 'otherdir]) This would install first.file to somedir and second.file to otherdir. If only one install_dir is provided, all outputs are installed there (same behaviour as before). To only install some outputs, pass `false` for the outputs that you don't want installed. For example: custom_target('only-install-second', output : ['first.file', 'second.file'], ... install : true, install_dir : [false, 'otherdir]) This would install second.file to otherdir and not install first.file. Build Targets: ============== With build_target() (which includes executable(), library(), etc), usually there is only one primary output. However some types of targets have multiple outputs. For example, while generating Vala libraries, valac also generates a header and a .vapi file both of which often need to be installed. This allows you to specify installation directories for those too. # This will only install the library (same as before) shared_library('somevalalib', 'somesource.vala', ... install : true) # This will install the library, the header, and the vapi into the # respective directories shared_library('somevalalib', 'somesource.vala', ... install : true, install_dir : ['libdir', 'incdir', 'vapidir']) # This will install the library into the default libdir and # everything else into the specified directories shared_library('somevalalib', 'somesource.vala', ... install : true, install_dir : [true, 'incdir', 'vapidir']) # This will NOT install the library, and will install everything # else into the specified directories shared_library('somevalalib', 'somesource.vala', ... install : true, install_dir : [false, 'incdir', 'vapidir']) true/false can also be used for secondary outputs in the same way. Valac can also generate a GIR file for libraries when the `vala_gir:` keyword argument is passed to library(). In that case, `install_dir:` must be given a list with four elements, one for each output. Includes tests for all these. Closes https://github.com/mesonbuild/meson/issues/705 Closes https://github.com/mesonbuild/meson/issues/891 Closes https://github.com/mesonbuild/meson/issues/892 Closes https://github.com/mesonbuild/meson/issues/1178 Closes https://github.com/mesonbuild/meson/issues/1193
* | Merge pull request #1518 from centricular/mesonintrospect-evarJussi Pakkanen2017-04-081-7/+8
|\ \ | | | | | | Export MESONINTROSPECT to postconf/install/run_command scripts
| * | Export MESONINTROSPECT to postconf/install/run_command scriptsNirbheek Chauhan2017-03-281-7/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | Points to the `mesonintrospect.py` script corresponding to the currently-running version of Meson. Includes a test for all three methods of running scripts/commands. Closes https://github.com/mesonbuild/meson/issues/1385
* | | add_project_arguments: allow call after subproject()Philipp Ittershagen2017-04-071-7/+10
| | | | | | | | | | | | | | | This commit fixes #1554 by removing the restriction of add_project_arguments() to be called before any subproject() statement.
* | | add_{project,global}_arguments: support language listPhilipp Ittershagen2017-04-061-3/+3
| | | | | | | | | | | | | | | This patch adds support for specifying a list of languages when calling add_project_arguments and add_global_arguments.
* | | Refactor function_add_{global,project}_{link_,}arguments common codePhilipp Ittershagen2017-04-061-60/+26
| | |
* | | Merge pull request #1511 from centricular/get-defineJussi Pakkanen2017-04-051-10/+30
|\ \ \ | | | | | | | | New compiler function: cc.get_define()
| * | | Prohibit ':' in project namesNirbheek Chauhan2017-04-051-7/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This would make it harder to parse an option to mesonconf such as -Dfoo:bar:baz:fun=value since it could mean either of these: * For subproject 'foo:bar:baz', set the option 'fun' to 'value' * For subproject 'foo:bar', an invalid option 'baz:fun' was set To differentiate between these two we'd need to create the list of subprojects first and then parse their options later, which complicates the parsing quite a bit.
| * | | Use CPPFLAGS for pre-processor compiler checksNirbheek Chauhan2017-04-041-3/+4
| | | | | | | | | | | | | | | | | | | | | | | | Also don't add CFLAGS twice for links() checks Includes a test for this.
| * | | New compiler function: cc.get_define()Nirbheek Chauhan2017-04-041-0/+15
| | |/ | |/| | | | | | | | | | | | | Runs the pre-processor and fetches the value of the define. Can find any arbitrary value and returns it as a string.
* | | Enable File() objects as an input parameter to configure_filePhilipp Ittershagen2017-04-031-2/+6
|/ / | | | | | | | | | | | | The configure_file command raised an exception when an input was specified as a File, because os.path.join does not take File objects directly. This patch converts a File object to a string and adjusts the subsequent os.path.join calls.
* | Merge pull request #1505 from centricular/dont-use-c++-for-assemblyJussi Pakkanen2017-04-021-3/+3
|\ \ | | | | | | Try harder to use the C compiler for compiling asm
| * | Try even harder to use the C compiler for assemblyNirbheek Chauhan2017-03-271-13/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Now as long as you have a C compiler available in the project, it will be used to compile assembly even if the target contains a C++ compiler and even if the target contains only assembly and C++ sources. Earlier, the order in which sources appeared in a target would decide which compiler would be used. However, if the project only provides a C++ compiler, that will be used for compiling assembly sources. If this breaks your use-case, please tell us. Includes a test that ensures that all of the above is adhered to.
| * | Don't require a language/compiler for configuringNirbheek Chauhan2017-03-271-2/+2
| | | | | | | | | | | | | | | | | | Not really needed for projects that don't compile anything. Closes https://github.com/mesonbuild/meson/issues/1208
| * | Try harder to use the C compiler for compiling asmNirbheek Chauhan2017-03-271-1/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Use an ordered dict for the compiler dictionary and sort it according to a priority order: fortran, c, c++, etc. This also ensures that builds are reproducible because it would be a toss-up whether a C or a C++ compiler would be used based on the order in which compilers.items() would return items. Closes https://github.com/mesonbuild/meson/issues/1370
* | | configure_file: make input arg optional if command is usedTim-Philipp Müller2017-03-291-3/+7
| | | | | | | | | | | | Fixes #1476
* | | Allow not-required not-found dependencies in subprojectsNirbheek Chauhan2017-03-271-2/+8
| | | | | | | | | | | | Closes https://github.com/mesonbuild/meson/issues/1474
* | | Fix typo in dependency invalid arguments errorNirbheek Chauhan2017-03-271-2/+2
|/ /
* | declare_dependency: flatten dependencies kwargs allowing [] as no-op depTim-Philipp Müller2017-03-251-1/+1
| | | | | | | | | | | | | | | | | | | | An empty / no-op dependency can be expressed as []. This works with the dependencies kwarg in executable targets such as shared_library, but now with declare_dependency, where it would error out with "error: Dependencies must be external deps" because the deps are not flattened in this case. This patch fixes that. Fixes #1500
* | wrap: Implement special wrap modes for use by packagersNirbheek Chauhan2017-03-251-2/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Special wrap modes: nofallback: Don't download wraps for dependency() fallbacks nodownload: Don't download wraps for all subproject() calls Subprojects are used for two purposes: 1. To download and build dependencies by using .wrap files if they are not provided by the system. This is usually expressed via dependency(..., fallback: ...). 2. To download and build 'copylibs' which are meant to be used by copying into your project. This is always done with an explicit subproject() call. --wrap-mode=nofallback will never do (1) --wrap-mode=nodownload will do neither (1) nor (2) If you are building from a release tarball, you should be able to safely use 'nodownload' since upstream is expected to ship all required sources with the tarball. If you are building from a git repository, you will want to use 'nofallback' so that any 'copylib' wraps will be download as subprojects. Note that these options do not affect subprojects that are git submodules since those are only usable in git repositories, and you almost always want to download them.
* | wrap: Initialize subprojects that are git submodulesNirbheek Chauhan2017-03-251-5/+7
|/ | | | | | | | | | This will benefit projects such as GNOME Recipes that prefer using submodules over wraps because it's easier to maintain since git is aware of it, and because it integrates with their existing workflow. Without this, these projects have to manually initialize the submodules which is completely unnecessary. Closes https://github.com/mesonbuild/meson/issues/1449
* Merge pull request #1456 from ieei/compute_intJussi Pakkanen2017-03-231-1/+29
|\ | | | | Add compute_int, fixes #435
| * compiler: Ensure prefix and dependencies are used for alignment.Haakon Sporsheim2017-03-101-1/+5
| | | | | | | | | | This is now similar to how prefix and dependencies are used in all the other similar checks performed by the compiler.
| * compiler: Fix compute_int and sizeof for cross compilation.Haakon Sporsheim2017-03-101-3/+12
| | | | | | | | sizeof now uses compute_int which again binary searches for correct value.
| * compiler: Add compute_int functionality.Haakon Sporsheim2017-03-091-0/+15
| | | | | | | | Fixes #435
* | interpretter: Use a namedtuple for the ModuleStateThibault Saunier2017-03-201-19/+24
|/
* Merge pull request #1402 from centricular/test-setup-fixesJussi Pakkanen2017-02-201-1/+5
|\ | | | | Various fixes to how mesontest handles test setups.
| * add_test_setup: Treat no env as empty envNirbheek Chauhan2017-02-191-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Otherwise env is {} and we get a traceback trying to use the setup: $ /home/cassidy/dev/meson/mesontest.py -C build --setup valgrind ninja: Entering directory `/home/cassidy/dev/gst/master/gst-build/build' ninja: no work to do. Traceback (most recent call last): File "/home/cassidy/dev/meson/mesontest.py", line 579, in <module> sys.exit(run(sys.argv[1:])) File "/home/cassidy/dev/meson/mesontest.py", line 575, in run return th.doit() File "/home/cassidy/dev/meson/mesontest.py", line 337, in doit self.run_tests(tests) File "/home/cassidy/dev/meson/mesontest.py", line 485, in run_tests self.drain_futures(futures, logfile, jsonlogfile) File "/home/cassidy/dev/meson/mesontest.py", line 504, in drain_futures self.print_stats(numlen, tests, name, result.result(), i, logfile, jsonlogfile) File "/usr/lib64/python3.5/concurrent/futures/_base.py", line 398, in result return self.__get_result() File "/usr/lib64/python3.5/concurrent/futures/_base.py", line 357, in __get_result raise self._exception File "/usr/lib64/python3.5/concurrent/futures/thread.py", line 55, in run result = self.fn(*self.args, **self.kwargs) File "/home/cassidy/dev/meson/mesontest.py", line 216, in run_single_test child_env.update(self.options.global_env.get_env(child_env)) AttributeError: 'dict' object has no attribute 'get_env' There is no harm in doing this, and this is the simplest fix for this. Closes https://github.com/mesonbuild/meson/issues/1371
| * Add repr() for EnvironmentVariables{,Holder}Nirbheek Chauhan2017-02-191-0/+4
| | | | | | | | Makes it easier to debug issues with it
* | Merge pull request #1403 from centricular/compile_resourcesJussi Pakkanen2017-02-201-8/+29
|\ \ | |/ |/| Make configure_file() great again
| * configure_file: Substitute @INPUT@/@OUTPUT@/etc in commandNirbheek Chauhan2017-02-201-8/+25
| | | | | | | | | | | | | | | | | | | | | | The same substitutions and rules as custom_target(). Also generally fix it to actually work when run in a subdir and with anything other than absolute paths for input and output files. We now also log a message when configuring files. Includes tests for all this.
| * configure_file: Don't allow both command and configuration kwargsNirbheek Chauhan2017-02-201-1/+5
| |
* | run_command: Fix error message on incorrect argumentNirbheek Chauhan2017-02-191-1/+2
| | | | | | | | Be more descriptive so people know what they can do.
* | rpm: We no longer provide the full path to a libraryNirbheek Chauhan2017-02-191-3/+0
| | | | | | | | | | | | Ever since we changed how we do library searching, the full path to the library has not been available under `.fullpath`. This has been broken for at least a year...
* | find_program: Fix implementation of .path()Nirbheek Chauhan2017-02-191-3/+3
| | | | | | | | | | | | | | | | 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.
* | find_program: Support passing mesonlib.File objectsNirbheek Chauhan2017-02-191-2/+14
|/ | | | | This means you can pass files() and the return value of configure_file() to find_program() now.
* Prohibit absolute paths in subdir().Jussi Pakkanen2017-02-171-0/+2
|
* Prohibit manually built paths that point in srcdir in include_directories ↵Jussi Pakkanen2017-02-171-1/+20
| | | | and give information on what to use instead.
* Merge pull request #1368 from dimkr/subproject_defaultsJussi Pakkanen2017-02-091-2/+3
|\ | | | | Bug fix - KeyError on subproject without default options
| * Bug fix - KeyError on subproject without default optionsDima Krasner2017-02-071-2/+3
| |
* | dependencies: Distinguish native/cross while cachingNirbheek Chauhan2017-02-071-0/+12
|/ | | | Closes https://github.com/mesonbuild/meson/issues/1366