forked from mesonbuild/meson
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This allows for handling special arguments like `--version-script=<path>`, where the `=` is required and may not be passed as two separate arguments. A new dsl function `file_argument` is added, and is used like this: ```meson executable( ..., c_args : [file_argument('--file-arg=', files('foo.arg'))] ) ``` This returns an opaque object, which meson will correctly add to either the build or link depends (depending on whether it was passed to a compile argument or to a link argument), and will convert the argument into `--file-arg=relative/path/to/foo.arg`
- Loading branch information
Showing
11 changed files
with
118 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
## New file_argument() function | ||
|
||
Sometimes arguments need to be passed as a single string, but that string needs | ||
to contain a File as part of the string. Consider how linker scripts work with GCC: | ||
`-Wl,--version-script,<file>`. This is painful to deal with when the `<file>` is | ||
a `files()` object. with `file_argument()` this becomes easier. | ||
|
||
```meson | ||
build_target( | ||
..., | ||
c_args : [file_argument('--file-arg=', files('foo.file'))], | ||
link_args : [file_argument('-Wl,--version-script,', file('file.map'))], | ||
) | ||
``` | ||
|
||
Meson will automatically create the correct strings, relative to the build | ||
directory, and will automatically add the file to the correct depends, so that | ||
compilation and/or linking will correctly depend on that file. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
name: file_argument | ||
since: 1.3.0 | ||
returns: file_arg | ||
description: | | ||
Passes a string argument that must be joined to a file path a [[build_tgt]] | ||
This allows passing [[file]] objects to the `<lang>_args` and `link_args` | ||
parameters of a [[build_tgt]]. Once passed they will be converted to a string | ||
argument, and the [[file]] will be added to the appropriate dependencies | ||
(either build or link). | ||
example: | | ||
This is particularly useful when working with linker scripts: | ||
```meson | ||
tgt = build_tgt( | ||
..., | ||
link_with : file_argument('-Wl,--linker-script,' files('link.map')), | ||
) | ||
``` | ||
In this case Meson will pass `-Wl,--linker-script,link.map` (or a relative | ||
path for `link.map`), and will add it to the link dependencies for `tgt` | ||
posargs: | ||
arg: | ||
type: str | ||
description: The string part of the argument | ||
|
||
file: | ||
type: file | ||
description: The file part of the argument |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
name: file_arg | ||
long_name: file argument | ||
description: Opaque object returned by [[file_argument]] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters