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.
Add required kwarg to compiler.{compiles,links,run}
This is a similar commit to the one that added required to all the compiler.has* functions.
- Loading branch information
1 parent
a2ac3bc
commit 374f744
Showing
7 changed files
with
124 additions
and
8 deletions.
There are no files selected for viewing
21 changes: 21 additions & 0 deletions
21
docs/markdown/snippets/requires_kwarg_on_more_compiler_methods.md
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,21 @@ | ||
## Required kwarg on more `compiler` methods | ||
|
||
The following `compiler` methods now support the `requires` keyword argument: | ||
|
||
- `compiler.compiles()` | ||
- `compiler.links()` | ||
- `compiler.runs()` | ||
|
||
```meson | ||
cc.compiles(valid, name: 'valid', required : true) | ||
cc.links(valid, name: 'valid', required : true) | ||
cc.run(valid, name: 'valid', required : true) | ||
assert(not cc.compiles(valid, name: 'valid', required : opt)) | ||
assert(not cc.links(valid, name: 'valid', required : opt)) | ||
res = cc.run(valid, name: 'valid', required : opt) | ||
assert(res.compiled()) | ||
assert(res.returncode() == 0) | ||
assert(res.stdout() == '') | ||
assert(res.stderr() == '') | ||
``` |
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
7 changes: 7 additions & 0 deletions
7
test cases/common/275 required keyword in compiles functions/invalid.c
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,7 @@ | ||
// The error in this file is an homage to the xz incident :) | ||
// | ||
int | ||
main(void) | ||
{ | ||
. return 0; | ||
} |
41 changes: 41 additions & 0 deletions
41
test cases/common/275 required keyword in compiles functions/meson.build
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,41 @@ | ||
project('required keyword in compiles functions', 'c') | ||
|
||
cc = meson.get_compiler('c') | ||
opt = get_option('opt') | ||
|
||
valid = files('valid.c') | ||
invalid = files('invalid.c') | ||
|
||
cc.compiles(valid, name: 'valid', required : true) | ||
cc.links(valid, name: 'valid', required : true) | ||
if meson.can_run_host_binaries() | ||
cc.run(valid, name: 'valid', required : true) | ||
endif | ||
|
||
assert(not cc.compiles(valid, name: 'valid', required : opt)) | ||
assert(not cc.links(valid, name: 'valid', required : opt)) | ||
if meson.can_run_host_binaries() | ||
res = cc.run(valid, name: 'valid', required : opt) | ||
assert(res.compiled()) | ||
assert(res.returncode() == 0) | ||
assert(res.stdout() == '') | ||
assert(res.stderr() == '') | ||
endif | ||
|
||
testcase expect_error('''compiler.compiles keyword argument 'required' was of type str but should have been one of: bool, UserFeatureOption''') | ||
cc.compiles(valid, name: 'valid', required : 'not a bool') | ||
endtestcase | ||
|
||
testcase expect_error('''Could not compile invalid''') | ||
cc.compiles(invalid, name: 'invalid', required : true) | ||
endtestcase | ||
|
||
testcase expect_error('''Could not link invalid''') | ||
cc.links(invalid, name: 'invalid', required : true) | ||
endtestcase | ||
|
||
if meson.can_run_host_binaries() | ||
testcase expect_error('''Could not run invalid''') | ||
cc.run(invalid, name: 'invalid', required : true) | ||
endtestcase | ||
endif |
1 change: 1 addition & 0 deletions
1
test cases/common/275 required keyword in compiles functions/meson_options.txt
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 @@ | ||
option('opt', type: 'feature', value: 'disabled') |
5 changes: 5 additions & 0 deletions
5
test cases/common/275 required keyword in compiles functions/valid.c
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,5 @@ | ||
int | ||
main(void) | ||
{ | ||
return 0; | ||
} |