Commit Graph

1600 Commits

Author SHA1 Message Date
Mis012 9694f9fefe java: use single javac invocation per jar
Instead of invoking javac for every .java file, pass all of the sources
for a jar target to a single javac invocation. This massively improves
first compilation time and doesn't meaningfully affect incremental builds
(it can even be faster in some cases).

The old approach also had issues where files would not always get recompiled
even though they should, necessitating a clean rebuild in order to see changes
reflected in the build output.

Multiple invocations seem to only make sense if:
- issues with files not getting flagged for rebuild are investigated and fixed
- something like the javaserver buildtool from openjdk sources is used
instead of directly spawning javac processes
- the amount of java files per jar is so large that it is faster to compile
several files one by one than to compile all the files at once (batching may
still make sense to get a reasonable balance)
2024-06-10 01:48:53 +03:00
Albert Tang f70de5885c xcode: Skip generating PBXBuildStyle on Xcode 9 and above
This was removed on Xcode 9, so only generate it for Xcode 8.3.3
and lower.
2024-06-03 20:06:57 +03:00
Albert Tang da20ea01ca xcode: Generate files for highest detected version
Some settings require "objectVersion" to be set to a certain value or
Xcode will not use it. To fix this, we set it to the highest possible
value, determined by the detected version of Xcode. We also set
"compatibilityVersion", but mainly so it lines up with "objectVersion".

At the same time, we should not be generating Xcode 3.2-compatible
projects by default anyway.
2024-06-03 20:06:57 +03:00
Albert Tang 8499e4535b xcode: Detect installed version of Xcode
This will allow for generating project files more specific to certain
versions of Xcode without breaking compatibility.
2024-06-03 20:06:57 +03:00
David Seifert 7f2c6f644b cuda: disable thin archives when cuda is added through `add_languages('cuda')` later 2024-05-29 19:13:14 -04:00
David Seifert b6e5683764 cuda: disable thin archives when 'cuda' is enabled globally
Bug: mesonbuild/meson/pull/9453
Bug: mesonbuild/meson/issues/9479#issuecomment-953485040
2024-05-07 22:32:35 -07:00
David Seifert 89a5bde9d9 cuda: pass static archives to nvcc without -Xlinker= prefix 2024-05-07 22:32:35 -07:00
matyalatte f1f24816a9 use a for loop, check more linker options 2024-05-01 09:45:53 -07:00
matyalatte e3db7af0ea vs2010backend: fix an error when using /MANIFEST:NO 2024-05-01 09:45:53 -07:00
Benjamin Gilbert 1684259f10 backend/ninja: use generate_basic_compiler_args() for C#, Java, Swift
C#, Java, and Swift targets were manually collecting compiler arguments
rather than using the helper function for this purpose.  This caused each
target type to add arguments in a different order, and to forget to add
some arguments respectively:

C#:    /nologo, -warnaserror
Java:  warning level (-nowarn, -Xlint:all, -Xdoclint:all), debug arguments
       (-g, -g:none), -Werror
Swift: -warnings-as-errors

Fix this.  Also fix up some no-longer-unused argument processing in the
Compiler implementations.
2024-04-27 08:09:03 -07:00
Dylan Baker 27dc1bcacb backend/ninja: use re.match instead of re.search
Since we've already determined that the first character is the start of
the expression anyway.
2024-04-24 20:40:34 -07:00
Dylan Baker f603a266ec backend: fix type annotation of Backend.generate
`func(value: dict = None)` is invalid, it must be `func(value: dict |
None = None)`, or in our older syntax: `T.Optional[T.Dict] = None`
2024-04-24 20:40:34 -07:00
Dylan Baker cf0fecfcef backend/ninja: Fix bug in NinjaRule.length_estimate
The code would create a dictionary that was of type `str : list[str] |
str | None`. Then would later try to call `len(' '.join(dict[key]))`.
This would result in two different bugs:

 1. If the value is `None` it would except, since None isn't iterable
    and cannot be converted to a string
 2. If the value was a string, then it would double the length of the
    actual string and return that, by adding a space between each
    character
2024-04-24 20:40:34 -07:00
Dylan Baker fb5a0b4b61 backend/ninja: add typing annotations to NinjaRule 2024-04-24 20:40:34 -07:00
Dylan Baker 9e3b3db705 backend/ninja: Fix cases where None is passed when unexpected
When getting debug file arguments we can sometimes pass None, where a
None is unexpected. This becomes a particular problem in the Cuda
compiler, where the output will unconditionally be concatenated with a
static string, resulting in an uncaught exception. This is really easy
to spot once we annotate the functions in question, where a static type
checker like mypy easily spots the issue.

This commit adds those annotations, and then fixes the resulting error.

Fixes: #12997
2024-04-18 13:12:15 -07:00
L. E. Segovia 5e10033eb5 backends: Add Nasm support to Xcode through a custom build rule 2024-04-09 22:11:04 -03:00
L. E. Segovia c0696889ff backends: Add Nasm support to Xcode through a custom build rule 2024-04-09 22:11:04 -03:00
Gerion Entrup 06bc8a8d37 depends keyword argument: accept CustomTargetIndex
That holds for all of these meson function: run_target, generator and
custom_target and additionally to the Windows and Gnome module.
2024-04-05 09:36:59 -07:00
Jussi Pakkanen 516a485136
Merge pull request #13021 from dcbaker/submit/depscanner-fixes-and-speedups
Cleanups, fixes, and speedups for the depscanner
2024-03-29 23:54:06 +02:00
Dylan Baker 2171a017be backend/ninja: Don't run -t cleandead when using dyndeps
There's a known ninja bug
(https://github.com/ninja-build/ninja/issues/1952) that running this
with dyndeps will result in Ninja deleting implicit outputs from the
dyndeps, leading to pointless rebuilds. For reference, this is what
CMake does as well.
2024-03-29 13:06:54 -07:00
Dylan Baker 2f8d51c833 backend/ninja: don't rewrite the pickle data if it hasn't changed
Which prevents spurious rebuilds of dyndeps
2024-03-29 13:06:54 -07:00
Dylan Baker 433117fc5a scripts/depscan: pick language once, at configure time
We already have to decide whether to scan a file at configure time, so
we don't want to have to do it again at compile time, every time the
depscan rule is run. We can do this by saving and passing the language
to use in the pickle, so depscan doesn't have to re-calculate it. As an
added bonus, this removes an import from depscan
2024-03-29 13:06:54 -07:00
Dylan Baker fae1363bd3 scripts/depscan: combine pickle and JSON data into a single file
We don't need to write and pass two separate files to the depscanner,
I've used the pickle because the pickle serializer/deserializer should
be faster than JSON, thought I haven't tested.
2024-03-29 13:06:54 -07:00
Dylan Baker 934c9074bd backend/ninja: add missing typing annotations 2024-03-28 15:30:16 -07:00
Dylan Baker 875a9b789f backend/ninja: remove duplicate isinstance() check 2024-03-28 15:30:16 -07:00
Dylan Baker 2812b21de5 backend/ninja: use A dataclass for TargetDependencyScannerInfo 2024-03-28 15:30:16 -07:00
Sam James 5bd28febf7
Pass Environment down from Backend
We'll need it in a moment for get_base_compile_args -> get_assert_args.

Bug: https://github.com/mesonbuild/meson/issues/12962
Signed-off-by: Sam James <sam@gentoo.org>
Signed-off-by: Eli Schwartz <eschwartz93@gmail.com>
2024-03-28 00:52:25 -04:00
Xavier Claessens c1076241af compilers: No need to pass exe_wrapper everywhere
Places where compiler needs it already have access to Environment object
and can use it directly.

This fixes mypy complaining that not all compilers have self.exe_wrapper
in run() method that got moved to base class.
2024-03-15 11:38:54 -04:00
Elliot e4622ff1ee
Only link to generated pch object when using msvc. (#12957)
backend: Only link to generated pch object when using msvc
2024-03-11 11:23:33 -07:00
Xavier Claessens 5e0a3073da rust: Link with rlib external dependencies
When linking with a Rust rlib, we should also link with its external
system dependencies. This was currently done only for C ABI crates, do
it for both rlib and staticlib now.
2024-03-05 09:18:32 -05:00
dragonmux 5495dc4315 backend/ninjabackend: Implemented logic for passing the discovered gcovr and llvm-cov along to the code coverage backend 2024-02-24 11:35:02 -08:00
dragonmux cfada46694 scripts/coverage: Implemented handling for passing the gcovr and llvm-cov binaries to use to the script 2024-02-24 11:35:02 -08:00
Charles Brunet 11f2e07071 Allow using CustomTarget as test executable
Fixes #6567
2024-02-24 09:08:20 -08:00
Stephan Lachnit 43fe006190 Fix warning when using scan-build
Using scan-build gives the following warning:

"Running the setup command as `meson [options]` instead of
`meson setup [options]` is ambiguous and deprecated."

This commit fixes this issue by adding the setup keyword to the meson command.
2024-02-19 09:12:12 -05:00
Akihiko Odaki adf09b8316 Raise if a postconf script fails
Raise MesonException if a postconf script fails to let the user know
about the failure.
2024-02-11 18:28:53 +05:30
Jouke Witteveen 10e269271d backends: restore shlex quoting of MESONINTROSPECT
The type of quoting was changed in 522392e to one that is suitable for
use with cmd.exe on Windows. However, the documentation states that the
type of quoting in MESONINTROSPECT is compatible with shlex.split() and
elsewhere in the code, the same variable is still quoted with
shlex.quote(). As mostly identified in #12148, there are a few choices:
1. Use shlex.quote() consistently and support Python but not cmd.exe.
2. Use join_args and support cmd.exe but not Python.
3. Use join_args and support splitting through the mesonbuild Python library.

This commit implements the first option and reverts part of 522392e.

Regression testing is implemented in #12115.

Fixes #12148
2024-02-10 20:04:18 -05:00
Charles Brunet 9659a8e6cf Fix minsize optimization for vs backend
Fixes #12265
2024-02-07 02:40:51 +05:30
Albert Tang 6e381714c7 xcode: Fix "clean" operation under new build system
Xcode 14 has dropped the legacy build system, forcing us to use the
new one introduced in Xcode 9. The new system requires that we conform
to its "clean build folder" behavior, or clean operations fail.

CMake achieves this by setting other variables instead of SYMROOT, so
we follow that approach while retaining our current behavior as much
as possible.

Ref: https://gitlab.kitware.com/cmake/cmake/-/merge_requests/7730
2024-01-26 00:42:24 -05:00
Albert Tang 02ee167296 xcode: Check custom target input for extracted objects
If there are any specified, the build target that generates them must
be added as a dependency.
2024-01-26 00:42:24 -05:00
Albert Tang df6926250d backends: Make object_filename_from_source() backend-agnostic
Some backends may need to use its own target directories instead of
our default one. For this, introduce an optional argument "targetdir"
that will still use our default one when not specified.
2024-01-26 00:42:24 -05:00
Albert Tang d2740cf0d1 xcode: Autodetect host machine's CPU architecture
Currently, the backend has "x86_64" hardcoded as the architecture,
which breaks cross compiling and compiling normally on arm64. Fix
this by setting it to the host machine's CPU architecture instead.
2024-01-26 00:42:24 -05:00
Charles Brunet d7bf365acd Fix compiler.preprocess compile_args not used
As described in
https://github.com/mesonbuild/meson/issues/12715#issuecomment-1883448780,
the compiler.preprocess function ignores compile_args. This should fix
it in both ninja and visualstudio backends.
2024-01-25 11:06:56 -08:00
Stas Sergeev 92f638e1f9 compiler.preprocess: add depends kwarg
This patch adds 'depends' keyword to compiler.preprocess().
It allows to execute other targets before doing the preprocessing.
Test-case is added to demonstrate that functionality: it
generates the header before preprocessing the C source that
uses that generated header.

Thanks to @bruchar1 for getting this patch to work.
2024-01-17 13:37:36 -08:00
Alyssa Ross 1ca2c74d16 rust: fix linking static executables
For the same reason as for static libraries, we have to use -l when
generating static executables.

Fixes: https://github.com/mesonbuild/meson/issues/12585
2024-01-17 13:36:15 -08:00
Roger Sanders 95cc34b342 Improve project naming and build configuration in genvslite projects
This change fixes two usability issues with the genvslite project
generation. Unlike when using the full VS backend, under genvslite the
ProjectName property wasn't being set for generated projects. This means
projects end up being named according to the project files, which
includes suffixes like "@exe" in the solution, which is undesirable.
This change adds the ProjectName field in for genvslite projects, to
keep the naming consistent with projects under the VS backend.

Additionally, previously under genvslite, no projects were set to build
under any solution configuration by default. This is inconvenient, as
the user has to manually edit the build settings for each solution
configuration before they can compile at the solution level. There was a
note in the code to do something about this. This change enables
compilation at the solution level for the default startup project in the
solution, so the user can now just press F5 to build the solution and
run the default startup project, as they would typically expect.
2024-01-17 16:27:18 -05:00
Jonathon Anderson 76ad5fe8d3 backend: Add rpath for external versioned .so's
On Linux many .so's are augmented with version information,
e.g. libxyz.so.1.2.3. CMake will happily refer to these versioned .so's
in its dependencies instead of libxyz.so (typically a symlink).
Unfortunately these versioned .so's aren't recognized as libraries by
the Backend's logic to produce build rpaths from library paths.

Fix this by recognizing any .so extension as sufficient reason to
produce a build rpath, not just if .so is the last extension.
2024-01-17 08:42:09 -08:00
Jonathon Anderson 57b7fbb29d backend: Add rpaths for external 'cmake' deps
Fixes https://github.com/mesonbuild/meson/issues/12338
2024-01-17 08:42:09 -08:00
Valeri ae857e841b
Vala: fixes to gresource handling (#12418)
* Vala: depend on gresources

Valac uses gresource at compile time to look up .ui files

* Automatically pass `--gresourcesdir` to valac

* gnome.compile_resources: clean up duplicate paths better

* Add a test for improved gresouce handling
2024-01-11 17:55:02 +02:00
byteblob ce2db13e94 ninja: Use platform dependent quote instead of shlex.quote() in gcc_rsp_quote() 2024-01-09 10:40:58 -08:00
Charles Brunet fbc744e6c6 Fix warning_level=everything in vs backends
Fixes #12688
2024-01-05 14:59:06 -08:00